Ordini
This commit is contained in:
@@ -54,7 +54,9 @@ const { MsgTemplate } = require('../models/msg_template');
|
||||
const Product = require('../models/product');
|
||||
const Producer = require('../models/producer');
|
||||
const Cart = require('../models/cart');
|
||||
const OrdersCart = require('../models/orderscart');
|
||||
const Storehouse = require('../models/storehouse');
|
||||
const ShareWithUs = require('../models/sharewithus');
|
||||
const Order = require('../models/order');
|
||||
|
||||
const tools = require('../tools/general');
|
||||
@@ -200,6 +202,8 @@ function getTableByTableName(tablename) {
|
||||
mytable = Product;
|
||||
else if (tablename === 'storehouses')
|
||||
mytable = Storehouse;
|
||||
else if (tablename === 'sharewithus')
|
||||
mytable = ShareWithUs;
|
||||
else if (tablename === 'orders')
|
||||
mytable = Order;
|
||||
else if (tablename === 'producers')
|
||||
@@ -270,7 +274,7 @@ router.post('/settable', authenticate, (req, res) => {
|
||||
}
|
||||
|
||||
|
||||
mytablerec = new mytable(mydata);
|
||||
let mytablerec = new mytable(mydata);
|
||||
console.log('mytablerec', mytablerec);
|
||||
|
||||
|
||||
@@ -993,7 +997,8 @@ router.delete('/delrec/:table/:id', authenticate, async (req, res) => {
|
||||
if (!cancellato) {
|
||||
ris = await mytable.findByIdAndRemove(id).then((rec) => {
|
||||
if (!rec) {
|
||||
return res.status(404).send();
|
||||
// res.status(404).send();
|
||||
return false;
|
||||
}
|
||||
myrec = rec;
|
||||
|
||||
@@ -1012,7 +1017,7 @@ router.delete('/delrec/:table/:id', authenticate, async (req, res) => {
|
||||
|
||||
if (cancellato) {
|
||||
// Do extra things after deleted
|
||||
let ris2 = await actions.doOtherlasThingsAfterDeleted(tablename, myrec, notifBot, req);
|
||||
//let ris2 = await actions.doOtherlasThingsAfterDeleted(tablename, myrec, notifBot, req);
|
||||
if (!!ris) {
|
||||
return res.send({ code: server_constants.RIS_CODE_OK, msg: '' });
|
||||
}
|
||||
@@ -1108,6 +1113,7 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
|
||||
let producers = Producer.findAllIdApp(idapp);
|
||||
let storehouses = Storehouse.findAllIdApp(idapp);
|
||||
let cart = null;
|
||||
let orderscart = null;
|
||||
if (sall) {
|
||||
newstosent = Newstosent.findAllIdApp(idapp);
|
||||
}
|
||||
@@ -1116,10 +1122,11 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
|
||||
if (req.user) {
|
||||
calcstat = User.calculateStat(idapp, req.user.username);
|
||||
cart = Cart.getCartByUserId(req.user.id, idapp);
|
||||
orderscart = OrdersCart.getOrdersCartByUserId(req.user.id, idapp);
|
||||
}
|
||||
|
||||
|
||||
return Promise.all([bookedevent, eventlist, operators, wheres, contribtype, settings, permissions, disciplines, newstosent, mailinglist, mypage, gallery, paymenttype, calcstat, calzoom, producers, cart, storehouses])
|
||||
return Promise.all([bookedevent, eventlist, operators, wheres, contribtype, settings, permissions, disciplines, newstosent, mailinglist, mypage, gallery, paymenttype, calcstat, calzoom, producers, cart, storehouses, orderscart])
|
||||
.then((arrdata) => {
|
||||
// console.table(arrdata);
|
||||
const myuser = req.user;
|
||||
@@ -1146,6 +1153,7 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
|
||||
producers: arrdata[15],
|
||||
cart: arrdata[16],
|
||||
storehouses: arrdata[17],
|
||||
orders: arrdata[18],
|
||||
myuser,
|
||||
});
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user