Lista Doni Navi

This commit is contained in:
Paolo Arena
2020-03-21 10:28:26 +01:00
parent fbc85ce06a
commit b2696d1898
139 changed files with 463 additions and 80 deletions

0
.directory Normal file → Executable file
View File

0
.gitignore vendored Normal file → Executable file
View File

0
css/basic.css Normal file → Executable file
View File

0
css/one/styles.css Normal file → Executable file
View File

0
docs/email.md Normal file → Executable file
View File

0
ecosystem.config.js Normal file → Executable file
View File

0
emails/admin/added_to_newsletter/it/html.pug Normal file → Executable file
View File

0
emails/admin/added_to_newsletter/it/subject.pug Normal file → Executable file
View File

0
emails/admin/cancelbooking/it/html.pug Normal file → Executable file
View File

0
emails/admin/cancelbooking/it/subject.pug Normal file → Executable file
View File

0
emails/admin/makebooking/it/html.pug Normal file → Executable file
View File

0
emails/admin/makebooking/it/subject.pug Normal file → Executable file
View File

0
emails/admin/modifybooking/it/html.pug Normal file → Executable file
View File

0
emails/admin/modifybooking/it/subject.pug Normal file → Executable file
View File

0
emails/admin/registration/enUs/html.pug Normal file → Executable file
View File

0
emails/admin/registration/enUs/subject.pug Normal file → Executable file
View File

0
emails/admin/registration/es/html.pug Normal file → Executable file
View File

0
emails/admin/registration/es/subject.pug Normal file → Executable file
View File

0
emails/admin/registration/it/html.pug Normal file → Executable file
View File

0
emails/admin/registration/it/subject.pug Normal file → Executable file
View File

0
emails/admin/registration/it/text.pug Normal file → Executable file
View File

0
emails/booking/cancelbooking/it/html.pug Normal file → Executable file
View File

0
emails/booking/cancelbooking/it/subject.pug Normal file → Executable file
View File

0
emails/booking/makebooking/it/html.pug Normal file → Executable file
View File

0
emails/booking/makebooking/it/subject.pug Normal file → Executable file
View File

0
emails/booking/modifybooking/it/html.pug Normal file → Executable file
View File

0
emails/booking/modifybooking/it/subject.pug Normal file → Executable file
View File

0
emails/msg/sendmsg/it/html.pug Normal file → Executable file
View File

0
emails/msg/sendmsg/it/subject.pug Normal file → Executable file
View File

0
emails/msg/sendmsgchat/it/html.pug Normal file → Executable file
View File

0
emails/msg/sendmsgchat/it/subject.pug Normal file → Executable file
View File

0
emails/newsletter/it/html.pug Normal file → Executable file
View File

0
emails/newsletter/it/subject.pug Normal file → Executable file
View File

0
emails/one/one.template.pug Normal file → Executable file
View File

0
emails/registration/enUs/html.pug Normal file → Executable file
View File

0
emails/registration/enUs/subject.pug Normal file → Executable file
View File

0
emails/registration/esEs/html.pug Normal file → Executable file
View File

0
emails/registration/esEs/subject.pug Normal file → Executable file
View File

0
emails/registration/it/html.pug Normal file → Executable file
View File

0
emails/registration/it/subject.pug Normal file → Executable file
View File

0
emails/registration_ayni/enUs/html.pug Normal file → Executable file
View File

0
emails/registration_ayni/enUs/subject.pug Normal file → Executable file
View File

0
emails/registration_ayni/es/html.pug Normal file → Executable file
View File

0
emails/registration_ayni/es/subject.pug Normal file → Executable file
View File

0
emails/registration_ayni/fr/html.pug Normal file → Executable file
View File

0
emails/registration_ayni/fr/subject.pug Normal file → Executable file
View File

0
emails/registration_ayni/it/html.pug Normal file → Executable file
View File

0
emails/registration_ayni/it/subject.pug Normal file → Executable file
View File

0
emails/registration_ayni/pt/html.pug Normal file → Executable file
View File

0
emails/registration_ayni/pt/subject.pug Normal file → Executable file
View File

0
emails/registration_ayni/si/html.pug Normal file → Executable file
View File

0
emails/registration_ayni/si/subject.pug Normal file → Executable file
View File

0
emails/resetpwd/en/html.pug Normal file → Executable file
View File

0
emails/resetpwd/en/subject.pug Normal file → Executable file
View File

