Reportistica Ore 3

This commit is contained in:
Paolo Arena
2021-02-25 02:59:25 +01:00
parent 39c08afb95
commit 4800186161
6 changed files with 23 additions and 5 deletions

View File

@@ -281,6 +281,8 @@ router.post('/settable', authenticate, (req, res) => {
if (mydata["_id"] === undefined) {
mydata._id = 1;
}
} else if (params.table === 'hours') {
} else {
if (mydata["_id"] === undefined) {
mydata._id = new ObjectID()
@@ -302,7 +304,11 @@ router.post('/settable', authenticate, (req, res) => {
if (e.code === 11000) {
const id = mytablerec._id;
delete mytablerec._doc['_id'];
return mytablestrutt.findByIdAndUpdate(id, { $set: mytablerec._doc }).then(async (rec) => {
const myfields = mytablerec._doc;
if (!myfields.userId) {
myfields.userId = req.user._id.toString();
}
return mytablestrutt.findByIdAndUpdate(id, { $set: myfields }).then(async (rec) => {
return res.send(rec);
}).catch((err) => {
tools.mylog('error: ', err.message);

View File

@@ -47,7 +47,7 @@ router.post('/', authenticate, (req, res) => {
.then(record => {
// tools.mylog('REC SAVED :', record.descr);
tools.sendNotificationToUser(todo.userId, titolo + ' ' + record.descr, record.descr, '/todo/' + todo.category, '', 'todo', [])
tools.sendNotificationToUser(record.userId, titolo + ' ' + record.descr, record.descr, '/todo/' + record._id, '', 'todo', [])
res.send({ record: record._doc });

View File

@@ -61,7 +61,7 @@ router.post('/load', authenticate, async (req, res) => {
//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);
let ressum = await Hours.getTotalHoursByDate(idapp, myuser.id, mydate);
if (tools.isMonday(mydatets)) {
totalacchours[myuser.username] = 0;
@@ -98,7 +98,7 @@ router.post('/load', authenticate, async (req, res) => {
colors.themebgcolor = mytodo.themebgcolor;
colors.themecolor = mytodo.themecolor;
myproj = await Project.findProjectByUserId('', mytodo.category);
if (!themebgcolor && myproj) {
if (!colors.themebgcolor && myproj) {
colors.themebgcolor = myproj.themebgcolor;
colors.themecolor = myproj.themecolor;
}