// Számla nyomtatása $("#printReport").click(function(ev) { isLoaded=false; var workId = $(this).attr('data-Id'); if (workId) { //$.get('/invoices/print2' , function(data) { console.log(data); $.get('/print_report/'+workId , function(data) { if (!isLoaded) { isLoaded=true; //console.log(data); pdfMake.createPdf(data).open(); } }); } else { alert('Nincs mit nyomtatni!'); } }); // Műhely munka nyomtatása $("#printWorkReport").click(function(ev) { isLoaded=false; var workId = $(this).attr('data-Id'); if (workId) { var selectedDate = $('#workReportDate').data("DateTimePicker").date().format('YYYY.MM'); //$.get('/invoices/print2' , function(data) { console.log(data); $.get('/print_workreport/'+workId+'/'+selectedDate , function(data) { if (!isLoaded) { isLoaded=true; //console.log(data); pdfMake.createPdf(data).open(); } }); } else { alert('Nincs mit nyomtatni!'); } }); // Műhely munka nyomtatása teljes $("#printWorkReportAll").click(function(ev) { isLoaded=false; var workId = $(this).attr('data-Id'); if (workId) { var selectedDate = $('#workReportDate').data("DateTimePicker").date().format('YYYY.MM'); //$.get('/invoices/print2' , function(data) { console.log(data); $.get('/print_workreportAll/'+workId , function(data) { if (!isLoaded) { isLoaded=true; //console.log(data); pdfMake.createPdf(data).open(); } }); } else { alert('Nincs mit nyomtatni!'); } }); function getXML(workId,drId,reportDate){ let filename = ''; fetch("/work/generateXML/"+workId+"/"+drId) .then((resp) => { const header = resp.headers.get('Content-Disposition'); const parts = header.split(';'); filename = parts[1].split('=')[1].replaceAll('"',''); return resp.blob(); }) //.then(resp => resp.blob()) .then(blob => { const url = window.URL.createObjectURL(blob); const a = document.createElement('a'); a.style.display = 'none'; a.href = url; // the filename you want a.download = filename;//'EN_'+reportDate+'.frm.enyk'; console.log(filename); document.body.appendChild(a); a.click(); window.URL.revokeObjectURL(url); //alert('your file has downloaded!'); // or you know, something with better UX... }) .catch(() => alert('Fájl letöltés sikertelen!')); } function getWorkReportSumMuhely() { document.getElementById ('workReportSumMuhely').textContent=0; //Fetch workReport var wid = document.getElementById ('wn').textContent; fetch('/workreportGetSum/'+wid , { method: 'GET', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer YOUR_ACCESS_TOKEN' } }) .then(response => response.json()) .then(data => { document.getElementById ('workReportSumMuhely').textContent=`Műhely munkaórák: ${data.workTimesSum} óra` }) .catch(error => console.error('Error:', error)); } function getDailyReportSum() { document.getElementById ('dailyReportGetSum').textContent=0; //Fetch workReport var wid = document.getElementById ('wn').textContent; fetch('/dailyReportGetSum/'+wid , { method: 'GET', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer YOUR_ACCESS_TOKEN' } }) .then(response => response.json()) .then(data => { document.getElementById ('dailyReportGetSum').textContent=`Terep munkaórák: ${data.dailyReportSum} óra` }) .catch(error => console.error('Error:', error)); } function updateWorkReport() { var selectedDate = $('#workReportDate').data("DateTimePicker").date().format('YYYY.MM'); //console.log("Selected Date:", selectedDate ? selectedDate.format('YYYY-MM-DD') : "No date selected"); document.getElementById ('workTimesSum').textContent=0; //Fetch workReport var wid = document.getElementById ('wn').textContent; fetch('/workreportGet/'+wid+'/'+selectedDate , { method: 'GET', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer YOUR_ACCESS_TOKEN' } }) .then(response => response.json()) .then(data => { $('#workReportTable2 > tbody').empty(); //console.log(data) //var t=data.reports[0]; var newRow= "" $.each(data.reports,function(ix,t){ newRow= `
${moment(t.date).format("YYYY.MM.DD")}
${moment(t.date).format("dddd")}
` $.each(t.workFlow,function(i,item){ //newRow+= `` + newRow+= `${item.Title}` $.each(item.employeeList,function(idx,employee){ if (employee.company) { newRow+=employee.company+'
' } else { newRow+="K-L Electro Bt"+'
' } }) newRow+= `` $.each(item.employeeList,function(idx,employee){ newRow+=employee.name+'
' }) newRow+= `` newRow+= `` }) //newRow+= `12` $('#workReportTable2 > tbody:last-child').append (newRow); }) //$('#workReportTable > tbody:last-child').append (newRow); document.getElementById ('workTimesSum').textContent=`Műhely munkaórák: ${data.workTimesSum} óra` }) .catch(error => console.error('Error:', error)); } $(document).ready(function () { getWorkReportSumMuhely(); getDailyReportSum(); $('#workReportDate').datetimepicker({ locale: 'hu', format: 'LD', defaultDate: new Date(), inline: false, sideBySide: true, showTodayButton: true, format: 'YYYY.MM' }).on('dp.change',function(e){ var calcdate=moment(e.date).format('YYYY.MM');// new Date($('#calcDate').val()); //refreshAccessDetails(calcdate); // Lista frissítése dátum választáskor updateWorkReport(); }); }) /* $("#getXML").click(function(ev) { //isLoaded=false; var workId = $(this).attr('data-wid'); var drId = $(this).attr('data-drid'); if (workId) { //$.get('/invoices/print2' , function(data) { console.log(data); $.get('/work/generateXML/'+workId+'/'+drId , function(data) { //$.fileDownload('some/file.pdf') console.log(data); //pdfMake.createPdf(data).open(); }); } else { alert('Nincs mit nyomtatni!'); } });*/