Műhelymunkák nyomtatása egész munka is hozzáadva.
This commit is contained in:
parent
ed7cbd167e
commit
f23a5faf53
51
app.js
51
app.js
|
|
@ -1823,6 +1823,57 @@ app.get('/print_workreport/:id/:date',utils.ensureAuthenticated,async function(r
|
|||
}
|
||||
})
|
||||
|
||||
// Napi műhely jelentések nyomtatása egész munka
|
||||
// Get Single Work
|
||||
app.get('/print_workreportAll/:id',utils.ensureAuthenticated,async function(req,res){
|
||||
var PdfPrinter=require('pdfmake');
|
||||
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
try{
|
||||
var wtSum=0;
|
||||
var dr_firstDay= moment(req.params.date,"YYYY.MM").startOf('month').toDate();
|
||||
var dr_lastDay = moment(req.params.date,"YYYY.MM").endOf('month').toDate();
|
||||
const reports=await WorkReport.find({workId: mongoose.Types.ObjectId(req.params.id)})
|
||||
const workHeader=await Work.findOne({"_id":mongoose.Types.ObjectId(req.params.id)},{poNumber:1,workNumber:1,megrendelo:1})
|
||||
const workTimesSum=await WorkReport.aggregate(
|
||||
[
|
||||
{ $match: { 'workId': mongoose.Types.ObjectId(req.params.id),
|
||||
/* date: {
|
||||
$gte: dr_firstDay,
|
||||
$lte: dr_lastDay
|
||||
}*/
|
||||
} },
|
||||
{$unwind: '$workFlow'},
|
||||
{$unwind: '$workFlow.employeeList'},
|
||||
{$group: {_id: '$workFlow.employeeList.company',
|
||||
count: {
|
||||
$sum: 8
|
||||
},
|
||||
employees:{
|
||||
$push:{
|
||||
name: "$workFlow.employeeList.name",
|
||||
id: "$_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
]
|
||||
)
|
||||
|
||||
//if (workTimesSum.length>0) wtSum=workTimesSum[0].count*8
|
||||
var data=await printWorkReport(reports,workHeader,workTimesSum)
|
||||
//console.log(JSON.stringify(data));
|
||||
// fss.writeFile(path.normalize('d:\\test.json'), JSON.stringify(data));
|
||||
res.send(data);
|
||||
//res.send({'response':'ok','reports':reports, 'workTimesSum':wtSum});
|
||||
}catch(err){
|
||||
|
||||
res.status(500).json({'response':'fail','message':'Hiba a mentésnél !\n'+err.message});
|
||||
}
|
||||
})
|
||||
|
||||
// Műhely Napi jelentés Nyomtatási kép generálás
|
||||
async function printWorkReport(reports, workHeader, workTimeSum)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -49,6 +49,32 @@
|
|||
}
|
||||
});
|
||||
|
||||
// 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)
|
||||
|
|
|
|||
|
|
@ -220,7 +220,10 @@ block content
|
|||
span.glyphicon.glyphicon-calendar
|
||||
.col-md-1.float-right
|
||||
button.btn.btn-success.button-spacer(id='printWorkReport',name='printWorkReport', data-id=work._id,type='button')
|
||||
span.fa.fa-solid.fa-print
|
||||
span.fa.fa-solid.fa-print
|
||||
.col-md-1.float-right
|
||||
button.btn.btn-success.button-spacer(id='printWorkReportAll',name='printWorkReportAll', 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
|
||||
|
|
|
|||
Loading…
Reference in New Issue