CM-helper bővítése dokumentumokkal

This commit is contained in:
Vincze József 2025-05-07 11:42:20 +02:00
parent c717d2b79a
commit 68d6249552
9 changed files with 147 additions and 93 deletions

19
app.js
View File

@ -885,6 +885,25 @@ app.get('/work/layout_table',utils.ensureAuthenticated, function(req, res) {
});
app.get("/cmfile/:id/:fileindex", async function(req,res){
const work=await Work.findById(req.params.id)
const outputPath = path.join(__dirname, 'sample.pdf');
if (work && work.filesCM.length > req.params.fileindex)
{
let filePath=work.pathCM+'\\'+work.filesCM[req.params.fileindex];
filepath=work.pathCM;//.replaceAll("\\","^^");
const param = encodeURIComponent(`${filepath}/${work.filesCM[req.params.fileindex]}`);
const url = `localhost:5000/api/db/getDocumentByPath?param=${param}`;
//const response = await fetch(url)
// console.log(work.pathCM+'\\'+work.filesCM[req.params.fileindex])
}
})
// Edit Work Route
app.get('/work/edit/:id', utils.ensureAuthenticated,function (req,res) {
Work.findById(req.params.id,function(err,work){

View File

@ -48,7 +48,8 @@ const CM_Fetch_WorkNumbers=async()=>
// console.log(work.workNumber);
work.workDate= moment().format('YYYY-MM-DD HH:mm:ss')
work.cmId=element.ID;
work.filesCM=element.files;
work.pathCM= element.Csatolasok
// Munka státusza
work.state='Opened'; // Nyitva
// Ütemterv
@ -57,7 +58,7 @@ const CM_Fetch_WorkNumbers=async()=>
work.ganttData.start_date=moment().format('DD-MM-YYYY');
work.ganttData.duration=5;//req.body.duration;
work.ganttData.progress=0;
//db.users.findOne({"username" : {$regex : ".*son.*"}});
Work.findOne({'workNumber': work.workNumber}, function(err,wn) // Megnézzük van e már
{
@ -93,24 +94,30 @@ const CM_Fetch_WorkNumbers=async()=>
}
else // Ha van már ilyen munka megnézzük módosították e.
{
const areEqual = JSON.stringify(foundWork.filesCM) === JSON.stringify(element.files);
//Módosítás
if (foundWork.title!=element.munkanev ||
foundWork.body!=element.Megjegyzes ||
foundWork.poNumber!=element.KulsoRendSzam ||
foundWork.megrendelo!=element.SzamlNev ||
foundWork.workNumber!=element.Szovertek ||
foundWork.cmRendAzonosito!=element.RendAzon)
foundWork.cmRendAzonosito!=element.RendAzon ||
!areEqual)
{
if (element.ID==foundWork.cmId)
{
console.log("Módosítás történt a CM-ben."+foundWork.title);
await Work.findOneAndUpdate({'cmId': foundWork.cmId}, {
title:element.munkanev,
body:element.Megjegyzes,
poNumber:element.KulsoRendSzam,
megrendelo:element.SzamlNev,
workNumber:element.Szovertek,
cmRendAzonosito:element.RendAzon
cmRendAzonosito:element.RendAzon,
filesCM:element.files,
pathCM: element.Csatolasok.replace
})
}

View File

@ -79,6 +79,8 @@ let workSchema = mongoose.Schema({
}],
//devicesArray: ['Article']
devicesArray: [{type: mongoose.Schema.Types.ObjectId}]
devicesArray: [{type: mongoose.Schema.Types.ObjectId}],
filesCM:[{type: String}],
pathCM: {type: String}
});
let Work = module.exports = mongoose.model('Work', workSchema);

View File

@ -79,26 +79,8 @@ exports.printPage=function(employee,som,month,weekend,mindate,holidaysArray,sick
{
drShift='';
}
if (element.isHoliday || element.isSickpay || element.isMunkaszunet)
{
var txt='';
var st='';
if (element.isHoliday) {txt='Szabadság';st='tableDataHo';}
if (element.isSickpay) {txt='Táppénz';st='tableDataSp';}
if (element.isMunkaszunet) {txt='Ünnep';st='tableDataHo';}
item.push([
{text:date, style:st},
{text:' --- ', style:st, alignment: 'center'},
{text:'--:--', style:st, alignment: 'center'},
{text:'--:--', style:st, alignment: 'center'},
{text:'--:--', style:st, alignment: 'center'},
{text:'--:--', style:st, alignment: 'center'},
{text:'--:--', style:st, alignment: 'center'},
{text:'--:--', style:st, alignment: 'center'},
{text:'--:--', style:st, alignment: 'center'},
{text: txt, style:st, alignment: 'left'}]);
}
else
if (element.isHoliday==false || element.isSickpay==false || element.isMunkaszunet==false)
// else
{
if (element.workReport){
locShift='\r\n'
@ -171,7 +153,27 @@ exports.printPage=function(employee,som,month,weekend,mindate,holidaysArray,sick
{text:drShift+wrShift+convertMinsToHrsMins(element.Surrogate), style:'tableData', alignment: 'center'}, //Pótlék
{text:drShift+wrShift+notes, style:'tableDataWe', alignment: 'left'}]);
}
}//else
}else{
if (element.isHoliday || element.isSickpay || element.isMunkaszunet)
{
var txt='';
var st='';
if (element.isHoliday) {txt='Szabadság';st='tableDataHo';}
if (element.isSickpay) {txt='Táppénz';st='tableDataSp';}
if (element.isMunkaszunet) {txt='Ünnep';st='tableDataHo';}
item.push([
{text:date, style:st},
{text:' --- ', style:st, alignment: 'center'},
{text:'--:--', style:st, alignment: 'center'},
{text:'--:--', style:st, alignment: 'center'},
{text:'--:--', style:st, alignment: 'center'},
{text:'--:--', style:st, alignment: 'center'},
{text:'--:--', style:st, alignment: 'center'},
{text:'--:--', style:st, alignment: 'center'},
{text:'--:--', style:st, alignment: 'center'},
{text: txt, style:st, alignment: 'left'}]);
}
}
return
});
item.push([

View File

@ -4111,9 +4111,7 @@ router.get('/androidList/:uid', async function (req, res) {
//sendEmailApiKey(document,apikey.apiKey)
//console.log(document.name);
res.send(resp);
});
// Havi munkaidők lekérdezése egymunkavállalóra AJAX Route
@ -4513,14 +4511,15 @@ function registerAccess(employee,city,lat,lon,device, callback)
access.longitudeE=lon;
access.deviceId=device._id;
var a = moment(wt.timeArrive, "YYYY.MM.DD. HH:mm");
var b = moment(access.timeGetaway, "YYYY.MM.DD. HH:mm");
var workhours = b.diff(a, 'minutes') // =1
var a = moment(wt.timeArrive, "YYYY.MM.DD. HH:mm")
var b = moment(access.timeGetaway, "YYYY.MM.DD. HH:mm")
// var c=b.subtract(60, 'minutes');
var workhours = b.diff(a, 'minutes')
if (isNaN(workhours))
{
workhours=0;
}
access.accumulatedTime=0;
access.accumulatedTime=wt.accumulatedTime+workhours; // belejavítva. HALMOZOTT IDŐ HOZZÁADÁSA
access.workHours=workhours;
@ -5815,6 +5814,7 @@ async function makeWorktimeAll(calcdate)
async function makeWorktimeAll(calcdate)
{
var num=0;
//'_id':'5cc0394bec573424a8f79059'
Employee.find({'konyvelesre':'on'}, function(err,res){
var fileList=[];
@ -5846,7 +5846,9 @@ async function makeWorktimeAll(calcdate)
{
if (element.isSubcontractor===null) // Alkalmazott
{
var data= printPage(element,som,month,weekend,calcdate,holidaysArray,sickpaysArray,msz)//.then(function(data){
msz=getMunkaszunet(calcdate);
const data= printPage(employee,som,month,weekend,req.params.mindate,holidaysArray,sickpaysArray,msz)
//var data= printPage(element,som,month,weekend,calcdate,holidaysArray,sickpaysArray,msz)//.then(function(data){
var fonts = {
Roboto: {
normal: 'public/fonts/Roboto-Regular.ttf',
@ -5883,8 +5885,10 @@ async function makeWorktimeAll(calcdate)
if (element.isSubcontractor==='on') // Alvállalkozó
{
msz=getMunkaszunet(calcdate);
//printPageContractor(element,som,month,weekend,calcdate,holidaysArray, function(err,data){
var data= printPage(element,som,month,weekend,calcdate,holidaysArray,sickpaysArray,msz)
const data= printPage(employee,som,month,weekend,req.params.mindate,holidaysArray,sickpaysArray,msz)
// var data= printPage(element,som,month,weekend,calcdate,holidaysArray,sickpaysArray,msz)
var fonts = {
Roboto: {
normal: 'public/fonts/Roboto-Regular.ttf',
@ -6042,9 +6046,12 @@ function proba(calcdate)
}
}*/
function sendMonthlyNotify(employee, monthNumber,callback)
async function sendMonthlyNotify(employee, monthNumber,callback)
{
getAccessDetails(employee._id,monthNumber,function(err,som,month,weekend){
var sickpaysArray=[]
var sickpaysArray=[]
var msz=getMunkaszunet(monthNumber);
getAccessDetails(employee._id,monthNumber,async function(err,som,month,weekend){
if(err)
{
console.log(err);
@ -6055,21 +6062,11 @@ function sendMonthlyNotify(employee, monthNumber,callback)
{
if (employee.isSubcontractor===null) // Alkalmazott
{
getSickpayListById(employee._id,moment(monthNumber,'YYYY.MM').format('MM.YYYY'),monthNumber,function(err,sickpaysArray){
if (err)
{
console.log("Sickpay Err: "+err);
}
else
{
getHolidayListById(employee._id,moment(monthNumber,'YYYY.MM').format('MM.YYYY'),monthNumber,function(err,holidaysArray){
if (err)
{
console.log("Holiday Err: "+err);
}
else
{
printPage(employee,som,month,weekend,monthNumber,holidaysArray,sickpaysArray, function(err,data){
var sickpaysArray= await getSickpayListById(employee._id,moment(monthNumber,'YYYY.MM').format('MM.YYYY'),monthNumber)//,function(err,sickpaysArray){
var holidaysArray=await getHolidayListById(employee._id,moment(monthNumber,'YYYY.MM').format('MM.YYYY'),monthNumber)//,function(err,holidaysArray){
msz=getMunkaszunet(monthNumber);
var data = await printPage(employee,som,month,weekend,monthNumber,holidaysArray,sickpaysArray, msz); //function(err,data){
var fonts = {
Roboto: {
normal: 'public/fonts/Roboto-Regular.ttf',
@ -6087,29 +6084,19 @@ function sendMonthlyNotify(employee, monthNumber,callback)
sendEmailMonthlyNotify(employee, function(err,res){
callback(err,res);
});
});
}
});
}
});
//});
// }
//});
// }
//});
}
if (employee.isSubcontractor==='on') // Alvállalkozó
{
getSickpayListById(employee._id,moment(monthNumber,'YYYY.MM').format('MM.YYYY'),monthNumber,function(err,sickpaysArray){
if (err)
{
console.log("Sickpay Err: "+err);
}
else
{
getHolidayListById(employee._id,moment(monthNumber,'YYYY.MM').format('MM.YYYY'),monthNumber,function(err,holidaysArray){
if (err)
{
console.log("Holiday Err: "+err);
}
else
{
printPageContractor(employee,som,month,weekend,monthNumber,holidaysArray, function(err,data){
sickpaysArray=await getSickpayListById(employee._id,moment(monthNumber,'YYYY.MM').format('MM.YYYY'),monthNumber);//,function(err,sickpaysArray){
holidaysArray=await getHolidayListById(employee._id,moment(monthNumber,'YYYY.MM').format('MM.YYYY'),monthNumber);//,function(err,holidaysArray){
msz=getMunkaszunet(monthNumber);
var data = await printPage(employee,som,month,weekend,monthNumber,holidaysArray,sickpaysArray, msz);//function(err,data){
var fonts = {
Roboto: {
normal: 'public/fonts/Roboto-Regular.ttf',
@ -6127,9 +6114,8 @@ function sendMonthlyNotify(employee, monthNumber,callback)
sendEmailMonthlyNotify(employee, function(err,res){
callback(err,res);
});
});
}}); // Holiday end
}}); // ickpay end
// });
}
}
else

View File

@ -131,20 +131,21 @@ block content
if (user.canDelete.files)
th Törlés
tbody
each doc, i in docObjs
tr
td #{i+1}
td
if (user.canDownload)
a(href='/articles/view/'+article.filePath+'/'+doc.filen) #{doc.filen}
else
p #{doc.filen}
td
img(src=doc.ico, width='32px', height='32px', alt='description here')
if (user.canDelete.files)
td
a.btn.btn-danger.delete-articleFile(href='#',data-path=doc.filen,data-id=article._id, data-wid=workId)
.glyphicon.glyphicon-trash
if (docObjs)
each doc, i in docObjs
tr
td #{i+1}
td
if (user.canDownload)
a(href='/articles/view/'+article.filePath+'/'+doc.filen) #{doc.filen}
else
p #{doc.filen}
td
img(src=doc.ico, width='32px', height='32px', alt='description here')
if (user.canDelete.files)
td
a.btn.btn-danger.delete-articleFile(href='#',data-path=doc.filen,data-id=article._id, data-wid=workId)
.glyphicon.glyphicon-trash
.panel-footer
if (user.canAdd.files)

View File

@ -77,7 +77,7 @@ block content
if(rot)
a.btn.btn-primary.col-sm-1(type='button',href='/employee/WTALL',value='Könyvelésre') Könyvelésre
a.btn.btn-primary.col-sm-21(type='button',disabled,href='/employee/WTALL2',value='Jelenléti személyenként') Jelenléti személyenként
a.btn.btn-primary.col-sm-21(type='button',href='/employee/WTALL2',value='Jelenléti személyenként') Jelenléti személyenként
a.btn.btn-primary.col-sm-1(type='button',disabled,href='/employee/tst',value='TST') TST
a.btn.btn-primary.col-sm-1(type='button',href='/gantt',value='Idővonal') Idővonal
@ -145,6 +145,7 @@ block content
col(width='5%')
col(width='5%')
col(width='5%')
col(width='5%')
col(width='3%')
col(width='3%')
col(width='5%')
@ -155,6 +156,7 @@ block content
th
th(style='text-align:left') Megrendelő
th Megnevezés
th(style='text-align:center') File
th(style='text-align:center') Létrehozva
th(style='text-align:center') Státusz
th(style='text-align:left') M.SZ.
@ -174,6 +176,11 @@ block content
td(style='text-align:left; vertical-align:middle;font-size: 9px;font-weight: bold;') #{work.megrendelo || "-"}
td(style='vertical-align:middle')
a(href="/work/"+work._id)= work.title
td(style='text-align:center;vertical-align:middle')
if (work.filesCM.length>0)
span.badge.badge-success #{work.filesCM.length}
else
span.badge #{work.filesCM.length}
td(style='text-align:center;vertical-align:middle') #{moment(work.workDate).format("YYYY.MM.DD")}
if (work.state==='Opened')
td(style='text-align:center;vertical-align:middle; color:green')

View File

@ -272,7 +272,7 @@ block content
if (!isNumber(editLastOilChange)){
return showErrorSuccess($('#editLastOilChange'), false, 'Kérem számokat adjon meg!');
}
if (editLastOilChange<=lastOilChange) {
if (editLastOilChange<=lastOilChange.kilometer) {
return showErrorSuccess($('#editLastOilChange'), false, 'Az olajcsere óra állása nem lehet kisebb, mint az előző!');
}
}

View File

@ -7,8 +7,22 @@ block content
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").
-function isOdd(number) { return number % 2 !== 0; }
style(type="text/css").
.normal-text{
height: 24px;
vertical-align: middle;
}
.normal-text:before {
background-image: url('/pdf.jpg');
background-size: 24px 24px;
background-repeat: no-repeat;
display: inline-block;
width: 32px;
height: 24px;
content:"";
}
.clickable{
cursor: pointer;
@ -70,6 +84,23 @@ block content
div.row
div.col-md-12
p Megjegyzés: #{work.body}
if (work.filesCM.length)
hr
each file, i in work.filesCM
if (isOdd(i))
.row
div.col-md-1
img(src='/pdf.jpg',align='right', width='16px', height='16px')
div.col-md-5
a(href="/cmfile/"+work._id+"/"+i)= file
else
div.col-md-1
img(src='/pdf.jpg',align='right', width='16px', height='16px')
div.col-md-5
//a(href="/cmfile/"+encodeURIComponent(work._id)+"/"+i)= file
a(href=`localhost:5000/api/db/getDocumentByPath?param=${encodeURIComponent(work.pathCM+"\\"+encodeURIComponent(work.filesCM[i]))}` target='_blank')= file
.panel-footer
#form-group
.btn-toolbar
@ -259,7 +290,6 @@ block content
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=""