This commit is contained in:
Surya Paolo
2024-01-13 16:21:07 +01:00
parent 7bf549569d
commit 79ca364e84
5 changed files with 23 additions and 6 deletions

View File

@@ -113,7 +113,7 @@ const orderSchema = new Schema({
date_delivered: { date_delivered: {
type: Date type: Date
}, },
notes: { note: {
type: String type: String
}, },
modify_at: { modify_at: {

View File

@@ -89,6 +89,12 @@ const OrdersCartSchema = new Schema({
note: { note: {
type: String type: String
}, },
note_per_gestore: {
type: String
},
note_per_admin: {
type: String
},
modify_at: { modify_at: {
type: Date type: Date
}, },

View File

@@ -193,15 +193,20 @@ module.exports.getProductById = async function (id) {
return arrris && arrris.length > 0 ? arrris[0] : null return arrris && arrris.length > 0 ? arrris[0] : null
} }
module.exports.findAllIdApp = async function (idapp, code, id) { module.exports.findAllIdApp = async function (idapp, code, id, all) {
let myfind = {}; let myfind = {};
let myqueryadd = {}; let myqueryadd = {};
let query = []; let query = [];
try { try {
if (idapp) if (idapp){
myfind = { idapp, active: true }; myfind = { idapp };
}
if (!all) {
myfind = { ...myfind, active: true }
}
if (code) { if (code) {
myfind = { ...myfind, code } myfind = { ...myfind, code }

View File

@@ -1443,7 +1443,7 @@ function load(req, res, version) {
let catprods = CatProd.findAllIdApp(idapp); let catprods = CatProd.findAllIdApp(idapp);
let subcatprods = SubCatProd.findAllIdApp(idapp); let subcatprods = SubCatProd.findAllIdApp(idapp);
let gasordines = Gasordine.findAllIdApp(idapp); let gasordines = Gasordine.findAllIdApp(idapp);
let products = Product.findAllIdApp(idapp); let products = Product.findAllIdApp(idapp, undefined, undefined, User.isManager(req.user.perm));
let productInfos = ProductInfo.findAllIdApp(idapp); let productInfos = ProductInfo.findAllIdApp(idapp);
let scontisticas = Scontistica.findAllIdApp(idapp); let scontisticas = Scontistica.findAllIdApp(idapp);
let departments = Department.findAllIdApp(idapp); let departments = Department.findAllIdApp(idapp);

View File

@@ -32,7 +32,13 @@ router.post('/', auth_default, async function (req, res, next) {
const idapp = req.body.idapp; const idapp = req.body.idapp;
let userId = req.body.userId; let userId = req.body.userId;
let products = await Product.findAllIdApp(idapp, ""); const myuser = await User.getUserById(idapp, userId);
let ismanager = false;
if (myuser && myuser.perm) {
ismanager = User.isManager(myuser.perm);
}
let products = await Product.findAllIdApp(idapp, "", undefined, ismanager);
let orders = null; let orders = null;
if (await User.isManagerById(userId)) { if (await User.isManagerById(userId)) {
// Prende Tutti gli Ordini ! // Prende Tutti gli Ordini !