Jelenléti ív átszerkesztve
This commit is contained in:
parent
966e240267
commit
8391e6aa8c
|
|
@ -0,0 +1,499 @@
|
|||
const Moment = require('moment');
|
||||
const MomentRange = require('moment-range');
|
||||
const moment = MomentRange.extendMoment(Moment);
|
||||
const { mongo} = require('mongoose');
|
||||
|
||||
let WorkingTime = require('../models/workingtime');
|
||||
let Work=require('../models/works');
|
||||
let WorkReport = require('../models/workReportModel');
|
||||
let Employee = require('../models/employee');
|
||||
|
||||
const munkaszunet=['2021.01.01','2021.03.15','2021.04.02','2021.04.05','2021.05.24','2021.08.20','2021.11.01','2021.12.24','2021.12.26',
|
||||
'2022.01.01','2022.03.14','2022.03.15','2022.04.15','2022.04.18','2022.06.06',
|
||||
'2023.01.01','2023.03.15','2023.04.07','2023.04.09','2023.04.10','2023.05.29','2023.10.23','2023.11.01','2023.12.25','2023.12.26',
|
||||
'2024.01.01','2024.03.15','2024.03.29','2024.04.01','2024.05.01','2024.05.20','2024.08.20','2024.10.23','2024.11.01','2024.12.24','2024.12.25','2024.12.26','2024.12.27',
|
||||
'2025.01.01','2025.04.18','2025.04.21','2025.05.01','2025.05.02','2025.06.09','2025.08.20','2025.10.23','2025.10.24','2024.12.25','2025.12.26'];
|
||||
|
||||
// Munkaszüneti napok
|
||||
const _getMunkaszunet=function (cmonth)
|
||||
{
|
||||
var t=[];
|
||||
munkaszunet.forEach(function(a){
|
||||
if (moment(a,'YYYY.MM.DD').isSame(moment(cmonth,'YYYY.MM'), 'month')) //true if dates are in the same month
|
||||
{
|
||||
t.push(moment(a,'YYYY.MM.DD').format('YYYY.MM.DD.'));
|
||||
}
|
||||
})
|
||||
//{date: '2021.01.06', isHoliday: true}
|
||||
//console.log(t);
|
||||
return t;
|
||||
}
|
||||
|
||||
function getDateRangeSickPay(startDate, endDate,mindate, dateFormat) {
|
||||
var dates = [],
|
||||
//selectedMonth=moment(mindate,'YYYY.DD').month();
|
||||
start=moment(startDate,'DD.MM.YYYY')
|
||||
end = moment(endDate,'DD.MM.YYYY');
|
||||
|
||||
diff = end.diff(start, 'days')+1;
|
||||
|
||||
|
||||
if(!start.isValid() || !end.isValid() || diff <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for(var i = 0; i < diff; i++) {
|
||||
|
||||
if (moment(start).format('YYYY.MM')===mindate)
|
||||
{
|
||||
//workDays.push({date:element.date,isWeekend:isWeekend,location:element.location,notes:element.notes,locations:[{arriveLoc:element.location,getawayLoc:element.locationStop}],startStop:[{start:element.timeArrive,stop:element.timeGetaway}],fullHours:element.workHours,hours:0,overTime:0});
|
||||
dates.push({date:start.format(dateFormat),isSickpay:true})
|
||||
}
|
||||
start.add(1,'d');
|
||||
}
|
||||
|
||||
return dates;
|
||||
};
|
||||
|
||||
function getDateRange(startDate, endDate,mindate, dateFormat) {
|
||||
var dates = [],
|
||||
//selectedMonth=moment(mindate,'YYYY.DD').month();
|
||||
start=moment(startDate,'DD.MM.YYYY')
|
||||
end = moment(endDate,'DD.MM.YYYY');
|
||||
|
||||
diff = end.diff(start, 'days')+1;
|
||||
|
||||
|
||||
if(!start.isValid() || !end.isValid() || diff <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for(var i = 0; i < diff; i++) {
|
||||
|
||||
if (moment(start).format('YYYY.MM')===mindate)
|
||||
{
|
||||
//workDays.push({date:element.date,isWeekend:isWeekend,location:element.location,notes:element.notes,locations:[{arriveLoc:element.location,getawayLoc:element.locationStop}],startStop:[{start:element.timeArrive,stop:element.timeGetaway}],fullHours:element.workHours,hours:0,overTime:0});
|
||||
dates.push({date:start.format(dateFormat),isHoliday:true})
|
||||
}
|
||||
start.add(1,'d');
|
||||
}
|
||||
|
||||
return dates;
|
||||
};
|
||||
|
||||
var _oneDayCalculate=function (fullTime)
|
||||
{
|
||||
const lunchtime=1*60
|
||||
const expectedWorkHours=8*60
|
||||
const overHourThreshold=1*60
|
||||
//var fullTime=moment(stop,"YYYY.MM.DD. HH.mm").diff(moment(start,"YYYY.MM.DD. HH.mm"),"minutes")
|
||||
const fl=fullTime-lunchtime; // Teljes idő - ebéd idő
|
||||
|
||||
const oh=fl-expectedWorkHours;
|
||||
const wh=fl-(fl-expectedWorkHours);
|
||||
var overHours=0;
|
||||
if (oh>overHourThreshold) overHours=oh; else overHours=0;
|
||||
const workHours=fl>=expectedWorkHours?wh:fl
|
||||
return {workHours:workHours,overHours:overHours,lunchtime:lunchtime}
|
||||
}
|
||||
|
||||
// Szabadság szűrés egy munkavállalóra dátum vég alapján.
|
||||
var _getHolidayListById=async function (employeeId,dateEndsWith,mindate)//,callback)
|
||||
{
|
||||
|
||||
var results = await Employee.aggregate([
|
||||
{ $match: {_id: mongo.ObjectId(employeeId)}},
|
||||
{ $unwind: '$holidayData'},
|
||||
{ $match: {$or:[{'holidayData.start_date': {$regex: dateEndsWith, $options:'/g/'}},{'holidayData.end_date': {$regex: dateEndsWith, $options:'/g/'}}]}},
|
||||
//{ $group: {_id: '$_id', list: {$push: {'start_date':'$holidayData.start_date', 'end_date':'$holidayData.end_date'}}}}
|
||||
{ $group: {_id: '$_id', list: {$push: '$holidayData'}}}
|
||||
]
|
||||
)
|
||||
var days=[];
|
||||
if (results.length>0)
|
||||
{
|
||||
console.log(results);
|
||||
results[0].list.forEach(element=>{
|
||||
var subDay=getDateRange(element.start_date,element.end_date,mindate,'YYYY.MM.DD');
|
||||
days.push.apply(days,subDay);
|
||||
|
||||
})
|
||||
}
|
||||
return days
|
||||
}
|
||||
|
||||
// Táppénz szűrés egy munkavállalóra dátum vég alapján.
|
||||
var _getSickpayListById=async function (employeeId,dateEndsWith,mindate)//,callback)
|
||||
{
|
||||
|
||||
var results =await Employee.aggregate([
|
||||
{ $match: {_id: mongo.ObjectId(employeeId)}},
|
||||
{ $unwind: '$sickpayData'},
|
||||
{ $match: {$or:[{'sickpayData.start_date': {$regex: dateEndsWith, $options:'/g/'}},{'sickpayData.end_date': {$regex: dateEndsWith, $options:'/g/'}}]}},
|
||||
{ $group: {_id: '$_id', list: {$push: '$sickpayData'}}}
|
||||
])
|
||||
var days=[];
|
||||
if (results.length>0)
|
||||
{
|
||||
console.log(results);
|
||||
results[0].list.forEach(element=>{
|
||||
var subDay=getDateRangeSickPay(element.start_date,element.end_date,mindate,'YYYY.MM.DD');
|
||||
days.push.apply(days,subDay);
|
||||
|
||||
})
|
||||
}
|
||||
return days
|
||||
|
||||
}
|
||||
|
||||
// workReport By User lekérdezés
|
||||
async function getWorkReportById(employeeId,mindate){
|
||||
|
||||
var dr_firstDay= moment(mindate,"YYYY.MM").startOf('month').toDate();
|
||||
var dr_lastDay = moment(mindate,"YYYY.MM").endOf('month').toDate();
|
||||
|
||||
const result= await WorkReport.aggregate([
|
||||
{$match: {"date":{$gte: dr_firstDay, $lte: dr_lastDay}}},
|
||||
//{$match: {"workId": mongo.ObjectId("6715f6ca6908a157c7d1f468")}},
|
||||
{
|
||||
|
||||
$unwind: "$workFlow"
|
||||
|
||||
},
|
||||
{ "$unwind": "$workFlow.employeeList" },
|
||||
{$match: {"workFlow.employeeList.employeeId": mongo.ObjectId(employeeId)}},
|
||||
|
||||
{$group: { _id:{
|
||||
'wf': '$employeeList.workFlow',
|
||||
'wid': '$_id',
|
||||
'name': '$workFlow.employeeList.name',
|
||||
},
|
||||
'id':{$first: '$_id'},
|
||||
'date':{$first:'$date'},
|
||||
'name': {$first:'$workFlow.employeeList.name'},
|
||||
'wf':{$first: '$workFlow.Title'},
|
||||
'wt':{$first: '$workTitle'}
|
||||
//'nm':{$push: {name:'$employee.name', wf:'$employeeList.workFlow'}}
|
||||
},
|
||||
},
|
||||
{
|
||||
// cleanup
|
||||
$project: {
|
||||
_id: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
])
|
||||
if (result.length){
|
||||
return result
|
||||
}
|
||||
else
|
||||
{
|
||||
return []
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Munkaidő lekérdezés
|
||||
function getWorkTimeListById(employeeId,mindate,callback)
|
||||
{
|
||||
var date = new Date();
|
||||
var query={};
|
||||
|
||||
// Ehavi esedékes
|
||||
|
||||
var firstDay= moment(mindate,"YYYY.MM").startOf('month').format("YYYY.MM.DD.");
|
||||
var lastDay = moment(mindate,"YYYY.MM").endOf('month').format("YYYY.MM.DD.");
|
||||
var dr_firstDay= moment(mindate,"YYYY.MM").startOf('month').format("YYYY.MM.DD");
|
||||
var dr_lastDay = moment(mindate,"YYYY.MM").endOf('month').format("YYYY.MM.DD");
|
||||
//query={$and:[{'state':'ENDED','date': {$gte : firstDay,$lte: lastDay},'employeeId': employeeId}]};
|
||||
query={$and:[{'date': {$gte : firstDay,$lte: lastDay},'employeeId': employeeId}]};
|
||||
|
||||
WorkingTime.find(query,null,function(err, wt){
|
||||
if (err)
|
||||
{
|
||||
callback(err);
|
||||
}
|
||||
else {
|
||||
Work.aggregate([
|
||||
{$unwind: '$dailyReport'},
|
||||
{
|
||||
"$match":{
|
||||
"dailyReport.employeeList": mongo.ObjectId(employeeId)
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
{"$match": {"dailyReport.date": {$gte: dr_firstDay, $lte: dr_lastDay} }},
|
||||
{$group: { _id: '$dailyReport._id','name': {$first: '$title'},'wid': {$first: '$_id'},'date': {$first: '$dailyReport.date'}}},
|
||||
], function(err,dr){
|
||||
if (err)
|
||||
{
|
||||
callback(err);
|
||||
}else
|
||||
{
|
||||
wt.rd=dr;
|
||||
// wt.wr=workReport // WorkReport Lekérése.;
|
||||
callback(null,wt);
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Egy havi munkaidő összegzés
|
||||
var _sumOfMonth=async function(employee_id,mindate,callback)
|
||||
{
|
||||
var msz=_getMunkaszunet(mindate);
|
||||
|
||||
workReport=await getWorkReportById(employee_id,mindate)//.then(workReport=>{ // WorkReport Lekérése.
|
||||
getWorkTimeListById(employee_id,mindate,function(err,wt){
|
||||
if (err)
|
||||
{
|
||||
console.log(err);
|
||||
callback(err);
|
||||
}
|
||||
else {
|
||||
var workDays=[];
|
||||
//wt.forEach(function(element)
|
||||
for (var element of wt)
|
||||
{
|
||||
var isMunkaszunet=false;//hoursToday=0;
|
||||
var drName='';
|
||||
var dwr=''
|
||||
var day = moment(element.date,'YYYY.MM.DD.').day();
|
||||
var drDate = moment(element.date,'YYYY.MM.DD.').format('YYYY.MM.DD');
|
||||
var isWeekend = (day === 6) || (day === 0); // 6 = Saturday, 0 = Sunday
|
||||
var latS=element.latitudeS;
|
||||
var lonS=element.longitudeS;
|
||||
var latE=element.latitudeE;
|
||||
var lonE=element.longitudeE;
|
||||
var workOnMunkaszunet=false;
|
||||
|
||||
|
||||
//var cNotes="";
|
||||
//var notes="";
|
||||
|
||||
var wr={}
|
||||
if (workReport.length){
|
||||
// wr=workReport.find(wrelement => wrelement.date===new Date(drDate))
|
||||
workReport.forEach(function(wrelement){
|
||||
///console.log(`Itemdate: ${wrelement.date} CurrDate: ${new Date(drDate)}`)
|
||||
if (new Date(wrelement.date).getTime()===new Date(drDate).getTime())
|
||||
{
|
||||
// console.log("Egyenlő!\n")
|
||||
wr=wrelement;
|
||||
}
|
||||
})
|
||||
|
||||
// if (wr!={})
|
||||
// console.log(wr.date)
|
||||
}
|
||||
var dr=wt.rd.filter(element => element.date==drDate)
|
||||
if (typeof element.latitudeS==='undefined') latS='N/A'
|
||||
if (typeof element.longitudeS==='undefined') lonS='N/A'
|
||||
if (typeof element.latitudeE==='undefined') latE='N/A'
|
||||
if (typeof element.longitudeE==='undefined') lonE='N/A'
|
||||
|
||||
// Ha hétköznap
|
||||
var wdays=workDays.find(e=>e.date===element.date);
|
||||
if (wdays)
|
||||
{ // Már van ilyen nap
|
||||
|
||||
wdays.startStop.push({id:element._id,start:element.timeArrive,stop:element.timeGetaway});
|
||||
wdays.locations.push({
|
||||
arriveLoc:element.location,
|
||||
getawayLoc:element.locationStop,
|
||||
arriveCoords:{lat:latS,lon:lonS},
|
||||
getavayCoords:{lat:latE,lon:lonE}
|
||||
});
|
||||
wdays.notes.push({userNote:element.notes, companyNote: element.company_notes});
|
||||
|
||||
wdays.fullHours+=element.workHours;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (typeof wr==='undefined')
|
||||
{
|
||||
dwr='';
|
||||
}
|
||||
else
|
||||
{
|
||||
dwr=wr;
|
||||
}
|
||||
if (typeof dr==='undefined')
|
||||
{
|
||||
drName='';
|
||||
}
|
||||
else
|
||||
{
|
||||
drName=dr;
|
||||
}
|
||||
// Még nincs ilyen nap, hozzáadjuk
|
||||
const idxmsz=msz.indexOf(element.date);
|
||||
if (idxmsz!==-1)
|
||||
{
|
||||
isMunkaszunet=true;
|
||||
element.company_notes="Ünnep"
|
||||
workOnMunkaszunet=true;
|
||||
element.isMunkaszunet=true
|
||||
msz.splice(idxmsz, 1);
|
||||
}
|
||||
workDays.push({
|
||||
date:element.date,
|
||||
isMunkaszunet:isMunkaszunet,
|
||||
workOnMunkaszunet:element.workOnMunkaszunet,
|
||||
isHoliday:false,
|
||||
isSickpay:false,
|
||||
isWeekend:isWeekend,
|
||||
state:element.state,
|
||||
location:element.location,
|
||||
notes:[{
|
||||
userNote: element.notes,
|
||||
companyNote: element.company_notes ?? "-"
|
||||
}],
|
||||
companyNotes: element.company_notes ?? "",
|
||||
locations:[{
|
||||
arriveLoc:element.location,
|
||||
getawayLoc:element.locationStop,
|
||||
arriveCoords:{lat:element.latitudeS,lon:element.longitudeS},
|
||||
getavayCoords:{lat:element.latitudeE,lon:element.longitudeE}
|
||||
}],
|
||||
startStop:[{
|
||||
id:element._id,
|
||||
start:element.timeArrive,
|
||||
stop:element.timeGetaway
|
||||
}],
|
||||
fullHours:element.workHours,
|
||||
hours:0,
|
||||
overTime:0,
|
||||
dailyReport:drName,
|
||||
workReport:dwr
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
msz.forEach(function(munkaszunet){
|
||||
workDays.push({date:munkaszunet,isMunkaszunet:true,hours:480,overTime:0,Surrogate:0,fullHours:0,startStop:[],locations:[],notes:[{userNote:'', companyNote: 'Ünnep'}]})
|
||||
})
|
||||
callback(null,workDays);
|
||||
}
|
||||
})//})
|
||||
|
||||
}
|
||||
|
||||
var _getAccessDetails=async function(id,mindate,callback) {
|
||||
|
||||
var holidaysArray=await _getHolidayListById(id,moment(mindate,'YYYY.MM').format('MM.YYYY'),mindate)//,function(err,holidaysArray){
|
||||
var sickpaysArray=await _getSickpayListById(id,moment(mindate,'YYYY.MM').format('MM.YYYY'),mindate)
|
||||
|
||||
|
||||
_sumOfMonth(id,mindate,function(err,som){
|
||||
if (err)
|
||||
{
|
||||
console.log(err);
|
||||
callback(err);
|
||||
}
|
||||
else {
|
||||
var month={overTime:0,workHours:0,fullWorkHours:0,sickPays:0};
|
||||
//var weekend={overTime:0,workHours:0,fullWorkHours:0,days:0};
|
||||
var weekend={
|
||||
Saturday:{overTime:0,workHours:0,fullWorkHours:0,days:0,Surrogate:0},
|
||||
Sunday:{overTime:0,workHours:0,fullWorkHours:0,days:0,Surrogate:0}
|
||||
}
|
||||
//var monthOverTime=0;
|
||||
//var monthWorkHours=0;
|
||||
//som.forEach(function(element)
|
||||
for (var element of som)
|
||||
{
|
||||
var hoursToday=0;
|
||||
var day = moment(element.date,'YYYY.MM.DD.').day();
|
||||
|
||||
if (element.state=="ENDED")//element.startStop[element.startStop.length-1].stop!='-')
|
||||
{
|
||||
// Napi idő kiszámítása
|
||||
var dayWorkHours=_oneDayCalculate(element.fullHours);
|
||||
|
||||
element.lunchtime=dayWorkHours.lunchtime;
|
||||
if (element.isWeekend)
|
||||
{
|
||||
|
||||
if (day===6) // Szombat
|
||||
{
|
||||
element.hours=(dayWorkHours.workHours);
|
||||
element.overTime=(dayWorkHours.overHours);
|
||||
element.Surrogate=Math.ceil((element.hours+element.overTime)*0.5);
|
||||
weekend.Saturday.workHours+=(element.hours*1.5);
|
||||
weekend.Saturday.overTime+=(element.overTime*1.5);
|
||||
weekend.Saturday.fullWorkHours+=((element.hours+element.overTime)*1.5);
|
||||
weekend.Saturday.days+=1;
|
||||
weekend.Saturday.Surrogate+=element.Surrogate;
|
||||
|
||||
}
|
||||
if (day===0) // Vasárnap
|
||||
{
|
||||
element.hours=dayWorkHours.workHours;
|
||||
element.overTime=dayWorkHours.overHours;
|
||||
element.Surrogate=(element.hours+element.overTime)
|
||||
weekend.Sunday.workHours+=element.hours;
|
||||
weekend.Sunday.overTime+=element.overTime;
|
||||
weekend.Sunday.fullWorkHours+=(element.hours+element.overTime);
|
||||
weekend.Sunday.days+=1;
|
||||
weekend.Sunday.Surrogate+=element.Surrogate;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ha hétköznap
|
||||
element.hours=dayWorkHours.workHours;//element.hours=540;
|
||||
element.overTime=dayWorkHours.overHours;//element.fullHours-element.hours
|
||||
element.Surrogate=0;
|
||||
month.workHours+=element.hours;
|
||||
month.overTime+=element.overTime;
|
||||
month.fullWorkHours+=(element.hours+element.overTime);
|
||||
|
||||
} // is Weekend
|
||||
}
|
||||
else
|
||||
{
|
||||
element.lunchtime=60;
|
||||
element.Surrogate=0;
|
||||
}
|
||||
|
||||
}
|
||||
var ja;
|
||||
var msz=_getMunkaszunet(mindate);
|
||||
|
||||
if (som.length>0) {
|
||||
ja = som.concat(holidaysArray);
|
||||
ja=ja.concat(sickpaysArray);
|
||||
}
|
||||
else
|
||||
{
|
||||
ja=holidaysArray;
|
||||
}
|
||||
ja.sort(function(a, b) {
|
||||
return moment(a.date,'YYYY.MM.DD') - moment(b.date,'YYYY.MM.DD');
|
||||
});
|
||||
month.sickPays=sickpaysArray.length;
|
||||
//callback(null,som,month,weekend);
|
||||
callback(null,ja,month,weekend);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
module.exports={
|
||||
getMunkaszunet:_getMunkaszunet,
|
||||
sumOfMonth: _sumOfMonth,
|
||||
getAccessDetails: _getAccessDetails,
|
||||
getHolidayListById: _getHolidayListById,
|
||||
getSickpayListById: _getSickpayListById,
|
||||
oneDayCalculate: _oneDayCalculate,
|
||||
}
|
||||
|
|
@ -0,0 +1,339 @@
|
|||
const moment = require('moment');
|
||||
// Nyomtatási kép generálás alkalmazottak
|
||||
// Segéd funkciók
|
||||
function convertMinsToHrsMins(minutes) {
|
||||
var h = Math.floor(minutes / 60);
|
||||
var m = minutes % 60;
|
||||
h = h < 10 ? '0' + h : h;
|
||||
m = m < 10 ? '0' + m : m;
|
||||
return h + ':' + m;
|
||||
}
|
||||
|
||||
function convertMinsToHrsMins_R(minutes) {
|
||||
var h = Math.floor(minutes / 60);
|
||||
var m = minutes % 60;
|
||||
if (m>=30) {
|
||||
h+=1;
|
||||
}
|
||||
h = h < 10 ? '0' + h : h;
|
||||
//m = m < 10 ? '0' + m : m;
|
||||
return h;// + ':' + m;
|
||||
}
|
||||
|
||||
exports.printPage=function(employee,som,month,weekend,mindate,holidaysArray,sickpaysArray,msz)
|
||||
{
|
||||
var dt = new Date();
|
||||
var item=[];
|
||||
var i=1;
|
||||
var namePostfix="";
|
||||
var drShift="";
|
||||
// Munkaszüneti napok ellenőrzése és kijelzése
|
||||
//var msz=getMunkaszunet(mindate);
|
||||
moment.locale('hu');
|
||||
|
||||
if (employee.isStudent==='on') namePostfix='Diák';
|
||||
|
||||
som.sort(function(a, b) {
|
||||
return moment(a.date,'YYYY.MM.DD') - moment(b.date,'YYYY.MM.DD');
|
||||
});
|
||||
|
||||
|
||||
item.push(['Dátum', //{text:'Nap', alignment: 'rleft'},
|
||||
{text:'Helyszín', alignment: 'center'},
|
||||
{text:'Érkezés', alignment: 'center'},
|
||||
{text:'Távozás', alignment: 'center'},
|
||||
{text:'Órák', alignment: 'center'},
|
||||
{text:'Ebéd', alignment: 'center'},
|
||||
{text:'Elszámolt', alignment: 'center'},
|
||||
{text:'Túlóra', alignment: 'center'},
|
||||
{text:'Pótlék', alignment: 'center'},
|
||||
'Megjegyzés']);
|
||||
som.forEach(element => {
|
||||
var arrives="";
|
||||
var getaways="";
|
||||
var locs="";
|
||||
var dreportList='';
|
||||
var workReport='';
|
||||
var locShift='';
|
||||
var wrShift='';
|
||||
var date = moment(element.date,'YYYY.MM.DD. HH:mm').format('DD')+' '+moment(element.date,'YYYY.MM.DD. HH:mm').format('dd').toUpperCase();
|
||||
var notes="";
|
||||
|
||||
|
||||
//if (element.dailyReport!='') drShift='\r\n'; else drShift='';
|
||||
drShift='';
|
||||
if (element.dailyReport)
|
||||
{
|
||||
if (element.dailyReport.length)
|
||||
{
|
||||
//drShift='\r\n';
|
||||
locShift='\r\n'
|
||||
}
|
||||
element.dailyReport.forEach(drelem=>{
|
||||
dreportList+= drelem.name.substring(0,60);
|
||||
if (element.dailyReport.length>1) dreportList+='\r\n'
|
||||
drShift+='\r\n';
|
||||
})
|
||||
}
|
||||
else
|
||||
{
|
||||
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.workReport){
|
||||
locShift='\r\n'
|
||||
//if (Object.keys(element.workReport).length!=0){
|
||||
if (Object.entries(element.workReport).length)
|
||||
{
|
||||
workReport='M: '+element.workReport.wt+' '+element.workReport.wf;
|
||||
workReport=workReport.substring(0,60);
|
||||
wrShift='\r\n'
|
||||
}
|
||||
}
|
||||
element.notes.forEach(note=>{
|
||||
notes+=note.userNote+' '+note.companyNote
|
||||
})
|
||||
if (element.isWeekend)
|
||||
{
|
||||
// Hétvége
|
||||
|
||||
element.startStop.forEach(interval=>{
|
||||
arrives+=moment(interval.start,'YYYY.MM.DD. HH:mm').format('HH:mm')+"\r\n";
|
||||
if (interval.stop==='-')
|
||||
{
|
||||
getaways+='-\r\n';
|
||||
}
|
||||
else
|
||||
{
|
||||
getaways+=moment(interval.stop,'YYYY.MM.DD. HH:mm').format('HH:mm')+"\r\n";
|
||||
}
|
||||
})
|
||||
|
||||
item.push([
|
||||
{text:date, style:'tableDataWe'},
|
||||
{text:dreportList+workReport+locShift+element.locations[0].arriveLoc+' - '+element.locations[0].getawayLoc, style:'tableDataWe', alignment: 'center'},
|
||||
{text:drShift+wrShift+arrives, style:'tableDataWe', alignment: 'center'},
|
||||
{text:drShift+wrShift+getaways, style:'tableDataWe', alignment: 'center'},
|
||||
{text:drShift+wrShift+convertMinsToHrsMins(element.fullHours), style:'tableDataWe', alignment: 'center'},
|
||||
{text:drShift+wrShift+convertMinsToHrsMins(element.lunchtime), style:'tableDataWe', alignment: 'center'},
|
||||
{text:drShift+wrShift+convertMinsToHrsMins(element.hours), style:'tableDataWe', alignment: 'center'}, //Elszámolt
|
||||
{text:drShift+wrShift+convertMinsToHrsMins(element.overTime), style:'tableDataWe', alignment: 'center'},
|
||||
{text:drShift+wrShift+convertMinsToHrsMins(element.Surrogate), style:'tableDataWe', alignment: 'center'}, //Pótlék
|
||||
{text:drShift+wrShift+notes, style:'tableDataWe', alignment: 'left'}]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Hétköznap
|
||||
element.startStop.forEach(interval=>{
|
||||
arrives+=moment(interval.start,'YYYY.MM.DD. HH:mm').format('HH:mm')+"\r\n";
|
||||
if (interval.stop==='-')
|
||||
{
|
||||
getaways+='-\r\n';
|
||||
}
|
||||
else
|
||||
{
|
||||
getaways+=moment(interval.stop,'YYYY.MM.DD. HH:mm').format('HH:mm')+"\r\n";
|
||||
}
|
||||
|
||||
})
|
||||
element.locations.forEach(interval=>{
|
||||
locs+=interval.arriveLoc+' - '+interval.getawayLoc+"\r\n";
|
||||
})
|
||||
item.push([
|
||||
{text:date, style:'tableData'},
|
||||
[{text:dreportList+workReport, style:'dailyReport'},{text:locs, style:'tableDataLoc', alignment: 'center'}],
|
||||
{text:drShift+wrShift+arrives, style:'tableData', alignment: 'center'},
|
||||
{text:drShift+wrShift+getaways, style:'tableData', alignment: 'center'},
|
||||
{text:drShift+wrShift+convertMinsToHrsMins(element.fullHours), style:'tableData', alignment: 'center'},
|
||||
{text:drShift+wrShift+convertMinsToHrsMins(element.lunchtime), style:'tableData', alignment: 'center'},
|
||||
{text:drShift+wrShift+convertMinsToHrsMins(element.hours), style:'tableData', alignment: 'center'}, //Elszámolt
|
||||
{text:drShift+wrShift+convertMinsToHrsMins(element.overTime), style:'tableData', alignment: 'center'},
|
||||
{text:drShift+wrShift+convertMinsToHrsMins(element.Surrogate), style:'tableData', alignment: 'center'}, //Pótlék
|
||||
{text:drShift+wrShift+notes, style:'tableDataWe', alignment: 'left'}]);
|
||||
}
|
||||
}//else
|
||||
return
|
||||
});
|
||||
item.push([
|
||||
{text:'Összesen:', style:'tableSum',colSpan: 6},
|
||||
// {text:'', style:'tableSum'},
|
||||
{text:'', style:'tableSum'},
|
||||
{text:'', style:'tableSum'},
|
||||
{text:'', style:'tableSum'},
|
||||
{text:'', style:'tableSum'},
|
||||
{text:'', style:'tableSum'},
|
||||
{text: convertMinsToHrsMins(month.workHours), style:'tableSum', alignment: 'center'},
|
||||
{text: convertMinsToHrsMins(month.overTime), style:'tableSum', alignment: 'center'},
|
||||
{text: convertMinsToHrsMins(weekend.Saturday.Surrogate+weekend.Sunday.Surrogate), style:'tableSum', alignment: 'center'},
|
||||
{text:'', style:'tableSum'},
|
||||
])
|
||||
// playground requires you to assign document definition to a variable called dd
|
||||
|
||||
if (employee.isSubcontractor==='on') employee.name+=" Alvállalkozó"
|
||||
if (employee.isStudent==='on') employee.name+=" Tanuló"
|
||||
var dd = {
|
||||
pageOrientation: 'landscape',
|
||||
footer: function(currentPage, pageCount) { return {text: currentPage.toString() + ' / ' + pageCount, alignment: 'center'}},
|
||||
header: {
|
||||
alignment: 'justify',
|
||||
columns: [
|
||||
{text: 'Jelenléti ív '+employee.name+' '+namePostfix, style: 'header',margin: [ 20, 10, 10, 20 ],width: '*'},
|
||||
{text: mindate, style: 'datum',margin: [ 5, 10, 20, 20 ],width: '*'}
|
||||
]
|
||||
},
|
||||
content: [
|
||||
|
||||
|
||||
{
|
||||
style: 'tableExample',
|
||||
table: {
|
||||
|
||||
headerRows: 1,
|
||||
widths: ['auto', 'auto','auto','auto','auto','auto','auto','auto','auto','*'],
|
||||
body: [],
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
stack:[
|
||||
{alignment: 'justify', columnGap: 10,
|
||||
columns:[
|
||||
{style: 'subheader',width: 'auto',alignment: 'left',margin: [ 5, 2, 0, 5 ],text: 'Ledolgozott órák:\n'+
|
||||
'Túlórák:\n'+
|
||||
'Hétvégi pótlékok:' },
|
||||
{style: 'subheader',width: 'auto',alignment: 'right',margin: [ 5, 2, 0, 5 ],text: `${convertMinsToHrsMins(month.workHours)} óra\n${convertMinsToHrsMins(month.overTime)} óra\n${convertMinsToHrsMins(weekend.Saturday.Surrogate+weekend.Sunday.Surrogate)} óra\n`}
|
||||
]},
|
||||
{alignment: 'justify',
|
||||
columns:[
|
||||
{style: 'subheader',width: 'auto',alignment: 'left',margin: [ 5, 2, 0, 5 ],text: 'Kiadott szabadság:\n'+
|
||||
'Táppénz:\n'+
|
||||
'Munkaszüneti napok:'},
|
||||
{style: 'subheader',width: '*',alignment: 'left',margin: [ 5, 2, 0, 5 ],text: `${holidaysArray.length} nap\n${month.sickPays} nap\n${msz.length} nap (${msz})\n`}
|
||||
]},
|
||||
|
||||
|
||||
|
||||
],
|
||||
unbreakable: true,
|
||||
id:'signature'
|
||||
}
|
||||
],
|
||||
pageBreakBefore: function(currentNode, followingNodesOnPage, nodesOnNextPage, previousNodesOnPage) {
|
||||
//check if signature part is completely on the last page, add pagebreak if not
|
||||
if (currentNode.id === 'signature' && (currentNode.pageNumbers.length != 1 || currentNode.pageNumbers[0] != currentNode.pages)) {
|
||||
return true;
|
||||
}
|
||||
//check if last paragraph is entirely on a single page, add pagebreak if not
|
||||
else if (currentNode.id === 'closingParagraph' && currentNode.pageNumbers.length != 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
styles: {
|
||||
header: {
|
||||
fontSize: 18,
|
||||
bold: true,
|
||||
fillColor: '#eeeeee',
|
||||
margin: [0, 0, 0, 10]
|
||||
},
|
||||
dailyReport: {
|
||||
fontSize: 8,
|
||||
bold: true,
|
||||
fillColor: '#494',
|
||||
alignment: 'center'
|
||||
},
|
||||
datum: {
|
||||
fontSize: 18,
|
||||
bold: true,
|
||||
fillColor: '#eeeeee',
|
||||
alignment: 'right'
|
||||
},
|
||||
subheader: {
|
||||
fontSize: 14,
|
||||
bold: true,
|
||||
fillColor: '#eeeeee',
|
||||
margin: [0, 10, 0, 5]
|
||||
},
|
||||
tableExample: {
|
||||
margin: [0, 5, 0, 15]
|
||||
},
|
||||
tableHeader: {
|
||||
bold: true,
|
||||
fontSize: 10,
|
||||
fillColor: '#eeeeee',
|
||||
color: 'red'
|
||||
},
|
||||
tableData: {
|
||||
bold: false,
|
||||
fontSize: 10,
|
||||
italics: true,
|
||||
color: 'green'
|
||||
},
|
||||
tableSum: {
|
||||
bold: true,
|
||||
fontSize: 10,
|
||||
italics: true,
|
||||
fillColor: '#ddddff',
|
||||
color: 'black'
|
||||
},
|
||||
tableDataLoc: {
|
||||
bold: false,
|
||||
fontSize: 8,
|
||||
italics: true,
|
||||
color: 'green'
|
||||
},
|
||||
tableDataWe: {
|
||||
bold: false,
|
||||
fontSize: 10,
|
||||
italics: true,
|
||||
fillColor: '#eeffee',
|
||||
color: 'red'
|
||||
},
|
||||
tableDataHo: {
|
||||
bold: false,
|
||||
fontSize: 10,
|
||||
italics: true,
|
||||
fillColor: '#eeeeff',
|
||||
color: 'red'
|
||||
},
|
||||
tableDataSp: {
|
||||
bold: false,
|
||||
fontSize: 10,
|
||||
italics: true,
|
||||
fillColor: '#eeeeee',
|
||||
color: 'brown'
|
||||
}
|
||||
},
|
||||
defaultStyle: {
|
||||
// alignment: 'justify'
|
||||
}
|
||||
};
|
||||
dd.content[0].table.body=item;
|
||||
|
||||
//pdf.createPdf(dd).open();
|
||||
// callback(null,dd);
|
||||
return dd;
|
||||
// ...
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ function renderWorkingTimesTable(wtList)
|
|||
'</td><td style="text-align:center">'+wt.state+
|
||||
'</td><td style="text-align:center">'+wt.device+
|
||||
'</td><td style="text-align:center">'+wt.location+
|
||||
'</td><td style="text-align:right">'+convertMinsToHrsMins(wt.month.fullHours)+//workHours)+
|
||||
'</td><td style="text-align:right">'+convertMinsToHrsMins(wt.month.workHours)+//workHours)+
|
||||
'</td>');
|
||||
}
|
||||
else
|
||||
|
|
@ -66,7 +66,7 @@ function renderWorkingTimesTable(wtList)
|
|||
'</td><td style="text-align:center">'+wt.state+
|
||||
'</td><td style="text-align:center">'+wt.device+
|
||||
'</td><td style="text-align:center">'+wt.location+
|
||||
'</td><td style="text-align:right">'+convertMinsToHrsMins(wt.month.fullHours)+//workHours)+
|
||||
'</td><td style="text-align:right">'+convertMinsToHrsMins(wt.month.workHours)+//workHours)+
|
||||
'</td>');
|
||||
}
|
||||
}
|
||||
|
|
@ -215,7 +215,15 @@ function renderWorkingTimesTableDetailed(wtList)
|
|||
document.getElementById('weekHourWork').value=convertMinsToHrsMins(monthWorkHours);
|
||||
document.getElementById('overTime').value=convertMinsToHrsMins(overTime);
|
||||
}
|
||||
|
||||
function isEmpty(obj) {
|
||||
for (var prop in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
// Táblázat sorainak generálása jelenléti ív részletes egy munkavállalóra egy havi
|
||||
function renderWorkingTimesTableDetailed2(wtList)
|
||||
{
|
||||
|
|
@ -246,7 +254,6 @@ function renderWorkingTimesTableDetailed2(wtList)
|
|||
var drName='<span>';
|
||||
var drShift='';
|
||||
var wrName='<span>';
|
||||
|
||||
var notes="";
|
||||
//var companyNotes="";
|
||||
/* if (wt.dailyReport==='')
|
||||
|
|
@ -265,16 +272,24 @@ function renderWorkingTimesTableDetailed2(wtList)
|
|||
|
||||
}*/
|
||||
//overTime='-';
|
||||
if (wt.isHoliday===false)
|
||||
if (wt.isHoliday===false && wt.isSickpay===false )
|
||||
{
|
||||
if (isEmpty(wt.workReport))
|
||||
{
|
||||
wrName='<span>';
|
||||
//wrShift='';
|
||||
}
|
||||
else{
|
||||
drShift+='<span></span><br>';
|
||||
}
|
||||
if (wt.dailyReport==='')
|
||||
{
|
||||
drName='<span>';
|
||||
drShift='';
|
||||
//drShift='';
|
||||
}
|
||||
else
|
||||
{
|
||||
drShift='';
|
||||
//drShift='';
|
||||
//drShift='<span></span><br>';
|
||||
$.each(wt.dailyReport,function(i,drs){
|
||||
drShift+='<span></span><br>';
|
||||
|
|
@ -291,6 +306,12 @@ function renderWorkingTimesTableDetailed2(wtList)
|
|||
color='#FB667A';
|
||||
|
||||
}
|
||||
if (wt.isMunkaszunet)
|
||||
{
|
||||
// Ha hétvége
|
||||
color='red';
|
||||
|
||||
}
|
||||
//document.getElementById("modifyColumn").rowSpan = wt.startStop.length;
|
||||
/*if (wt.startStop.length>1)
|
||||
{
|
||||
|
|
@ -298,8 +319,8 @@ function renderWorkingTimesTableDetailed2(wtList)
|
|||
}
|
||||
else
|
||||
{*/
|
||||
modifyColumn='</td><td>';
|
||||
deleteColumn='</td><td>';
|
||||
modifyColumn='</td><td><div>'+drShift;
|
||||
deleteColumn='</td><td><div>'+drShift;
|
||||
//}
|
||||
$.each(wt.startStop,function(i,interval){//</a><span class="glyphicon glyphicon-edit"></span>
|
||||
arrives+=moment(interval.start,'YYYY.MM.DD. HH:mm').format('HH:mm')+"<br>";
|
||||
|
|
@ -310,15 +331,15 @@ function renderWorkingTimesTableDetailed2(wtList)
|
|||
}*/
|
||||
if (interval.stop==='-')
|
||||
{
|
||||
modifyColumn+='<div>'+drShift+'<a.disabledLink href=\"#\" class=\"disabledLink\" style=\"color:gray;cursor:not-allowed;\"></a><span class="glyphicon glyphicon-edit disabledLink"></span></div>';
|
||||
deleteColumn+='<div>'+drShift+'<a.disabledLink href=\"#\" class=\".disabledLink\" style=\"color:gray;cursor:not-allowed;\"></a><span class="glyphicon glyphicon-trash disabledLink"></span></div>';
|
||||
modifyColumn+='<a.disabledLink href=\"#\" class=\"disabledLink\" style=\"color:gray;cursor:not-allowed;\"></a><span class="glyphicon glyphicon-edit disabledLink"></span></div>';
|
||||
deleteColumn+='<a.disabledLink href=\"#\" class=\".disabledLink\" style=\"color:gray;cursor:not-allowed;\"></a><span class="glyphicon glyphicon-trash disabledLink"></span></div>';
|
||||
|
||||
getaways+="-";
|
||||
}
|
||||
else
|
||||
{
|
||||
modifyColumn+='<div>'+drShift+'<a.openModal href=\"#\" data-toggle=\"modal\" data-id=\"'+interval.id+'\" data-target=\"#wtimeEditModal\" class=\"openModal\" style=\"color:green\"></a><span class="glyphicon glyphicon-edit normal"></span></div>';
|
||||
deleteColumn+='<div>'+drShift+'<a.delete-worktime href=\"#\" , data-id=\"'+interval.id+'\" class=\"delete-worktime\" style=\"color:red\"></a><span class="glyphicon glyphicon-trash normal"></span></div>';
|
||||
modifyColumn+='<a.openModal href=\"#\" data-toggle=\"modal\" data-id=\"'+interval.id+'\" data-target=\"#wtimeEditModal\" class=\"openModal\" style=\"color:green\"></a><span class="glyphicon glyphicon-edit normal"></span></div>';
|
||||
deleteColumn+='<a.delete-worktime href=\"#\" , data-id=\"'+interval.id+'\" class=\"delete-worktime\" style=\"color:red\"></a><span class="glyphicon glyphicon-trash normal"></span></div>';
|
||||
|
||||
getaways+=moment(interval.stop,'YYYY.MM.DD. HH:mm').format('HH:mm')+"<br>";
|
||||
}
|
||||
|
|
@ -347,9 +368,10 @@ function renderWorkingTimesTableDetailed2(wtList)
|
|||
$.each(wt.notes,function(i,note){
|
||||
notes+='<div class="ibr">'+note.userNote+'<span2>'+ ' '+note.companyNote+'</span2></div>'
|
||||
})
|
||||
|
||||
newRow.append(
|
||||
'<td style="text-align:right">'+moment(wt.date,'YYYY.MM.DD. HH:mm').format('DD')+'</td>'+
|
||||
'<td class="td" style="text-align:left;color:'+color+'">'+moment(wt.date,'YYYY.MM.DD. HH:mm').format('dddd')+'</td>'+
|
||||
'<td style="text-align:center">'+moment(wt.date,'YYYY.MM.DD. HH:mm').format('DD')+'</td>'+
|
||||
'<td class="td" style="text-align:center;color:'+color+'">'+moment(wt.date,'YYYY.MM.DD. HH:mm').format('dd').toUpperCase()+'</td>'+
|
||||
'<td style="text-align:center">'+drName+wrName+locs+'</span>'+'</td>'+//wt.location+
|
||||
'<td style="text-align:center">'+drShift+arrives+'</td>'+//moment(wt.timeArrive,'YYYY.MM.DD. HH:mm').format('HH:mm')+
|
||||
|
||||
|
|
@ -357,8 +379,11 @@ function renderWorkingTimesTableDetailed2(wtList)
|
|||
modifyColumn+
|
||||
deleteColumn+
|
||||
//'</td><td style="text-align:right">'+convertMinsToHrsMins(wt.workHours)+
|
||||
'<td style="text-align:right">'+drShift+convertMinsToHrsMins(wt.hours)+'</td>'+
|
||||
'<td style="text-align:right">'+drShift+convertMinsToHrsMins(wt.overTime)+'</td>'+
|
||||
'<td style="text-align:right">'+drShift+convertMinsToHrsMins(wt.fullHours)+'</td>'+
|
||||
'<td style="text-align:right">'+drShift+convertMinsToHrsMins(wt.lunchtime)+'</td>'+
|
||||
'<td style="text-align:center">'+drShift+convertMinsToHrsMins(wt.hours)+'</td>'+
|
||||
'<td style="text-align:center">'+drShift+convertMinsToHrsMins(wt.overTime)+'</td>'+
|
||||
'<td style="text-align:center">'+drShift+convertMinsToHrsMins(wt.Surrogate)+'</td>'+
|
||||
//'<td style="text-align:left;><div class="ibr">'+wt.notes+'<span2>'+ ' '+wt.companyNotes+'</span2></div>'+'</td>'
|
||||
'<td style="text-align:left">'+notes+'</td>'
|
||||
);
|
||||
|
|
@ -370,7 +395,7 @@ function renderWorkingTimesTableDetailed2(wtList)
|
|||
hol++;
|
||||
newRow.append(
|
||||
'<td style="text-align:right">'+moment(wt.date,'YYYY.MM.DD. HH:mm').format('DD')+
|
||||
'</td><td class="td" style="text-align:left;color:'+color+'">'+moment(wt.date,'YYYY.MM.DD. HH:mm').format('dddd')+
|
||||
'</td><td class="td" style="text-align:left;color:'+color+'">'+moment(wt.date,'YYYY.MM.DD. HH:mm').format('dd').toUpperCase()+
|
||||
'</td><td style="text-align:center"> ---- '+//wt.location+
|
||||
'</td><td style="text-align:center"> --:-- '+//moment(wt.timeArrive,'YYYY.MM.DD. HH:mm').format('HH:mm')+
|
||||
|
||||
|
|
@ -380,16 +405,77 @@ function renderWorkingTimesTableDetailed2(wtList)
|
|||
//'</td><td style="text-align:right">'+convertMinsToHrsMins(wt.workHours)+
|
||||
'</td><td style="text-align:right"> --:--'+
|
||||
'</td><td style="text-align:right"> --:--'+
|
||||
'</td><td style="text-align:right"> --:--'+
|
||||
'</td><td style="text-align:right"> --:--'+
|
||||
'</td><td style="text-align:right"> --:--'+
|
||||
'</td><td style="text-align:left"> Szabadság'+
|
||||
'</td>');
|
||||
}
|
||||
|
||||
if (wt.isSickpay===true)
|
||||
{
|
||||
hol++;
|
||||
newRow.append(
|
||||
'<td style="text-align:right">'+moment(wt.date,'YYYY.MM.DD. HH:mm').format('DD')+
|
||||
'</td><td class="td" style="text-align:left;color:'+color+'">'+moment(wt.date,'YYYY.MM.DD. HH:mm').format('dd').toUpperCase()+
|
||||
'</td><td style="text-align:center"> ---- '+//wt.location+
|
||||
'</td><td style="text-align:center"> --:-- '+//moment(wt.timeArrive,'YYYY.MM.DD. HH:mm').format('HH:mm')+
|
||||
|
||||
'</td><td style="text-align:center"> --:--'+
|
||||
'</td><td>'+
|
||||
'</td><td>'+
|
||||
//'</td><td style="text-align:right">'+convertMinsToHrsMins(wt.workHours)+
|
||||
'</td><td style="text-align:right"> --:--'+
|
||||
'</td><td style="text-align:right"> --:--'+
|
||||
'</td><td style="text-align:right"> --:--'+
|
||||
'</td><td style="text-align:right"> --:--'+
|
||||
'</td><td style="text-align:right"> --:--'+
|
||||
'</td><td style="text-align:left"> Táppénz'+
|
||||
'</td>');
|
||||
}
|
||||
}
|
||||
if (wt.isMunkaszunet===true && wt.startStop.length===0)
|
||||
{
|
||||
|
||||
newRow.append(
|
||||
'<td style="text-align:right">'+moment(wt.date,'YYYY.MM.DD. HH:mm').format('DD')+
|
||||
'</td><td class="td" style="text-align:left;color:red">'+moment(wt.date,'YYYY.MM.DD. HH:mm').format('dd').toUpperCase()+
|
||||
'</td><td style="text-align:center"> ---- '+//wt.location+
|
||||
'</td><td style="text-align:center"> --:-- '+//moment(wt.timeArrive,'YYYY.MM.DD. HH:mm').format('HH:mm')+
|
||||
|
||||
'</td><td style="text-align:center"> --:--'+
|
||||
'</td><td>'+
|
||||
'</td><td>'+
|
||||
//'</td><td style="text-align:right">'+convertMinsToHrsMins(wt.workHours)+
|
||||
'</td><td style="text-align:right"> --:--'+
|
||||
'</td><td style="text-align:right"> --:--'+
|
||||
'</td><td style="text-align:right"> --:--'+
|
||||
'</td><td style="text-align:right"> --:--'+
|
||||
'</td><td style="text-align:right"> --:--'+
|
||||
'</td><td style="text-align:left;color:red"> Ünnep'+
|
||||
'</td>');
|
||||
}
|
||||
$('#monthHoursTableDetails > tbody:last-child').append (newRow);
|
||||
// document.getElementById('weekendsCount').value=wtList.weekend.days;//weekendDays.length;
|
||||
|
||||
})
|
||||
|
||||
var sumRow='<tr>'+
|
||||
'<td style="text-align:right;color: white;font-size: 16px;">∑</td>'+
|
||||
'<td></td>'+
|
||||
'<td></td>'+
|
||||
'<td></td>'+
|
||||
'<td></td>'+
|
||||
'<td></td>'+
|
||||
'<td></td>'+
|
||||
'<td></td>'+
|
||||
'<td></td>'+
|
||||
'<td style="text-align:center;color: white;font-size: 16px;">'+convertMinsToHrsMins(wtList.month.workHours)+'</td>'+
|
||||
'<td style="text-align:center;color: white;font-size: 16px;">'+convertMinsToHrsMins(wtList.month.overTime)+'</td>'+
|
||||
'<td style="text-align:center;color: white;font-size: 16px;">'+convertMinsToHrsMins(wtList.weekend.Saturday.Surrogate+wtList.weekend.Sunday.Surrogate)+'</td>'+
|
||||
'<td></td>'+
|
||||
'</tr>'
|
||||
$('#monthHoursTableDetails > tbody:last-child').append (sumRow);
|
||||
|
||||
|
||||
// személyi adatok lekérése
|
||||
var uid=document.getElementById('uid').textContent;
|
||||
|
||||
|
|
@ -399,16 +485,35 @@ function renderWorkingTimesTableDetailed2(wtList)
|
|||
document.getElementById('vacations').value=(employee.vacationYear-employee.vacationUsed);
|
||||
document.getElementById('vacationsY').value=employee.vacationYear;
|
||||
document.getElementById('munkaszunet').value=wtList.munkaszunet.length;
|
||||
newRow=$('<tr>"'+
|
||||
'<td style="text-align:left;color: white;font-size: 16px;"> Munkaszüneti napokra elszámolt órák: '+'</td>'+
|
||||
'<td style="text-align:center;font-size: 16px;"> '+convertMinsToHrsMins((wtList.munkaszunet.length*480))+'</td>'+
|
||||
'<td style="text-align:center;font-size: 16px;"> --:--'+'</td>'+
|
||||
'<td style="text-align:center;font-size: 16px;"> '+convertMinsToHrsMins((wtList.munkaszunet.length*480))+'</td>'+
|
||||
'<td style="text-align:center;font-size: 16px;"> -'+'</td>'+
|
||||
'<td style="text-align:center;font-size: 16px;"> '+convertMinsToHrsMins((wtList.munkaszunet.length*480))+'</td>'+
|
||||
newRow=$(
|
||||
'<tr>"'+
|
||||
'<td style="text-align:left;color: white;font-size: 16px;"> Ledolgozott órák: '+'</td>'+
|
||||
'<td style="text-align:center;font-size: 16px;"> '+convertMinsToHrsMins(wtList.month.workHours)+'</td>'+
|
||||
'"</tr>'+
|
||||
'<tr>"'+
|
||||
'<td style="text-align:left;color: white;font-size: 16px;"> Szabadságra elszámolt órák: '+'</td>'+
|
||||
'<td style="text-align:left;color: white;font-size: 16px;"> Túlórák: '+'</td>'+
|
||||
'<td style="text-align:center;font-size: 16px;"> '+convertMinsToHrsMins(wtList.month.overTime)+'</td>'+
|
||||
'"</tr>'+
|
||||
'<tr>"'+
|
||||
'<td style="text-align:left;color: white;font-size: 16px;"> Hétvégi pótlékok: '+'</td>'+
|
||||
'<td style="text-align:center;font-size: 16px;"> '+convertMinsToHrsMins(wtList.weekend.Saturday.Surrogate+wtList.weekend.Sunday.Surrogate)+'</td>'+
|
||||
'"</tr>'+
|
||||
'<tr>"'+
|
||||
'<td style="text-align:left;color: white;font-size: 16px;"> Kiadott szabadságok: '+'</td>'+
|
||||
'<td style="text-align:center;font-size: 16px;"> '+wtList.munkaszunet.length+'</td>'+
|
||||
'"</tr>'+
|
||||
'<tr>"'+
|
||||
'<td style="text-align:left;color: white;font-size: 16px;"> Táppénz: '+'</td>'+
|
||||
'<td style="text-align:center;font-size: 16px;"> '+wtList.month.sickPays+'</td>'+
|
||||
'"</tr>'+
|
||||
|
||||
'<tr>"'+
|
||||
'<td style="text-align:left;color: white;font-size: 16px;"> Munkaszüneti napok: '+'</td>'+
|
||||
'<td style="text-align:center;font-size: 16px;"> '+wtList.munkaszunet.length+'</td>'+
|
||||
'"</tr>'
|
||||
|
||||
/*'<tr>"'+
|
||||
'<td style="text-align:left;color: white;font-size: 16px;"> Kiadott szabadságok: '+'</td>'+
|
||||
'<td style="text-align:center;font-size: 16px;"> '+convertMinsToHrsMins((hol*480))+'</td>'+
|
||||
'<td style="text-align:center;font-size: 16px;"> --:--'+'</td>'+
|
||||
'<td style="text-align:center;font-size: 16px;"> '+convertMinsToHrsMins((hol*480))+'</td>'+
|
||||
|
|
@ -464,55 +569,27 @@ function renderWorkingTimesTableDetailed2(wtList)
|
|||
(wtList.munkaszunet.length*480)+
|
||||
(hol*480)
|
||||
)+'</td>'+
|
||||
'"</tr>'
|
||||
'"</tr>'*/
|
||||
);
|
||||
}
|
||||
else
|
||||
{ // Vállalkozó
|
||||
newRow=$(
|
||||
'<tr>"'+
|
||||
'<td style="text-align:left;color: white;font-size: 16px;"> Munkanapok: '+'</td>'+
|
||||
'<td style="text-align:left;color: white;font-size: 16px;"> Ledolgozott órák: '+'</td>'+
|
||||
'<td style="text-align:center;font-size: 16px;"> '+convertMinsToHrsMins(wtList.month.workHours)+'</td>'+
|
||||
'"</tr>'+
|
||||
'<tr>"'+
|
||||
'<td style="text-align:left;color: white;font-size: 16px;"> Túlórák: '+'</td>'+
|
||||
'<td style="text-align:center;font-size: 16px;"> '+convertMinsToHrsMins(wtList.month.overTime)+'</td>'+
|
||||
'<td style="text-align:center;font-size: 16px;"> '+convertMinsToHrsMins(wtList.month.fullWorkHours)+'</td>'+
|
||||
//'<td style="text-align:center;font-size: 16px;"> -'+'</td>'+
|
||||
//'<td style="text-align:center;font-size: 16px;"> '+convertMinsToHrsMins(wtList.month.fullWorkHours)+'</td>'+
|
||||
'"</tr>'+
|
||||
'<tr>"'+
|
||||
'<td style="text-align:left;color: white;font-size: 16px;"> Szombat: '+'</td>'+
|
||||
'<td style="text-align:center;font-size: 16px;"> '+convertMinsToHrsMins(wtList.weekend.Saturday.workHours)+'</td>'+
|
||||
'<td style="text-align:center;font-size: 16px;"> '+convertMinsToHrsMins(wtList.weekend.Saturday.overTime)+'</td>'+
|
||||
'<td style="text-align:center;font-size: 16px;"> '+convertMinsToHrsMins(wtList.weekend.Saturday.fullWorkHours)+'</td>'+
|
||||
//'<td style="text-align:center;font-size: 16px;"> 50%'+'</td>'+
|
||||
//'<td style="text-align:center;font-size: 16px;"> '+convertMinsToHrsMins((wtList.weekend.Saturday.fullWorkHours*1.5))+'</td>'+
|
||||
'<td style="text-align:left;color: white;font-size: 16px;"> Hétvégi pótlékok: '+'</td>'+
|
||||
'<td style="text-align:center;font-size: 16px;"> '+convertMinsToHrsMins(wtList.weekend.Saturday.Surrogate+wtList.weekend.Sunday.Surrogate)+'</td>'+
|
||||
'"</tr>'+
|
||||
'<tr>"'+
|
||||
'<td style="text-align:left;color: white;font-size: 16px;"> Vasárnap: '+'</td>'+
|
||||
'<td style="text-align:center;font-size: 16px;"> '+convertMinsToHrsMins(wtList.weekend.Sunday.workHours)+'</td>'+
|
||||
'<td style="text-align:center;font-size: 16px;"> '+convertMinsToHrsMins(wtList.weekend.Sunday.overTime)+'</td>'+
|
||||
'<td style="text-align:center;font-size: 16px;"> '+convertMinsToHrsMins(wtList.weekend.Sunday.fullWorkHours)+'</td>'+
|
||||
//'<td style="text-align:center;font-size: 16px;"> 100%'+'</td>'+
|
||||
//'<td style="text-align:center;font-size: 16px;"> '+convertMinsToHrsMins((wtList.weekend.Sunday.fullWorkHours*2))+'</td>'+
|
||||
'"</tr>'+
|
||||
'<tr>"'+
|
||||
'<td style="text-align:left;color: white;font-weight:bold;font-size: 16px;"> Összesen: '+'</td>'+
|
||||
'<td style="text-align:center;font-weight:bold;font-size: 16px;"> '+convertMinsToHrsMins(wtList.month.workHours+
|
||||
wtList.weekend.Saturday.workHours+
|
||||
wtList.weekend.Sunday.workHours
|
||||
)+'</td>'+
|
||||
'<td style="text-align:center;font-weight:bold;font-size: 16px;"> '+convertMinsToHrsMins(wtList.month.overTime+
|
||||
wtList.weekend.Saturday.overTime+
|
||||
wtList.weekend.Sunday.overTime
|
||||
)+'</td>'+
|
||||
'<td style="text-align:center;font-weight:bold;font-size: 16px;"> '+convertMinsToHrsMins(wtList.month.fullWorkHours+
|
||||
wtList.weekend.Saturday.fullWorkHours+
|
||||
wtList.weekend.Sunday.fullWorkHours
|
||||
)+'</td>'+
|
||||
//'<td>'+'</td>'+
|
||||
/*'<td style="text-align:center;color: red;font-weight:bold;font-size: 16px;"> '+convertMinsToHrsMins(wtList.month.fullWorkHours+
|
||||
(wtList.weekend.Saturday.fullWorkHours*1.5)+
|
||||
(wtList.weekend.Sunday.fullWorkHours*2)
|
||||
)+'</td>'*/+
|
||||
'<td style="text-align:left;color: white;font-size: 16px;"> Munkaszüneti napok: '+'</td>'+
|
||||
'<td style="text-align:center;font-size: 16px;"> '+wtList.munkaszunet.length+'</td>'+
|
||||
'"</tr>'
|
||||
);
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,112 @@
|
|||
const moment=require("moment")
|
||||
|
||||
const start="2025.02.07. 6:59"
|
||||
const stop="2025.02.07. 17:12"
|
||||
const lunchtime=1*60
|
||||
const expectedWorkHours=8*60
|
||||
const overHourThreshold=1*60
|
||||
|
||||
function convertMinsToHrsMins(minutes) {
|
||||
var h = Math.floor(minutes / 60);
|
||||
var m = minutes % 60;
|
||||
h = h < 10 ? '0' + h : h;
|
||||
m = m < 10 ? '0' + m : m;
|
||||
return h + ':' + m;
|
||||
}
|
||||
|
||||
|
||||
/*function convertMinsToHrsMins(minutes) {
|
||||
const hours = Math.floor(minutes / 60);
|
||||
const remainingMinutes = minutes % 60;
|
||||
console.log("remainingminutes: "+remainingMinutes)
|
||||
return `${String(hours).padStart(2, '0')}:${String(remainingMinutes).padStart(2, '0')}`;
|
||||
}*/
|
||||
|
||||
var fullTime=moment(stop,"YYYY.MM.DD. HH.mm").diff(moment(start,"YYYY.MM.DD. HH.mm"),"minutes")
|
||||
const fl=fullTime-lunchtime; // Teljes idő - ebéd idő
|
||||
|
||||
const oh=fl-expectedWorkHours;
|
||||
const wh=fl-(fl-expectedWorkHours);
|
||||
var overHours=0;
|
||||
if (oh>overHourThreshold) overHours=oh; else overHours=0;
|
||||
var workHours=fl>=expectedWorkHours?wh:fl
|
||||
console.log(`Full Time: ${convertMinsToHrsMins(fullTime)}
|
||||
Lunch: ${convertMinsToHrsMins(lunchtime)}
|
||||
WorkHour: ${convertMinsToHrsMins(workHours)}
|
||||
OverHour: ${convertMinsToHrsMins(overHours)}`)
|
||||
|
||||
|
||||
/*
|
||||
|
||||
if (element.startStop[element.startStop.length-1].stop!='-')
|
||||
{
|
||||
if (element.isWeekend)
|
||||
{
|
||||
if (element.fullHours>540)
|
||||
{ // A túlórát nem számoljuk a munkaidő közé
|
||||
element.hours=540;
|
||||
if (element.fullHours>=600)
|
||||
{
|
||||
element.overTime=element.fullHours-element.hours;
|
||||
}
|
||||
else
|
||||
{
|
||||
element.overTime=0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
element.hours=element.fullHours;
|
||||
element.overTime=0;
|
||||
}
|
||||
if (day===6) // Szombat
|
||||
{
|
||||
weekend.Saturday.workHours+=element.hours;
|
||||
weekend.Saturday.overTime+=element.overTime;
|
||||
//weekend.Saturday.fullWorkHours+=element.fullHours;
|
||||
weekend.Saturday.fullWorkHours+=(element.hours+element.overTime);
|
||||
weekend.Saturday.days+=1;
|
||||
}
|
||||
if (day===0) // Vasárnap
|
||||
{
|
||||
weekend.Sunday.workHours+=element.hours;
|
||||
weekend.Sunday.overTime+=element.overTime;
|
||||
//weekend.Sunday.fullWorkHours+=element.fullHours;
|
||||
weekend.Sunday.fullWorkHours+=(element.hours+element.overTime);
|
||||
weekend.Sunday.days+=1;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (element.fullHours>540)
|
||||
{ // A túlórát nem számoljuk a munkaidő közé
|
||||
element.hours=540;
|
||||
//element.overTime=element.fullHours-element.hours;
|
||||
if (element.fullHours>=600)
|
||||
{
|
||||
element.overTime=element.fullHours-element.hours;
|
||||
}
|
||||
else
|
||||
{
|
||||
element.overTime=0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
element.hours=element.fullHours;
|
||||
element.overTime=0;
|
||||
}
|
||||
month.workHours+=element.hours;
|
||||
month.overTime+=element.overTime;
|
||||
//month.fullWorkHours+=element.fullHours;
|
||||
month.fullWorkHours+=(element.hours+element.overTime);
|
||||
//monthWorkHours+= element.hours;
|
||||
//monthOverTime+=element.overTime;
|
||||
// Ha hétköznap
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
|
@ -142,17 +142,17 @@ block content
|
|||
table#monthSumTable.container(style='width:90%;')
|
||||
col(width='auto')
|
||||
col(width='10%')
|
||||
col(width='10%')
|
||||
col(width='10%')
|
||||
col(width='10%')
|
||||
col(width='10%')
|
||||
//-col(width='10%')
|
||||
col(width='10%')
|
||||
col(width='10%')
|
||||
col(width='10%')
|
||||
thead
|
||||
tr
|
||||
th
|
||||
h1(style='text-align:left;font-size: 16px;') Megnevezés
|
||||
th
|
||||
h1(style='text-align:center;font-size: 16px;') Normál
|
||||
th
|
||||
h1(style='text-align:center;font-size: 16px;') Érték
|
||||
//-th
|
||||
h1(style='text-align:center;font-size: 16px;') Túlóra
|
||||
th
|
||||
h1(style='text-align:center;font-size: 16px;') Összesen
|
||||
|
|
@ -166,15 +166,15 @@ block content
|
|||
table#monthSumTable.container(style='width:90%;')
|
||||
col(width='auto')
|
||||
col(width='10%')
|
||||
col(width='10%')
|
||||
col(width='10%')
|
||||
//-col(width='10%')
|
||||
col(width='10%')
|
||||
thead
|
||||
tr
|
||||
th
|
||||
h1(style='text-align:left;font-size: 16px;') Megnevezés
|
||||
th
|
||||
h1(style='text-align:center;font-size: 16px;') Normál
|
||||
th
|
||||
h1(style='text-align:center;font-size: 16px;') Érték
|
||||
//-th
|
||||
h1(style='text-align:center;font-size: 16px;') Túlóra
|
||||
th
|
||||
h1(style='text-align:center;font-size: 16px;') Összesen
|
||||
|
|
@ -201,9 +201,9 @@ block content
|
|||
#darktable.container
|
||||
br
|
||||
table#monthHoursTableDetails.container(style='width:90%;')
|
||||
col(width='5%')
|
||||
col(width='5%')
|
||||
col(width='40%')
|
||||
col(width='4%')
|
||||
col(width='4%')
|
||||
col(width='35%')
|
||||
col(width='6%')
|
||||
col(width='6%')
|
||||
if(userIsAdmin==true)
|
||||
|
|
@ -211,6 +211,9 @@ block content
|
|||
col(width='3%')
|
||||
col(width='6%')
|
||||
col(width='6%')
|
||||
col(width='6%')
|
||||
col(width='6%')
|
||||
col(width='6%')
|
||||
col(width='auto')
|
||||
thead
|
||||
tr
|
||||
|
|
@ -232,7 +235,13 @@ block content
|
|||
th
|
||||
h1(style='text-align:left') Órák
|
||||
th
|
||||
h1(style='text-align:center') Túlóra
|
||||
h1(style='text-align:left') Ebéd
|
||||
th
|
||||
h1(style='text-align:left') Elszámolt
|
||||
th
|
||||
h1(style='text-align:center') Túlóra
|
||||
th
|
||||
h1(style='text-align:center') Pótlék
|
||||
th
|
||||
h1(style='text-align:left') Megjegyzés
|
||||
tbody
|
||||
|
|
|
|||
Loading…
Reference in New Issue