Aggiornamento Ore
This commit is contained in:
@@ -201,7 +201,7 @@ async function ImportData(locale, idapp, strdata, settomailchimp) {
|
||||
|
||||
}
|
||||
|
||||
ris = {numadded, numtot, numalreadyexisted};
|
||||
ris = { numadded, numtot, numalreadyexisted };
|
||||
|
||||
console.log(ris);
|
||||
return ris
|
||||
@@ -349,13 +349,15 @@ router.post('/testemail', authenticate, async (req, res) => {
|
||||
|
||||
const test = false;
|
||||
|
||||
let ris = null;
|
||||
|
||||
if (test) {
|
||||
const email = 'pao.loarena77@gmail.com';
|
||||
const myuser = await User.findOne({ idapp, email });
|
||||
|
||||
const ris = await sendemail.testemailHtml(idapp, lang, email, myuser);
|
||||
ris = await sendemail.testemailHtml(idapp, lang, email, myuser);
|
||||
} else {
|
||||
const ris = await sendemail.testemail(idapp, lang, previewonly);
|
||||
ris = await sendemail.testemail(idapp, lang, previewonly);
|
||||
}
|
||||
|
||||
if (ris)
|
||||
|
||||
@@ -11,6 +11,7 @@ const { authenticate } = require('../middleware/authenticate');
|
||||
|
||||
const { Project } = require('../models/project');
|
||||
const { Todo } = require('../models/todo');
|
||||
const { User } = require('../models/user');
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
@@ -160,7 +161,6 @@ router.get('/:userId', authenticate, (req, res) => {
|
||||
const userId = req.params.userId;
|
||||
const idapp = req.query.idapp;
|
||||
|
||||
tools.mylog('GET PROJECTS : ', req.params);
|
||||
|
||||
if (!ObjectID.isValid(userId)) {
|
||||
return res.status(404).send();
|
||||
@@ -171,21 +171,28 @@ router.get('/:userId', authenticate, (req, res) => {
|
||||
return res.status(404).send({ code: server_constants.RIS_CODE_TODO_CREATING_NOTMYUSER });
|
||||
}
|
||||
|
||||
// Extract all the projects of the userId only
|
||||
return Project.getAllProjects(userId, idapp).then((objprojects) => {
|
||||
if (!!objprojects.arrproj)
|
||||
tools.mylog('projects', objprojects.arrproj.length);
|
||||
// Receive the Projects only for specific Users:
|
||||
return User.isUserVisuProjects(idapp, req.user.username).then((isresidente) => {
|
||||
// Extract all the projects of the userId only
|
||||
if (!isresidente)
|
||||
return res.send({ projects: [] });
|
||||
|
||||
return objprojects
|
||||
return Project.getAllProjects(userId, idapp).then((objprojects) => {
|
||||
if (!!objprojects.arrproj)
|
||||
tools.mylog('projects', objprojects.arrproj.length);
|
||||
|
||||
}).then((objprojects) => {
|
||||
return objprojects
|
||||
|
||||
res.send({ projects: objprojects.arrproj });
|
||||
}).then((objprojects) => {
|
||||
|
||||
}).catch((e) => {
|
||||
console.log(e.message);
|
||||
res.status(400).send(e);
|
||||
});
|
||||
res.send({ projects: objprojects.arrproj });
|
||||
|
||||
}).catch((e) => {
|
||||
console.log(e.message);
|
||||
res.status(400).send(e);
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -123,6 +123,8 @@ async function SendMsgToParam(idapp, params) {
|
||||
invia = user.profile.socioresidente;
|
||||
}else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_NON_SOCI) {
|
||||
invia = !user.profile.socio;
|
||||
}else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_PAOLO) {
|
||||
invia = user.username === 'paoloarcnm';
|
||||
} else {
|
||||
invia = true;
|
||||
}
|
||||
|
||||
@@ -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 });
|
||||
|
||||
@@ -94,15 +94,17 @@ router.post('/', async (req, res) => {
|
||||
// Controlla se anche l'ultimo record era dallo stesso IP:
|
||||
const lastrec = await User.getLastRec(body.idapp);
|
||||
if (!!lastrec) {
|
||||
if (lastrec.ipaddr === user.ipaddr) {
|
||||
// Se l'ha fatto troppo ravvicinato
|
||||
if (lastrec.date_reg) {
|
||||
let ris = tools.isdiffSecDateLess(lastrec.date_reg, 120);
|
||||
if (ris) {
|
||||
tools.writeIPToBan(user.ipaddr + ': [' + user.username + '] ' + user.name + ' ' + user.surname);
|
||||
await tools.snooze(10000);
|
||||
res.status(400).send({ code: server_constants.RIS_CODE_BANIP, msg: '' });
|
||||
return 1;
|
||||
if (process.env.LOCALE !== "1") {
|
||||
if (lastrec.ipaddr === user.ipaddr) {
|
||||
// Se l'ha fatto troppo ravvicinato
|
||||
if (lastrec.date_reg) {
|
||||
let ris = tools.isdiffSecDateLess(lastrec.date_reg, 120);
|
||||
if (ris) {
|
||||
tools.writeIPToBan(user.ipaddr + ': [' + user.username + '] ' + user.name + ' ' + user.surname);
|
||||
await tools.snooze(10000);
|
||||
res.status(400).send({ code: server_constants.RIS_CODE_BANIP, msg: '' });
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -279,9 +281,9 @@ router.post('/', async (req, res) => {
|
||||
// Invia un'email all'utente
|
||||
// tools.mylog('process.env.TESTING_ON', process.env.TESTING_ON);
|
||||
console.log('res.locale', res.locale);
|
||||
if (!tools.testing()) {
|
||||
// if (!tools.testing()) {
|
||||
await sendemail.sendEmail_Registration(user.lang, user.email, user, user.idapp, user.linkreg);
|
||||
}
|
||||
// }
|
||||
res.header('x-auth', token).send(user);
|
||||
return true;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user