++GasOrdini
This commit is contained in:
72
src/server/models/gasordine.js
Executable file
72
src/server/models/gasordine.js
Executable file
@@ -0,0 +1,72 @@
|
|||||||
|
mongoose = require('mongoose').set('debug', false)
|
||||||
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
|
mongoose.Promise = global.Promise;
|
||||||
|
mongoose.level = "F";
|
||||||
|
|
||||||
|
|
||||||
|
// Resolving error Unknown modifier: $pushAll
|
||||||
|
mongoose.plugin(schema => {
|
||||||
|
schema.options.usePushEach = true
|
||||||
|
});
|
||||||
|
|
||||||
|
const gasordineSchema = new Schema({
|
||||||
|
active: {
|
||||||
|
type: Boolean,
|
||||||
|
},
|
||||||
|
idapp: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
name: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
referente: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
city: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
img: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
dataora_chiusura: {
|
||||||
|
type: Date,
|
||||||
|
},
|
||||||
|
dataora_ritiro: {
|
||||||
|
type: Date,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
var Gasordine = module.exports = mongoose.model('Gasordine', gasordineSchema);
|
||||||
|
|
||||||
|
module.exports.getFieldsForSearch = function () {
|
||||||
|
return [
|
||||||
|
{field: 'name', type: tools.FieldType.string},
|
||||||
|
{field: 'description', type: tools.FieldType.string},
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.executeQueryTable = function (idapp, params) {
|
||||||
|
params.fieldsearch = this.getFieldsForSearch();
|
||||||
|
return tools.executeQueryTable(this, idapp, params);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.findAllIdApp = async function (idapp) {
|
||||||
|
const myfind = { idapp };
|
||||||
|
|
||||||
|
return await Gasordine.find(myfind);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
module.exports.getGasordineByID = function (id, callback) {
|
||||||
|
Gasordine.findById(id, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.createIndexes((err) => {
|
||||||
|
if (err) throw err;
|
||||||
|
});
|
||||||
@@ -28,6 +28,7 @@ const orderSchema = new Schema({
|
|||||||
idStorehouse: { type: Schema.Types.ObjectId, ref: 'StoreHouse' },
|
idStorehouse: { type: Schema.Types.ObjectId, ref: 'StoreHouse' },
|
||||||
idScontisticas: [{ type: Schema.Types.ObjectId, ref: 'Scontistica' }],
|
idScontisticas: [{ type: Schema.Types.ObjectId, ref: 'Scontistica' }],
|
||||||
idProvider: { type: Schema.Types.ObjectId, ref: 'Provider' },
|
idProvider: { type: Schema.Types.ObjectId, ref: 'Provider' },
|
||||||
|
idGasordine: { type: Schema.Types.ObjectId, ref: 'Gasordine' },
|
||||||
price: {
|
price: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 0,
|
default: 0,
|
||||||
@@ -169,6 +170,14 @@ module.exports.findAllIdApp = async function (idapp) {
|
|||||||
as: 'provider'
|
as: 'provider'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: 'gasordines',
|
||||||
|
localField: 'idGasordine',
|
||||||
|
foreignField: '_id',
|
||||||
|
as: 'gasordine'
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
$lookup: {
|
$lookup: {
|
||||||
from: 'scontisticas',
|
from: 'scontisticas',
|
||||||
@@ -194,6 +203,12 @@ module.exports.findAllIdApp = async function (idapp) {
|
|||||||
path: '$provider',
|
path: '$provider',
|
||||||
preserveNullAndEmptyArrays: true,
|
preserveNullAndEmptyArrays: true,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: '$gasordine',
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
];
|
];
|
||||||
@@ -346,6 +361,14 @@ module.exports.getTotalOrderById = async function (id) {
|
|||||||
as: 'provider'
|
as: 'provider'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: 'gasordines',
|
||||||
|
localField: 'idGasordine',
|
||||||
|
foreignField: '_id',
|
||||||
|
as: 'gasordine'
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
$lookup: {
|
$lookup: {
|
||||||
from: 'scontisticas',
|
from: 'scontisticas',
|
||||||
@@ -378,6 +401,12 @@ module.exports.getTotalOrderById = async function (id) {
|
|||||||
preserveNullAndEmptyArrays: true,
|
preserveNullAndEmptyArrays: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: '$gasordine',
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
$lookup: {
|
$lookup: {
|
||||||
from: 'orders',
|
from: 'orders',
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ var { User } = require('../models/user');
|
|||||||
|
|
||||||
const Storehouse = require('../models/storehouse');
|
const Storehouse = require('../models/storehouse');
|
||||||
const Provider = require('../models/provider');
|
const Provider = require('../models/provider');
|
||||||
|
const Gasordine = require('../models/gasordine');
|
||||||
const Product = require('../models/product');
|
const Product = require('../models/product');
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
@@ -202,6 +203,13 @@ module.exports.getOLDOrdersCartByQuery = async function (query) {
|
|||||||
model: 'Provider'
|
model: 'Provider'
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
.populate({
|
||||||
|
path: 'items.order',
|
||||||
|
populate: {
|
||||||
|
path: 'idGasordine',
|
||||||
|
model: 'Gasordine'
|
||||||
|
},
|
||||||
|
})
|
||||||
.populate({
|
.populate({
|
||||||
path: 'items.order',
|
path: 'items.order',
|
||||||
populate: {
|
populate: {
|
||||||
@@ -237,6 +245,8 @@ module.exports.getOLDOrdersCartByQuery = async function (query) {
|
|||||||
item.order.idStorehouse = item.order.storehouse ? item.order.storehouse._id : '';
|
item.order.idStorehouse = item.order.storehouse ? item.order.storehouse._id : '';
|
||||||
item.order.provider = item.order.idProvider;
|
item.order.provider = item.order.idProvider;
|
||||||
item.order.idProvider = item.order.provider ? item.order.provider._id : '';
|
item.order.idProvider = item.order.provider ? item.order.provider._id : '';
|
||||||
|
item.order.gasordine = item.order.idGasordine;
|
||||||
|
item.order.idGasordine = item.order.gasordine ? item.order.gasordine._id : '';
|
||||||
item.order.scontisticas = item.order.scontisticas;
|
item.order.scontisticas = item.order.scontisticas;
|
||||||
item.order.idScontisticas = item.order.idScontisticas ? item.order.idScontisticas._id : '';
|
item.order.idScontisticas = item.order.idScontisticas ? item.order.idScontisticas._id : '';
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -278,6 +288,13 @@ module.exports.getOrdersCartByQuery = async function (query) {
|
|||||||
model: 'Provider'
|
model: 'Provider'
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
.populate({
|
||||||
|
path: 'items.order',
|
||||||
|
populate: {
|
||||||
|
path: 'idGasordine',
|
||||||
|
model: 'Gasordine'
|
||||||
|
},
|
||||||
|
})
|
||||||
.populate({
|
.populate({
|
||||||
path: 'items.order',
|
path: 'items.order',
|
||||||
populate: {
|
populate: {
|
||||||
@@ -313,6 +330,8 @@ module.exports.getOrdersCartByQuery = async function (query) {
|
|||||||
item.order.idStorehouse = item.order.storehouse ? item.order.storehouse._id : '';
|
item.order.idStorehouse = item.order.storehouse ? item.order.storehouse._id : '';
|
||||||
item.order.provider = item.order.idProvider;
|
item.order.provider = item.order.idProvider;
|
||||||
item.order.idProvider = item.order.provider ? item.order.provider._id : '';
|
item.order.idProvider = item.order.provider ? item.order.provider._id : '';
|
||||||
|
item.order.gasordine = item.order.idGasordine;
|
||||||
|
item.order.idGasordine = item.order.gasordine ? item.order.gasordine._id : '';
|
||||||
item.order.scontisticas = item.order.scontisticas;
|
item.order.scontisticas = item.order.scontisticas;
|
||||||
item.order.idScontisticas = item.order.idScontisticas ? item.order.idScontisticas._id : '';
|
item.order.idScontisticas = item.order.idScontisticas ? item.order.idScontisticas._id : '';
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ const tools = require('../tools/general');
|
|||||||
const Producer = require('../models/producer');
|
const Producer = require('../models/producer');
|
||||||
const Storehouse = require('../models/storehouse');
|
const Storehouse = require('../models/storehouse');
|
||||||
const Provider = require('../models/provider');
|
const Provider = require('../models/provider');
|
||||||
|
const Gasordine = require('../models/gasordine');
|
||||||
const Scontistica = require('../models/scontistica');
|
const Scontistica = require('../models/scontistica');
|
||||||
|
|
||||||
const shared_consts = require('../tools/shared_nodejs');
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ const Cart = require('../models/cart');
|
|||||||
const OrdersCart = require('../models/orderscart');
|
const OrdersCart = require('../models/orderscart');
|
||||||
const Storehouse = require('../models/storehouse');
|
const Storehouse = require('../models/storehouse');
|
||||||
const Provider = require('../models/provider');
|
const Provider = require('../models/provider');
|
||||||
|
const Gasordine = require('../models/gasordine');
|
||||||
const Scontistica = require('../models/scontistica');
|
const Scontistica = require('../models/scontistica');
|
||||||
const Department = require('../models/department');
|
const Department = require('../models/department');
|
||||||
const { Category } = require('../models/category');
|
const { Category } = require('../models/category');
|
||||||
@@ -1434,6 +1435,7 @@ function load(req, res, version) {
|
|||||||
let workers = User.getusersWorkersList(idapp);
|
let workers = User.getusersWorkersList(idapp);
|
||||||
let storehouses = Storehouse.findAllIdApp(idapp);
|
let storehouses = Storehouse.findAllIdApp(idapp);
|
||||||
let providers = Provider.findAllIdApp(idapp);
|
let providers = Provider.findAllIdApp(idapp);
|
||||||
|
let gasordines = Gasordine.findAllIdApp(idapp);
|
||||||
let scontisticas = Scontistica.findAllIdApp(idapp);
|
let scontisticas = Scontistica.findAllIdApp(idapp);
|
||||||
let departments = Department.findAllIdApp(idapp);
|
let departments = Department.findAllIdApp(idapp);
|
||||||
let categories = Category.findAllIdApp(idapp);
|
let categories = Category.findAllIdApp(idapp);
|
||||||
@@ -1523,6 +1525,7 @@ function load(req, res, version) {
|
|||||||
categories, // 39
|
categories, // 39
|
||||||
providers,
|
providers,
|
||||||
scontisticas,
|
scontisticas,
|
||||||
|
gasordines,
|
||||||
]).then((arrdata) => {
|
]).then((arrdata) => {
|
||||||
// console.table(arrdata);
|
// console.table(arrdata);
|
||||||
let myuser = req.user;
|
let myuser = req.user;
|
||||||
@@ -1607,6 +1610,7 @@ function load(req, res, version) {
|
|||||||
categories: arrdata[39],
|
categories: arrdata[39],
|
||||||
providers: arrdata[40],
|
providers: arrdata[40],
|
||||||
scontisticas: arrdata[41],
|
scontisticas: arrdata[41],
|
||||||
|
gasordines: arrdata[42],
|
||||||
});
|
});
|
||||||
|
|
||||||
const prova = 1;
|
const prova = 1;
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ const Cart = require('../models/cart');
|
|||||||
const OrdersCart = require('../models/orderscart');
|
const OrdersCart = require('../models/orderscart');
|
||||||
const Storehouse = require('../models/storehouse');
|
const Storehouse = require('../models/storehouse');
|
||||||
const Provider = require('../models/provider');
|
const Provider = require('../models/provider');
|
||||||
|
const Gasordine = require('../models/gasordine');
|
||||||
const Scontistica = require('../models/scontistica');
|
const Scontistica = require('../models/scontistica');
|
||||||
const Department = require('../models/department');
|
const Department = require('../models/department');
|
||||||
const { Category } = require('../models/category');
|
const { Category } = require('../models/category');
|
||||||
@@ -108,6 +109,8 @@ module.exports = {
|
|||||||
mytable = Storehouse;
|
mytable = Storehouse;
|
||||||
else if (tablename === 'providers')
|
else if (tablename === 'providers')
|
||||||
mytable = Provider;
|
mytable = Provider;
|
||||||
|
else if (tablename === 'gasordines')
|
||||||
|
mytable = Gasordine;
|
||||||
else if (tablename === 'scontisticas')
|
else if (tablename === 'scontisticas')
|
||||||
mytable = Scontistica;
|
mytable = Scontistica;
|
||||||
else if (tablename === 'departments')
|
else if (tablename === 'departments')
|
||||||
|
|||||||
Reference in New Issue
Block a user