Calcolo Hours
This commit is contained in:
@@ -59,6 +59,8 @@ const Storehouse = require('../models/storehouse');
|
||||
const Department = require('../models/department');
|
||||
const ShareWithUs = require('../models/sharewithus');
|
||||
const Group = require('../models/group');
|
||||
const { Todo } = require('../models/todo');
|
||||
const Hours = require('../models/hours');
|
||||
const Order = require('../models/order');
|
||||
|
||||
const tools = require('../tools/general');
|
||||
@@ -210,6 +212,10 @@ function getTableByTableName(tablename) {
|
||||
mytable = ShareWithUs;
|
||||
else if (tablename === 'groups')
|
||||
mytable = Group;
|
||||
else if (tablename === 'todos')
|
||||
mytable = Todo;
|
||||
else if (tablename === 'hours')
|
||||
mytable = Hours;
|
||||
else if (tablename === 'orders')
|
||||
mytable = Order;
|
||||
else if (tablename === 'producers')
|
||||
@@ -285,6 +291,7 @@ router.post('/settable', authenticate, (req, res) => {
|
||||
let mytablerec = new mytable(mydata);
|
||||
console.log('mytablerec', mytablerec);
|
||||
|
||||
const mytablestrutt = getTableByTableName(params.table);
|
||||
|
||||
return mytablerec.save()
|
||||
.then(rec => {
|
||||
@@ -293,7 +300,16 @@ router.post('/settable', authenticate, (req, res) => {
|
||||
|
||||
}).catch((e) => {
|
||||
console.log(e.message);
|
||||
res.status(400).send(e);
|
||||
if (e.code === 11000) {
|
||||
const id = mytablerec._id;
|
||||
delete mytablerec._doc['_id'];
|
||||
return mytablestrutt.findByIdAndUpdate(id, { $set: mytablerec._doc }).then(async (rec) => {
|
||||
return res.send(rec);
|
||||
}).catch((e) => {
|
||||
tools.mylog('error: ', e.message);
|
||||
return res.status(400).send(e);
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1120,6 +1136,8 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
|
||||
let gallery = Gallery.findAllIdApp(idapp);
|
||||
let producers = Producer.findAllIdApp(idapp);
|
||||
let groups = Group.findAllIdApp(idapp);
|
||||
let resps = User.getusersRespList(idapp);
|
||||
let workers = User.getusersWorkersList(idapp);
|
||||
let storehouses = Storehouse.findAllIdApp(idapp);
|
||||
let departments = Department.findAllIdApp(idapp);
|
||||
let cart = null;
|
||||
@@ -1136,7 +1154,7 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
|
||||
}
|
||||
|
||||
|
||||
return Promise.all([bookedevent, eventlist, operators, wheres, contribtype, settings, permissions, disciplines, newstosent, mailinglist, mypage, gallery, paymenttype, calcstat, calzoom, producers, cart, storehouses, departments, orderscart, groups])
|
||||
return Promise.all([bookedevent, eventlist, operators, wheres, contribtype, settings, permissions, disciplines, newstosent, mailinglist, mypage, gallery, paymenttype, calcstat, calzoom, producers, cart, storehouses, departments, orderscart, groups, resps, workers])
|
||||
.then((arrdata) => {
|
||||
// console.table(arrdata);
|
||||
const myuser = req.user;
|
||||
@@ -1166,6 +1184,8 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
|
||||
departments: arrdata[18],
|
||||
orders: arrdata[19],
|
||||
groups: arrdata[20],
|
||||
resps: arrdata[21],
|
||||
workers: arrdata[22],
|
||||
myuser,
|
||||
});
|
||||
})
|
||||
|
||||
@@ -139,6 +139,24 @@ router.get('/', (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
router.get('/calc/:id/:actualphase', authenticate, (req, res) => {
|
||||
var id = req.params.id;
|
||||
var actualphase = parseInt(req.params.actualphase);
|
||||
|
||||
let rec = {};
|
||||
|
||||
return Todo.calculateTreeTodo(actualphase, '', id, false, id, false)
|
||||
.then((rec) => {
|
||||
return res.send({ rec });
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).send();
|
||||
});
|
||||
|
||||
})
|
||||
;
|
||||
|
||||
|
||||
router.get('/:userId', authenticate, (req, res) => {
|
||||
const userId = req.params.userId;
|
||||
const idapp = req.query.idapp;
|
||||
@@ -173,7 +191,6 @@ router.get('/:userId', authenticate, (req, res) => {
|
||||
});
|
||||
|
||||
|
||||
|
||||
// USATO SOLO LE PRIME VOLTE! O A RICHIESTA!
|
||||
async function calcProjects(userId, obj) {
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ const Subscription = mongoose.model('subscribers');
|
||||
|
||||
var { Todo } = require('../models/todo');
|
||||
|
||||
const Hours = require('../models/hours');
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
const { ObjectID } = require('mongodb');
|
||||
@@ -79,7 +81,6 @@ router.patch('/:id', authenticate, (req, res) => {
|
||||
return res.status(404).send();
|
||||
}
|
||||
|
||||
|
||||
Todo.findByIdAndUpdate(id, { $set: body }, { new: true })
|
||||
.then((todo) => {
|
||||
if (!todo) {
|
||||
@@ -111,6 +112,22 @@ router.patch('/:id', authenticate, (req, res) => {
|
||||
});
|
||||
|
||||
|
||||
router.get('/calc/:id', authenticate, (req, res) => {
|
||||
var id = req.params.id;
|
||||
|
||||
let rec = {};
|
||||
|
||||
Hours.calculateHoursTodo(id).then((hoursworked) => {
|
||||
rec.hoursworked = hoursworked;
|
||||
return res.send({ rec });
|
||||
}).catch((err) => {
|
||||
res.status(400).send();
|
||||
});
|
||||
|
||||
return rec;
|
||||
|
||||
});
|
||||
|
||||
router.get('/:userId', authenticate, (req, res) => {
|
||||
var userId = req.params.userId;
|
||||
// var category = req.params.category;
|
||||
@@ -166,7 +183,7 @@ router.get('/test', (req, res) => {
|
||||
|
||||
});
|
||||
|
||||
res.send({ });
|
||||
res.send({});
|
||||
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user