Munkanapló cég hozzáadva

This commit is contained in:
Vincze József 2025-05-12 14:25:11 +02:00
parent 68d6249552
commit f46a5792cb
12 changed files with 114 additions and 25 deletions

18
app.js
View File

@ -1796,8 +1796,10 @@ async function printWorkReport(reports, workHeader)
var item=[]; var item=[];
var wName=workHeader; var wName=workHeader;
var i=0; var i=0;
var emps="";
var companies="";
moment.locale('hu'); moment.locale('hu');
item.push([ {text:'#', alignment: 'left'},{text:'Dátum', alignment: 'center'}, {text:'Munkafolyamat', alignment: 'center'}, {text:'Résztvevők', alignment: 'center'}]); item.push([ {text:'#', alignment: 'left'},{text:'Dátum', alignment: 'center'}, {text:'Munkafolyamat', alignment: 'center'}, {text:'Cég', alignment: 'center'}, {text:'Résztvevők', alignment: 'center'}]);
wName=reports[0].workTitle; wName=reports[0].workTitle;
@ -1805,15 +1807,25 @@ async function printWorkReport(reports, workHeader)
report.workFlow.forEach((wf,idx)=>{ report.workFlow.forEach((wf,idx)=>{
var emps=""; emps="";
companies="";
wf.employeeList.forEach((employee,ind)=>{ wf.employeeList.forEach((employee,ind)=>{
emps=emps+employee.name+'\r\n'; emps=emps+employee.name+'\r\n';
if (employee.company)
{
companies=companies+employee.company+'\r\n'
}
else
{
companies=companies+"K-L Electro Bt"+'\r\n'
}
i++; i++;
}) })
item.push([ item.push([
{id:i,text: index+1, style:'tableData',rowSpan: report.workFlow.length}, {id:i,text: index+1, style:'tableData',rowSpan: report.workFlow.length},
{text: moment(report.date).format('YYYY.MM.DD'), style:'tableData', alignment: 'center',rowSpan: report.workFlow.length}, {text: moment(report.date).format('YYYY.MM.DD'), style:'tableData', alignment: 'center',rowSpan: report.workFlow.length},
{text: wf.Title, style:'tableData', alignment: 'center'}, {text: wf.Title, style:'tableData', alignment: 'center'},
{text: companies, style:'tableData', alignment: 'center'},
{text: emps, style:'tableData', alignment: 'center'}, {text: emps, style:'tableData', alignment: 'center'},
]); ]);
@ -1890,7 +1902,7 @@ async function printWorkReport(reports, workHeader)
//widths: [20, 'auto', 80, 80,'*','*','*'], //widths: [20, 'auto', 80, 80,'*','*','*'],
// widths: [20, '*', 70, 70,50,'auto','auto'], // widths: [20, '*', 70, 70,50,'auto','auto'],
widths: [20, 70,'*', 100], widths: [20, 70,'*', 100, 100],
body: item,//[], body: item,//[],
}, },

View File

@ -130,14 +130,34 @@ exports.apiGetUsers=asyncHandler(async (req,res)=>{
//const {workId,foremanId, workTitle,employeeList }=req.body; //const {workId,foremanId, workTitle,employeeList }=req.body;
res.setHeader('Content-Type', 'application/json'); res.setHeader('Content-Type', 'application/json');
try{ /* try{
const users=await Employee.find({'konyvelesre': 'on'},{_id:1,name:1},{sort: {name: 1}}) const users=await Employee.find({'konyvelesre': 'on'},{_id:1,name:1,company:1},{sort: {name: 1}})
res.send({'response':'ok','users':users}); res.send({'response':'ok','users':users});
}catch(err){ }catch(err){
res.status(500).json({'response':'fail','message':'Hiba a mentésnél !\n'+err.message});
}*/
try{
const users=await Employee.aggregate([
{ $sort: { "name": 1 } },
{$match: { "konyvelesre": "on"}},
{
$group: {
_id: {company:'$company'},
employees:{
$push:{
name: "$name",
id: "$_id"
}
}
}
},
]);
res.send({'response':'ok','users':users});
}
catch(err){
res.status(500).json({'response':'fail','message':'Hiba a mentésnél !\n'+err.message}); res.status(500).json({'response':'fail','message':'Hiba a mentésnél !\n'+err.message});
} }
}); });
exports.apiGetReportList=asyncHandler(async (req,res)=>{ exports.apiGetReportList=asyncHandler(async (req,res)=>{

View File

@ -128,7 +128,11 @@ let employeeSchema = mongoose.Schema({
end_date: {type: String}, end_date: {type: String},
duration: {type: Number}, duration: {type: Number},
}] }],
company:{
type: String,
required: true
},
}); });
employeeSchema.methods.comparePassword = function(candidatePassword, cb) { employeeSchema.methods.comparePassword = function(candidatePassword, cb) {

View File

@ -25,6 +25,7 @@ let workReportSchema = mongoose.Schema({
employeeList:[{ employeeList:[{
employeeId:{type: mongoose.Schema.Types.ObjectId}, employeeId:{type: mongoose.Schema.Types.ObjectId},
name: {type: String}, name: {type: String},
company: {type: String},
}] }]
}], }],
}) })

