klnodekb/views/work.pug

429 lines
18 KiB
Plaintext

extends layout
block content
.container
link(rel='stylesheet' href='/bower_components/bootstrap/dist/css/bootstrap.css')
link(href='//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css', rel='stylesheet')
link(rel='stylesheet', type='text/css', href='https://unpkg.com/lightpick@latest/css/lightpick.css')
link(rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/11.14.2/sweetalert2.css" integrity="sha512-TG239kA30BXeGpy+HpJei+qfJcKo8V9HKpe8UWuVdpk49NGUe86EDhmdXkCxMqD5gSlkLLi6YQ9SbNp+yRa9xQ==" crossorigin="anonymous" referrerpolicy="no-referrer")
include Modals/modal_workReport
style(type="text/css").
.clickable{
cursor: pointer;
}
.zoom-in-out-box {
margin: 2px;
width: 50px;
height: 50px;
animation: zoom-in-zoom-out 2s ease infinite;
}
@keyframes zoom-in-zoom-out {
0% {
transform: scale(0.5, 0.5);
}
50% {
transform: scale(1, 1);
}
100% {
transform: scale(0.5, 0.5);
}
}
#form-group
.panel.panel-primary
.panel-heading
h4#title #{work.title}
.panel-body
div.row
div.col-md-2
h4(id='wn',style='display:none;') #{work.id}
h4(id='entemp',style='display:none;') #{work.enaploTemplate}
h4(id='user_id',style='display:none;') #{user._id}
h4(style="text-align:right;") Munka szám:
h4(style="text-align:right;") PO szám:
h4(style="text-align:right;") CMR Rendszám:
if (enaplodata.azonosito)
h5(style="text-align:right;") e-napló:
h5(style="text-align:right;") Projekt:
h5(style="text-align:right;") Munka:
div.col-md-7
h4 #{work.workNumber}
h4 #{work.poNumber}
h4 #{work.cmRendAzonosito}
if (enaplodata.azonosito)
h5 #{enaplodata.azonosito}
h5 #{enaplodata.project+' '+enaplodata.helyszin}
h5 #{enaplodata.munka}
div.col-md-3
h5(style="font-weight: bold;text-align:right;") Létrehozó:
p(style="font-weight: normal;text-align:right;") #{author}
p(style="font-weight: normal;text-align:right;") #{work.workDate}
if (enaplodata.azonosito)
img.zoom-in-out-box(src='/enaplo.png',align='right', width='32px', height='32px')
if (work.body)
hr
div.row
div.col-md-12
p Megjegyzés: #{work.body}
.panel-footer
#form-group
.btn-toolbar
if(user.canModify.work)
a.btn.btn-primary.col-sm-2(href='/work/edit/'+work._id)
i.fa.fa-edit.fa-lg.fa-fw
| Szerkesztés
if (articles.length===0)
if(user.canDelete.work)
a.btn.btn-primary.col-sm-1(href='/work/edit/'+work._id)
i.fa.fa-trash.fa-lg.fa-fw
| Törlés
if(user.canModify.work)
a.btn.btn-primary.col-sm-2(href='/work/copy/'+work._id)
i.fa.fa-copy.fa-lg.fa-fw
| Másolat készítése
if(user.canAdd.files)
input(id='enaploImp',type='file',enctype="multipart/form-data",style='display:none;',accept=".enyk")
a.btn.btn-warning.col-sm-2(onclick="document.getElementById('enaploImp').click();",type='button')
i.fa.fa-solid.fa-upload
| Enapló import
if(work.state==='Opened')
a.btn.btn-danger.col-sm-2(name='wClose',id='wClose',href='/work/close/'+work._id)
i.fa.fa-flag-checkered.fa-lg.fa-fw
| Munka lezárása
a.btn.btn-success.col-sm-1(href='/')
i.fa.fa-home.fa-lg.fa-fw
| Vissza
br
//-a(href='http://localhost/work/generateXML/634fdcc026d48a5c353a3e8d/63bd6a7d38a2c0150522567e')
span.glyphicon.glyphicon-download
//-form(id='a',method='get', action='/work/generateXML/634fdcc026d48a5c353a3e8d/63bd6a7d38a2c0150522567e')
input.btn.btn-primary(id='a',type='submit',value='enaplo',tabindex='56')
form(id="myForm",name="myForm",method='get', action='/work/generateXML/')
.panel.panel-primary( data-toggle="collapse")
.panel-heading
.row
.col-md-9
h4 Résztvevők
.col-md-1
if (dailyReports.length>0)
button.btn.btn-success.button-spacer(id='printReport',name='printReport', data-id=work._id,type='button')
span.fa.fa-solid.fa-print
else
button.btn.btn-secondary.button-spacer(id='printReport',name='printReport',disabled, data-id=work._id,type='button')
span.fa.fa-solid.fa-print
.col-md-2.float-right
span.pull-right.clickable
i.glyphicon.glyphicon-chevron-up
#collapsePanel.panel-body
form#form-1(method='POST' action='/submit/form-1')
.row
.table-responsive
table.table.table-striped
col(width='5%')
col(width='10%')
col(width='auto')
col(width='15%')
if (work.enaploTemplate)
col(width='5%')
thead
tr
th #
th Dátum
th(style='text-align:left') Munkavégzés leírása
th(style='text-align:left') Jelenlévők
if (work.enaploTemplate)
th(style='text-align:middle') export
tbody
if (dailyReports)
each report, i in dailyReports
tr
td(style='vertical-align: middle') #{i+1}
td(style='text-align:left;vertical-align: middle') #{report.date}
td(style='text-align:left;vertical-align: middle') #{report.title}
td(style='text-align:left;vertical-align: middle')
each empl, l in report.list
if (report.foreman===empl._id.toString())
div
| #{empl.name}
i.fa.fa-solid.fa-star.fa-fw(style='color:red')
else
p(style='margin-bottom:0px') #{empl.name}
if (work.enaploTemplate)
td(style='text-align:left;vertical-align: middle')
//-a(name='getXML'+i,id='getXML'+i,href='/work/generateXML', data-wid=work._id,data-drid=report._id)
a(name='getXML'+i,id='getXML'+i,href='#',onclick='getXML(\''+work._id+'\',\''+report._id+'\',\''+report.date+'\')')
span.glyphicon.glyphicon-download
//-button(type='submit' name='a' form='form-1')
//-button.btn.btn-primary(id=report._id,form="myForm",type='submit',formaction='/work/generateXML/'+work._id+'/'+report._id, value='enaplo',tabindex='56')
//-button.btn.btn-secondary.button-spacer(id=report._id,form="myForm", data-wid=work._id,data-rid=report._id, type='submit')
br
.panel.panel-warning
.panel-heading
.row
.col-md-9
h4 Műhely munkavégzés
.col-md-1
.col-md-2.float-right
span.pull-right.clickable
i.glyphicon.glyphicon-chevron-up
.panel-body
.row
.table-responsive
table#workReportTable2.table.table-striped
-//col(width='5%')
col(width='10%')
col(width='auto')
col(width='15%')
thead
tr
-//th #
th(style='text-align:left') Dátum
th(style='text-align:left') Munkavégzés leírása
th(style='text-align:left') Résztvevők
tbody
.panel-footer
.btn-toolbar
if(user.canAdd.device)
button.btn.btn-default(data-toggle='modal', disabled data-wn=work._id,data-title=work.title, data-target='#workReportModal',data-headertitle='Műhely munkavégzés',type='button')
i.fa.fa-plus.fa-lg.fa-fw
| Bejegyzés hozzáadása
a.btn.btn-primary(href='/workReport/new/'+work._id)
i.fa.fa-plus.fa-lg.fa-fw
| Bejegyzés hozzáadása
br
.panel.panel-primary
.panel-heading
h4 Berendezések:
.panel-body
.row
.table-responsive
table.table.table-striped
col(width='5%')
col(width='auto')
col(width='15%')
col(width='15%')
col(width='15%')
thead
tr
th #
th Megnevezés
th(style='text-align:center') Létrehozva
th(style='text-align:right') Munka szám
th(style='text-align:right') Gyártási szám
tbody
each article, i in articles
tr
td #{i+1}
td
a(href="/articles/"+article._id+"/"+work._id)= article.title+' +'+article.workSign
td(style='text-align:center') #{article.deviceDate}
td(style='text-align:right') #{article.workNumber}
td(style='text-align:right') #{article.deviceNumber}
.panel-footer
.btn-toolbar
if(user.canAdd.device)
a.btn.btn-primary.col-sm-3(href='/articles/addTo/'+work._id)
i.fa.fa-plus.fa-lg.fa-fw
| Berendezés hozzáadása
a.btn.btn-success.col-sm-2(href='/')
i.fa.fa-home.fa-lg.fa-fw
| Vissza
script(src='/bower_components/jquery/dist/jquery.js')
script(src='/js/work_utils.js')
script(type='text/javascript', src='/bower_components/moment/min/moment.min.js')
script(src='/bower_components/moment/min/moment-with-locales.js')
script(type='text/javascript',src='/build/pdfmake.js')
script(type='text/javascript',src='/build/vfs_fonts.js')
script(src='https://unpkg.com/lightpick@latest/lightpick.js')
script(src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/11.14.2/sweetalert2.min.js" integrity="sha512-nD7/PXl2UD6bAYMJVKTLhr7qwnWVvoyqk8/WMzedDKMiQbaNXT3EUPzLYbLUHCLWqAZoXO37aVCtCKmAxZfqGw==" crossorigin="anonymous" referrerpolicy="no-referrer")
script.
function getEmployeeList(wf)
{
var elist=""
$.each(wf.employeeList,function(i,el){
elist+=el.name+'<br>'
});
return elist;
}
function editReport(b){
var wid = document.getElementById ('wn').textContent;
location.href = '/workReport/edit/'+wid+'/'+b.getAttribute('data-id');
console.log(b.getAttribute('data-id'))
}
$(document).ready(function () {
moment.locale('HU')
//Fetch workReport
var wid = document.getElementById ('wn').textContent;
fetch('/workreport/'+wid, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
}
})
.then(response => response.json())
.then(data => {
console.log(data)
//var t=data.reports[0];
var newRow= ""
$.each(data.reports,function(ix,t){
newRow= `<tr><td rowspan=${t.workFlow.length}>
<div class="row" style="margin-left: 3px">
${moment(t.date).format("YYYY.MM.DD")}
</div>
<div class="row" style="margin-left: 3px">
${moment(t.date).format("dddd")}
</div>
<div class="row justify-content-center" style="margin-left: 3px">
<button type="button" class="btn btn-primary btn-sm" style="margin-left: 4px" data-id=${t._id} onclick="editReport(this);">
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
</button>
</div>
</td>`
$.each(t.workFlow,function(i,item){
//newRow+= `<tr>` +
newRow+= `<td>${item.Title}</td><td>`
$.each(item.employeeList,function(idx,employee){
newRow+=employee.name+'<br>'
})
newRow+= `</td>`
newRow+= `</tr>`
})
//newRow+= `<td rowspan=${t.workFlow.length}>12</td></tr>`
$('#workReportTable2 > tbody:last-child').append (newRow);
})
//$('#workReportTable > tbody:last-child').append (newRow);
})
.catch(error => console.error('Error:', error));
/*fetch('/workreportList/'+wid, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
}
})
.then(response => response.json())
.then(data => {
console.log(data)
$.each(data.reports,function(i,item){
var newRow="<tr><td>"+(i+1)+"</td>"
newRow+=
'<td style="text-align:left">'+moment(new Date(item.date)).format('YYYY.MM.DD')+'</td>'
//'<td style="text-align:right">'+item.workTitle+'</td>'
newRow+='<td>'
$.each(item.items,function(i,employee){
newRow+=employee.name+'<br>'
});
newRow+='</td>'
newRow+='<td>'
$.each(item.items,function(i,wf){
newRow+=wf.workFlow+'<br>'
});
newRow+='</td>'
newRow+='</tr>';
$('#workReportTable > tbody:last-child').append (newRow);
})
})
.catch(error => console.error('Error:', error));
*/
document.getElementById('enaploImp').addEventListener('change', readFile, false);
/* var entemplate = document.getElementById ('entemp').textContent;
if (entemplate){
xmlDoc = $.parseXML(entemplate);
var fl=$(xmlDoc).find('file');
var docname = $(fl).find('head').find('docinfo').attr('name');
document.getElementById ('endata').textContent='e-napló: '+docname;
var nyom=$(xmlDoc).find('nyomtatvanyok').find('nyomtatvany').find('mezok')
}*/
$(document).on('click', '.panel-heading span.clickable', function(e){
var $this = $(this);
if(!$this.hasClass('panel-collapsed')) {
$this.parents('.panel').find('.panel-body').slideUp();
$this.addClass('panel-collapsed');
$this.find('i').removeClass('glyphicon-chevron-up').addClass('glyphicon-chevron-down');
} else {
$this.parents('.panel').find('.panel-body').slideDown();
$this.removeClass('panel-collapsed');
$this.find('i').removeClass('glyphicon-chevron-down').addClass('glyphicon-chevron-up');
}
})
function readFile (evt) {
var files = evt.target.files;
var file = files[0];
var reader = new FileReader();
reader.onload = function(event) {
var id = document.getElementById ('wn').textContent;
console.log("DataId: "+id)
xmlDoc = $.parseXML( event.target.result )
var xmlString = (new XMLSerializer()).serializeToString(xmlDoc);
var fl=$(xmlDoc).find('file');
var filetype = $(fl).find('head').attr('filetype');
if (filetype!='zn1810')
{
alert("Nem megfelelő fájl!");
return;
}
$.ajax({
type: 'POST',
url: '/work/enaploUpload/'+id,
data: {'xml':xmlString},
success: function(response){
//refreshAccessDetails(); // Lista frissítése betöltéskor
// window.location.href='/';
console.log(response);
location.reload();
},
error: function(err){
alert('A feltöltés nem sikerült!');
}
});
console.log(filetype );
// })
// console.log(event.target.result);
}
reader.readAsText(file)
}
$("#wClose").on("click", function( e ){ //e => event
if( ! confirm("Valóban lezárja a munkát?") ){
e.preventDefault(); // ! => don't want to do this
} else {
//want to do this! => maybe do something about it?
}
});
});