- Iscrizione Conacreis

- Ordini
- Carrello
This commit is contained in:
Paolo Arena
2021-04-30 01:31:12 +02:00
parent 0b4203067a
commit e05bbb39ee
41 changed files with 1495 additions and 337 deletions

View File

@@ -32,6 +32,9 @@ const bookingSchema = new Schema({
numpeopleDinner: {
type: Number,
},
numpeopleDinnerShared: {
type: Number,
},
infoevent: {
type: String,
},

View File

@@ -0,0 +1,160 @@
const mongoose = require('mongoose');
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 IscrittiConacreisSchema = new Schema({
idapp: {
type: String,
},
userId: {
type: String,
},
name: {
type: String,
trim: true,
},
surname: {
type: String,
trim: true,
},
email: {
type: String,
trim: true,
},
fiscalcode: {
type: String,
trim: true,
},
residency_address: {
type: String,
},
residency_city: {
type: String,
trim: true,
},
residency_province: {
type: String,
trim: true,
},
residency_country: {
type: String,
trim: true,
},
residency_zipcode: {
type: String,
trim: true,
},
dateofbirth: {
type: Date,
},
cell_phone: {
type: String,
},
newsletter_on: {
type: Boolean,
},
accetta_carta_costituzionale_on: {
type: Boolean,
},
terms: {
type: Boolean,
},
iscrizione_compilata: {
type: Boolean,
},
dateofreg: {
type: Date,
},
codiceConacreis: {
type: String,
},
annoTesseramento: {
type: Number
},
motivazioni: {
type: String,
},
competenze_professionalita: {
type: String,
},
cosa_potrei_offrire: {
type: String,
},
cosa_vorrei_ricevere: {
type: String,
},
altre_comunicazioni: {
type: String,
},
come_ci_hai_conosciuto: {
type: String,
},
note: {
type: String,
},
});
var IscrittiConacreis = module.exports = mongoose.model('IscrittiConacreis', IscrittiConacreisSchema);
module.exports.getFieldsForSearch = function () {
return [{ field: 'name', type: tools.FieldType.string },
{ field: 'surname', type: tools.FieldType.string },
{ field: 'email', type: tools.FieldType.string }]
};
module.exports.executeQueryTable = function (idapp, params) {
params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, idapp, params);
};
module.exports.getLastRec = async function (idapp) {
const lastrec = await IscrittiConacreis.find({ idapp }).sort({ dateofreg: -1 }).limit(1);
if (!!lastrec) {
return lastrec[0];
} else {
return null;
}
};
module.exports.getNameSurnameByEmail = async function (idapp, email) {
return await IscrittiConacreis.findOne({
idapp, email,
}, { name: 1, surname: 1 })
.then((rec) => {
return (!!rec) ? `${rec.name} ${rec.surname}` : '';
}).catch((e) => {
console.error('getNameSurnameByUsername', e);
});
};
module.exports.findByEmail = function (idapp, email) {
return IscrittiConacreis.findOne({
'idapp': idapp,
'email': email,
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
});
};
module.exports.findAllIdApp = async function (idapp) {
const myfind = { idapp };
return await IscrittiConacreis.find(myfind, (err, arrrec) => {
return arrrec
});
};

View File

@@ -1205,40 +1205,6 @@ ListaIngressoSchema.statics.getnumInvitati = async function (idapp, username) {
};
ListaIngressoSchema.statics.Esegui_CronTab = async function (idapp, mydata) {
const ListaIngresso = this;
// console.log('Lancia CronTab: [IDAPP=' + idapp + ']');
let num = 0;
try {
/*
if (!await Graduatoria.isUpdating()) {
await Graduatoria.setGradUpdating(idapp, true);
ris = await Nave.delNaviProvvisorie(idapp);
mystr = await ListaIngresso.GeneraGraduatoria(idapp, true);
await Graduatoria.setWorking(idapp, false);
num = await Nave.generaNave(idapp, mydata, false);
}*/
} catch (e) {
console.error('ERRORE CronTab: [IDAPP=' + idapp + ']', e.message);
} finally {
// await Graduatoria.setGradUpdating(idapp, false);
// await Graduatoria.setWorking(idapp, false);
console.log('FINE CronTab: [IDAPP=' + idapp + ']');
}
return num;
};
ListaIngressoSchema.statics.getnumInvitatiAttivi = function (idapp, username) {
const ListaIngresso = this;

View File

@@ -94,6 +94,9 @@ const MyEventSchema = new Schema({
dinnerAvailable: {
type: Boolean,
},
dinnerSharedAvailable: {
type: Boolean,
},
lunchType: {
type: Number,
},

View File

@@ -56,9 +56,45 @@ const MyPageSchema = new Schema({
imgback: {
type: String,
},
img1: {
type: String,
},
content: {
type: String,
},
video1: {
type: String,
},
ratio1: {
type: String,
},
img2: {
type: String,
},
content2: {
type: String,
},
video2: {
type: String,
},
ratio2: {
type: String,
},
img3: {
type: String,
},
content3: {
type: String,
},
video3: {
type: String,
},
ratio3: {
type: String,
},
content4: {
type: String,
},
active: {
type: Boolean,
},
@@ -101,6 +137,28 @@ MyPageSchema.statics.findAllIdApp = async function (idapp) {
});
};
MyPageSchema.statics.findOnlyStruttRec = async function (idapp) {
const MyPage = this;
const myfind = { idapp };
return MyPage.find(myfind, {
title: 1,
icon: 1,
order: 1,
keywords: 1,
description: 1,
path: 1,
active: 1,
onlyif_logged: 1,
only_residenti: 1,
inmenu: 1,
submenu: 1
}, (err, arrrec) => {
return arrrec
});
};
const MyPage = mongoose.model('MyPage', MyPageSchema);
module.exports = { MyPage };

View File

@@ -4,6 +4,7 @@ const Schema = mongoose.Schema;
const shared_consts = require('../tools/shared_nodejs');
const Order = require('../models/order');
var { User } = require('../models/user');
const tools = require('../tools/general');
@@ -39,6 +40,9 @@ const OrdersCartSchema = new Schema({
created_at: {
type: Date
},
completed_at: {
type: Date
},
});
var OrdersCart = module.exports = mongoose.model('OrdersCart', OrdersCartSchema);
@@ -78,23 +82,44 @@ module.exports.getNewNumOrder = async function (uid, idapp) {
};
module.exports.getOrdersCartByUserId = async function (uid, idapp, numorder) {
module.exports.getStatusCartByUserId = async function (uid, idapp, numorder) {
let query = { userId: uid, idapp, status: { $gte: shared_consts.OrderStatus.CHECKOUT_SENT } }
let myorderscart = null;
if (numorder > 0) {
query = { userId: uid, idapp, numorder, status: { $gte: shared_consts.OrderStatus.CHECKOUT_SENT } }
}
myorderscart = await OrdersCart.findOne(query);
if (!!myorderscart)
return myorderscart.status;
else
return shared_consts.OrderStatus.NONE
}
module.exports.getOrdersCartByUserId = async function (uid, idapp, numorder) {
let query = { idapp, status: { $gte: shared_consts.OrderStatus.CHECKOUT_SENT } }
let myorderscart = null;
if (numorder > 0) {
query.numorder = numorder;
}
if (uid !== 'ALL') {
query.userId = uid;
}
myorderscart = await OrdersCart.find(query);
for (let ind = 0; ind < myorderscart.length; ind++) {
for (const idkey in myorderscart[ind].items) {
try {
idorder = myorderscart[ind].items[idkey]._id.toString();
let idorder = myorderscart[ind].items[idkey]._id.toString();
const myorder = myorderscart[ind].items[idkey].order;
if (!!myorder) {
idorder = myorderscart[ind].items[idkey].order._id.toString();
}
myorderscart[ind]._doc.nameSurname = await User.getNameSurnameById(idapp, myorderscart[ind].userId);
const myord = await Order.getTotalOrderById(idorder);
if (myord.length > 0) {
myorderscart[ind].items[idkey]._doc.order = myord[0];
@@ -134,11 +159,39 @@ module.exports.getOrdersCartByDepartmentId = async function (depId, idapp) {
for (let ind = 0; ind < myorderscart.length; ind++) {
for (const idkey in myorderscart[ind].items) {
try {
idorder = myorderscart[ind].items[idkey]._id.toString();
let idorder = myorderscart[ind].items[idkey]._id.toString();
const myorder = myorderscart[ind].items[idkey].order;
if (!!myorder) {
idorder = myorderscart[ind].items[idkey].order._id.toString();
}
myorderscart[ind]._doc.nameSurname = await User.getNameSurnameById(idapp, myorderscart[ind].userId);
const myord = await Order.getTotalOrderById(idorder);
if (myord.length > 0) {
myorderscart[ind].items[idkey]._doc.order = myord[0];
}
} catch (e) {
console.log('err', e);
}
}
}
return myorderscart
// return null;
}
module.exports.getOrderById = async function (Id, idapp) {
let query = { _id: Id, idapp, status: { $gte: shared_consts.OrderStatus.CHECKOUT_SENT } }
const myorderscart = await OrdersCart.find(query);
for (let ind = 0; ind < myorderscart.length; ind++) {
for (const idkey in myorderscart[ind].items) {
try {
let idorder = myorderscart[ind].items[idkey]._id.toString();
const myorder = myorderscart[ind].items[idkey].order;
if (!!myorder) {
idorder = myorderscart[ind].items[idkey].order._id.toString();
}
myorderscart[ind]._doc.nameSurname = await User.getNameSurnameById(idapp, myorderscart[ind].userId);
const myord = await Order.getTotalOrderById(idorder);
if (myord.length > 0) {
myorderscart[ind].items[idkey]._doc.order = myord[0];

View File

@@ -16,6 +16,9 @@ const productSchema = new Schema({
idapp: {
type: String,
},
active: {
type: Boolean,
},
idProducer: {
type: String
},

83
src/server/models/site.js Executable file
View File

@@ -0,0 +1,83 @@
const mongoose = require('mongoose');
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 SiteSchema = new Schema({
active: {
type: Boolean,
},
idapp: {
type: String,
},
name: {
type: String,
},
adminemail: {
type: String,
},
manageremail: {
type: String,
},
replyTo: {
type: String,
},
host: {
type: String,
},
portapp: {
type: String,
},
dir: {
type: String,
},
email_from: {
type: String,
},
email_pwd: {
type: String,
},
telegram_key: {
type: String,
},
telegram_bot_name: {
type: String,
},
pathreg_add: {
type: String,
},
});
var Site = module.exports = mongoose.model('Site', SiteSchema);
module.exports.getFieldsForSearch = function () {
return []
};
module.exports.executeQueryTable = async function (idapp, params) {
params.fieldsearch = this.getFieldsForSearch();
// return tools.executeQueryTable(this, null, params);
const myarr = await Site.find({});
return ({ count: myarr.length, rows: myarr })
};
module.exports.findAllIdApp = async function (idapp) {
const myfind = { active: true };
return await Site.find(myfind, (err, arrrec) => {
return arrrec
});
};

View File

@@ -19,8 +19,6 @@ const { ObjectID } = require('mongodb');
const shared_consts = require('../tools/shared_nodejs');
const queryclass = require('../classes/queryclass');
const telegrambot = require('../telegram/telegrambot');
mongoose.Promise = global.Promise;
mongoose.level = "F";
@@ -254,21 +252,30 @@ const UserSchema = new mongoose.Schema({
sex: {
type: Number,
},
chisei: {
motivazioni: {
type: String
},
iltuoimpegno: {
competenze_professionalita: {
type: String
},
come_aiutare: {
cosa_offrire: {
type: String
},
socio: {
cosa_ricevere: {
type: String
},
altre_comunicazioni: {
type: Boolean,
},
come_ci_hai_conosciuto: {
type: Boolean,
},
socioresidente: {
type: Boolean,
},
consiglio: {
type: Boolean,
},
myshares: [{
description: { type: String },
rating: { type: Number },
@@ -373,9 +380,9 @@ UserSchema.statics.isManager = function (perm) {
}
};
UserSchema.statics.isTraduttrici = function (perm) {
UserSchema.statics.isEditor = function (perm) {
try {
return ((perm & shared_consts.Permissions.Traduttrici) === shared_consts.Permissions.Traduttrici);
return ((perm & shared_consts.Permissions.Editor) === shared_consts.Permissions.Editor);
} catch (e) {
return false
}
@@ -721,6 +728,27 @@ UserSchema.statics.isUserResidente = async function (idapp, username) {
}
};
UserSchema.statics.isUserConsiglio = async function (idapp, username) {
const User = this;
if (username === undefined)
return false;
const myquery = {
'idapp': idapp,
'username': username,
};
const myrec = await User.findOne(myquery);
if (!!myrec) {
return myrec.profile.consiglio;
} else {
return false;
}
};
UserSchema.statics.isUserVisuProjects = async function (idapp, username) {
@@ -1209,6 +1237,21 @@ UserSchema.statics.getNameSurnameByUsername = async function (idapp, username) {
});
};
UserSchema.statics.getNameSurnameById = async function (idapp, userId) {
const User = this;
return await User.findOne({
idapp,
_id: userId,
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }]
}, { name: 1, surname: 1 })
.then((rec) => {
return (!!rec) ? `${rec.name} ${rec.surname}` : '';
}).catch((e) => {
console.error('getNameSurnameById', e);
});
};
UserSchema.statics.getSmallRecByIndOrder = async function (idapp, ind_order) {
try {
@@ -1943,7 +1986,7 @@ UserSchema.statics.getUsersResidenti = async function (idapp) {
'profile.socioresidente': { $exists: true, $eq: true }
};
return await User.find(myfind, {username: 1, name: 1, surname: 1});
return await User.find(myfind, { username: 1, name: 1, surname: 1 });
};
UserSchema.statics.getSaw_and_Accepted = async function (idapp) {
@@ -2057,7 +2100,10 @@ UserSchema.statics.getUsersRegDaily = function (idapp, nrec) {
}
},
{
$group: { _id: { $dateToString: { format: "%Y-%m-%d", date: "$date_reg", timezone: 'Europe/Rome' } }, count: { $sum: 1 } }
$group: {
_id: { $dateToString: { format: "%Y-%m-%d", date: "$date_reg", timezone: 'Europe/Rome' } },
count: { $sum: 1 }
}
},
{
$sort: { _id: 1 }
@@ -2076,7 +2122,10 @@ UserSchema.statics.getUsersRegWeekly = function (idapp, nrec) {
}
},
{
$group: { _id: { $dateToString: { format: "%Y-%U", date: "$date_reg", timezone: 'Europe/Rome' } }, count: { $sum: 1 } }
$group: {
_id: { $dateToString: { format: "%Y-%U", date: "$date_reg", timezone: 'Europe/Rome' } },
count: { $sum: 1 }
}
},
{
$sort: { _id: 1 }
@@ -2097,7 +2146,10 @@ UserSchema.statics.getnumRegNDays = function (idapp, nrec) {
}
},
{
$group: { _id: { $dateToString: { format: "%Y-%m-%d", date: "$date_reg", timezone: 'Europe/Rome' } }, count: { $sum: 1 } }
$group: {
_id: { $dateToString: { format: "%Y-%m-%d", date: "$date_reg", timezone: 'Europe/Rome' } },
count: { $sum: 1 }
}
},
{
$sort: { _id: 1 }