View File

@ -2642,6 +2642,7 @@ router.post('/add',utils.ensureAuthenticated,function(req,res){
req.checkBody('rfid','RFID azonosító megadása kötelező!').notEmpty(); req.checkBody('rfid','RFID azonosító megadása kötelező!').notEmpty();
req.checkBody('vacationYear','Éves szabadság megadása kötelező!').notEmpty(); req.checkBody('vacationYear','Éves szabadság megadása kötelező!').notEmpty();
req.checkBody('vacationUsed','Kiadott szabadság megadása kötelező!').notEmpty(); req.checkBody('vacationUsed','Kiadott szabadság megadása kötelező!').notEmpty();
req.checkBody('company','Cégnév megadása kötelező!').notEmpty();
req.checkBody('email', 'Email megadása kötelező!').notEmpty(); req.checkBody('email', 'Email megadása kötelező!').notEmpty();
req.checkBody('email', 'Nem valós email cím!').isEmail(); req.checkBody('email', 'Nem valós email cím!').isEmail();
req.checkBody('password', 'Jelszó megadása kötelező!').notEmpty(); req.checkBody('password', 'Jelszó megadása kötelező!').notEmpty();
@ -2672,6 +2673,7 @@ router.post('/add',utils.ensureAuthenticated,function(req,res){
employee.vacationUsed=req.body.vacationUsed; employee.vacationUsed=req.body.vacationUsed;
employee.password=req.body.password; employee.password=req.body.password;
employee.email=req.body.email; employee.email=req.body.email;
employee.company=req.body.company
employee.apiKey='-'; employee.apiKey='-';
employee.uuid='-'; employee.uuid='-';
mobilePortalAccessEnabled=false; mobilePortalAccessEnabled=false;
@ -2768,6 +2770,7 @@ router.post('/edit/:id', utils.ensureAuthenticated,function(req,res){
req.checkBody('rfid','RFID azonosító megadása kötelező!').notEmpty(); req.checkBody('rfid','RFID azonosító megadása kötelező!').notEmpty();
req.checkBody('vacationYear','Éves szabadság megadása kötelező!').notEmpty(); req.checkBody('vacationYear','Éves szabadság megadása kötelező!').notEmpty();
req.checkBody('vacationUsed','Kiadott szabadság megadása kötelező!').notEmpty(); req.checkBody('vacationUsed','Kiadott szabadság megadása kötelező!').notEmpty();
req.checkBody('company','Cégnév megadása kötelező!').notEmpty();
// Get errors // Get errors
let errors = req.validationErrors(); let errors = req.validationErrors();
@ -2790,6 +2793,7 @@ router.post('/edit/:id', utils.ensureAuthenticated,function(req,res){
employee.vacationYear=req.body.vacationYear; employee.vacationYear=req.body.vacationYear;
employee.vacationUsed=req.body.vacationUsed; employee.vacationUsed=req.body.vacationUsed;
employee.konyvelesre=req.body.flagKonyveles; employee.konyvelesre=req.body.flagKonyveles;
employee.company=req.body.company;
employee.mobilePortalAccessEnabled=Boolean(req.body.mobilePortalAccessEnabled); employee.mobilePortalAccessEnabled=Boolean(req.body.mobilePortalAccessEnabled);
employee.isSubcontractor=req.body.flagSubContractor; employee.isSubcontractor=req.body.flagSubContractor;
employee.isStudent=req.body.flagStudent; employee.isStudent=req.body.flagStudent;

View File

@ -50,9 +50,10 @@ script.
//const d=JSON.parse(decodeURIComponent($(identifier).data('item'))) //const d=JSON.parse(decodeURIComponent($(identifier).data('item')))
const d=$(identifier).data('id') const d=$(identifier).data('id')
const name=$(identifier).data('name') const name=$(identifier).data('name')
const company=$(identifier).data('company')
if (!state) if (!state)
{ {
workers.push({employeeId:d, name:name}); workers.push({employeeId:d, name:name,company:company});
} }
else else
{ {
@ -185,9 +186,18 @@ script.
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
console.log(data) console.log(data)
$.each(data.users,function(i,item){ /*$.each(data.users,function(i,item){
var data_str = encodeURIComponent(JSON.stringify(item)); var data_str = encodeURIComponent(JSON.stringify(item));
$('<button class="btn btn-primary aaa" disabled onclick="handleClick(this)" id="'+item._id+'" data-item="'+data_str+'" data-name="'+item.name+'" data-id="'+item._id+'" style="width:150px;margin: 3px" data-toggle="button" type="button">'+item.name+'</button>').appendTo('#buttons2'); $('<button class="btn btn-primary aaa" disabled onclick="handleClick(this)" id="'+item._id+'" data-item="'+data_str+'" data-name="'+item.name+'" data-id="'+item._id+'" style="width:150px;margin: 3px" data-toggle="button" type="button">'+item.name+'</button>').appendTo('#buttons2');
})*/
$.each(data.users,function(i,item){
$('<hr><h3>'+item._id.company+'</h3>').appendTo('#buttons2');
$.each(item.employees,function(l,user){
var data_str = encodeURIComponent(JSON.stringify(user));
$('<button class="btn btn-primary aaa" disabled onclick="handleClick(this)" id="'+user.id+'"data-item="'+data_str+'" data-name="'+user.name+'" data-id="'+user.id+'" data-company="'+item._id.company+'"style="width:150px;margin: 3px" data-toggle="button" type="button">'+user.name+'</button>').appendTo('#buttons2');
})
}) })
textChanged() textChanged()
}) })

View File

@ -50,9 +50,10 @@ script.
//const d=JSON.parse(decodeURIComponent($(identifier).data('item'))) //const d=JSON.parse(decodeURIComponent($(identifier).data('item')))
const d=$(identifier).data('id') const d=$(identifier).data('id')
const name=$(identifier).data('name') const name=$(identifier).data('name')
const company=$(identifier).data('company')
if (!state) if (!state)
{ {
workers.push({employeeId:d, name:name}); workers.push({employeeId:d, name:name,company:company});
} }
else else
{ {
@ -185,9 +186,18 @@ script.
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
console.log(data) console.log(data)
$.each(data.users,function(i,item){ /* $.each(data.users,function(i,item){
var data_str = encodeURIComponent(JSON.stringify(item)); var data_str = encodeURIComponent(JSON.stringify(item));
$('<button class="btn btn-primary aaa" disabled onclick="handleClick(this)" id="'+item._id+'" data-item="'+data_str+'" data-name="'+item.name+'" data-id="'+item._id+'" style="width:150px;margin: 3px" data-toggle="button" type="button">'+item.name+'</button>').appendTo('#buttons3'); $('<button class="btn btn-primary aaa" disabled onclick="handleClick(this)" id="'+item._id+'" data-item="'+data_str+'" data-name="'+item.name+'" data-id="'+item._id+'" style="width:150px;margin: 3px" data-toggle="button" type="button">'+item.name+'</button>').appendTo('#buttons3');
})*/
$.each(data.users,function(i,item){
$('<hr><h3>'+item._id.company+'</h3>').appendTo('#buttons3');
$.each(item.employees,function(l,user){
var data_str = encodeURIComponent(JSON.stringify(user));
$('<button class="btn btn-primary aaa" disabled onclick="handleClick(this)" id="'+user.id+'"data-item="'+data_str+'" data-name="'+user.name+'" data-id="'+user.id+'" data-company="'+item._id.company+'"style="width:150px;margin: 3px" data-toggle="button" type="button">'+user.name+'</button>').appendTo('#buttons3');
})
}) })
textChanged1() textChanged1()
}) })

View File

@ -50,9 +50,10 @@ script.
//const d=JSON.parse(decodeURIComponent($(identifier).data('item'))) //const d=JSON.parse(decodeURIComponent($(identifier).data('item')))
const d=$(identifier).data('id') const d=$(identifier).data('id')
const name=$(identifier).data('name') const name=$(identifier).data('name')
const company=$(identifier).data('company')
if (!state) if (!state)
{ {
workers.push({employeeId:d, name:name}); workers.push({employeeId:d, name:name,company:company});
} }
else else
{ {
@ -228,8 +229,14 @@ script.
.then(data => { .then(data => {
console.log(data) console.log(data)
$.each(data.users,function(i,item){ $.each(data.users,function(i,item){
var data_str = encodeURIComponent(JSON.stringify(item)); $('<hr><h3>'+item._id.company+'</h3>').appendTo('#buttons');
$('<button class="btn btn-primary aaa" disabled onclick="handleClick(this)" id="'+item._id+'"data-item="'+data_str+'" data-name="'+item.name+'" data-id="'+item._id+'" style="width:150px;margin: 3px" data-toggle="button" type="button">'+item.name+'</button>').appendTo('#buttons'); $.each(item.employees,function(l,user){
var data_str = encodeURIComponent(JSON.stringify(user));
//$('<button class="btn btn-primary aaa" disabled onclick="handleClick(this)" id="'+item._id+'"data-item="'+data_str+'" data-name="'+item.name+'" data-id="'+item._id+'" style="width:150px;margin: 3px" data-toggle="button" type="button">'+item.name+'</button>').appendTo('#buttons');
$('<button class="btn btn-primary aaa" disabled onclick="handleClick(this)" id="'+user.id+'"data-item="'+data_str+'" data-name="'+user.name+'" data-id="'+user.id+'" data-company="'+item._id.company+'"style="width:150px;margin: 3px" data-toggle="button" type="button">'+user.name+'</button>').appendTo('#buttons');
})
}) })
}) })
.catch(error => console.error('Error:', error)); .catch(error => console.error('Error:', error));

View File

@ -10,8 +10,13 @@ block content
.form-group(style='width:100%; background-color:#1F2739;') .form-group(style='width:100%; background-color:#1F2739;')
form(method='POST', action='/employee/add',onsubmit='frmSubmit(event)',style='padding:20px') form(method='POST', action='/employee/add',onsubmit='frmSubmit(event)',style='padding:20px')
#form-group #form-group
.row
.col-sm-6
label Név: label Név:
input.form-control.inputDark(name='Name',type=text, autofocus,tabindex='1', readonly=false,width='1000', value= workNum) input.form-control.inputDark(name='Name',type=text, autofocus,tabindex='1', readonly=false,width='1000', value= workNum)
.col-sm-6
label Cég:
input.form-control.inputDark(name='company',type=text, autofocus,tabindex='1', readonly=false,width='1000', value= "K-L Electro Bt",style='color: white;background-color:blueviolet;')
label Rövidített név: label Rövidített név:
input.form-control.inputDark(name='shortName',type=text, tabindex='2', readonly=false, value= workNum) input.form-control.inputDark(name='shortName',type=text, tabindex='2', readonly=false, value= workNum)
label Email: label Email:

View File

@ -10,8 +10,13 @@ block content
br br
form(method='POST',style='width:90%;padding-left: 50px', action='/employee/edit/'+employee._id,onsubmit='frmSubmit(event)') form(method='POST',style='width:90%;padding-left: 50px', action='/employee/edit/'+employee._id,onsubmit='frmSubmit(event)')
#form-group #form-group
.row
.col-sm-6
label Név: label Név:
input.form-control.inputDark(name='Name',type=text, autofocus,tabindex='1', readonly=false,width='1000', value= employee.name) input.form-control.inputDark(name='Name',type=text, autofocus,tabindex='1', readonly=false,width='1000', value= employee.name)
.col-sm-6
label Cégnév:
input.form-control.inputDark(name='company',type=text, autofocus,tabindex='1', readonly=false,width='1000', value= employee.company)
br br
label Rövidített név: label Rövidített név:
input.form-control.inputDark(name='shortName',type=text, tabindex='2', readonly=false, value= employee.shortName) input.form-control.inputDark(name='shortName',type=text, tabindex='2', readonly=false, value= employee.shortName)

View File

@ -219,13 +219,14 @@ block content
-//col(width='5%') -//col(width='5%')
col(width='10%') col(width='10%')
col(width='auto') col(width='auto')
col(width='15%') col(width='10%')
col(width='10%')
thead thead
tr tr
-//th # -//th #
th(style='text-align:left') Dátum th(style='text-align:left') Dátum
th(style='text-align:left') Munkavégzés leírása th(style='text-align:left') Munkavégzés leírása
th(style='text-align:left') Cég
th(style='text-align:left') Résztvevők th(style='text-align:left') Résztvevők
@ -340,7 +341,17 @@ block content
//newRow+= `<tr>` + //newRow+= `<tr>` +
newRow+= `<td>${item.Title}</td><td>` newRow+= `<td>${item.Title}</td><td>`
$.each(item.employeeList,function(idx,employee){
if (employee.company)
{
newRow+=employee.company+'<br>'
}
else
{
newRow+="K-L Electro Bt"+'<br>'
}
})
newRow+= `</td><td>`
$.each(item.employeeList,function(idx,employee){ $.each(item.employeeList,function(idx,employee){
newRow+=employee.name+'<br>' newRow+=employee.name+'<br>'
}) })

View File

@ -13,7 +13,7 @@ block content
.clickable{ .clickable{
cursor: pointer; cursor: pointer;
} }
h4#dummy(style="display:none") h4#dummy
#form-group #form-group
form(id="myForm",name="myForm",method='get', action='/work/generateXML/') form(id="myForm",name="myForm",method='get', action='/work/generateXML/')
.panel.panel-warning .panel.panel-warning