Add Movement !
This commit is contained in:
@@ -31,6 +31,7 @@ const _ = require('lodash');
|
||||
|
||||
const {User} = require('../models/user');
|
||||
const {MyGroup} = require('../models/mygroup');
|
||||
const {Circuit} = require('../models/circuit');
|
||||
const {Booking} = require('../models/booking');
|
||||
const {Operator} = require('../models/operator');
|
||||
const {Where} = require('../models/where');
|
||||
@@ -220,7 +221,12 @@ router.post('/testServer', authenticate_noerror, (req, res) => {
|
||||
router.post('/settable', authenticate, async (req, res) => {
|
||||
const params = req.body;
|
||||
const mytable = globalTables.getTableByTableName(params.table);
|
||||
const mydata = req.body.data;
|
||||
let mydata = req.body.data;
|
||||
let extrarec = {};
|
||||
if (myapp.hasOwnProperty('extrarec')) {
|
||||
extrarec = mydata['extrarec'];
|
||||
delete mydata['extrarec'];
|
||||
}
|
||||
|
||||
const fieldsvalue = {'ALL': 1};
|
||||
|
||||
@@ -263,7 +269,6 @@ router.post('/settable', authenticate, async (req, res) => {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (params.table === shared_consts.TAB_MYGROUPS) {
|
||||
if (shared_consts.MYGROUPS_KEY_TO_CRYPTED in mydata) {
|
||||
if (mydata[shared_consts.MYGROUPS_KEY_TO_CRYPTED]) {
|
||||
@@ -301,10 +306,11 @@ router.post('/settable', authenticate, async (req, res) => {
|
||||
}
|
||||
|
||||
if (shared_consts.TABLES_ID_NUMBER.includes(params.table)) {
|
||||
|
||||
} else if (params.table === 'hours') {
|
||||
|
||||
} else {
|
||||
if (mydata['_id'] === undefined) {
|
||||
if (mydata['_id'] === undefined || (mytablerec.isNew && mydata['_id'] === 0)) {
|
||||
mydata._id = new ObjectID();
|
||||
}
|
||||
}
|
||||
@@ -362,7 +368,7 @@ router.post('/settable', authenticate, async (req, res) => {
|
||||
typedir = shared_consts.TypeNotifs.TYPEDIR_BACHECA;
|
||||
typeid = (params.table === shared_consts.TABLES_MYGOODS)
|
||||
? shared_consts.TypeNotifs.ID_BACHECA_NEW_GOOD
|
||||
: shared_consts.TypeNotifs.ID_BACHECA_NEW_SERVICE
|
||||
: shared_consts.TypeNotifs.ID_BACHECA_NEW_SERVICE;
|
||||
setnotif = true;
|
||||
}
|
||||
|
||||
@@ -402,12 +408,11 @@ router.post('/settable', authenticate, async (req, res) => {
|
||||
// nuovo Record:
|
||||
// aggiungi il creatore al Circuito stesso
|
||||
return User.setCircuitCmd(mydata.idapp, req.user.username, myrec.name,
|
||||
shared_consts.CIRCUITCMD.SET, true, req.user.username).then((ris) => {
|
||||
shared_consts.CIRCUITCMD.SET, true, req.user.username, extrarec).then((ris) => {
|
||||
return res.send(myrec);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return res.send(myrec);
|
||||
}).catch((e) => {
|
||||
console.error('settable', e.message);
|
||||
@@ -1202,6 +1207,7 @@ function load(req, res, version) {
|
||||
let catgrps = CatGrp.findAllIdApp(idapp);
|
||||
let site = Site.findAllIdApp(idapp);
|
||||
let mygroups = MyGroup.findAllGroups(idapp);
|
||||
let listcircuits = Circuit.findAllIdApp(idapp);
|
||||
// let cities = City.findAllIdApp(idapp);
|
||||
let provinces = Province.findAllIdApp(idapp);
|
||||
let cart = null;
|
||||
@@ -1268,6 +1274,7 @@ function load(req, res, version) {
|
||||
goods,
|
||||
site,
|
||||
mygroups,
|
||||
listcircuits, // 37
|
||||
]).then((arrdata) => {
|
||||
// console.table(arrdata);
|
||||
let myuser = req.user;
|
||||
@@ -1347,6 +1354,7 @@ function load(req, res, version) {
|
||||
goods: arrdata[34],
|
||||
site: arrdata[35],
|
||||
mygroups: arrdata[36],
|
||||
listcircuits: arrdata[37],
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -719,6 +719,7 @@ router.post('/circuits/cmd', authenticate, (req, res) => {
|
||||
const circuitname = req.body.circuitname;
|
||||
const cmd = req.body.cmd;
|
||||
const value = req.body.value;
|
||||
const extrarec = req.body.extrarec;
|
||||
|
||||
/*if (!User.isAdmin(req.user.perm) || !User.isManager(req.user.perm)) {
|
||||
// If without permissions, exit
|
||||
@@ -728,7 +729,7 @@ router.post('/circuits/cmd', authenticate, (req, res) => {
|
||||
}
|
||||
}*/
|
||||
|
||||
return User.setCircuitCmd(idapp, usernameOrig, circuitname, cmd, value, usernameLogged).
|
||||
return User.setCircuitCmd(idapp, usernameOrig, circuitname, cmd, value, usernameLogged, extrarec).
|
||||
then((ris) => {
|
||||
res.send(ris);
|
||||
}).
|
||||
|
||||
Reference in New Issue
Block a user