0
emails/resetpwd/es/html.pug Normal file → Executable file
View File

0
emails/resetpwd/es/subject.pug Normal file → Executable file
View File

0
emails/resetpwd/it/html.pug Normal file → Executable file
View File

0
emails/resetpwd/it/subject.pug Normal file → Executable file
View File

0
gulpfile.js Normal file → Executable file
View File

0
package.json Normal file → Executable file
View File

0
plugins/file.js Normal file → Executable file
View File

0
plugins/googleapi.js Normal file → Executable file
View File

0
sass/basic.scss Normal file → Executable file
View File

0
sass/one/styles.scss Normal file → Executable file
View File

0
src/server/calculations/todo.js Normal file → Executable file
View File

0
src/server/classes/queryclass.js Normal file → Executable file
View File

0
src/server/config/config.js Normal file → Executable file
View File

0
src/server/db/mongoose.js Normal file → Executable file
View File

0
src/server/ftp/FTPClient.js Normal file → Executable file
View File

0
src/server/locales/back/en.json Normal file → Executable file
View File

0
src/server/locales/back/es.json Normal file → Executable file
View File

0
src/server/locales/back/it.json Normal file → Executable file
View File

0
src/server/locales/en.json Normal file → Executable file
View File

0
src/server/locales/es.json Normal file → Executable file
View File

0
src/server/locales/it.json Normal file → Executable file
View File

0
src/server/middleware/authenticate.js Normal file → Executable file
View File

0
src/server/models/booking.js Normal file → Executable file
View File

2
src/server/models/calzoom.js Normal file → Executable file
View File

