Aggiornamento Ore
This commit is contained in:
@@ -22,7 +22,7 @@ const _ = require('lodash');
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
router.post('/load', authenticate, async (req, res) => {
|
||||
const date_start = req.body.date_start;
|
||||
let date_start = req.body.date_start;
|
||||
const date_end = req.body.date_end;
|
||||
const filter = req.body.filter;
|
||||
const idapp = req.body.idapp;
|
||||
@@ -43,8 +43,17 @@ router.post('/load', authenticate, async (req, res) => {
|
||||
|
||||
const arrhour = {};
|
||||
|
||||
let mydatets = tools.dateToEpoch(date_start)
|
||||
let mydatets_end = tools.dateToEpoch(date_end)
|
||||
// date_start = '2021-03-04T01:37:47.969Z';
|
||||
|
||||
// let mydatets = tools.dateToEpoch(date_start)
|
||||
// let mydate = new Date(tools.getstrDateYYYY_MM_DD(new Date(date_start)));
|
||||
let mydate = new Date(date_start);
|
||||
let mydatestr = mydate.toDateString();
|
||||
let mydatets = tools.dateToEpoch(mydatestr) + (new Date().getTimezoneOffset() * 60 * 1000);
|
||||
mydate = new Date(mydatets);
|
||||
let mydateyyymmdd = tools.getstrUTCDateYYYY_MM_DD(tools.AddDate(new Date(mydatestr), 1));
|
||||
|
||||
let mydatets_end = tools.dateToEpoch(date_end);
|
||||
|
||||
for (const myuser of listaResidenti) {
|
||||
arrhour[myuser.username] = [];
|
||||
@@ -55,24 +64,27 @@ router.post('/load', authenticate, async (req, res) => {
|
||||
totalacchours[myuser.username] = 0;
|
||||
}
|
||||
|
||||
let rectotal = {};
|
||||
|
||||
|
||||
while (mydatets <= mydatets_end) {
|
||||
// console.log('mydatets', mydatets, 'mydate', mydate);
|
||||
for (const myuser of listaResidenti) {
|
||||
// for (const myproj of objprojects.arrproj) {
|
||||
//let myhours = await Hours.getHoursByIdCat(idapp, myuser._id, myproj._id, date_start, date_end);
|
||||
let mydate = new Date(mydatets);
|
||||
let rechours = await Hours.getHoursByDate(idapp, myuser._id, mydate);
|
||||
let ressum = await Hours.getTotalHoursByDate(idapp, myuser.id, mydate);
|
||||
|
||||
if (tools.isMonday(mydatets)) {
|
||||
if (tools.isMondayDate(mydate)) {
|
||||
totalacchours[myuser.username] = 0;
|
||||
}
|
||||
|
||||
if ((ressum > 0) || ((tools.isSunday(mydatets)) && totalacchours[myuser.username] > 0)) {
|
||||
if ((ressum > 0) || ((tools.isSundayDate(mydate)) && totalacchours[myuser.username] > 0)) {
|
||||
totalacchours[myuser.username] = totalacchours[myuser.username] + ressum;
|
||||
const rectotal = {
|
||||
rectotal = {
|
||||
totalhours: ressum,
|
||||
totalacchours: 0,
|
||||
date: tools.getstrDateYYYY_MM_DD(mydate),
|
||||
date: mydateyyymmdd,
|
||||
}
|
||||
|
||||
if (tools.isSunday(mydatets)) {
|
||||
@@ -108,7 +120,7 @@ router.post('/load', authenticate, async (req, res) => {
|
||||
colors.themebgcolor = myproj.themebgcolor;
|
||||
colors.themecolor = myproj.themecolor;
|
||||
}
|
||||
if (!colors.themebgcolor) {
|
||||
if (!colors.themebgcolor || colors.themebgcolor === 'white') {
|
||||
if (myproj) {
|
||||
colors = await Project.findColorsByProject(myproj._id);
|
||||
}
|
||||
@@ -128,7 +140,15 @@ router.post('/load', authenticate, async (req, res) => {
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
// console.log('mydatestr', mydatestr, 'mydateyyymmdd', mydateyyymmdd)
|
||||
// if (!!rectotal)
|
||||
// console.log('TOT', rectotal.totalacchours);
|
||||
|
||||
mydatets += 86400000;
|
||||
mydate = tools.AddDate(mydate, 1);
|
||||
mydatestr = mydate.toDateString();
|
||||
mydateyyymmdd = tools.getstrUTCDateYYYY_MM_DD(tools.AddDate(new Date(mydatestr), 1));
|
||||
}
|
||||
|
||||
return res.send({ listaResidenti, arrhour });
|
||||
|
||||
Reference in New Issue
Block a user