@@ -40,7 +40,7 @@ const CalZoomSchema = new Schema({
});
CalZoomSchema.statics.getFieldsForSearch = function () {
return ['title']
return [{field: 'title', type: tools.FieldType.string}]
};
CalZoomSchema.statics.executeQueryTable = function (idapp, params) {

0
src/server/models/cfgserver.js Normal file → Executable file
View File

2
src/server/models/contribtype.js Normal file → Executable file
View File

@@ -25,7 +25,7 @@ const ContribtypeSchema = new Schema({
});
ContribtypeSchema.statics.getFieldsForSearch = function () {
return ['label']
return [{field: 'label', type: tools.FieldType.string}]
};
ContribtypeSchema.statics.executeQueryTable = function (idapp, params) {

3
src/server/models/discipline.js Normal file → Executable file
View File

@@ -89,7 +89,8 @@ DisciplineSchema.statics.getDisciplineforNewsletter = function (idapp) {
DisciplineSchema.statics.getFieldsForSearch = function () {
return ['label', 'description']
return [{ field: 'label', type: tools.FieldType.string },
{ field: 'description', type: tools.FieldType.string }]
};
DisciplineSchema.statics.executeQueryTable = function (idapp, params) {

8
src/server/models/extralist.js Normal file → Executable file
View File

@@ -208,7 +208,12 @@ ExtraListSchema.statics.getUserNotRegisteredByNameSurname = function (idapp, nam
ExtraListSchema.statics.getFieldsForSearch = function () {
return ['username', 'name', 'surname', 'cell_complete', 'aportador_solidario_name_surname', 'aportador_solidario_originale_name_surname']
return [{ field: 'username', type: tools.FieldType.string },
{ field: 'name', type: tools.FieldType.string },
{ field: 'surname', type: tools.FieldType.string },
{ field: 'cell_complete', type: tools.FieldType.string },
{ field: 'aportador_solidario_name_surname', type: tools.FieldType.string },
{ field: 'aportador_solidario_originale_name_surname', type: tools.FieldType.string }]
};
ExtraListSchema.statics.executeQueryTable = function (idapp, params) {
@@ -321,7 +326,6 @@ ExtraListSchema.statics.ImportData = async function (locale, idapp, strdata) {
};
const ExtraList = mongoose.model('ExtraList', ExtraListSchema);

2
src/server/models/gallery.js Normal file → Executable file
View File

@@ -44,7 +44,7 @@ const GallerySchema = new Schema({
});
GallerySchema.statics.getFieldsForSearch = function () {
return ['title']
return [{ field: 'title', type: tools.FieldType.string }]
};
GallerySchema.statics.executeQueryTable = function (idapp, params) {

11
src/server/models/listaingresso.js Normal file → Executable file
View File

@@ -144,8 +144,8 @@ ListaIngressoSchema.statics.addUserInListaIngresso = async function (idapp, ind_
const telegrambot = require('../telegram/telegrambot');
try {
let listaingresso = null;
if (!await ListaIngresso.findByIndOrderETess(idapp, ind_order, num_tess)) {
let listaingresso = await ListaIngresso.findByIndOrderETess(idapp, ind_order, num_tess);
if (!listaingresso) {
listaingresso = new ListaIngresso({
ind_order: ind_order,
idapp,
@@ -168,11 +168,11 @@ ListaIngressoSchema.statics.addUserInListaIngresso = async function (idapp, ind_
}
}
const giapresente = await Nave.findOne({ idapp, ind_order: num_tess });
const giapresente = await Nave.findOne({ idapp, ind_order, num_tess });
if (!!giapresente) {
// Era stato già aggiunto!
let fields_to_update = { added: true };
await ListaIngresso.findOneAndUpdate({ _id: params.id.toString() }, { $set: fields_to_update }, { new: false });
await ListaIngresso.findOneAndUpdate({ _id: listaingresso._id }, { $set: fields_to_update }, { new: false });
return false;
}
@@ -229,7 +229,7 @@ ListaIngressoSchema.statics.showListaOrd = async function (idapp) {
ListaIngressoSchema.statics.getFieldsForSearch = function () {
return ['ind_order']
return [{field: 'ind_order', type: tools.FieldType.number }]
};
ListaIngressoSchema.statics.executeQueryTable = function (idapp, params) {
@@ -273,6 +273,7 @@ ListaIngressoSchema.statics.getProssimiInLista = async function (idapp, tutti) {
if (rec.numinvitatiattivi > 2)
rec.numinvitatiattivi = 2;
}
if (arrlista) {
arrlista = sortRec(arrlista);
// arrlista.reverse();

4
src/server/models/mailinglist.js Normal file → Executable file
View File

@@ -45,7 +45,9 @@ const MailingListSchema = new Schema({
});
MailingListSchema.statics.getFieldsForSearch = function () {
return ['name', 'surname', 'email']
return [{ field: 'name', type: tools.FieldType.string },
{ field: 'surname', type: tools.FieldType.string },
{ field: 'email', type: tools.FieldType.string }]
};
MailingListSchema.statics.executeQueryTable = function (idapp, params) {

5
src/server/models/myevent.js Normal file → Executable file
View File

@@ -165,7 +165,10 @@ MyEventSchema.statics.getLastEvents = async function (idapp) {
MyEventSchema.statics.getFieldsForSearch = function () {
return ['short_tit', 'title', 'teacher', 'details']
return [{ field: 'short_tit', type: tools.FieldType.string },
{ field: 'title', type: tools.FieldType.string },
{ field: 'teacher', type: tools.FieldType.string },
{ field: 'details', type: tools.FieldType.string }]
};
MyEventSchema.statics.executeQueryTable = function (idapp, params) {

5
src/server/models/mypage.js Normal file → Executable file
View File

@@ -74,7 +74,10 @@ const MyPageSchema = new Schema({
});
MyPageSchema.statics.getFieldsForSearch = function () {
return ['title', 'keywords', 'description', 'content']
return [{ field: 'title', type: tools.FieldType.string },
{ field: 'keywords', type: tools.FieldType.string },
{ field: 'description', type: tools.FieldType.string },
{ field: 'content', type: tools.FieldType.string }]
};
MyPageSchema.statics.executeQueryTable = function (idapp, params) {

255
src/server/models/nave.js Normal file → Executable file
View File

@@ -45,6 +45,9 @@ const NaveSchema = new mongoose.Schema({
date_start: {
type: Date
},
date_gift_chat_open: {
type: Date
},
link_chat: {
type: String,
},
@@ -72,6 +75,9 @@ const NaveSchema = new mongoose.Schema({
num_tess: { // numero di tessitura
type: Number,
default: 1
},
provvisoria: {
type: Boolean
}
});
@@ -121,7 +127,8 @@ NaveSchema.statics.findByIndPrimario = function (idapp, indprimario) {
NaveSchema.statics.getFieldsForSearch = function () {
return ['username', 'name', 'surname', 'ind_order']
return [{ field: 'ind_order', type: tools.FieldType.number },
{ field: 'col', type: tools.FieldType.number }]
};
NaveSchema.statics.executeQueryTable = function (idapp, params) {
@@ -187,13 +194,16 @@ function getIndColonneByNave(navemediatore) {
let col = navemediatore.col;
let col_ini = calcval(riga, col, 8) + 1;
let col_fine = col_ini + 8;
let col_fine = col_ini + 7;
return { riga: riga + 3, col_ini, col_fine }
}
NaveSchema.statics.getusersByNave = function (idapp, navemediatore) {
if ((!navemediatore.riga) || (!navemediatore.col))
return [];
const obj = getIndColonneByNave(navemediatore);
const miacol_ini = obj.col_ini;
@@ -248,7 +258,8 @@ NaveSchema.statics.findRecByRigaColParent = async function (idapp, riga, col, nu
myrigacol.riga = lastrec.riga;
myrigacol.col = lastrec.col;
} else {
lastrec = await User.findByIndOrder(idapp, 0);
//lastrec = await User.findByIndOrder(idapp, 0);
lastrec = await Nave.findGeneric({ idapp, riga: 0, col: 0 });
break;
}
}
@@ -257,7 +268,8 @@ NaveSchema.statics.findRecByRigaColParent = async function (idapp, riga, col, nu
}
if (!lastrec) {
return await User.findByIndOrder(idapp, 0);
// return await User.findByIndOrder(idapp, 0);
return await Nave.findGeneric({ idapp, riga: 0, col: 0 });
}
return lastrec;
@@ -278,14 +290,6 @@ function getlimiti(mypos) {
return mypos;
}
function getRigaColByPosUp(mypos) {
mypos.riga = mypos.riga - mypos.numup;
mypos.col = Math.floor(mypos.col / (Math.pow(2, mypos.numup)));
// if ((mypos.col % 2) !== 0)
// mypos.col++;
}
function getRigaColGenerica(idapp, riga, col, numup) {
mypos = {
idapp,
@@ -295,7 +299,7 @@ function getRigaColGenerica(idapp, riga, col, numup) {
};
if (idapp === tools.AYNI) {
getRigaColByPosUp(mypos);
tools.getRigaColByPosUp(mypos);
ris = getlimiti(mypos);
}
@@ -395,22 +399,26 @@ NaveSchema.statics.findMediatoreByFuoco = async function (idapp, riga, col, offs
// return Nave.findGeneric(myrigacol);
return await Nave.findRecByRigaColParent(idapp, riga, col, 3 - offset);
};
function getQueryProj(myfilter) {
myobjField = {
_id: 1,
idapp: 1,
lang: 1,
ind_order: 1,
name: 1,
surname: 1,
username: 1,
'profile.paymenttypes': 1,
'profile.email_paypal': 1,
date_start: 1,
date_gift_chat_open: 1,
made_gift: 1,
link_chat: 1,
date_made_gift: 1,
provvisoria: 1,
received_gift: 1,
date_received_gift: 1,
num_tess: 1,
@@ -464,7 +472,11 @@ function getmaxcol(riga) {
}
function getPrimoFuocoByIndCol(col) {
return Math.floor(col - (col % 8)) + 1;
// let ris = Math.ceil(col - (col % 8)) + 1;
let ris = ((Math.ceil(col / 8) - 1) * 8) + 1;
if (ris <= 0)
ris = 1;
return ris
}
async function getusertextbyrec(myrec, symbol, lettera, riga, col, ind) {
@@ -480,12 +492,26 @@ async function getusertextbyrec(myrec, symbol, lettera, riga, col, ind) {
} else {
if (myrec)
return lettera + ind + ' - ' + symbol + '[' + miariga + ',' + miacol + ']' + ' ' + myrec.name + ' ' + myrec.surname + '';
return lettera + ind + ' - ' + symbol + '[' + riga + ',' + col + ']' + ' ' + myrec.name + ' ' + myrec.surname + '';
else
return lettera + ind + ' - ' + symbol;
}
}
function checkifNullThenEmpty(rec, riga, col) {
if (rec === null) {
return {
name: '',
surname: '',
username: '',
riga,
col,
}
} else {
return rec;
}
}
NaveSchema.statics.getPlaccaGenerica = async function (idapp, riga, col, offset, solorecord) {
const Nave = this;
@@ -526,17 +552,25 @@ NaveSchema.statics.getPlaccaGenerica = async function (idapp, riga, col, offset,
// mystr += '🔥🌏💦💨🔥🌏💦💨' + tools.ACAPO;
let arrdonatori = [];
// let numcol = Math.pow(2, indriga - 1);
primofuoco = getPrimoFuocoByIndCol(col * Math.pow(2, offset));
let ind = 1;
for (let indcol = primofuoco; indcol < primofuoco + 8; indcol++) {
let indr = riga + offset;
let indc = indcol + (offset * indr);
indr = riga + offset;
indc = calcval(riga, col, 8) + (indcol - primofuoco + 1);
// indc = calcval(riga, col, 8) + (indcol - primofuoco + 1);
if (offset === 0)
indc = indcol;
else
indc = indcol;
// miacol = calcval(riga, col, 8) + (indfuoco);
let recfuoco = await Nave.findByRigaCol(idapp, indr, indc, true);
recfuoco = checkifNullThenEmpty(recfuoco, indr, indc);
arrdonatori.push(recfuoco);
mystr += await getusertextbyrec(recfuoco, symb.icona, symb.car, indr, indc, ind) + tools.ACAPO;
ind++;
@@ -560,14 +594,63 @@ NaveSchema.statics.getPlaccaGenerica = async function (idapp, riga, col, offset,
};
NaveSchema.statics.getPlaccaPerDonatore = async function (idapp, riga, col, solorecord) {
NaveSchema.statics.getPlaccaPerDonatore = async function (idapp, riga, col, solorecord, rec) {
const Nave = this;
return Nave.getPlaccaGenerica(idapp, riga, col, tools.Placca.SONOFUOCO, solorecord);
if (solorecord) {
rec.donatore = await Nave.getPlaccaGenerica(idapp, riga, col, tools.Placca.SONOFUOCO, solorecord);
newcol = Math.ceil(col / (Math.pow(2, 3)));
rec.donatore.arrterra = await Nave.getArrTerra(idapp, riga - 3, newcol);
rec.donatore.arraria = await Nave.getArrAria(idapp, riga - 3, newcol);
return rec;
} else {
return await Nave.getPlaccaGenerica(idapp, riga, col, tools.Placca.SONOFUOCO, solorecord);
}
};
NaveSchema.statics.getPlaccaPerMediatore = async function (idapp, riga, col, solorecord) {
NaveSchema.statics.getPlaccaPerMediatore = async function (idapp, riga, col, solorecord, rec) {
const Nave = this;
return Nave.getPlaccaGenerica(idapp, riga, col, tools.Placca.SONOACQUA, solorecord);
rec.mediatore = await Nave.getPlaccaGenerica(idapp, riga, col, tools.Placca.SONOACQUA, solorecord);
rec.mediatore.arrterra = await Nave.getArrTerra(idapp, riga, col);
rec.mediatore.arraria = await Nave.getArrAria(idapp, riga, col);
return rec;
};
NaveSchema.statics.getArrTerra = async function (idapp, riga, col) {
const Nave = this;
let arrterra = [];
for (let indterra = 1; indterra <= 2; indterra++) {
miacol = calcval(riga, col, 2) + (indterra);
miariga = riga + 1;
let rec = await Nave.findByRigaCol(idapp, miariga, miacol, true);
rec = checkifNullThenEmpty(rec, miariga, miacol);
arrterra.push(rec);
}
return arrterra;
};
NaveSchema.statics.getArrAria = async function (idapp, riga, col) {
const Nave = this;
let arraria = [];
for (let indaria = 1; indaria <= 4; indaria++) {
miacol = calcval(riga, col, 4) + (indaria);
miariga = riga + 2;
let rec = await Nave.findByRigaCol(idapp, miariga, miacol, true);
rec = checkifNullThenEmpty(rec, miariga, miacol);
arraria.push(rec);
}
return arraria;
};
function calcval(riga, col, quanti) {
@@ -624,12 +707,21 @@ NaveSchema.statics.getNavePos = async function (idapp, riga, col, solorecord) {
}
let data = "";
if (primofuoco)
data = "Partenza il " + tools.getstrDateLong(primofuoco.date_start) + tools.ACAPO;
else
let mystrtemp = '';
if (primofuoco) {
data = '💬 Giorno di Apertura GIFT CHAT: ' + tools.getstrDateLong(primofuoco.date_gift_chat_open) + tools.ACAPO;
data += "🎁 Giorno in cui Inviare il DONO : " + tools.getstrDateLong(primofuoco.date_start) + tools.ACAPO;
data += tools.ACAPO;
data += 'Il Mediatore sarà contattato 1 giorno prima dal Tutor' + tools.ACAPO;
if (primofuoco.provvisoria)
mystrtemp = 'TEMPORANEA ';
} else
data = "";
mystr = tools.ACAPO + 'NAVE (' + riga + '.' + col + ') ' + tools.ACAPO + data + tools.ACAPO + mystr;
mystr = tools.ACAPO + 'NAVE ' + '[' + riga + '.' + col + '] ' + mystrtemp + tools.ACAPO + data + tools.ACAPO + mystr;
return mystr;
} catch (e) {
@@ -679,7 +771,7 @@ NaveSchema.statics.getArrPosizioniByIndOrder = async function (idapp, ind_order)
NaveSchema.statics.getPrimaNaveByRiga = async function (idapp, riga) {
const Nave = this;
nave = await Nave.find({ 'idapp': idapp, riga: (riga + 3), col: 1 });
nave = await Nave.findOne({ 'idapp': idapp, riga: (riga + 3), col: 1 });
return nave;
};
@@ -702,12 +794,20 @@ NaveSchema.statics.showListaOrd = async function (idapp) {
return mystr;
};
NaveSchema.statics.getLastRigaCol = async function (idapp) {
return Nave.findOne({ idapp }).sort({ _id: -1 });
};
async function addRecordNaveByParams(params, siRitesse) {
const { ListaIngresso } = require('./listaingresso');
if (!siRitesse) {
// Check if Exist:
const giapresente = await Nave.findOne({ idapp: params.idapp, ind_order: params.ind_order, num_tess: params.num_tess });
const giapresente = await Nave.findOne({
idapp: params.idapp,
ind_order: params.ind_order,
num_tess: params.num_tess
});
if (!!giapresente) {
let fields_to_update = { added: true };
await ListaIngresso.findOneAndUpdate({ _id: params.id.toString() }, { $set: fields_to_update }, { new: false });
@@ -724,7 +824,9 @@ async function addRecordNaveByParams(params, siRitesse) {
riga: params.riga,
col: params.col,
date_start: params.date_start,
date_gift_chat_open: params.date_gift_chat_open,
num_tess: params.num_tess,
provvisoria: params.provvisoria,
});
myNave.created = new Date();
@@ -834,10 +936,13 @@ NaveSchema.statics.addUserFromListaIngresso_IntoNave = async function (init, ida
let recmediatore = await Nave.findMediatoreByFuoco(idapp, myriga, mycol, 0);
if (!!recmediatore) {
const ris = await Nave.checkifDeveRitessersi(recmediatore);
if (ris.num_tess > 2) {
if (ris.num_tess >= 2) {
console.log('E\' arrivato alla TERZA RITESSITURA, PERTANTO LO METTIAMO IN CODA... [riga=', params.riga, 'col', params.col, '] indorder=' + recmediatore.ind_order);
// E' arrivato alla TERZA RITESSITURA, PERTANTO LO METTIAMO IN CODA...
const risultato = await ListaIngresso.addUserInListaIngresso(idapp, recmediatore.ind_order, rec.lang, false, ris.num_tess);
//++Todo: TESSITURA????
//const risultato = await ListaIngresso.addUserInListaIngresso(idapp, recmediatore.ind_order, rec.lang, false, ris.num_tess);
} else {
console.log('Si deve ritessere: [riga=', params.riga, 'col', params.col, ']');
@@ -883,6 +988,7 @@ NaveSchema.statics.generaNave = async function (idapp, mydata) {
riga: await Nave.getRiga(idapp),
col: await Nave.getCol(idapp),
date_start: mydata.date_start,
date_gift_chat_open: tools.AddDate(mydata.date_start, -7),
numpersone: mydata.numpersone,
};
@@ -912,6 +1018,7 @@ NaveSchema.statics.generaNave = async function (idapp, mydata) {
params.ind_order = reclista.ind_order;
params.id = reclista._id;
params.num_tess = reclista.num_tess;
params.provvisoria = mydata.provvisoria;
await Nave.addUserFromListaIngresso_IntoNave(index === 0, idapp, params, false);
index++;
@@ -932,6 +1039,7 @@ async function addUserToNave(idapp, rec) {
params.ind_order = rec.ind_order;
params.id = rec._id;
params.num_tess = rec.num_tess;
params.provvisoria = false;
return await Nave.addUserFromListaIngresso_IntoNave(true, idapp, params, true);
@@ -952,16 +1060,48 @@ NaveSchema.statics.checkIfDevoAggiungereInNave = async function (idapp) {
};
NaveSchema.statics.pulisciNonPresenzeInNave = async function (idapp) {
const Nave = this;
let numrec = 0;
const { ListaIngresso } = require('./listaingresso');
const myquery = getQueryProj({
idapp,
ind_order: { $gt: 0 },
added: true,
deleted: false,
});
arrrec = await ListaIngresso.aggregate(myquery)
.then(async (arrlista) => {
for (const rec of arrlista) {
const trovato = await Nave.findByIndOrder(idapp, rec.ind_order);
if (!trovato) {
let fields_to_update = { added: false };
await ListaIngresso.findOneAndUpdate({ _id: rec._id }, { $set: fields_to_update }, { new: false });
numrec++;
}
}
});
return numrec;
};
NaveSchema.statics.getNaveByUser = async function (idapp, ind_order, lang, fuoco) {
const Nave = this;
let mystr = '';
let rec = {};
const arrposiz = await Nave.getArrPosizioniByIndOrder(idapp, ind_order);
if (!!arrposiz) {
for (const pos of arrposiz) {
mystr += await Nave.getNavePos(idapp, pos.riga - 3, Math.floor(pos.col / (2 * 4)), false);
mystr += await Nave.getPlaccaPerDonatore(idapp, pos.riga, pos.col, false);
mystr += await Nave.getPlaccaPerMediatore(idapp, pos.riga, pos.col, false);
mystr += await Nave.getPlaccaPerDonatore(idapp, pos.riga, pos.col, false, rec);
mystr += await Nave.getPlaccaPerMediatore(idapp, pos.riga, pos.col, false, rec);
}
}
@@ -972,20 +1112,65 @@ NaveSchema.statics.getNaveByUser = async function (idapp, ind_order, lang, fuoco
return mystr;
};
NaveSchema.statics.getNaveByRigaCol = async function (idapp, riga, col) {
NaveSchema.statics.getNaveByRigaCol = async function (idapp, riganave, colnave) {
const Nave = this;
const rigaprec = riganave;
rec = {};
rec.donatore = await Nave.getPlaccaPerDonatore(idapp, riga, col, true);
rec.mediatore = await Nave.getPlaccaPerMediatore(idapp, riga, col, true);
rec = await Nave.getPlaccaPerMediatore(idapp, riganave, colnave, true, rec);
if (riganave < 4) {
riganave = 4;
colnave = 1;
}
rec = await Nave.getPlaccaPerDonatore(idapp, riganave, colnave, true, rec);
return rec;
};
NaveSchema.statics.getDonatoridelSognatore = async function (idapp, riganave, colnave) {
const Nave = this;
coldonatoreIni = calcval(riganave, colnave, 8) + (1);
coldonatoreFine = calcval(riganave, colnave, 8) + (64);
const myquery = getQueryProj({
idapp,
riga: riganave + 6,
col: { $gte: coldonatoreIni, $lte: coldonatoreFine }
});
const arrnaviout = [];
const arrnavi = await Nave.aggregate(myquery);
for (const nave of arrnavi) {
// Se è il mediatore, allora non includerlo nei Donatori!
mypos = {
riga: nave.riga,
col: nave.col,
numup: 3,
};
tools.getRigaColByPosUp(mypos);
const navemediatore = await Nave.findByRigaCol(idapp, mypos.riga, mypos.col, true);
if (!!navemediatore) {
if (navemediatore.ind_order !== nave.ind_order) {
arrnaviout.push(nave);
}
} else {
arrnaviout.push(nave);
}
}
return arrnaviout;
};
const Nave = mongoose.model('Nave', NaveSchema);
module.exports = { Nave };

5
src/server/models/newstosent.js Normal file → Executable file
View File

@@ -64,7 +64,9 @@ const NewstosentSchema = new Schema({
});
NewstosentSchema.statics.getFieldsForSearch = function () {
return ['name', 'surname', 'email']
return [{ field: 'name', type: tools.FieldType.string },
{ field: 'surname', type: tools.FieldType.string },
{ field: 'email', type: tools.FieldType.string }]
};
NewstosentSchema.statics.executeQueryTable = function (idapp, params) {
@@ -166,7 +168,6 @@ NewstosentSchema.statics.isActivated = async function (_id) {
};
const Newstosent = mongoose.model('Newstosent', NewstosentSchema);
module.exports = { Newstosent };

5
src/server/models/operator.js Normal file → Executable file
View File

@@ -85,7 +85,10 @@ OperatorSchema.statics.getEmailByUsername = async function (idapp, username) {
};
OperatorSchema.statics.getFieldsForSearch = function () {
return ['name', 'surname', 'email', 'cell']
return [{ field: 'name', type: tools.FieldType.string },
{ field: 'surname', type: tools.FieldType.string },
{ field: 'email', type: tools.FieldType.string },
{ field: 'cell', type: tools.FieldType.string }]
};

2
src/server/models/opzemail.js Normal file → Executable file
View File

@@ -24,7 +24,7 @@ const OpzEmailSchema = new Schema({
OpzEmailSchema.statics.getFieldsForSearch = function () {
return ['label_it']
return [{field: 'label_it', type: tools.FieldType.string}]
};
OpzEmailSchema.statics.executeQueryTable = function (idapp, params) {

2
src/server/models/paymenttype.js Normal file → Executable file
View File

@@ -25,7 +25,7 @@ const PaymentTypeSchema = new Schema({
});
PaymentTypeSchema.statics.getFieldsForSearch = function () {
return ['label']
return [{field: 'label', type: tools.FieldType.string}]
};
PaymentTypeSchema.statics.executeQueryTable = function (idapp, params) {

0
src/server/models/permission.js Normal file → Executable file
View File

0
src/server/models/project.js Normal file → Executable file
View File

0
src/server/models/sendmsg.js Normal file → Executable file
View File

3
src/server/models/settings.js Normal file → Executable file
View File

@@ -43,7 +43,8 @@ const SettingsSchema = new Schema({
});
SettingsSchema.statics.getFieldsForSearch = function () {
return ['key', 'value_str']
return [{ field: 'key', type: tools.FieldType.string },
{ field: 'value_str', type: tools.FieldType.string }, { field: 'value_num', type: tools.FieldType.number }]
};
SettingsSchema.statics.executeQueryTable = function (idapp, params) {

0
src/server/models/subscribers.js Normal file → Executable file
View File

2
src/server/models/templemail.js Normal file → Executable file
View File

@@ -41,7 +41,7 @@ const TemplEmailSchema = new Schema({
});
TemplEmailSchema.statics.getFieldsForSearch = function () {
return ['']
return []
};
TemplEmailSchema.statics.executeQueryTable = function (idapp, params) {

0
src/server/models/todo.js Normal file → Executable file
View File

19
src/server/models/user.js Normal file → Executable file
View File

@@ -800,6 +800,7 @@ UserSchema.statics.getSmallRecByIndOrder = async function (idapp, ind_order) {
return await User.findOne({ idapp, ind_order },
{
idapp: 1,
ind_order: 1,
username: 1,
name: 1,
@@ -929,7 +930,15 @@ UserSchema.statics.getUsersListByParams = function (params) {
*/
UserSchema.statics.getFieldsForSearch = function () {
return ['username', 'name', 'surname', 'email', 'profile.cell', 'profile.email_paypal', 'profile.username_telegram', 'aportador_solidario']
return [{field: 'username', type: tools.FieldType.string},
{filed: 'name', type: tools.FieldType.string },
{filed: 'ind_order', type: tools.FieldType.number },
{field: 'surname', type: tools.FieldType.string },
{field: 'email', type: tools.FieldType.string },
{field: 'profile.cell', type: tools.FieldType.string},
{field: 'profile.email_paypal', type: tools.FieldType.string},
{field: 'profile.username_telegram', type: tools.FieldType.string},
{field: 'aportador_solidario', type: tools.FieldType.string}]
};
UserSchema.statics.executeQueryTable = function (idapp, params) {
@@ -998,8 +1007,11 @@ UserSchema.statics.getDashboard = async function (idapp, aportador_solidario, us
for (let mynave of dashboard.arrnavi) {
mynave._doc.rec = await Nave.getNaveByRigaCol(idapp, mynave.riga, mynave.col);
mynave._doc.listadonatoridelsognatore = await Nave.getDonatoridelSognatore(idapp, mynave.riga, mynave.col);
}
// console.table(dashboard.arrnavi);
return dashboard;
} catch (e) {
console.error(e);
@@ -1303,12 +1315,7 @@ async function addUtentiInLista(idapp, mode, arrusers) {
} else if (mode === 4) {
ok = qualified && (numinvitati === 1);
} else if (mode === 5) {
// 7 punti qualificati
ok = qualified;
// // almeno telegram ID
// ok = user.profile.teleg_id > 0;
// } else {
// ok = true;
}
if (ok) {

Some files were not shown because too many files have changed in this diff Show More