diff --git a/docs/email.md b/docs/email.md index 33c3101..a21ca4f 100755 --- a/docs/email.md +++ b/docs/email.md @@ -11,3 +11,10 @@ EMOJI:
https://listemoji.com/symbols-emoji + + +Copy Database: + +db.copyDatabase('FreePlanet', 'test_FreePlanet') + + diff --git a/docs/note.txt b/docs/note.txt new file mode 100644 index 0000000..dbea10b --- /dev/null +++ b/docs/note.txt @@ -0,0 +1 @@ +TiziCaso 6 IDTELEG 989199479 diff --git a/docs/passi.txt b/docs/passi.txt new file mode 100644 index 0000000..db45952 --- /dev/null +++ b/docs/passi.txt @@ -0,0 +1,54 @@ +AGGIORNARE: +------------ + +// ++Todo: DA FARE: + +TESTARE -> inviare il msg anche al Sognatore della Gift Chat +- Aggiornare il titolo della Gift Chat (da 5/5 a 12/5) +- Aggiornare il testo sulla Placca (Data Inizio e Data Fine Doni) + + +// ++Todo: TOGLIERE! + +- AGGIONARE AMBIENTE DI TEST +- ESEGUIRE LA CONVERSIONE 1 E 2 ! + +- CHECK getProssimiInLista +X - CONTROLLARE arrIdTelegramUsers + +- TESTARE SOSTITUISCI UTENTE DA NAVE + +- TESTARE AGGIUNGI VIAGGIO + +- Accorpare tutti i sotto account, in 1 unico ! + - Nel campo note, metterci l'username vecchio. + + - Sistemare le navi con num_tess === 4 : indorder=0 e 46 : + Prendere quelli del num_tess === 3 e SOSTITUISCI ind_order del num_Tess = 4 con ind_order di num_tess = 3 + +------------- +- AGGIONARE AMBIENTE DI PRODUZIONE +- ESEGUIRE LA CONVERSIONE 1 E 2 ! + + - Sistemare le navi con num_tess === 4 : indorder=0 e 46 : + Prendere quelli del num_tess === 3 e SOSTITUISCI ind_order del num_Tess = 4 con ind_order di num_tess = 3 + +------------- + + +SOSTITUISCI: + - Mettere flag se si vuole spostare l'Utente oppure Aggiungerlo... + + +- Sistemare che in Edit Pagina, se è troppo grande, va oltre l'altezza della finestra. + +- Aggiornare le FAQ in lingua +- Attivare le Traduttrici alle Pagine + + +- CONTROLLARE CON ARGENTINA E PORTOGALLO e Brasile: + Il sito deve comparire in Spagnolo e in Portoghese + + +TRADURRE: +'Giorno in cui Inviare il DONO': 'Hai 4 giorni di tempo per inviare il tuo dono. Giorno di Chiusura:', diff --git a/src/server/models/extralist.js b/src/server/models/extralist.js index 6b6d924..6c20e72 100755 --- a/src/server/models/extralist.js +++ b/src/server/models/extralist.js @@ -170,46 +170,47 @@ ExtraListSchema.statics.getUsersList = function (idapp) { }; -ExtraListSchema.statics.getDownlineNotRegisteredByNameSurname = function (idapp, nameandsurname) { - const ExtraList = this; - - return ExtraList.find({ - 'aportador_solidario_name_surname': nameandsurname, - registered: false, - }, { - ind_order: 1, - name: 1, - surname: 1, - cell_complete: 1, - num_invitati: 1, - nationality: 1, - }, (err, arrrec) => { - return arrrec - }); -}; - -ExtraListSchema.statics.getUserNotRegisteredByNameSurname = function (idapp, nameandsurname) { - const ExtraList = this; - - return ExtraList.findOne({ - name_complete: nameandsurname, - registered: false, - }, { - lang: 1, - ind_order: 1, - name: 1, - surname: 1, - cell_complete: 1, - num_invitati: 1, - nationality: 1, - }, (err, arrrec) => { - return arrrec - }); -}; +// ExtraListSchema.statics.getDownlineNotRegisteredByNameSurname = function (idapp, nameandsurname) { +// const ExtraList = this; +// +// return ExtraList.find({ +// 'aportador_solidario_name_surname': nameandsurname, +// registered: false, +// }, { +// ind_order: 1, +// name: 1, +// surname: 1, +// cell_complete: 1, +// num_invitati: 1, +// nationality: 1, +// }, (err, arrrec) => { +// return arrrec +// }); +// }; +// ExtraListSchema.statics.getUserNotRegisteredByNameSurname = function (idapp, nameandsurname) { +// const ExtraList = this; +// +// return ExtraList.findOne({ +// name_complete: nameandsurname, +// registered: false, +// }, { +// lang: 1, +// ind_order: 1, +// name: 1, +// surname: 1, +// cell_complete: 1, +// num_invitati: 1, +// nationality: 1, +// }, (err, arrrec) => { +// return arrrec +// }); +// }; +// ExtraListSchema.statics.getFieldsForSearch = function () { - return [{ field: 'username', type: tools.FieldType.string }, + 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 }, @@ -239,6 +240,7 @@ ExtraListSchema.statics.DuplicateAllRecords = async function (idapporig, idappde }; +/* ExtraListSchema.statics.ImportData = async function (locale, idapp, strdata) { const ExtraList = this; @@ -325,6 +327,7 @@ ExtraListSchema.statics.ImportData = async function (locale, idapp, strdata) { console.err(e); } }; +*/ const ExtraList = mongoose.model('ExtraList', ExtraListSchema); diff --git a/src/server/models/listaingresso.js b/src/server/models/listaingresso.js index 8705bdb..e6d9d61 100755 --- a/src/server/models/listaingresso.js +++ b/src/server/models/listaingresso.js @@ -10,7 +10,6 @@ const { ObjectID } = require('mongodb'); const { Nave } = require('./nave'); - const shared_consts = require('../tools/shared_nodejs'); const queryclass = require('../classes/queryclass'); @@ -29,9 +28,18 @@ const ListaIngressoSchema = new mongoose.Schema({ type: String, required: true, }, + username: { + type: String, + }, ind_order: { type: Number, }, + index: { + type: Number, + }, + invitante_username: { + type: String, + }, date_added: { type: Date, }, @@ -42,6 +50,9 @@ const ListaIngressoSchema = new mongoose.Schema({ num_tess: { type: Number, }, + note: { + type: String, + }, deleted: { type: Boolean, default: false, @@ -49,6 +60,27 @@ const ListaIngressoSchema = new mongoose.Schema({ }); +ListaIngressoSchema.pre('save', async function (next) { + if (this.isNew) { + try { + if (!this.ind_order) { + const myrec = await ListaIngresso.findOne({ idapp: this.idapp }).limit(1).sort({ ind_order: -1 }); + + if (!!myrec) { + this.ind_order = myrec._doc.ind_order + 1; + } else { + this.ind_order = 1; + } + } + } catch (e) { + this.ind_order = 2; + } + } + + next(); +}); + + // ListaIngressoSchema.methods.toJSON = function () { // const ListaIngresso = this; // const userObject = ListaIngresso.toObject(); @@ -86,13 +118,27 @@ ListaIngressoSchema.statics.findByIndOrder = function (idapp, ind_order) { } }; -ListaIngressoSchema.statics.findByIndOrderETess = function (idapp, ind_order, num_tess) { +ListaIngressoSchema.statics.findByAllRecByUsername = function (idapp, username) { const ListaIngresso = this; try { - return ListaIngresso.findOne({ - 'idapp': idapp, - 'ind_order': ind_order, + return ListaIngresso.find({ + idapp, + username, + deleted: false + }); + } catch (e) { + + } +}; + +ListaIngressoSchema.statics.findByUsernameETess = async function (idapp, username, num_tess) { + const ListaIngresso = this; + + try { + return await ListaIngresso.findOne({ + idapp, + username, num_tess, }); } catch (e) { @@ -100,67 +146,87 @@ ListaIngressoSchema.statics.findByIndOrderETess = function (idapp, ind_order, nu } }; -ListaIngressoSchema.statics.findAllByIndOrder = function (idapp, ind_order) { +ListaIngressoSchema.statics.findAllByUsername = function (idapp, username) { const ListaIngresso = this; try { return ListaIngresso.find({ 'idapp': idapp, - 'ind_order': ind_order, - added: false, + username, + added: false, // NON QUELLI GIA INSERITI ! $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }], }); } catch (e) { - + console.error(e.message); } }; -ListaIngressoSchema.statics.deleteUserInListaIngresso = async function (idapp, ind_order) { +ListaIngressoSchema.statics.deleteUserInListaIngresso = async function (idapp, username) { const ListaIngresso = this; - return ListaIngresso.findOneAndUpdate({ + return ListaIngresso.updateMany({ idapp, - ind_order, + username, }, { $set: { deleted: true } }, { new: false }) }; -ListaIngressoSchema.statics.addUserInListaIngresso = async function (idapp, ind_order, lang, addednowreal, num_tess) { +ListaIngressoSchema.statics.addUserInListaIngresso = async function (idapp, username, invitante_username, lang, addednowreal, nuovo, dateins, note, added) { const ListaIngresso = this; const { User } = require('./user'); const telegrambot = require('../telegram/telegrambot'); try { - let listaingresso = await ListaIngresso.findByIndOrderETess(idapp, ind_order, num_tess); + let listaingresso = null; + if (!nuovo) { + listaingresso = await ListaIngresso.findByUsernameETess(idapp, username, 1); + } if (!listaingresso) { listaingresso = new ListaIngresso({ - ind_order: ind_order, + _id: new ObjectID(), idapp, - num_tess, + username, + num_tess: 1, date_added: new Date(), - _id: new ObjectID() + invitante_username, }); + if (!!note) { + listaingresso.note = note; + } + if (!!added) { + listaingresso.added = added; + } + + if (!!dateins) { + try { + listaingresso.date_added = dateins; + } catch (e) { + listaingresso.date_added = new Date(); + } + } + if (listaingresso) { - return await listaingresso.save().then(async (ris) => { - if (addednowreal) { - if (!!ris) { - const username = await User.getUsernameByIndOrder(idapp, ind_order); - msgtext = '🔵 ' + username + ' ' + tools.gettranslate('ADDED_TOLISTAINGRESSO', lang); - await telegrambot.sendMsgTelegram(idapp, username, msgtext, true); // Anche a STAFF - } + const ris = await listaingresso.save(); + if (addednowreal) { + if (!!ris) { + const nome = await User.getNameSurnameByUsername(idapp, username); + msgtext = '🔵 ' + nome + ' (' + username + ') ' + tools.gettranslate('ADDED_TOLISTAINGRESSO', lang); + await telegrambot.sendMsgTelegram(idapp, username, msgtext, true); // Anche a STAFF } - return ris; - }); + } + return ris; } } - const giapresente = await Nave.findOne({ idapp, ind_order, num_tess }); + const giapresente = await + Nave.findOne({ idapp, ind_order, num_tess: 1 }); if (!!giapresente) { // Era stato già aggiunto! let fields_to_update = { added: true }; - await ListaIngresso.findOneAndUpdate({ _id: listaingresso._id }, { $set: fields_to_update }, { new: false }); + await + ListaIngresso.findOneAndUpdate({ _id: listaingresso._id }, { $set: fields_to_update }, { new: false }); return false; } @@ -171,44 +237,69 @@ ListaIngressoSchema.statics.addUserInListaIngresso = async function (idapp, ind_ console.error(e.message); } return null; -}; +} +; -function getQueryProj(myfilter, myobjField, myfilter2) { +function getQueryProj(myfilter, myobjField, myfilter2, mygroup) { const query = [ { $match: myfilter }, { $lookup: { from: "users", - localField: "ind_order", - foreignField: "ind_order", // field in the user collection - as: "user" + as: "user", + let: { username: '$username' }, + pipeline: [ + { + $match: { + $expr: { + $and: [ + { $eq: ['$username', '$$username'] }, + { $eq: ['$idapp', myfilter.idapp] }, + ] + } + } + } + ] } }, { $replaceRoot: { newRoot: { $mergeObjects: [{ $arrayElemAt: ["$user", 0] }, "$$ROOT"] } } }, { $match: myfilter2 }, - { $project: myobjField } ]; + if (!!mygroup) { + query.push( + { $group: mygroup } + ); + } + + if (!!myobjField) { + query.push( + { $project: myobjField } + ); + } + return query; } -ListaIngressoSchema.statics.getPosizioneInLista = async function (idapp, ind_order, num_tess) { +ListaIngressoSchema.statics.getPosizioneInLista = async function (idapp, arrrec, ind_order, num_tess) { - arrrec = await ListaIngresso.getProssimiInLista(idapp, true); let posiz = 0; let totposiz = arrrec.length; + let numNaviEntrato = 0; for (let ind = 0; ind < arrrec.length; ind++) { if (arrrec[ind].ind_order === ind_order && arrrec[ind].num_tess === num_tess) { posiz = ind; + numNaviEntrato = arrrec[ind].numNaviEntrato; + break; } } - return { posiz: posiz + 1, totposiz, num_tess } + return { posiz: posiz + 1, totposiz, num_tess, numNaviEntrato } }; @@ -220,7 +311,8 @@ ListaIngressoSchema.statics.showListaOrd = async function (idapp, solonuovi) { let mystr = ''; let conta = 1; for (const rec of arrrec) { - mystr += '[' + conta + '] ' + rec.ind_order + ' [' + rec.numinvitatiattivi + '] - [' + rec.numinvitati + '] (' + rec.ind_order + ') ' + rec.name + ' ' + rec.surname; + mystr += conta + ' - ' + ' [' + rec.numinvitatiattivi + '] - [' + rec.numinvitati + '] (' + rec.ind_order + ') ' + rec.username + ' ' + rec.name + ' ' + rec.surname; + mystr += ' inv = ' + rec.invitante_username; mystr += ' num_tess = ' + rec.num_tess; if (rec.added) mystr += ' (ADDED ++)'; @@ -234,7 +326,11 @@ ListaIngressoSchema.statics.showListaOrd = async function (idapp, solonuovi) { ListaIngressoSchema.statics.getFieldsForSearch = function () { - return [{field: 'ind_order', type: tools.FieldType.number }] + return [ + { field: 'ind_order', type: tools.FieldType.number }, + { field: 'username', type: tools.FieldType.string }, + { field: 'invitante_username', type: tools.FieldType.string }, + ] }; ListaIngressoSchema.statics.executeQueryTable = function (idapp, params) { @@ -269,6 +365,7 @@ ListaIngressoSchema.statics.getProssimiInLista = async function (idapp, solonuov name: 1, surname: 1, username: 1, + invitante_username: 1, email: 1, lang: 1, num_tess: 1, @@ -278,7 +375,7 @@ ListaIngressoSchema.statics.getProssimiInLista = async function (idapp, solonuov }; let myfilter2 = { - username: { $exists: true }, + surname: { $exists: true }, $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }], }; @@ -297,19 +394,36 @@ ListaIngressoSchema.statics.getProssimiInLista = async function (idapp, solonuov }, myobjField, myfilter2); } - arrrec = await ListaIngresso.aggregate(myquery).sort({ ind_order: 1 }) + // await ListaIngresso.aggiornaIndex(); + + arrrec = await ListaIngresso.aggregate(myquery).sort({ date_added: 1 }) .then(async (arrlista) => { const { User } = require('../models/user'); - for (const rec of arrlista) { - rec.numinvitati = await User.getnumInvitati(idapp, rec.username); - rec.numinvitatiattivi = await User.getnumInvitatiAttivi(idapp, rec.username); + const arrindex = {}; - if (rec.num_tess > 2) { - rec.numinvitati = rec.numinvitati - (rec.num_tess - 1); - rec.numinvitatiattivi = rec.numinvitatiattivi - (rec.num_tess - 1); + for (const rec of arrlista) { + + // ++Todo: TOGLIERE! + if (false) { + rec.numNaviEntrato = await Nave.getnumNaviByUsername(idapp, rec.username); + + rec.numinvitati = await ListaIngresso.getnumInvitati(idapp, rec.username); + rec.numinvitatiattivi = await ListaIngresso.getnumInvitatiAttivi(idapp, rec.username); } + + const arrListaIngrUser = arrindex[rec.username]; + if (!arrListaIngrUser) { + arrindex[rec.username] = 1 + rec.numNaviEntrato; + } else { + arrindex[rec.username] += 1; // incrementa + } + + // if (rec.num_tess > 2) { + rec.numinvitati = rec.numinvitati - (arrindex[rec.username] - 1) * 2; + rec.numinvitatiattivi = rec.numinvitatiattivi - (arrindex[rec.username] - 1) * 2; + // } if (rec.numinvitati < 0) { rec.numinvitati = 0; } @@ -335,6 +449,337 @@ ListaIngressoSchema.statics.getProssimiInLista = async function (idapp, solonuov return arrrec; }; +ListaIngressoSchema.statics.creaTessituraeConv = async function (idapp) { + const ListaIngresso = this; + + const { User } = require('./user'); + + try { + if (true) { + // Elimina TUTTI i Cancellati (ma non Sospesi) + await User.remove({ + idapp, + $and: [ + { deleted: { $exists: true, $eq: true } }, // cancellati + { $or: [{ sospeso: { $exists: false } }, { sospeso: { $exists: true, $eq: false } }] }, // ma non sospeso + ] + }); + + + // Comprende anche i sospesi + const arrusers = await User.find({ + idapp, + }); + + // Ricalcola il Campo Index + await User.ricalcolaIndex(idapp); + + // Ricrea i record ListaIngresso (num_tess = 1), per ogni User + for (const user of arrusers) { + if (user.ind_order >= 0) { + let ingr = new ListaIngresso(); + ingr._id = new ObjectID(); + ingr.idapp = idapp; + ingr.ind_order = user.ind_order; + ingr.username = user.username; + ingr.invitante_username = user.aportador_solidario; + ingr.num_tess = 1; + // ingr.date_added = user.date_reg; + ingr.added = false; + const listaingr = await ListaIngresso.find({ idapp, ind_order: ingr.ind_order, num_tess: 1 }); + + const trovatanave = await Nave.findOne({ idapp, ind_order: ingr.ind_order, num_tess: 1 }) + .then((mynave) => { + if (!!mynave) { + ingr.date_added = mynave.created; + ingr.added = true; + } + return !!mynave; + }); + + if (listaingr.length === 0) { + if (trovatanave) + await ingr.save(); + else { + // non ha ancora i 7 requisiti + } + + } else { + + const listaingr2 = await ListaIngresso.find({ idapp, ind_order: ingr.ind_order }); + + for (const ingr2 of listaingr2) { + + const ris = await ListaIngresso.findByIdAndUpdate(ingr2._id, { + $set: { + username: ingr.username, + invitante_username: ingr.invitante_username + } + }, { new: false }); + } + + } + + // cancella in user i campi che non uso più + await User.findByIdAndUpdate(user.id, { + $set: { + old_order: user.ind_order, + ind_order: -1, + // aportador_solidario: '' + } + }) + } + } + } + + // Comprende anche i sospesi + const arrIdTelegramUsers = await User.find({ idapp, 'profile.teleg_id': { $gt: 1 } }, + { _id: 1, username: 1, aportador_solidario: 1, old_order: 1, lang: 1, date_reg: 1, 'profile.teleg_id': 1 }) + .sort({ + 'profile.teleg_id': 1, + old_order: 1 + }); + + + // Crea altri ListaIngresso per gli utenti con i sottoaccount: + /* + const arrIdTelegramUsers = []; + const arrusersAlreadyExist = []; + for (const user of arrusers) { + if (!!user.profile.teleg_id) { + const trovati = arrusersAlreadyExist.find((rec) => rec.teleg_id === user.profile.teleg_id); + if (trovati) { + // era già presente, quindi lo aggiungo ! + const trovatoidteleg = arrIdTelegramUsers.find((rec) => rec.teleg_id === user.profile.teleg_id); + if (!trovatoidteleg) + arrIdTelegramUsers.push({ teleg_id: user.profile.teleg_id, username: user.username }); + } else { + arrusersAlreadyExist.push({ teleg_id: user.profile.teleg_id, username: user.username }); + } + } + } + */ + + let index = 0; + + let teleg_id = 0; + let username = ''; + let invitante_username = ''; + let invitante_degli_invitati = ''; + + // Questi sono Utenti che hanno associato Telegram a più Account ! + for (const myuser of arrIdTelegramUsers) { + + // Crea 1 record listaingresso per ogni record aggiuntivo ! escludendo il primo! + if (teleg_id !== myuser.profile.teleg_id) { + index = 0; + teleg_id = myuser.profile.teleg_id; + username = myuser.username; + invitante_username = myuser.aportador_solidario; + invitante_degli_invitati = myuser.username; + } + + if (index > 0) { + // Ind_order to find ! + const ind_order = myuser.old_order; + //const findnave = await Nave.find({ idapp, ind_order: myuser.old_order, num_tess: 1 }); + + if (ind_order >= 0) { + const findlistaingresso = await ListaIngresso.findOne({ idapp, ind_order, num_tess: 1 }); + + if (!!findlistaingresso) { + await ListaIngresso.findByIdAndUpdate(findlistaingresso._id, { + $set: { + username, + invitante_username, + note: findlistaingresso.username, + } + }, { new: false }); + + await Nave.updateMany({idapp, ind_order}, { + $set: { + note: findlistaingresso.username, + } + }, { new: false }); + + + // Crea Record ListaIngresso + // const newrecingr = await ListaIngresso.addUserInListaIngresso(idapp, myuser.username, invitante_username, myuser.lang, false, true, myuser.date_reg, note, added); + + // Assegna l'Invitante agli Invitati ! trova tutti gli invitati che hanno questo username + const arrinvitati = await User.find({ idapp, aportador_solidario: myuser.username }, { username: 1 }); + for (const invitato of arrinvitati) { + await User.changeInvitante(idapp, invitato.username, invitante_degli_invitati, ind_order) + } + + // poi imposta come cancellato questo record + await User.findByIdAndUpdate(myuser._id, { $set: { deleted: true } }); + } + } + + } + index++; + } + + return index; + + } catch (e) { + console.error(e.message); + } + +}; + +ListaIngressoSchema.statics.getListaTessByUsername = function (idapp, username) { + const ListaIngresso = this; + + return ListaIngresso.find({ + idapp, + username, + // added: true, + deleted: false, + }); + + +}; + +ListaIngressoSchema.statics.getarray = async function (idapp, filtri, myobjField) { + const ListaIngresso = this; + + let myfilter2 = { + surname: { $exists: true }, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }], + }; + + let myquery = getQueryProj( + filtri, + myobjField, + myfilter2 + ); + + return await ListaIngresso.aggregate(myquery); + +}; + + +ListaIngressoSchema.statics.getInvitati = async function (idapp, username, myobjField) { + const ListaIngresso = this; + + return ListaIngresso.getarray(idapp, + { + idapp, + deleted: false, + invitante_username: username, + username: { $ne: username }, + }, + myobjField); + +}; + +/* +ListaIngressoSchema.statics.getUserByInvitante_Username = async function (idapp, invitante_username) { + const ListaIngresso = this; + + const arr = ListaIngresso.getarray(idapp, + { + idapp, + deleted: false, + invitante_username: invitante_username, + username: { $ne: {invitante_username} }, + }, + null); + + if (!!arr) + return arr[0]; + else + return null; +}; + +*/ + +ListaIngressoSchema.statics.getnumInvitati = async function (idapp, username) { + const ListaIngresso = this; + + const arrlistainv = await ListaIngresso.find({ + idapp, + invitante_username: username, + deleted: false, + username: { $ne: username }, + }, { username: 1 }); + + const { User } = require('./user'); + + // Ottieni gli invitati che ancora non hanno un'imbarco + const arrinv = await User.find({ + idapp, + aportador_solidario: username, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] + }); + + for (const inv of arrinv) { + if (!arrlistainv.find((rec) => rec.username === inv.username)) + arrlistainv.push(inv); + } + + if (!!arrlistainv) + return arrlistainv.length; + else + return 0; + +}; + +ListaIngressoSchema.statics.getnumInvitatiAttivi = async function (idapp, username) { + const ListaIngresso = this; + + const { User } = require('./user'); + + let myfilter2 = { + surname: { $exists: true }, + $and: User.getQueryQualified(), + }; + + let myquery = getQueryProj({ + idapp, + invitante_username: username, + username: { $ne: username }, + deleted: false, + }, + { username: 1, ind_order: 1 }, + myfilter2, + ); + + // { _id: null, count: { $sum: 1 } + + arrlistainv = await ListaIngresso.aggregate(myquery); + + // Ottieni gli invitati che ancora non hanno un'imbarco + const arrinv = await User.find({ + idapp, + aportador_solidario: username, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }], + $and: User.getQueryQualified() + }); + + for (const inv of arrinv) { + if (!arrlistainv.find((rec) => rec.username === inv.username)) + arrlistainv.push(inv); + } + + if (!!arrlistainv) + return arrlistainv.length; + else + return 0; +}; + + +ListaIngressoSchema.statics.aggiornaIndex = function (idapp) { + const ListaIngresso = this; + + const arrlista = ListaIngresso.find({ idapp }).sort({ created: 1 }); + + +}; + + const ListaIngresso = mongoose.model('ListaIngresso', ListaIngressoSchema); diff --git a/src/server/models/nave.js b/src/server/models/nave.js index 15900c9..24f9c34 100755 --- a/src/server/models/nave.js +++ b/src/server/models/nave.js @@ -91,6 +91,31 @@ NaveSchema.statics.findByIndOrder = function (idapp, ind_order) { } }; +NaveSchema.statics.checkIfNaveExist = async function (idapp, username) { + const Nave = this; + + try { + + const arrlista = await ListaIngresso.find({ + idapp, + username, + // added: true, + deleted: false, + }); + + for (const rec of arrlista) { + const mynave = await Nave.find({ idapp, ind_order: rec.ind_order }); + if (!!mynave) + return true; + } + + return false; + + } catch (e) { + + } +}; + NaveSchema.statics.findByIndOrderAndNumTess = function (idapp, ind_order, num_tess) { const Nave = this; @@ -108,9 +133,34 @@ NaveSchema.statics.findByIndOrderAndNumTess = function (idapp, ind_order, num_te NaveSchema.statics.findById = function (idapp, id) { const Nave = this; - const myquery = getQueryProj({ idapp, '_id': ObjectID(id) }); + const { User } = require('./user'); - return Nave.aggregate(myquery); + const myquery = getQueryProj({ idapp, '_id': id }); + + return Nave.aggregate(myquery) + .then(async (rec) => { + try { + if (!!rec) { + if (rec.length > 0) { + const ris = await User.findByIndOrder(idapp, rec[0].ind_order); + if (!!ris) { + if (!!ris._doc) + rec[0] = { ...rec[0], ...ris._doc }; + else + rec[0] = { ...rec[0], ...ris }; + return rec[0]; + } + return rec[0]; + } else { + return null; + } + } else { + return null; + } + }catch (e) { + console.error(e.message); + } + }); }; @@ -176,7 +226,7 @@ NaveSchema.statics.findDonatoreByNave = function (idapp, nave) { return Nave.findOne(miaquery); } catch (e) { - + console.error(e.message); } }; @@ -243,16 +293,13 @@ NaveSchema.statics.findRecByRigaColParent = async function (idapp, riga, col, nu recfind = await Nave.findById(idapp, myrec.parent_id); if (!!recfind) { - if (recfind.length > 0) { - recfind = recfind[0]; - lastrec = recfind; - myrigacol.riga = lastrec.riga; - myrigacol.col = lastrec.col; - } else { - //lastrec = await User.findByIndOrder(idapp, 0); - lastrec = await Nave.findGeneric({ idapp, riga: 0, col: 0 }); - break; - } + lastrec = recfind; + myrigacol.riga = lastrec.riga; + myrigacol.col = lastrec.col; + } else { + //lastrec = await User.findByIndOrder(idapp, 0); + lastrec = await Nave.findGeneric({ idapp, riga: 0, col: 0 }); + break; } } parentup++; @@ -267,43 +314,6 @@ NaveSchema.statics.findRecByRigaColParent = async function (idapp, riga, col, nu }; -function getlimiti(mypos) { - - if (mypos.col < 0) { - mypos.col = 0; - } - - if (mypos.riga < 0) { - mypos.riga = 0; - mypos.col = 0; - } - - return mypos; -} - -function getRigaColGenerica(idapp, riga, col, numup) { - mypos = { - idapp, - riga, - col, - numup - }; - - if (idapp === tools.AYNI) { - tools.getRigaColByPosUp(mypos); - ris = getlimiti(mypos); - } - - return ris; -} - -function getRigaColSognatoreByFuoco(idapp, riga, col) { - return getRigaColGenerica(idapp, riga, col, 6); -} - -function getRigaColMediatoreByFuoco(idapp, riga, col) { - return getRigaColGenerica(idapp, riga, col, 3); -} NaveSchema.statics.findGeneric = function (myrigacol) { @@ -339,17 +349,17 @@ NaveSchema.statics.findGeneric = function (myrigacol) { if (!!newrec) { let myarr = {}; if (rec[0]._doc === undefined) - myarr = { ...newrec._doc, ...rec[0] }; + myarr = { ...newrec, ...rec[0] }; else - myarr = { ...newrec._doc, ...rec[0]._doc }; + myarr = { ...newrec, ...rec[0]._doc }; return myarr; } else { let myarr = rec[0]; if (!!newrec) { if (rec[0]._doc === undefined) - myarr = { ...newrec._doc, ...rec[0] }; + myarr = { ...newrec, ...rec[0] }; else - myarr = { ...newrec._doc, ...rec[0]._doc }; + myarr = { ...newrec, ...rec[0]._doc }; } return myarr; } @@ -403,9 +413,11 @@ function getQueryProj(myfilter) { name: 1, surname: 1, username: 1, + invitante_username: 1, deleted: 1, sospeso: 1, 'profile.paymenttypes': 1, + 'profile.teleg_id': 1, 'profile.email_paypal': 1, 'profile.cell': 1, made_gift: 1, @@ -433,10 +445,32 @@ function getQueryProj(myfilter) { { $match: myfilter }, { $lookup: { - from: "users", + from: "listaingressos", localField: "ind_order", foreignField: "ind_order", // field in the user collection - as: "user" + as: "mylista" + } + }, + { + $unwind: "$mylista" + }, + { + $lookup: { + from: "users", + as: "user", + let: {username: '$mylista.username' }, + pipeline: [ + { + $match: { + $expr: { + $and: [ + { $eq: ['$username', '$$username'] }, + { $eq: ['$idapp', myfilter.idapp] }, + ] + } + } + } + ] } }, { @@ -521,32 +555,34 @@ NaveSchema.statics.getPlaccaGenerica = async function (idapp, riga, col, offset, let recmediatore = await Nave.findMediatoreByFuoco(idapp, riga, col, offset); let navepersistente = await NavePersistente.findByRigaColByDonatore(idapp, riga, col, offset); - mystr = tools.ACAPO; + if (!solorecord) { + mystr = tools.ACAPO; - mystr += 'GIFTING CHAT (' + riga + '.' + col + ') ' + tools.ACAPO + tools.ACAPO; + mystr += 'GIFTING CHAT (' + riga + '.' + col + ') ' + tools.ACAPO + tools.ACAPO; - if (offset === tools.Placca.SONOFUOCO) { - mystr += tools.Placca.SOGNATORE + tools.Placca.STR_SOGNATORE + ': ' + await getusertextbyrec(recsognatori[0], '', '', riga, col, '') + tools.ACAPO + tools.ACAPO; - mystr += tools.Placca.MEDIATORE + tools.Placca.STR_MEDIATORE + ': ' + await getusertextbyrec(recmediatore, '', '', riga, col, '') + tools.ACAPO + tools.ACAPO; - } + if (offset === tools.Placca.SONOFUOCO) { + mystr += tools.Placca.SOGNATORE + tools.Placca.STR_SOGNATORE + ': ' + await getusertextbyrec(recsognatori[0], '', '', riga, col, '') + tools.ACAPO + tools.ACAPO; + mystr += tools.Placca.MEDIATORE + tools.Placca.STR_MEDIATORE + ': ' + await getusertextbyrec(recmediatore, '', '', riga, col, '') + tools.ACAPO + tools.ACAPO; + } - if (offset === tools.Placca.SONOACQUA) { - mystr += tools.Placca.SOGNATORE + tools.Placca.STR_SOGNATORE + ': ' + await getusertextbyrec(recmediatore, '', '', riga, col, '') + tools.ACAPO + tools.ACAPO; - } + if (offset === tools.Placca.SONOACQUA) { + mystr += tools.Placca.SOGNATORE + tools.Placca.STR_SOGNATORE + ': ' + await getusertextbyrec(recmediatore, '', '', riga, col, '') + tools.ACAPO + tools.ACAPO; + } - let symb = { - car: 'D', - icona: '🔥' - }; - - if (offset === tools.Placca.SONOFUOCO) { - mystr += tools.Placca.STR_DONATORI + ':' + tools.ACAPO; - } else if (offset === tools.Placca.SONOACQUA) { - mystr += tools.Placca.STR_MEDIATORI + ':' + tools.ACAPO; - symb = { - car: 'A', - icona: '💦' + let symb = { + car: 'D', + icona: '🔥' }; + + if (offset === tools.Placca.SONOFUOCO) { + mystr += tools.Placca.STR_DONATORI + ':' + tools.ACAPO; + } else if (offset === tools.Placca.SONOACQUA) { + mystr += tools.Placca.STR_MEDIATORI + ':' + tools.ACAPO; + symb = { + car: 'A', + icona: '💦' + }; + } } // mystr += '🔥🌏💦💨🔥🌏💦💨' + tools.ACAPO; @@ -573,7 +609,9 @@ NaveSchema.statics.getPlaccaGenerica = async function (idapp, riga, col, offset, recfuoco = checkifNullThenEmpty(recfuoco, indr, indc); arrdonatori.push({ index: ind, ...recfuoco }); - mystr += await getusertextbyrec(recfuoco, symb.icona, symb.car, indr, indc, ind) + tools.ACAPO; + if (!solorecord) { + mystr += await getusertextbyrec(recfuoco, symb.icona, symb.car, indr, indc, ind) + tools.ACAPO; + } ind++; } @@ -777,45 +815,82 @@ NaveSchema.statics.getNavePos = async function (idapp, riga, col, solorecord, in }; -async function Fuochi8Completati(idapp, params) { - // Inviare un msg al Mediatore che può aprire la Chat con gli 8 fuochi - const telegrambot = require('../telegram/telegrambot'); - - let text = '\nCompletata NAVE [riga=' + params.riga + ',col=' + params.col + ', ind_order=' + params.ind_order + ']'; - console.log(text); - tools.writeNaveLog(text); - - const { User } = require('./user'); - - const rec = await User.findByIndOrder(idapp, params.ind_order); - - text = await Nave.getNaveByUser(idapp, params.ind_order, rec.lang, true); - - // Inviare un msg a questi 8 Fuochi, che la loro placca è Pronta ! - - if (tools.isAbilitaNave(idapp)) { - // ............. - } - - if (false) { - await telegrambot.sendMsgTelegram(idapp, rec.username, text, true); - } else { - await telegrambot.sendMsgTelegramToTheAdmin(idapp, text); - } - - // Inviare la placca a Managers - // await telegrambot.sendMsgTelegramToTheManagers(idapp, txt); -} +// async function Fuochi8Completati(idapp, params) { +// // Inviare un msg al Mediatore che può aprire la Chat con gli 8 fuochi +// const telegrambot = require('../telegram/telegrambot'); +// +// let text = '\nCompletata NAVE [riga=' + params.riga + ',col=' + params.col + ', ind_order=' + params.ind_order + ']'; +// console.log(text); +// tools.writeNaveLog(text); +// +// const { User } = require('./user'); +// +// const rec = await User.findByIndOrder(idapp, params.ind_order); +// +// text = await Nave.getNaveByUser(idapp, params.ind_order, rec.lang, true); +// +// // Inviare un msg a questi 8 Fuochi, che la loro placca è Pronta ! +// +// if (tools.isAbilitaNave(idapp)) { +// // ............. +// } +// +// if (false) { +// await telegrambot.sendMsgTelegram(idapp, rec.username, text, true); +// } else { +// await telegrambot.sendMsgTelegramToTheAdmin(idapp, text); +// } +// +// // Inviare la placca a Managers +// // await telegrambot.sendMsgTelegramToTheManagers(idapp, txt); +// } NaveSchema.statics.getArrPosizioniByIndOrder = async function (idapp, ind_order) { const Nave = this; - arrposizioni = await Nave.find({ 'idapp': idapp, ind_order }).sort({ riga: 1, col: 1 }); + arrposizioni = await Nave.find({ idapp, ind_order }).sort({ riga: 1, col: 1 }); return arrposizioni; }; +NaveSchema.statics.getArrPosizioniByUsername = async function (idapp, username) { + const Nave = this; + + const { ListaIngresso } = require('./listaingresso'); + + try { + const arrrec_indorder = await ListaIngresso.findByAllRecByUsername(idapp, username).distinct("ind_order"); + + let arrposizioni = []; + + for (const ind_order of arrrec_indorder) { + const arr = await Nave.find({ 'idapp': idapp, ind_order }).sort({ riga: 1, col: 1 }); + if (!!arr) + arrposizioni = [...arrposizioni, ...arr]; + } + + return arrposizioni; + } catch (e) { + console.error(e.message); + } + +}; + +NaveSchema.statics.getArrProfiliByIndOrder = async function (idapp, ind_order) { + const Nave = this; + + arrposizioni = await Nave.find({ 'idapp': idapp, ind_order }).sort({ riga: 1, col: 1 }); + + arrprofili = []; + + // Ind_Order + // Ind_order_base + + + return arrprofili; +}; + NaveSchema.statics.getPrimaNaveByRiga = async function (idapp, riga) { const Nave = this; @@ -1174,32 +1249,36 @@ NaveSchema.statics.visuNaviUtentiEliminati = async function (idapp) { }; -NaveSchema.statics.getNaveByUser = async function (idapp, ind_order, lang, fuoco) { +NaveSchema.statics.getNaveByUser = async function (idapp, username, lang, fuoco) { const Nave = this; let mystr = ''; let rec = {}; - const arrposiz = await Nave.getArrPosizioniByIndOrder(idapp, ind_order); - if (!!arrposiz) { - for (const pos of arrposiz) { - let mypos = { - riga: pos.riga, - col: pos.col, - numup: 3, - }; - tools.getRigaColByPosUp(mypos); + try { + const arrposiz = await Nave.getArrPosizioniByUsername(idapp, username); + if (!!arrposiz) { + for (const pos of arrposiz) { + let mypos = { + riga: pos.riga, + col: pos.col, + numup: 3, + }; + tools.getRigaColByPosUp(mypos); - let persistente = await NavePersistente.findByRigaColByDonatore(idapp, pos.riga, pos.col, 0); - if (!!persistente) { - if (persistente.provvisoria) { - mystr += tools.ACAPO + tools.get__('NAVE', lang) + ' ' + '[' + mypos.riga + '.' + mypos.col + '] - ' + tools.get__('TEMPORANEA', lang) + tools.ACAPO+ tools.ACAPO; - } else { - mystr += await Nave.getNavePos(idapp, mypos.riga, mypos.col, false, ind_order); + let persistente = await NavePersistente.findByRigaColByDonatore(idapp, pos.riga, pos.col, 0); + if (!!persistente) { + if (persistente.provvisoria) { + mystr += tools.ACAPO + tools.get__('NAVE', lang) + ' ' + '[' + mypos.riga + '.' + mypos.col + '] - ' + tools.get__('TEMPORANEA', lang) + tools.ACAPO + tools.ACAPO; + } else { + mystr += await Nave.getNavePos(idapp, mypos.riga, mypos.col, false, ind_order); + } } + // mystr += await Nave.getPlaccaPerDonatore(idapp, pos.riga, pos.col, false, rec); + // mystr += await Nave.getPlaccaPerMediatore(idapp, pos.riga, pos.col, false, rec); } - // mystr += await Nave.getPlaccaPerDonatore(idapp, pos.riga, pos.col, false, rec); - // mystr += await Nave.getPlaccaPerMediatore(idapp, pos.riga, pos.col, false, rec); } + } catch (e) { + console.error(e.message); } return mystr; @@ -1333,6 +1412,53 @@ NaveSchema.statics.getNextNumTess = async function (idapp, ind_order) { }; +NaveSchema.statics.getnumNaviByUsername = async function (idapp, username) { + const Nave = this; + + try { + + const { ListaIngresso } = require('./listaingresso'); + + // Get array di ind_order + const arrind_order = await ListaIngresso.find({ idapp, username }).distinct('ind_order'); + + const arrrec = await Nave.find({ idapp, ind_order: arrind_order, num_tess: { $mod: [ 2 , 1] } }, { + riga: 1, + col: 1, + ind_order: 1 + }); + + if (!!arrrec) + return arrrec.length; + else + return 0; + + }catch (e) { + console.error(e.message); + } +}; + +NaveSchema.statics.getSognatoreByRigaColMediatore = async function (idapp, navemediatore) { + + const ris = this.getRigaColSognatoreByMediatore(idapp, navemediatore.riga, navemediatore.col, 3); + + const myquery = getQueryProj({ + idapp, + riga: ris.riga, + col: ris.col, + }); + + arrrec = await Nave.aggregate(myquery); + + if (!!arrrec) { + if (arrrec.length > 0) + return arrrec[0]; + } + + return null; +}; + + const Nave = mongoose.model('Nave', NaveSchema); diff --git a/src/server/models/navepersistente.js b/src/server/models/navepersistente.js index 56be2ef..9b33351 100755 --- a/src/server/models/navepersistente.js +++ b/src/server/models/navepersistente.js @@ -118,10 +118,32 @@ function getQueryProj(myfilter) { { $match: myfilter }, { $lookup: { - from: "users", + from: "listaingressos", localField: "ind_order", foreignField: "ind_order", // field in the user collection - as: "user" + as: "mylista" + } + }, + { + $unwind: "$mylista" + }, + { + $lookup: { + from: "users", + as: "user", + let: {username: '$mylista.username' }, + pipeline: [ + { + $match: { + $expr: { + $and: [ + { $eq: ['$username', '$$username'] }, + { $eq: ['$idapp', myfilter.idapp] }, + ] + } + } + } + ] } }, { diff --git a/src/server/models/project.js b/src/server/models/project.js index 74c34bd..10b2a9d 100755 --- a/src/server/models/project.js +++ b/src/server/models/project.js @@ -333,8 +333,6 @@ ProjectSchema.statics.updateCalc = async function (userId, idproj, objdatacalc, ProjectSchema.pre('save', function (next) { - // var Project = this; - // console.log('Project.expiring_at', Project.expiring_at); next(); diff --git a/src/server/models/user.js b/src/server/models/user.js index ae723e2..6ac73f4 100755 --- a/src/server/models/user.js +++ b/src/server/models/user.js @@ -10,7 +10,7 @@ const { Settings } = require('../models/settings'); const { ListaIngresso } = require('../models/listaingresso'); const { Nave } = require('../models/nave'); const { NavePersistente } = require('../models/navepersistente'); -const { ExtraList } = require('../models/extralist'); +// const { ExtraList } = require('../models/extralist'); const { ObjectID } = require('mongodb'); @@ -46,9 +46,15 @@ const UserSchema = new mongoose.Schema({ type: String, required: true, }, + index: { + type: Number + }, ind_order: { type: Number }, + old_order: { + type: Number + }, username: { type: String, required: true, @@ -121,7 +127,7 @@ const UserSchema = new mongoose.Schema({ news_on: { type: Boolean }, - aportador_solidario: { + aportador_solidario: { // da cancellare type: String, }, aportador_iniziale: { @@ -401,6 +407,7 @@ UserSchema.statics.getUserShortDataByUsername = async function (idapp, username) lang: 1, ind_order: 1, username: 1, + aportador_solidario: 1, name: 1, surname: 1, deleted: 1, @@ -429,101 +436,96 @@ UserSchema.statics.getUserShortDataByUsername = async function (idapp, username) if (myrec) { myrec.qualified = await User.isUserQualified7(idapp, myrec.username); - myrec.numinvitati = await User.getnumInvitati(idapp, myrec.username); - myrec.numinvitatiattivi = await User.getnumInvitatiAttivi(idapp, myrec.username); + myrec.numNaviEntrato = await Nave.getnumNaviByUsername(idapp, myrec.username); + myrec.numinvitati = await ListaIngresso.getnumInvitati(idapp, myrec.username); + myrec.numinvitatiattivi = await ListaIngresso.getnumInvitatiAttivi(idapp, myrec.username); } return myrec }; UserSchema.statics.getDownlineByUsername = async function (idapp, username) { + if (username === undefined) return null; - const User = this; - const arrrec = await User.find({ - 'idapp': idapp, - 'aportador_solidario': username, + const arrrec = await ListaIngresso.getInvitati(idapp, username, + { + index: 1, + lang: 1, + invitante_username: 1, + ind_order: 1, + username: 1, + name: 1, + surname: 1, + verified_email: 1, + 'profile.teleg_id': 1, + 'profile.saw_zoom_presentation': 1, + 'profile.saw_and_accepted': 1, + 'profile.email_paypal': 1, + 'profile.my_dream': 1, + 'profile.paymenttypes': 1, + 'profile.cell': 1, + made_gift: 1, + email: 1, + date_reg: 1, + img: 1 + } + ); + + // Ottieni gli invitati che ancora non hanno un'imbarco + const arrinv = await User.find({ + idapp, + aportador_solidario: username, $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] - }, { - lang: 1, - aportador_solidario: 1, - ind_order: 1, - username: 1, - name: 1, - surname: 1, - verified_email: 1, - 'profile.teleg_id': 1, - 'profile.saw_zoom_presentation': 1, - 'profile.saw_and_accepted': 1, - 'profile.email_paypal': 1, - 'profile.my_dream': 1, - 'profile.paymenttypes': 1, - 'profile.cell': 1, - made_gift: 1, - email: 1, - date_reg: 1, - img: 1 - }, (err, arrrec) => { - return arrrec; }); + for (const inv of arrinv) { + if (!arrrec.find((rec) => rec.username === inv.username)) + arrrec.push(inv); + } + + if (!!arrrec) { for (const rec of arrrec) { - rec._doc.qualified = await User.isUserQualified7(idapp, rec.username); - rec._doc.numinvitati = await User.getnumInvitati(idapp, rec.username); - rec._doc.numinvitatiattivi = await User.getnumInvitatiAttivi(idapp, rec.username); + rec.qualified = await User.isUserQualified7(idapp, rec.username); + rec.numNaviEntrato = await Nave.getnumNaviByUsername(idapp, rec.username); + rec.numinvitati = await ListaIngresso.getnumInvitati(idapp, rec.username); + rec.numinvitatiattivi = await ListaIngresso.getnumInvitatiAttivi(idapp, rec.username); } } - - return arrrec + return arrrec; }; +UserSchema.statics.getQueryQualified = function () { + return [ + { + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }], + }, + { + $or: [ + { + 'profile.special_req': true + }, + { + verified_email: true, + 'profile.teleg_id': { $gt: 1 }, + 'profile.saw_and_accepted': shared_consts.ALL_SAW_AND_ACCEPTED, + 'profile.saw_zoom_presentation': true, + 'profile.my_dream': { $exists: true }, + 'profile.email_paypal': { $exists: true }, + 'profile.paymenttypes': { "$in": ['paypal'] }, + $and: [ + { "$expr": { "$gt": [{ "$strLenCP": "$profile.my_dream" }, 10] } }, + { "$expr": { "$gt": [{ "$strLenCP": "$profile.email_paypal" }, 6] } } + ], + // $where: "this.profile.paymenttypes.length >= 1", + }] + } + ]; +} -UserSchema.statics.getnumInvitatiAttivi = function (idapp, username) { - const User = this; - - if (username === undefined) - return 0; - - // return User.count({ - return User.countDocuments({ - idapp, - aportador_solidario: username, - $and: [ - { - $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }], - }, - { - $or: [ - { - 'profile.special_req': true - }, - { - - verified_email: true, - 'profile.teleg_id': { $gt: 1 }, - 'profile.saw_and_accepted': shared_consts.ALL_SAW_AND_ACCEPTED, - 'profile.saw_zoom_presentation': true, - 'profile.my_dream': { $exists: true }, - 'profile.paymenttypes': { "$in": ['paypal'] }, - $and: [ - { 'profile.my_dream': { $exists: true } }, - { "$expr": { "$gt": [{ "$strLenCP": "$profile.my_dream" }, 10] } }, - { - $and: [ - { 'profile.email_paypal': { $exists: true } }, - { "$expr": { "$gt": [{ "$strLenCP": "$profile.email_paypal" }, 6] } } - ], - } - ], - }] - } - ] - }) - ; -}; UserSchema.statics.isUserQualified7 = async function (idapp, username) { const User = this; @@ -534,30 +536,7 @@ UserSchema.statics.isUserQualified7 = async function (idapp, username) { const myquery = { 'idapp': idapp, 'username': username, - $and: [ - { - $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }], - }, - { - $or: [ - { - 'profile.special_req': true - }, - { - verified_email: true, - 'profile.teleg_id': { $gt: 1 }, - 'profile.saw_and_accepted': shared_consts.ALL_SAW_AND_ACCEPTED, - 'profile.saw_zoom_presentation': true, - 'profile.my_dream': { $exists: true }, - 'profile.email_paypal': { $exists: true }, - 'profile.paymenttypes': { "$in": ['paypal'] }, - $and: [ - { "$expr": { "$gt": [{ "$strLenCP": "$profile.my_dream" }, 10] } }, - { "$expr": { "$gt": [{ "$strLenCP": "$profile.email_paypal" }, 6] } } - ], - $where: "this.profile.paymenttypes.length >= 1", - }] - }] + $and: User.getQueryQualified(), }; const myrec = await User.findOne(myquery); @@ -572,7 +551,7 @@ UserSchema.statics.isUserQualified9 = async function (idapp, username) { return false; qualified = await User.isUserQualified7(idapp, username); - numinvitatiattivi = await User.getnumInvitatiAttivi(idapp, username); + numinvitatiattivi = await ListaIngresso.getnumInvitatiAttivi(idapp, username); return qualified && (numinvitatiattivi >= 2); @@ -616,16 +595,6 @@ UserSchema.statics.getindOrderDuplicate = function (idapp) { }); }; -UserSchema.statics.getnumInvitati = function (idapp, username) { - const User = this; - - return User.count({ - idapp, - aportador_solidario: username, - $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }], - }); -}; - UserSchema.statics.findByLinkreg = function (idapp, linkreg) { const User = this; @@ -696,24 +665,55 @@ UserSchema.statics.findByIndOrder = function (idapp, ind_order) { } }; +UserSchema.statics.findByOldOrder = function (idapp, old_order) { + const User = this; -UserSchema.pre('save', function (next) { - const user = this; - - - /* - if (user.isModified('password')) { - bcrypt.genSalt(10, (err, salt) => { - bcrypt.hash(user.password, salt, (err, hash) => { - user.password = hash; - next(); - }); + try { + return User.findOne({ + idapp, + old_order, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }], }); - } else { - next(); + } catch (e) { + console.error(e.message); + } +}; + + +UserSchema.pre('save', async function (next) { + + try { + if (this.isNew) { + try { + const myrec = await User.findOne({ idapp: this.idapp }).limit(1).sort({ index: -1 }); + + if (!!myrec) { + this.index = myrec._doc.index + 1; + } else { + this.index = 1; + } + } catch (e) { + this.index = 2; + } + } + + /* + if (user.isModified('password')) { + bcrypt.genSalt(10, (err, salt) => { + bcrypt.hash(user.password, salt, (err, hash) => { + user.password = hash; + next(); + }); + }); + } else { + next(); + } + */ + + next(); + }catch (e) { + console.error(e.message); } - */ - next(); }); UserSchema.methods.removeToken = function (token) { @@ -763,15 +763,6 @@ UserSchema.statics.getUserById = function (idapp, id) { }) }; -UserSchema.statics.getUserByAportador = function (idapp, aportador_solidario) { - const User = this; - - return User.findOne({ - idapp, aportador_solidario, - $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }], - }) -}; - UserSchema.statics.getAportadorSolidarioByUsername = async function (idapp, username) { const User = this; @@ -920,25 +911,31 @@ UserSchema.statics.getNameSurnameByUsername = async function (idapp, username) { }; UserSchema.statics.getSmallRecByIndOrder = async function (idapp, ind_order) { - const User = this; - return await User.findOne({ - idapp, ind_order, - $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] - }, - { - idapp: 1, - ind_order: 1, - username: 1, - name: 1, - surname: 1 - } - ) - .then((rec) => { - return rec; - }).catch((e) => { - console.error('getSmallRecByIndOrder', e); - }); + try { + const rec = await ListaIngresso.getarray(idapp, + { + idapp, + ind_order, + deleted: false, + }, + { + idapp: 1, + ind_order: 1, + username: 1, + name: 1, + surname: 1 + }); + + if (!!rec) + return rec[0]; + + return null; + + } catch (e) { + console.error('getSmallRecByIndOrder', e); + } + }; @@ -995,7 +992,7 @@ UserSchema.statics.isAdminByIdTeleg = async function (idapp, idtelegram) { return await User.findOne({ idapp, - 'username': 'paoloar77', + username: 'paoloar77', 'profile.manage_telegram': true, 'profile.teleg_id': idtelegram }, { 'profile.teleg_id': 1 }) @@ -1061,13 +1058,17 @@ UserSchema.statics.getUsersListByParams = function (params) { */ UserSchema.statics.getFieldsForSearch = function () { - return [{ field: 'username', type: tools.FieldType.string }, + return [ + { field: 'username', type: tools.FieldType.string }, { field: 'name', type: tools.FieldType.string }, + { field: 'index', type: tools.FieldType.number }, { field: 'ind_order', type: tools.FieldType.number }, + { field: 'old_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.teleg_id', type: tools.FieldType.number }, { field: 'profile.username_telegram', type: tools.FieldType.string }, { field: 'aportador_solidario', type: tools.FieldType.string }] }; @@ -1102,20 +1103,23 @@ UserSchema.statics.getDashboard = async function (idapp, aportador_solidario, us // DATA: username, name, surname, email, intcode_cell, cell const dashboard = { aportador: {}, - downline: [] + downline: [], + arrposizioni: [], + arrimbarchi: [], + arrusers: {}, }; dashboard.myself = await User.getUserShortDataByUsername(idapp, username); // Data of my Aportador dashboard.aportador = await User.getUserShortDataByUsername(idapp, aportador_solidario); - if (dashboard.aportador === undefined) { - dashboard.aportador = await ExtraList.getUserNotRegisteredByNameSurname(idapp, aportador_solidario_nome_completo); - } + // if (dashboard.aportador === undefined) { + // dashboard.aportador = await ExtraList.getUserNotRegisteredByNameSurname(idapp, aportador_solidario_nome_completo); + // } dashboard.downline = []; // Data of my Downline - const arrap = await User.getDownlineByUsername(idapp, aportador_solidario); + const arrap = await User.getDownlineByUsername(idapp, username); if (!!arrap) dashboard.numpeople_aportador = arrap.length; @@ -1132,32 +1136,33 @@ UserSchema.statics.getDashboard = async function (idapp, aportador_solidario, us } } - if (!!dashboard.myself.ind_order) - dashboard.arrposizioni = await Nave.getArrPosizioniByIndOrder(idapp, dashboard.myself.ind_order); - else - dashboard.arrposizioni = []; + dashboard.arrimbarchi = await ListaIngresso.findAllByUsername(idapp, username); - if (!!dashboard.myself.ind_order) - dashboard.arrimbarchi = await ListaIngresso.findAllByIndOrder(idapp, dashboard.myself.ind_order); - else - dashboard.arrimbarchi = []; + // dashboard.arrprofili = await Nave.getArrProfiliByIndOrder(idapp, dashboard.myself.ind_order); + + dashboard.arrposizioni = await Nave.getArrPosizioniByUsername(idapp, username); + + const arrrec = await ListaIngresso.getProssimiInLista(idapp, true); for (let myimbarco of dashboard.arrimbarchi) { - myimbarco._doc.posiz = await ListaIngresso.getPosizioneInLista(idapp, myimbarco.ind_order, myimbarco.num_tess); + if (!!myimbarco.invitante_username) + dashboard.arrusers[myimbarco.invitante_username] = await User.getUserShortDataByUsername(idapp, myimbarco.invitante_username); + myimbarco._doc.posiz = await ListaIngresso.getPosizioneInLista(idapp, arrrec, myimbarco.ind_order, myimbarco.num_tess); } dashboard.navi_partenza = await NavePersistente.getListaNavi(idapp); dashboard.lastnave = await NavePersistente.getLastNave(idapp); - //for (let indriga = 0; indriga < 10; indriga++) { - // dashboard.navi_partenza.push(await Nave.getPrimaNaveByRiga(idapp, indriga)); - //} - for (let mypos of dashboard.arrposizioni) { mypos._doc.rec = await Nave.getNaveByRigaCol(idapp, mypos.riga, mypos.col); mypos._doc.nave_partenza = await NavePersistente.findByRigaColByDonatore(idapp, mypos.riga, mypos.col, 0); } + //for (let indriga = 0; indriga < 10; indriga++) { + // dashboard.navi_partenza.push(await Nave.getPrimaNaveByRiga(idapp, indriga)); + //} + + const arrnew = []; for (let mypos of dashboard.arrposizioni) { @@ -1167,7 +1172,8 @@ UserSchema.statics.getDashboard = async function (idapp, aportador_solidario, us if (mypos.num_tess % 2 !== 0) { for (let myrec of dashboard.arrposizioni) { - if (myrec.num_tess === mypos.num_tess + 1) { + if (myrec.num_tess === mypos.num_tess + 1 && (myrec.ind_order === mypos.ind_order)) { + // La Nave di Ritorno (numtess = 2) esiste nella lista ! trovato = true } } @@ -1190,14 +1196,14 @@ UserSchema.statics.getDashboard = async function (idapp, aportador_solidario, us myrec.nave_partenza = await NavePersistente.findByRigaColByDonatore(idapp, myrec.riga, myrec.col, 0); - arrnew.push(myrec); + arrnew.push(myrec); } } } dashboard.arrposizioni = [...dashboard.arrposizioni, ...arrnew]; - // console.table(dashboard.arrnavi); + // console.table(dashboard.arrnavi); return dashboard; } catch (e) { @@ -1248,6 +1254,7 @@ UserSchema.statics.getUsersRegistered = async function (idapp) { return await User.count(myfind); }; +/* UserSchema.statics.getUsersQualified = async function (idapp, numinvitati) { const User = this; @@ -1285,7 +1292,7 @@ UserSchema.statics.getUsersQualified = async function (idapp, numinvitati) { let arrris = []; for (const rec of arrusers) { - rec.numinvitatiattivi = await User.getnumInvitatiAttivi(idapp, rec.username); + rec.numinvitatiattivi = await ListaIngresso.getnumInvitatiAttivi(idapp, rec.username); if (rec.numinvitatiattivi >= numinvitati) { arrris.push(rec); } @@ -1294,33 +1301,14 @@ UserSchema.statics.getUsersQualified = async function (idapp, numinvitati) { return arrris }; +*/ UserSchema.statics.visuUtentiNonInNavi = async function (idapp) { const User = this; const arrusers = await User.find({ idapp, - $and: [ - { $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] }, - { - $or: [ - { - 'profile.special_req': true - }, - { - verified_email: true, - 'profile.teleg_id': { $gt: 0 }, - 'profile.paymenttypes': { "$in": ['paypal'] }, - 'profile.saw_and_accepted': shared_consts.ALL_SAW_AND_ACCEPTED, - 'profile.saw_zoom_presentation': true, - 'profile.my_dream': { $exists: true }, - $and: [ - { "$expr": { "$gt": [{ "$strLenCP": "$profile.my_dream" }, 10] } }, - { "$expr": { "$gt": [{ "$strLenCP": "$profile.email_paypal" }, 6] } } - ], - }] - }] - + $and: User.getQueryQualified() }, { name: 1, surname: 1, @@ -1373,7 +1361,7 @@ UserSchema.statics.visuUtentiNonInNavi = async function (idapp) { visualizza = true; } - user.numinvitati = await User.getnumInvitati(idapp, user.username); + user.numinvitati = await ListaIngresso.getnumInvitati(idapp, user.username); reg++; let mianave = await Nave.findOne({ idapp, ind_order: user.ind_order }); let mialistaingresso = await ListaIngresso.findOne({ idapp, ind_order: user.ind_order }); @@ -1439,13 +1427,13 @@ UserSchema.statics.visuUtentiNonInNavi = async function (idapp) { return { num, mystr }; }; -UserSchema.statics.getNumUsersQualified = async function (idapp, numinvitati) { - - arrrec = await this.getUsersQualified(idapp, numinvitati); - - return arrrec.length - -}; +// UserSchema.statics.getNumUsersQualified = async function (idapp, numinvitati) { +// +// arrrec = await this.getUsersQualified(idapp, numinvitati); +// +// return arrrec.length +// +// }; UserSchema.statics.getEmailNotVerified = async function (idapp) { @@ -1562,8 +1550,8 @@ UserSchema.statics.calculateStat = async function (idapp, username) { const User = this; return calcstat = { - numinvitati: await User.getnumInvitati(idapp, username), - numinvitati_attivi: await User.getnumInvitatiAttivi(idapp, username), + numinvitati: await ListaIngresso.getnumInvitati(idapp, username), + numinvitati_attivi: await ListaIngresso.getnumInvitatiAttivi(idapp, username), }; }; @@ -1693,12 +1681,13 @@ if (tools.INITDB_FIRSTIME) { } async function addUtentiInLista(idapp, mode, arrusers) { + let num = 0; for (const rec of arrusers) { let ok = false; let qualified = await User.isUserQualified7(idapp, rec.username); - let numinvitatiattivi = await User.getnumInvitatiAttivi(idapp, rec.username); - let numinvitati = await User.getnumInvitati(idapp, rec.username); + let numinvitatiattivi = await ListaIngresso.getnumInvitatiAttivi(idapp, rec.username); + let numinvitati = await ListaIngresso.getnumInvitati(idapp, rec.username); if (rec.profile.special_req) { numinvitatiattivi = 2; @@ -1719,12 +1708,13 @@ async function addUtentiInLista(idapp, mode, arrusers) { } if (ok) { - ris = await ListaIngresso.addUserInListaIngresso(idapp, rec.ind_order, rec.lang, false, 1); + ris = await ListaIngresso.addUserInListaIngresso(idapp, rec.username, rec.aportador_solidario, rec.lang, false, true); if (!!ris) num++; } } return num; + } UserSchema.statics.deveRitessersi = async function (idapp, ind_order) { @@ -1750,6 +1740,72 @@ UserSchema.statics.getUsernameByIndOrder = async function (idapp, ind_order) { }; +UserSchema.statics.getUsernameByIndex = async function (idapp, index) { + + const myrec = await User.findOne({ + idapp, + index, + }, { username: 1 }); + + return (!!myrec) ? myrec.username : '' + +}; + +UserSchema.statics.ricalcolaIndex = async function (idapp) { + const User = this; + + const arrusers = await User.find({ idapp }).sort({ ind_order: 1 }); + let index = 1; + try { + for (const user of arrusers) { + let field = { + index + }; + + index++; + + const ris = await User.findOneAndUpdate({ _id: user._id }, { $set: field }, { new: false }); + } + }catch (e) { + console.error(e.message); + } + + +}; + +UserSchema.statics.changeInvitante = async function (idapp, username, invitante_username, ind_order_ingr) { + const User = this; + + const rec_ind_order_prima = await ListaIngresso.findOne({ idapp, username }); + + let modif_aportador = false; + // cambia aportador_solidario solo se è la prima nave! + + // Oppure se ancora non sono in Lista! + if (!rec_ind_order_prima) { + modif_aportador = true; + } else { + if (rec_ind_order_prima.ind_order === ind_order_ingr) { + modif_aportador = true; + } + } + + if (modif_aportador) { + await User.findOneAndUpdate({ idapp, username }, { $set: { aportador_solidario: invitante_username } }); + } + + // ** + // ** Cambia invitante_username e ind_order di LISTAINGRESSO + // ** + const rec_ingr = await ListaIngresso.findOne({ idapp, username: username }); + if (!!rec_ingr) { + await ListaIngresso.findByIdAndUpdate(rec_ingr._id, { $set: { invitante_username, ind_order: ind_order_ingr } }); + } + + +}; + + UserSchema.statics.DbOp = async function (idapp, mydata) { const User = this; try { @@ -1788,7 +1844,7 @@ UserSchema.statics.DbOp = async function (idapp, mydata) { arrusers = await User.find({ 'idapp': idapp, $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] - }).sort({ ind_order: 1 }); + }).sort({ date_added: 1 }); let num = 0; num += await addUtentiInLista(idapp, 1, arrusers); diff --git a/src/server/router/api/actions.js b/src/server/router/api/actions.js index 7e03e6d..53e45a6 100755 --- a/src/server/router/api/actions.js +++ b/src/server/router/api/actions.js @@ -11,7 +11,7 @@ module.exports = { try { if (tablename === 'users') { - await ListaIngresso.deleteUserInListaIngresso(rec.idapp, rec.ind_order); + await ListaIngresso.deleteUserInListaIngresso(rec.idapp, rec.username); // Controlla se aveva invitati, li regala a quello sopra const arrap = await User.getDownlineByUsername(rec.idapp, rec.username); diff --git a/src/server/router/index_router.js b/src/server/router/index_router.js index 6d385fc..f555627 100755 --- a/src/server/router/index_router.js +++ b/src/server/router/index_router.js @@ -30,7 +30,7 @@ const _ = require('lodash'); const { User } = require('../models/user'); const { Nave } = require('../models/nave'); const { NavePersistente } = require('../models/navepersistente'); -const { ExtraList } = require('../models/extralist'); +// const { ExtraList } = require('../models/extralist'); const { Booking } = require('../models/booking'); const { Operator } = require('../models/operator'); const { Where } = require('../models/where'); @@ -179,8 +179,10 @@ function getTableByTableName(tablename) { mytable = ''; if (tablename === 'users') mytable = User; - else if (tablename === 'extralist') - mytable = ExtraList; + else if (tablename === 'tessitura') + mytable = Tessitura; + // else if (tablename === 'extralist') + // mytable = ExtraList; else if (tablename === 'bookings') mytable = Booking; else if (tablename === 'operators') @@ -280,7 +282,7 @@ router.post('/gettable', authenticate, (req, res) => { async function checkIfSbloccatiRequisiti(idapp, allData, id) { - if (await Nave.findByIndOrder(idapp, allData.myuser.ind_order)) { + if (await Nave.checkIfNaveExist(idapp, allData.myuser.username)) { // Se già sei dentro la Nave, allora sei OK return true; } @@ -289,18 +291,18 @@ async function checkIfSbloccatiRequisiti(idapp, allData, id) { const is7req = await User.isUserQualified7(idapp, allData.myuser.username); const is9req = await User.isUserQualified9(idapp, allData.myuser.username); - const userlista = await ListaIngresso.findByIndOrder(idapp, allData.myuser.ind_order); - if (!userlista) { + const userlista = await ListaIngresso.getListaTessByUsername(idapp, allData.myuser.username); + if (userlista.length === 0) { // Se non sono ancora dentro alla lista, allora controllo if (!allData.precDataUser.is7req && is7req) { // ORA HAI I 7 REQUISITI ! - const msgtext = telegrambot.getCiao(idapp, allData.myuser.username, allData.myuser.lang) + tools.gettranslate('HAI_I_7_REQUISITI', allData.myuser.lang); - telegrambot.sendMsgTelegram(idapp, allData.myuser.username, msgtext, true); // Anche a STAFF + // const msgtext = telegrambot.getCiao(idapp, allData.myuser.username, allData.myuser.lang) + tools.gettranslate('HAI_I_7_REQUISITI', allData.myuser.lang); + // telegrambot.sendMsgTelegram(idapp, allData.myuser.username, msgtext, true); // Anche a STAFF if (tools.isAbilitaNave(idapp)) { // Aggiungilo alla ListaIngresso - ris = await ListaIngresso.addUserInListaIngresso(idapp, allData.myuser.ind_order, allData.myuser.lang, true, 1); + risingr = await ListaIngresso.addUserInListaIngresso(idapp, allData.myuser.username, allData.myuser.aportador_iniziale, allData.myuser.lang, true, false); } } } @@ -308,11 +310,12 @@ async function checkIfSbloccatiRequisiti(idapp, allData, id) { if (!allData.precDataUser.is9req && is9req) { // ORA HAI I 9 REQUISITI ! const msgtext = telegrambot.getCiao(idapp, allData.myuser.username, allData.myuser.lang) + tools.gettranslate('HAI_I_9_REQUISITI', allData.myuser.lang); - telegrambot.sendMsgTelegram(idapp, allData.myuser.username, msgtext, true); // Anche a STAFF + telegrambot.sendMsgTelegram(idapp, allData.myuser.username, msgtext, false); // Anche a STAFF } // CHECK APORTADOR SOLIDARIO: if (!!allData.useraportador) { +/* const is9reqAportador = await User.isUserQualified9(idapp, allData.myuser.aportador_solidario); if (!allData.precDataAportador.is9req && is9reqAportador) { @@ -320,6 +323,7 @@ async function checkIfSbloccatiRequisiti(idapp, allData, id) { const msgtext = telegrambot.getCiao(idapp, allData.myuser.aportador_solidario, allData.useraportador.lang) + tools.gettranslate('HAI_I_9_REQUISITI', allData.useraportador.lang); telegrambot.sendMsgTelegram(idapp, allData.myuser.aportador_solidario, msgtext, true); // Anche a STAFF } +*/ } } @@ -385,8 +389,8 @@ router.patch('/chval', authenticate, async (req, res) => { allData = {}; allData.myuser = await User.getUserById(idapp, id); allData.precDataUser = await getInfoUser(idapp, allData.myuser.username); - allData.useraportador = await User.getUserByAportador(idapp, allData.myuser.aportador_solidario); - allData.precDataAportador = await getInfoUser(idapp, allData.myuser.aportador_solidario); + // allData.useraportador = await ListaIngresso.getUserByInvitante_Username(idapp, allData.myuser.aportador_solidario); + // allData.precDataAportador = await getInfoUser(idapp, allData.myuser.aportador_solidario); } } @@ -401,7 +405,7 @@ router.patch('/chval', authenticate, async (req, res) => { // Send Notification to the BOT await telegrambot.sendMsgTelegram(idapp, mydata.notifBot.un, mydata.notifBot.txt); addtext = '[Msg Inviato a ' + mydata.notifBot.un + ']:' + '\n' + mydata.notifBot.txt; - await telegrambot.sendMsgTelegramToTheManagers(idapp, addtext); + await telegrambot.sendMsgTelegramToTheManagers(idapp, addtext, true); } if (mydata.table === 'users') { @@ -412,12 +416,26 @@ router.patch('/chval', authenticate, async (req, res) => { if (mydata.table === 'users') { if ('aportador_solidario' in fieldsvalue) { + ind_order_ingr = mydata.ind_order_ingr; + // SERVE SE CI METTO LE MINUSCOLE/MAIUSCOLE SBAGLIATE in invitante_username! const myuserfound = await User.findByUsername(idapp, fieldsvalue.aportador_solidario, false); if (!!myuserfound) { if (!!myuserfound._id && !myuserfound.deleted) { - fieldsvalue.aportador_solidario = await User.getUsernameById(idapp, myuserfound._id); + const aportador = await User.getUsernameById(idapp, myuserfound._id); + fieldsvalue.aportador_solidario = aportador; //Aggiorna record ! await mytable.findByIdAndUpdate(id, { $set: fieldsvalue }); + + const myfirstrec = await ListaIngresso.findOne({ username: rec.username, ind_order: ind_order_ingr }); + if (!!myfirstrec) { + if (!!myfirstrec._id && !myfirstrec.deleted) { + let fieldsv2 = { + invitante_username: aportador + }; + //Aggiorna record ! + const ris = await ListaIngresso.findByIdAndUpdate(myfirstrec._id.toString(), { $set: fieldsv2 }); + } + } } } else { res.send({ code: server_constants.RIS_CODE_ERR, msg: 'Non aggiornato' }); @@ -427,6 +445,33 @@ router.patch('/chval', authenticate, async (req, res) => { } } + if (mydata.table === 'listaingressos') { + if ('invitante_username' in fieldsvalue) { + // SERVE SE CI METTO LE MINUSCOLE/MAIUSCOLE SBAGLIATE in invitante_username! + const myuserfound = await User.findByUsername(idapp, fieldsvalue.invitante_username, false); + if (!!myuserfound) { + if (!!myuserfound._id && !myuserfound.deleted) { + fieldsvalue.invitante_username = await User.getUsernameById(idapp, myuserfound._id); + //Aggiorna record ! + const ris = await mytable.findByIdAndUpdate(id, { $set: fieldsvalue }); + if (!!ris) { + /*let fieldsv2 = { + aportador_solidario: fieldsvalue.invitante_username + }; + + //Aggiorna record ! + await User.findByIdAndUpdate(myuserfound._id, { $set: fieldsv2 }); + */ + } + } + } else { + // res.send({ code: server_constants.RIS_CODE_ERR, msg: 'Non aggiornato' }); + // res.status(400).send(); + // return false; + } + } + } + if (tools.ModificheConsentite(mydata.table, fieldsvalue)) { let msg = ''; if (mydata.table === 'users') { @@ -463,12 +508,15 @@ router.patch('/chval', authenticate, async (req, res) => { tools.mylogserr('Error patch USER: ', e.message); res.status(400).send(); }) + + }); router.patch('/callfunz', authenticate, async (req, res) => { // const idapp = req.body.idapp; const id = req.body.data.id; const ind_order = req.body.data.ind_order; + const username = req.body.data.username; const idapp = req.body.idapp; const mydata = req.body.data; @@ -486,7 +534,7 @@ router.patch('/callfunz', authenticate, async (req, res) => { } } - const myuser = await User.findOne({ idapp, ind_order }); + const myuser = await User.findOne({ idapp, username }); let rimosso = 0; @@ -518,8 +566,12 @@ router.patch('/callfunz', authenticate, async (req, res) => { } if (!!myuser) { + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CONTROLLARE !!! + // ++Todo: Controllare che sia corretto che lo nascondo !!! + // Metti campo 'delete': true su ListaIngresso - olduseringresso = await ListaIngresso.findOne({ idapp, ind_order: myuser.ind_order }); + olduseringresso = await ListaIngresso.findOne({ idapp, ind_order: old_ind_order }); if (!!olduseringresso) { let fieldsvalue = { deleted: true @@ -553,13 +605,13 @@ router.patch('/callfunz', authenticate, async (req, res) => { } else { if (mydata.notifBot && !!navepersistente.link_chat) { // Send Notification to the BOT - let messaggio = 'Sei stato Spostato in una Nuova Nave !'; + let messaggio = tools.get__('SPOSTATO', req.user.lang); if (!!navepersistente.date_start) { - messaggio += tools.ACAPO + ' data di Partenza della Nave: ' + tools.getstrDateLong(navepersistente.date_start) + tools.ACAPO; + messaggio += tools.ACAPO + tools.get__('DATA_PART_NAVE', req.user.lang) + tools.getstrDateLong(navepersistente.date_start) + tools.ACAPO; } if (!!navepersistente.link_chat) { - messaggio += tools.ACAPO + 'Entra nella Gift Chat: ' + navepersistente.link_chat + tools.ACAPO; + messaggio += tools.ACAPO + tools.get__('ENTRA_GIFT_CHAT', req.user.lang) + navepersistente.link_chat + tools.ACAPO; } const myplacca = await Nave.getNavePos(idapp, navepersistente.riga, navepersistente.col); @@ -586,21 +638,28 @@ router.patch('/callfunz', authenticate, async (req, res) => { } } else if (mydata.myfunc === shared_consts.CallFunz.AGGIUNGI_NUOVO_IMBARCO) { // Ottieni il prossimo Numero di Tessitura - let num_tess = await Nave.getNextNumTess(idapp, ind_order); + //let num_tess = await Nave.getNextNumTess(idapp, ind_order); + const num_tess = 1; + /* let listaingr = await ListaIngresso.find({ idapp, ind_order }).sort({ num_tess: 1 }); const trovato = listaingr.find((rec) => rec.num_tess === num_tess); if (trovato) { num_tess = listaingr.slice(-1)[0].num_tess + 2; } + */ - ris = await ListaIngresso.addUserInListaIngresso(idapp, ind_order, myuser.lang, true, num_tess); + // metti l'invitante inizialmente a Te stesso ! + const invitante_username = req.body.data.invitante_username; - arrimbarchi = await ListaIngresso.findAllByIndOrder(idapp, ind_order); + ris = await ListaIngresso.addUserInListaIngresso(idapp, username, invitante_username, myuser.lang, true, true); + + arrimbarchi = await ListaIngresso.findAllByUsername(idapp, username); return res.send({ code: server_constants.RIS_CODE_OK, arrimbarchi }); + } else if (mydata.myfunc === shared_consts.CallFunz.CANCELLA_IMBARCO) { - await ListaIngresso.remove({ idapp, ind_order, num_tess: mydata.data.num_tess }); + await ListaIngresso.remove({ idapp, username, ind_order }); return res.send({ code: server_constants.RIS_CODE_OK }); diff --git a/src/server/router/site_router.js b/src/server/router/site_router.js index 4acec06..865bc23 100755 --- a/src/server/router/site_router.js +++ b/src/server/router/site_router.js @@ -17,7 +17,7 @@ const _ = require('lodash'); const { ObjectID } = require('mongodb'); -const { ExtraList } = require('../models/extralist'); +// const { ExtraList } = require('../models/extralist'); router.post('/load', async (req, res) => { const idapp = req.body.idapp; @@ -32,7 +32,7 @@ router.post('/load', async (req, res) => { num_teleg_attivo: await User.getUsersTelegramAttivo(idapp), num_teleg_pending: await User.getUsersTelegramPending(idapp), // num_qualificati: await User.getNumUsersQualified(idapp, 2), - num_requisiti: await User.getNumUsersQualified(idapp, 0), + // num_requisiti: await User.getNumUsersQualified(idapp, 0), num_modalita_pagamento: await User.getnumPaymentOk(idapp), num_part_zoom: await User.getUsersZoom(idapp), num_part_accepted: await User.getSaw_and_Accepted(idapp), diff --git a/src/server/router/users_router.js b/src/server/router/users_router.js index ba9e997..a9663b3 100755 --- a/src/server/router/users_router.js +++ b/src/server/router/users_router.js @@ -5,7 +5,7 @@ const { User } = require('../models/user'); const { Nave } = require('../models/nave'); const { NavePersistente } = require('../models/navepersistente'); const { ListaIngresso } = require('../models/listaingresso'); -const { ExtraList } = require('../models/extralist'); +// const { ExtraList } = require('../models/extralist'); const { ObjectID } = require('mongodb'); const sendemail = require('../sendemail'); @@ -126,16 +126,16 @@ router.post('/', async (req, res) => { // } const lastuser = await User.getLastUser(user.idapp); - const lastextra = await ExtraList.getLastUser(user.idapp); + // const lastextra = await ExtraList.getLastUser(user.idapp); let lastindorder = 0; if (lastuser) { lastindorder = lastuser.ind_order; } - if (lastextra) { - if (lastextra.ind_order > lastindorder) - lastindorder = lastextra.ind_order; - } + //if (lastextra) { + // if (lastextra.ind_order > lastindorder) + // lastindorder = lastextra.ind_order; + //} if (lastindorder > 0) user.ind_order = lastindorder + 1; @@ -210,9 +210,9 @@ router.post('/', async (req, res) => { user.perm = shared_consts.Permissions.Manager + shared_consts.Permissions.Admin; } - const useraportador = await ExtraList.findByIndOrder(user.idapp, user.aportador_solidario_ind_order); - if (useraportador) - user.aportador_solidario = useraportador.username; + // const useraportador = await ExtraList.findByIndOrder(user.idapp, user.aportador_solidario_ind_order); + // if (useraportador) + // user.aportador_solidario = useraportador.username; } } @@ -263,6 +263,10 @@ router.get('/:idapp/:username', async (req, res) => { var username = req.params.username; const idapp = req.params.idapp; + // if (username === 'pippo') { + // return res.status(200).send(); + // } + await User.findByUsername(idapp, username, false).then((user) => { if (!user) { return res.status(404).send(); @@ -406,7 +410,7 @@ router.post('/import_extralist', async (req, res) => { idapp = req.body.idapp; locale = req.body.locale; - const ris = await ExtraList.ImportData(locale, idapp, strdata); + // const ris = await ExtraList.ImportData(locale, idapp, strdata); console.log('ris', ris); res.send(ris); @@ -482,6 +486,51 @@ router.post('/dbop', authenticate, async (req, res) => { ris = { mystr }; } else if (mydata.dbop === 'visuNaviUtentiEliminati') { ris = await Nave.visuNaviUtentiEliminati(idapp); + } else if (mydata.dbop === 'creaTessituraeConv') { + ris = await ListaIngresso.creaTessituraeConv(idapp); + ris = { mystr }; + } else if (mydata.dbop === 'convNaviTessinListaIngressoRec') { + let num = 0; + + const arrnavitess = await Nave.find({idapp, num_tess: { $gte: 3 } }); + + for (const recnave of arrnavitess) { + if (recnave.num_tess === 3 || recnave.num_tess === 5 || recnave.num_tess === 7) { + const ind_order = recnave.ind_order; + + // Prima controlla se ho già 2 record dello stesso ind_order, allora non lo faccio: + const arringr = await ListaIngresso.find({idapp, ind_order}); + let dafare = true; + if (arringr.length > 0) { + const arringrtest = await ListaIngresso.find({idapp, ind_order}).distinct('num_tess'); + if (arringr.length !== arringrtest.length){ + dafare = false; // Ci sono 2 o piu record! pertanto probabilmente l'ho già fatto! + } + } + if (dafare) { + const user = await User.findByOldOrder(idapp, ind_order); + + if (!!user) { + let note = recnave.num_tess; + // Crea record ListaIngresso + const newrecingr = await ListaIngresso.addUserInListaIngresso(idapp, user.username, user.username, user.lang, false, true, recnave.created, note, true); + + const fieldsvalue = { + ind_order: newrecingr.ind_order, + num_tess: 1, + }; + + // Aggiorna la nave con l'Ind_order nuovo e il num_tess a 1 + await Nave.findOneAndUpdate({ _id: recnave._id }, { $set: fieldsvalue }, { new: false }); + + num++; + } + } + } + } + + ris = { num }; + } else if (mydata.dbop === 'initListaIngresso') { // const aaa = await User.updateMany({ idapp }, { $set: { 'profile.nationality': 'IT' } }); @@ -595,10 +644,18 @@ router.post('/dbop', authenticate, async (req, res) => { let num = 0; lastrec = await User.find({ idapp }).sort({ _id: -1 }).limit(1); + let last = 1; + if (lastrec) { + last = lastrec[0].ind_order; + } + if (!last) { + last = 1; + } + for (let ind = 0; ind < 100; ind++) { let myuser = new User(); myuser._id = new ObjectID(); - myuser.ind_order = lastrec[0].ind_order + ind + 1; + myuser.ind_order = last + ind + 1; myuser.idapp = idapp; myuser.password = "$2a$12$DEaX1h5saTUVC43f7kubyOAlah1xHDgqQTfSIux0.RFDT9WGbyCaG"; myuser.lang = 'it'; @@ -659,7 +716,7 @@ router.post('/dbop', authenticate, async (req, res) => { const user = await User.getUserShortDataByUsername(idapp, mydata.username); if (user) { - arrnavi = await Nave.getArrPosizioniByIndOrder(idapp, user.ind_order); + arrnavi = await Nave.getArrPosizioniByUsername(idapp, user.username); for (let mynave of arrnavi) { mynave._doc.rec = await Nave.getNaveByRigaCol(idapp, mynave.riga, mynave.col); diff --git a/src/server/sendemail.js b/src/server/sendemail.js index d945ba9..8c4d86c 100755 --- a/src/server/sendemail.js +++ b/src/server/sendemail.js @@ -565,7 +565,7 @@ module.exports = { // console.log('-> Invio Email (', mynewsrec.numemail_sent, '/', mynewsrec.numemail_tot, ')'); const esito = this.sendEmail_base('newsletter/' + lang, mylocalsconf.emailto, mylocalsconf, mylocalsconf.dataemail.email_reply, smtpTransport); - if ((mynewsrec.numemail_sent % 50) === 0) { + if ((mynewsrec.numemail_sent % 100) === 0) { const msgproc = 'In Corso ' + mynewsrec.numemail_sent + ' / ' + mynewsrec.numemail_tot + ' Email inviate...'; await telegrambot.sendMsgTelegramToTheManagers(idapp, msgproc); } diff --git a/src/server/telegram/telegrambot.js b/src/server/telegram/telegrambot.js index 3d305d7..5a33fa4 100755 --- a/src/server/telegram/telegrambot.js +++ b/src/server/telegram/telegrambot.js @@ -492,29 +492,33 @@ module.exports = { }, - sendMsgTelegramToTheManagers: async function (idapp, text) { - const usersmanagers = await User.getusersManagers(idapp); - // console.log('usersmanagers', usersmanagers); + sendMsgTelegramToTheManagers: async function (idapp, text, onlyintofile) { tools.writeManagersLog(text); - if (usersmanagers) { - for (const rec of usersmanagers) { - await this.sendMsgTelegramByIdTelegram(idapp, rec.profile.teleg_id, emo.ROBOT_FACE + '[BOT-STAFF]' + emo.ADMIN + ': ' + text, undefined, undefined, true); - await tools.snooze(300) + if (!onlyintofile) { + const usersmanagers = await User.getusersManagers(idapp); + if (usersmanagers) { + for (const rec of usersmanagers) { + await this.sendMsgTelegramByIdTelegram(idapp, rec.profile.teleg_id, emo.ROBOT_FACE + '[BOT-STAFF]' + emo.ADMIN + ': ' + text, undefined, undefined, true); + await tools.snooze(300) + } } } return true }, - getMsgByTipoMsg: function (mydata, lang, user) { + getMsgByTipoMsg: function (mydata, lang, user, sonosognatore) { if (!!mydata.msgextra) { return mydata.msgextra; } if (mydata.tipomsg === tools.TipoMsg.SEND_LINK_CHAT_DONATORI) { - return printf(tools.gettranslate('SEND_LINK_CHAT_DONATORI', lang), user.name, mydata.msgpar1); + if (sonosognatore) + return printf(tools.gettranslate('SEND_LINK_CHAT_SOGNATORE', lang), user.name, mydata.navemediatore.riga + '.' + mydata.navemediatore.col, mydata.msgpar1); + else + return printf(tools.gettranslate('SEND_LINK_CHAT_DONATORI', lang), user.name, mydata.navemediatore.riga + '.' + mydata.navemediatore.col, mydata.msgpar1); } else if (mydata.tipomsg === tools.TipoMsg.SEND_MSG || mydata.tipomsg === tools.TipoMsg.SEND_MSG_SINGOLO) { let mymsg = ''; if (!!mydata.username_mitt) { @@ -533,19 +537,17 @@ module.exports = { try { const arrnavi = await Nave.getusersByNave(idapp, mydata.navemediatore); - // console.log('usersmanagers', usersmanagers); - tools.writeManagersLog('sendMsgTelegramToNave'); - if (arrnavi) { + tools.writeManagersLog('sendMsgTelegramToNave', mydata.navemediatore.riga + '.' + mydata.navemediatore.col); for (const nave of arrnavi) { const user = await User.findByIndOrder(idapp, nave.ind_order); if (!!user) { const lang = user.lang; const idteleg = user.profile.teleg_id; - const mymsg = this.getMsgByTipoMsg(mydata, lang, user); + const mymsg = this.getMsgByTipoMsg(mydata, lang, user, false); if (!!idteleg) { strout += '\n' + user.name + ' ' + user.surname + ':'; @@ -568,6 +570,31 @@ module.exports = { } } + if (mydata.tipomsg === tools.TipoMsg.SEND_LINK_CHAT_DONATORI) { + + const usersognatore = await Nave.getSognatoreByRigaColMediatore(idapp, mydata.navemediatore); + + console.log('Sognatore: ', usersognatore.username); + + if (!!usersognatore) { + const lang = usersognatore.lang; + const idteleg = usersognatore.profile.teleg_id; + const mymsg = this.getMsgByTipoMsg(mydata, lang, usersognatore, true); + + // Invia Msg al Sognatore ! + if (mydata.inviareale) { + await this.sendMsgTelegramByIdTelegram(idapp, idteleg, mymsg, undefined, undefined, true); + await tools.snooze(300); + nummsgsent++; + strout += '\n' + usersognatore.name + ' ' + usersognatore.surname + ':'; + strout += ' -> MSG INVIATO'; + } else { + strout += ' (Pronto da Inviare)'; + } + } + + } + if (nummsgsent > 0) { if (mydata.tipomsg === tools.TipoMsg.SEND_LINK_CHAT_DONATORI) { const fields_to_update = { @@ -887,8 +914,12 @@ class Telegram { rec.msgcodeprec = MsgBot.COME_STAI } else if (MsgBot.CHI_SONO_IO.includes(testo.replace('?', ''))) { risp = 'Su Telegram ti chiami "' + msg.chat.first_name + ' ' + msg.chat.last_name + '"\n'; + if (!!rec.user) { - risp += '\nSul sito ti sei registrato come:\n\n[N. ' + rec.user.ind_order + ']: ' + rec.user.name + ' ' + rec.user.surname + '\nUsername: ' + rec.user.username + '\n' + 'Email: ' + rec.user.email + '\nLang: ' + rec.user.lang; + const myrec = await User.getUserShortDataByUsername(this.idapp, rec.user.username); + risp += '\nSul sito ti sei registrato come:\n\n[N. ' + rec.user.ind_order + ']: ' + rec.user.name + ' ' + rec.user.surname + '\nUsername: ' + rec.user.username + '\n' + 'Email: ' + rec.user.email + '\nLang: ' + rec.user.lang + tools.ACAPO; + risp += 'Num Invitati: ' + myrec.numinvitati + tools.ACAPO; + risp += 'Num Invitati Attivi: ' + myrec.numinvitatiattivi + tools.ACAPO; } else { risp = 'Ancora non ti sei Attivato su AYNI BOT'; } @@ -965,6 +996,7 @@ class Telegram { if (contastiera) { keyboard = { + "parse_mode": "HTML", "reply_markup": { "resize_keyboard": true, "keyboard": await this.getKeyboard(id, undefined, this.getlang(msg)) @@ -1209,7 +1241,7 @@ class Telegram { tuttie9 = dashboard.myself.qualified && (numpersone >= 2) && invitati_attivi >= 2; - mystrnave = await Nave.getNaveByUser(this.idapp, user.ind_order, user.lang, true); + mystrnave = await Nave.getNaveByUser(this.idapp, user.username, user.lang, true); if (mystrnave === '' && tuttie9) { mystr += tools.gettranslate('NO_PROG', user.lang); @@ -1305,7 +1337,7 @@ class Telegram { if (!rec.user) return ""; - let ind_order_to_check = rec.user.ind_order; + let username_to_check = rec.user.username; let arrstringa = msg.text.split(" "); if (!!arrstringa) { @@ -1317,7 +1349,7 @@ class Telegram { } } - mystr = await Nave.getNaveByUser(this.idapp, ind_order_to_check, rec.user.lang, true); + mystr = await Nave.getNaveByUser(this.idapp, username_to_check, rec.user.lang, true); if (!!mystr) await this.sendMsg(msg.chat.id, mystr); @@ -1484,9 +1516,46 @@ class Telegram { } } + getlink(qualelink) { + + if (qualelink === 'website') { + return 'https://ayni.gifteconomy.app' + } else if (qualelink === 'biblio') { + return 'https://t.me/joinchat/AAAAAFMDe8b5lB1X7vOYng'; + } else if (qualelink === 'help') { + return 'https://t.me/joinchat/AL2qKE80rxDkgbeMGO-0bw'; + } else if (qualelink === 'faq') { + return 'https://ayni.gifteconomy.app/faq'; + } else if (qualelink === 'empower') { + return "ITA 🇮🇹: https://t.me/joinchat/C741mkx5QYXu-kyYCYvA8g" + tools.ACAPO + + "SLO 🇸🇮: https://t.me/aynislovenija" + tools.ACAPO + + "ESP 🇪🇸 - PRT 🇵🇹: https://t.me/joinchat/AL2qKBqJRuIEuc2FivgAzg" + tools.ACAPO + + "ENG 🇬🇧: https://t.me/joinchat/AL2qKBYX0yVvOJ6Ssf9hKg" + tools.ACAPO + + "FRA 🇫🇷: https://t.me/joinchat/Kz0wtxieJjzoC3L_DsrdZw"; + } + } + async menuAssistenza(msg) { - const mytext = tools.get__('TESTO_ASSISTENZA', this.getlang(msg)); + const sito = this.getlink('website'); + const empower = this.getlink('empower'); + const biblio = this.getlink('biblio'); + const faq = this.getlink('faq'); + + let help = ""; + let helpaperta = true; + if (tools.isMonToSat() && tools.isBetweenTwoTime('8:00:00', '19:50:00')) { + help = '✅ ' + this.getlink('help'); + } else { + help = "🔴 [ORA CHIUSA - NOW CLOSED]"; + helpaperta = false; + } + + let mytext = ""; + if (this.getlang(msg) === 'it') + mytext = printf(tools.get__('TESTO_ASSISTENZA', this.getlang(msg)), sito, empower, biblio, faq, help); + else + mytext = printf(tools.get__('TESTO_ASSISTENZA', this.getlang(msg)), sito, empower, biblio, help); let menu = null; const rec = this.getRecInMem(msg); @@ -1544,8 +1613,8 @@ class Telegram { if (conmsg) { await this.sendMsg(msg.from.id, getstr(this.getlang(msg), 'MSG_ERRORE_USERNAME_NOT_FOUND'), MenuNoLogin); const lang = this.getlang(msg); - const textman = msg.chat.first_name + ' ' + msg.chat.last_name + ' sta tentando di autenticarsi con il BOT (lang=' + lang + ') (username che scrive: ' + msg.text + ') '; - await local_sendMsgTelegramToTheManagers(this.idapp, textman, msg); + // const textman = msg.chat.first_name + ' ' + msg.chat.last_name + ' sta tentando di autenticarsi con il BOT (lang=' + lang + ') (username che scrive: ' + msg.text + ') '; + // await local_sendMsgTelegramToTheManagers(this.idapp, textman, msg); rec.username_bo = ''; } } else { @@ -1615,7 +1684,7 @@ class Telegram { if (recuser) { let name = recuser.name; this.sendMsg(msg.from.id, printf(getstr(recuser.lang, 'MSG_VERIFY_OK'), name)); - local_sendMsgTelegramToTheManagers(this.idapp, recuser.name + ' ' + recuser.surname + ' si è Verificato a Telegram BOT! (lang=' + recuser.lang + ')' + emo.STARS, msg); + // local_sendMsgTelegramToTheManagers(this.idapp, recuser.name + ' ' + recuser.surname + ' si è Verificato a Telegram BOT! (lang=' + recuser.lang + ')' + emo.STARS, msg); } else { this.sendMsg(msg.from.id, getstr(this.getlang(msg), 'MSG_ERR_UNKNOWN_VERIFY_CODE')); } @@ -1724,8 +1793,8 @@ class Telegram { } else if (destin === Destin.MSG_TO_NAVE) { invia = !await Nave.findDonatoreByNave(this.idapp, rec.extraparam); } else if (destin === Destin.SI_INVITATI_NO_7REQ_INVITATI) { - const numinvitati = await User.getnumInvitati(this.idapp, utente.username); - const numinvitatiattivi = await User.getnumInvitatiAttivi(this.idapp, utente.username); + const numinvitati = await ListaIngresso.getnumInvitati(this.idapp, utente.username); + const numinvitatiattivi = await ListaIngresso.getnumInvitatiAttivi(this.idapp, utente.username); invia = (numinvitati >= 2) && (numinvitatiattivi < 2); } if (invia) { @@ -2021,6 +2090,7 @@ class Telegram { try { if (!form) { form = { + "parse_mode": "HTML", "message_id": msg_id, "reply_markup": { "resize_keyboard": true, @@ -2116,6 +2186,7 @@ class Telegram { async msgScegliMenu(msg) { // const rec = this.getRecInMem(msg); this._inviaMsg(msg.from.id, getstr(this.getlang(msg), 'MSG_SCEGLI_MENU'), { + "parse_mode": "HTML", "reply_markup": { "resize_keyboard": true, "keyboard": await this.getKeyboard(msg.from.id, undefined, this.getlang(msg)) diff --git a/src/server/tools/general.js b/src/server/tools/general.js index e0b8757..91f9aa8 100755 --- a/src/server/tools/general.js +++ b/src/server/tools/general.js @@ -51,7 +51,13 @@ textlang = { "Nuova Registrazione": "Nuova Registrazione", "Effettuata una Nuova Registrazione": "Effettuata una Nuova Registrazione", "partecipanti": "partecipanti", - 'TESTO_ASSISTENZA': "Per entrare nel Sito AYNI:\nhttps://ayni.gifteconomy.app\n\nChat AYNI - EMPOWER: Entra ⛩ nella nostra Community chat:\n ITA 🇮🇹: https://t.me/joinchat/C741mkx5QYXu-kyYCYvA8g\n SLO 🇸🇮: https://t.me/aynislovenija\n ESP 🇪🇸 - PRT 🇵🇹: https://t.me/joinchat/AL2qKBqJRuIEuc2FivgAzg\n ENG 🇬🇧: https://t.me/joinchat/AL2qKBYX0yVvOJ6Ssf9hKg\n FRA 🇫🇷: https://t.me/joinchat/Kz0wtxieJjzoC3L_DsrdZw \n\nChat AYNI-BIBLIO: https://t.me/joinchat/AL2qKExZKvenLgpVhOyefQ \n\nPER AIUTO: Leggi le Domande più Frequenti:\nhttps://ayni.gifteconomy.app/faq\n\nChat di Supporto 'AYNI - HELP'\nDa Lunedì al Sabato (8:00 - 20:00)\nhttps://t.me/joinchat/AL2qKE80rxDkgbeMGO-0bw\n1 - Fai la tua domanda e chiedi assistenza.\n2 - Dopo aver ricevuto aiuto esci dalla chat.\nPotrai rientrare ogni qualvolta ne avrai la necessità.", + 'TESTO_ASSISTENZA': "👉 Per entrare nel Sito AYNI\n\n" + + "👉 Hai dimenticato la password?\n\n" + + "👉 Chat AYNI - EMPOWER: Entra ⛩ nella nostra Community chat\n%s\n\n" + + "👉 Canale News e Informazioni AYNI-BIBLIO\n\n" + + "👉 PER AIUTO: Leggi le Domande più Frequenti:\n%s\n\n" + + "Chat di Supporto 'AYNI - HELP'\nDa Lunedì al Sabato (8:00 - 20:00)\n%s\n" + + "1 - Fai la tua domanda e chiedi assistenza.\n2 - Dopo aver ricevuto aiuto Esci dalla chat.\nPotrai rientrare ogni qualvolta ne avrai la necessità.", 'BENVENUTO': "Benvenuto", 'TUE_NAVI': "Ecco le tue Navi programmate", 'HAI_I_7_REQUISITI': 'PRIMI PASSI OK!\nHai i Primi 7 Requisiti per Entrare nella Lista d\'Imbarco!', @@ -85,9 +91,12 @@ textlang = { 'SCEGLI_VOCE': 'scegli una voce:', 'INVITATI_LISTA': 'I Tuoi Invitati (in verde con almeno i primi 7 Requisiti)', 'CIAO': 'Ciao', - 'ADDED_TOLISTAINGRESSO': 'Sei stato aggiunto alla Lista delle persone che entreranno nella Lista D\'Imbarco !\nNei prossimi giorni riceverai un messaggio quando la tua Nave partirà.', + 'ADDED_TOLISTAINGRESSO': 'Complimenti ! Hai completato i 7 Passi!🎊\nSei stato aggiunto alla Lista delle persone che entreranno nella Lista D\'Imbarco !\nNei prossimi giorni riceverai un messaggio quando la tua Nave partirà.', 'NO_PROG': 'Attualmente non sei ancora dentro alla Lista d\'Imbarco!', - 'SEND_LINK_CHAT_DONATORI': 'Ciao %s!\nLa tua NAVE sta finalmente Salpando!\nEntra nella Gift Chat cliccando qui: %s', + 'SEND_LINK_CHAT_DONATORI': 'Ciao %s!\nLa tua NAVE sta finalmente Salpando!\nEntra nella Gift Chat della nave {%s} cliccando qui: %s', + 'SEND_LINK_CHAT_SOGNATORE': 'Ciao %s!\nOggi Diventi Sognatore !!! 🎊🎊🎊 Entra nella Gift Chat della nave {%s} cliccando qui: %s', + 'ENTRA_GIFT_CHAT': 'Entra nella Gift Chat', + 'DATA_PART_NAVE': 'data di Partenza della Nave:', 'SOGNATORE': 'SOGNATORE', 'MEDIATORE': 'MEDIATORE', 'DONATORI': 'DONATORI', @@ -96,7 +105,8 @@ textlang = { 'Doni Effettuati': 'Doni Effettuati', 'Tutor che affianchèra il Mediatore': 'Tutor che affianchèra il Mediatore', 'Giorno di Apertura GIFT CHAT': 'Giorno di Apertura GIFT CHAT', - 'Giorno in cui Inviare il DONO': 'Giorno in cui Inviare il DONO', + 'Giorno in cui Inviare il DONO': 'Hai 4 giorni di tempo per inviare il tuo dono. Giorno di Chiusura:', + 'SPOSTATO': 'Sei stato Spostato in una Nuova Nave !', 'Note': 'Note', 'TEMPORANEA': 'TEMPORANEA', 'NAVE': 'NAVE', @@ -107,7 +117,14 @@ textlang = { "Nuova Registrazione": "Nova Registracija", "Effettuata una Nuova Registrazione": "Izpelji novo Registracijo", "partecipanti": "Udeleženci", - 'TESTO_ASSISTENZA': "Za vstop na spletno stran:\nhttps://ayni.gifteconomy.app\n\nSi pozabil geslo za vstop na stran?\nhttps://ayni.gifteconomy.app/requestresetpwd\n\nKlepet AYNI BOT (questa):\nhttps://t.me/notevoleaynibot\n\nKlepet AYNI - EMPOWER: Vstopi ⛩ v našo Skupnost klepet:\n ITA 🇮🇹: https://t.me/joinchat/C741mkx5QYXu-kyYCYvA8g\n SLO 🇸🇮: https://t.me/aynislovenija\n ESP 🇪🇸 - PRT 🇵🇹: https://t.me/joinchat/AL2qKBqJRuIEuc2FivgAzg\n ENG 🇬🇧: https://t.me/joinchat/AL2qKBYX0yVvOJ6Ssf9hKg\n FRA 🇫🇷: https://t.me/joinchat/Kz0wtxieJjzoC3L_DsrdZw \n\nKlepet AYNI-BIBLIO: https://t.me/joinchat/AL2qKExZKvenLgpVhOyefQ \n\nKlepet za Pomoč in Suport: 'AYNI - HELP'\nhttps://t.me/joinchat/AL2qKE80rxDkgbeMGO-0bw\n1 - Postavi svoje vprašanje in prosi za asistenco.\n2 - KO si sprejel pomoč, izstopi iz klepeta.\n Vstopil boš lahko vedno, ko boš potreboval pomoč.", + 'TESTO_ASSISTENZA': "Za vstop na spletno stran:\n%s\n\n" + + "Si pozabil geslo za vstop na stran?\nhttps://ayni.gifteconomy.app/requestresetpwd\n\n" + + "Klepet AYNI BOT (questa):\nhttps://t.me/notevoleaynibot\n\n" + + "Klepet AYNI - EMPOWER: Vstopi ⛩ v našo Skupnost klepet:\n%s\n\n" + + "Canal News AYNI-BIBLIO:\n%s\n\n" + + "Klepet za Pomoč in Suport: 'AYNI - HELP'\n%s\n" + + "1 - Postavi svoje vprašanje in prosi za asistenco.\n2 - KO si sprejel pomoč, izstopi iz klepeta.\n " + + "Vstopil boš lahko vedno, ko boš potreboval pomoč.", 'BENVENUTO': "Dobrodošel", 'TUE_NAVI': "Tvoje programirane Ladje", 'HAI_I_7_REQUISITI': 'PRVI KORAKI OK!\nIzpolnjuješ Prvih 7 Zahtev za vstop na Listo d\'Vkrcanje!', @@ -144,6 +161,9 @@ textlang = { 'ADDED_TOLISTAINGRESSO': 'Si bil dodan na Seznam oseb, ki bodo vstopile v Listo D\'Vkrcanje !', 'NO_PROG': 'Trenutno še nisi na Listi d\'Vkrcanja!', 'SEND_LINK_CHAT_DONATORI': 'Zdravo %s!\nTvoja LADJA bo končno Izplula!\nVstopi v Darilni (Gift) klepet s klikom tu: %s', + 'SEND_LINK_CHAT_SOGNATORE': 'Zdravo %s!\nDanes Postajaš Sanjač !!! 🎊🎊🎊 Vstopi v Darilni Klepet {%s} s klikom tu: %s', + 'ENTRA_GIFT_CHAT': 'Vstopi v Darilni Klepet', + 'DATA_PART_NAVE': 'Datum odhoda ladje:', 'SOGNATORE': 'Sanjača', 'MEDIATORE': 'MEDIATOR', 'DONATORI': 'DONATOR', @@ -153,6 +173,7 @@ textlang = { 'Tutor che affianchèra il Mediatore': 'Tutor, ki bo podpiral Mediatorja', 'Giorno di Apertura GIFT CHAT': 'Dan odpiranja GIFT CHAT', 'Giorno in cui Inviare il DONO': 'Dan za pošiljanje DARILA', + 'SPOSTATO': 'Prestavljen si v Novo Ladjico !', 'Note': 'Opombe', 'TEMPORANEA': 'ZAČASNA', 'NAVE': 'LADJE', @@ -163,7 +184,12 @@ textlang = { "Nuova Registrazione": "Nuevo Registro", "Effettuata una Nuova Registrazione": "Se ha realizado un nuevo registro", "partecipanti": "participantes", - 'TESTO_ASSISTENZA': "Para entrar en el sitio de AYNI:\nhttps://ayni.gifteconomy.app\n\n¿Olvidó su contraseña para acceder al sitio?\nhttps://ayni.gifteconomy.app/requestresetpwd\n\nChat AYNI BOT (este):\nhttps://t.me/notevoleaynibot\n\nChat AYNI - EMPOWER: Entra en ⛩ en nuestra comunidad de chat:\n ITA 🇮🇹: https://t.me/joinchat/C741mkx5QYXu-kyYCYvA8g\n SLO 🇸🇮: https://t.me/aynislovenija\n ESP 🇪🇸 - PRT 🇵🇹: https://t.me/joinchat/AL2qKBqJRuIEuc2FivgAzg\n ENG 🇬🇧: https://t.me/joinchat/AL2qKBYX0yVvOJ6Ssf9hKg\n FRA 🇫🇷: https://t.me/joinchat/Kz0wtxieJjzoC3L_DsrdZw \n\nChat de la AYNI-BIBLIO: https://t.me/joinchat/AL2qKExZKvenLgpVhOyefQ \n\nChat de ayuda y soporte: 'AYNI - HELP'\nDe lunes a sábado (8:00 - 21:00)\nhttps://t.me/joinchat/AL2qKE80rxDkgbeMGO-0bw\n1 - Haga su pregunta y pida ayuda.\n2 - Después de que consigas ayuda, sal de la sala de chat.\nPuedes volver cuando necesites ayuda..", + 'TESTO_ASSISTENZA': "Para entrar en el sitio de AYNI:\n%s\n\n" + + "¿Olvidó su contraseña para acceder al sitio?\nhttps://ayni.gifteconomy.app/requestresetpwd\n\n" + + "Chat AYNI BOT (este):\nhttps://t.me/notevoleaynibot\n\n" + + "Chat AYNI - EMPOWER: Entra en ⛩ en nuestra comunidad de chat:\n%s\n\n" + + "Chat de ayuda y soporte: 'AYNI - HELP'\nDe lunes a sábado (8:00 - 21:00)\n%s\n" + + "1 - Haga su pregunta y pida ayuda.\n2 - Después de que consigas ayuda, sal de la sala de chat.\nPuedes volver cuando necesites ayuda..", 'BENVENUTO': "Bienvenido", 'TUE_NAVI': "Aquí están sus naves programadas", 'HAI_I_7_REQUISITI': '¡LOS PRIMEROS PASOS ESTÁN BIEN!\nTiene los primeros 7 requisitos para entrar en la lista de embarque!', @@ -200,6 +226,9 @@ textlang = { 'ADDED_TOLISTAINGRESSO': 'Has sido añadido a la lista de personas que entrarán en Lista de embarque!', 'NO_PROG': 'Actualmente no está en la lista de embarque.!', 'SEND_LINK_CHAT_DONATORI': 'Hola %s!\n¡Tu barco por fin está navegando!\nEntra en el Gift Chat haciendo clic aquí: %s', + 'SEND_LINK_CHAT_SOGNATORE': '¡Hola!\n¡Hoy te conviertes en un soñador! 🎊🎊🎊 Entre en el Chat de Regalos de la nave {%s} haciendo clic aquí: %s', + 'ENTRA_GIFT_CHAT': 'Entre en el Chat de Regalos', + 'DATA_PART_NAVE': 'fecha de salida de la nave:', 'SOGNATORE': 'SOÑADOR', 'MEDIATORE': 'MEDIATOR', 'DONATORI': 'DONANTES', @@ -209,6 +238,7 @@ textlang = { 'Tutor che affianchèra il Mediatore': 'Tutor de apoyo al Donante', 'Giorno di Apertura GIFT CHAT': 'Día de apertura GIFT CHAT', 'Giorno in cui Inviare il DONO': 'Día en el que enviar el REGALO', + 'SPOSTATO': 'Has sido trasladado a una nueva nave !', 'Note': 'Notas', 'TEMPORANEA': 'TEMPORAL', 'NAVE': 'NAVE', @@ -216,7 +246,12 @@ textlang = { }, enUs: { "partecipanti": "participants", - 'TESTO_ASSISTENZA': "To enter the AYNI Site:\nhttps://ayni.gifteconomy.app\n\nForgot your password to access the site?\nhttps://ayni.gifteconomy.app/requestresetpwd\nChat AYNI BOT (this one):\nhttps://t.me/notevoleaynibot\n\nChat AYNI - EMPOWER: Enter ⛩ into our chat community:\nITA 🇮🇹: https://t.me/joinchat/C741mkx5QYXu-kyYCYvA8g\n SLO 🇸🇮: https://t.me/aynislovenija\n ESP 🇪🇸 - PRT 🇵🇹: https://t.me/joinchat/AL2qKBqJRuIEuc2FivgAzg\n ENG 🇬🇧: https://t.me/joinchat/AL2qKBYX0yVvOJ6Ssf9hKg\n FRA 🇫🇷: https://t.me/joinchat/Kz0wtxieJjzoC3L_DsrdZw \n\nChat AYNI-BIBLIO: https://t.me/joinchat/AL2qKExZKvenLgpVhOyefQ \n\nHelp and Support Chat: 'AYNI - HELP'.\nMonday to Saturday (8:00 - 20:00)\nhttps://t.me/joinchat/AL2qKE80rxDkgbeMGO-0bw\n1 - Ask your question and ask for assistance.\n2 - After receiving help, exit the chat.\nYou can come back whenever you need help.", + 'TESTO_ASSISTENZA': "To enter the AYNI Site:\n%s\n\nForgot your password to access the site?\n" + + "https://ayni.gifteconomy.app/requestresetpwd\nChat AYNI BOT (this one):\nhttps://t.me/notevoleaynibot\n\n" + + "Chat AYNI - EMPOWER: Enter ⛩ into our chat community:\n%s\n\n" + + "Canale News AYNI-BIBLIO:\n%s\n\n" + + "Help and Support Chat: 'AYNI - HELP'.\nMonday to Saturday (8:00 - 20:00)\n%s\n" + + "1 - Ask your question and ask for assistance.\n2 - After receiving help, exit the chat.\nYou can come back whenever you need help.", 'BENVENUTO': "Welcome", 'TUE_NAVI': "Here are your programmed ships", 'HAI_I_7_REQUISITI': 'FIRST STEPS OK!\nYou have the First 7 Requirements to Enter the Boarding List!', @@ -253,6 +288,9 @@ textlang = { 'ADDED_TOLISTAINGRESSO': 'You have been added to the List of people who will enter the Boarding List!', 'NO_PROG': 'You are not currently on the boarding list.!', 'SEND_LINK_CHAT_DONATORI': 'Hi %s!\nYour ship is finally sailing!\nEnter the Gift Chat by clicking here: %s', + 'SEND_LINK_CHAT_SOGNATORE': 'Hello %s!\nToday you become a Dreamer! 🎊🎊🎊 Enter the ship\'s Gift Chat {%s} by clicking here: %s', + 'ENTRA_GIFT_CHAT': 'Enter the ship\'s Gift Chat', + 'DATA_PART_NAVE': 'date of departure of the ship:', 'SOGNATORE': 'DREAMER', 'MEDIATORE': 'MEDIATOR', 'DONATORI': 'DONOR', @@ -262,6 +300,7 @@ textlang = { 'Tutor che affianchèra il Mediatore': 'Tutor supporting the Mediator', 'Giorno di Apertura GIFT CHAT': 'Opening Day GIFT CHAT', 'Giorno in cui Inviare il DONO': 'Day on which to send the Gift', + 'SPOSTATO': 'You\'ve been moved to a New Ship !', 'Note': 'Note', 'TEMPORANEA': 'TEMPORARY', 'NAVE': 'SHIP', @@ -272,7 +311,13 @@ textlang = { "Nuova Registrazione": "Nouvelle inscription", "Effettuata una Nuova Registrazione": "Un nouvel enregistrement a été effectué", "partecipanti": "participants", - 'TESTO_ASSISTENZA': "Pour entrer sur le site AYNI:\nhttps://ayni.gifteconomy.app\n\nVous avez oublié votre mot de passe pour accéder au site ?\nhttps://ayni.gifteconomy.app/requestresetpwd\n\nChat AYNI BOT (ce):\nhttps://t.me/notevoleaynibot\n\nChat AYNI - EMPOWER : Entrez ⛩ dans notre Community chat:\nITA 🇮🇹: https://t.me/joinchat/C741mkx5QYXu-kyYCYvA8g\n SLO 🇸🇮: https://t.me/aynislovenija\n ESP 🇪🇸 - PRT 🇵🇹: https://t.me/joinchat/AL2qKBqJRuIEuc2FivgAzg\n ENG 🇬🇧: https://t.me/joinchat/AL2qKBYX0yVvOJ6Ssf9hKg\n FRA 🇫🇷: https://t.me/joinchat/Kz0wtxieJjzoC3L_DsrdZw \n\nChat AYNI-BIBLIO: https://t.me/joinchat/AL2qKExZKvenLgpVhOyefQ \n\nChat d’Aide et de Support: 'AYNI - HELP'\nDu lundi au samedi (8:00 - 20:00)\nhttps://t.me/joinchat/AL2qKE80rxDkgbeMGO-0bw\n1 - Posez votre question et demandez d’être assisté.\n2 - Après avoir reçu l’aide, quittez le groupe .\\n Vous pourrez y entrer chaque fois qu’il vous sera nécessaire.", + 'TESTO_ASSISTENZA': "Pour entrer sur le site AYNI:\n%s\n\n" + + "Vous avez oublié votre mot de passe pour accéder au site ?\nhttps://ayni.gifteconomy.app/requestresetpwd\n\n" + + "Chat AYNI BOT (ce):\nhttps://t.me/notevoleaynibot\n\n" + + "Chat AYNI - EMPOWER : Entrez ⛩ dans notre Community chat:\n%s\n\n" + + "Canale News AYNI-BIBLIO:\n%s\n\n" + + "Chat d’Aide et de Support: 'AYNI - HELP'\nDu lundi au samedi (8:00 - 20:00)\n%s\n" + + "1 - Posez votre question et demandez d’être assisté.\n2 - Après avoir reçu l’aide, quittez le groupe.\nVous pourrez y entrer chaque fois qu’il vous sera nécessaire.", 'BENVENUTO': "Bienvenue", 'TUE_NAVI': "Voici vos navires programmés", 'HAI_I_7_REQUISITI': 'PREMIÈRES ÉTAPES OK!\nvous avez les 7 premiers Requis pour Entrer dans la liste d\'embarquement!', @@ -309,6 +354,9 @@ textlang = { 'ADDED_TOLISTAINGRESSO': 'Vous avez été ajouté à la liste d\'embarquement !', 'NO_PROG': 'Vous n\'êtes pas encore sur la liste d\'embarquement.!', 'SEND_LINK_CHAT_DONATORI': 'Salut %s!\nVotre SHIP prend enfin la mer.!\nEntrez dans le Chat Cadeau en cliquant ici: %s', + 'SEND_LINK_CHAT_SOGNATORE': 'Bonjour %s !\nAujourd\'hui, vous devenez un Rêveur ! 🎊🎊🎊 Entrez dans le chat des cadeaux du navire {%s} en cliquant ici : %s', + 'ENTRA_GIFT_CHAT': 'Entrez dans le chat des cadeaux', + 'DATA_PART_NAVE': 'la date de départ du navire:', 'SOGNATORE': 'Rêveur', 'MEDIATORE': 'Médiateur', 'DONATORI': 'DONATEUR', @@ -318,6 +366,7 @@ textlang = { 'Tutor che affianchèra il Mediatore': 'Le tuteur qui soutient le Mediateur', 'Giorno di Apertura GIFT CHAT': 'Jour d\'ouverture GIFT CHAT', 'Giorno in cui Inviare il DONO': 'Envoyer le jour il DONO', + 'SPOSTATO': 'Vous avez été transféré sur un nouveau navire !', 'Note': 'Notes', 'TEMPORANEA': 'TEMPORAIRE', 'NAVE': 'NAVIRE', @@ -328,7 +377,13 @@ textlang = { "Nuova Registrazione": "Novo Registo", "Effettuata una Nuova Registrazione": "Foi efectuado um novo registo", "partecipanti": "participantes", - 'TESTO_ASSISTENZA': "Para entrar no site do AYNI:\nhttps://ayni.gifteconomy.app\n\nEsqueceu sua senha para acessar o site?\nhttps://ayni.gifteconomy.app/requestresetpwd\n\nChat AYNI BOT (isto):\nhttps://t.me/notevoleaynibot\n\nChat AYNI - EMPOWER: Entrar em ⛩ na nossa comunidade de chat:ITA 🇮🇹: https://t.me/joinchat/C741mkx5QYXu-kyYCYvA8g\n SLO 🇸🇮: https://t.me/aynislovenija\n ESP 🇪🇸 - PRT 🇵🇹: https://t.me/joinchat/AL2qKBqJRuIEuc2FivgAzg\n ENG 🇬🇧: https://t.me/joinchat/AL2qKBYX0yVvOJ6Ssf9hKg\n FRA 🇫🇷: https://t.me/joinchat/Kz0wtxieJjzoC3L_DsrdZw \n\nChat AYNI-BIBLIO: https://t.me/joinchat/AL2qKExZKvenLgpVhOyefQ \n\nChat de Ajuda e Suporte: 'AYNI - HELP'.\nDe segunda a sábado (8:00 - 20:00 ITALY)\nhttps://t.me/joinchat/AL2qKE80rxDkgbeMGO-0bw\n1 - Faça a sua pergunta e peça ajuda.\n2 - Depois de receber ajuda, saia do chat.\nPode voltar sempre que precisar de o fazer..", + 'TESTO_ASSISTENZA': "Para entrar no site do AYNI:\n%s\n\n" + + "Esqueceu sua senha para acessar o site?\nhttps://ayni.gifteconomy.app/requestresetpwd\n\n" + + "Chat AYNI BOT (isto):\nhttps://t.me/notevoleaynibot\n\n" + + "Chat AYNI - EMPOWER: Entrar em ⛩ na nossa comunidade de chat:%s\n\n" + + "Canale News AYNI-BIBLIO:\n%s\n\n" + + "Chat de Ajuda e Suporte: 'AYNI - HELP'.\nDe segunda a sábado (8:00 - 20:00 ITALY)\n%s\n" + + "1 - Faça a sua pergunta e peça ajuda.\n2 - Depois de receber ajuda, saia do chat.\nPode voltar sempre que precisar de o fazer..", 'BENVENUTO': "Bem-vindo", 'TUE_NAVI': "Aqui estão os seus navios programados", 'HAI_I_7_REQUISITI': 'PRIMEIROS PASSOS OK!\nVocê tem os 7 primeiros requisitos para entrar na lista de embarque!', @@ -365,6 +420,9 @@ textlang = { 'ADDED_TOLISTAINGRESSO': 'Foi acrescentado à Lista de Embarque !', 'NO_PROG': 'Actualmente, ainda não consta da lista de embarque.!', 'SEND_LINK_CHAT_DONATORI': 'Olà %s!\nO seu SHIP está finalmente a zarpar.!\nEntre no Gift Chat, clicando aqui: %s', + 'SEND_LINK_CHAT_SOGNATORE': 'Olá %s!\nHoje você se torna um sonhador! 🎊🎊🎊 Entre no Gift Chat do navio {%s} clicando aqui: %s', + 'ENTRA_GIFT_CHAT': 'Entre no Gift Chat do navio', + 'DATA_PART_NAVE': 'data de partida do navio:', 'SOGNATORE': 'SONHEIROS', 'MEDIATORE': 'MEDIATOR', 'DONATORI': 'DONATORES', @@ -374,6 +432,7 @@ textlang = { 'Tutor che affianchèra il Mediatore': 'Tutor que apoia o Mediator', 'Giorno di Apertura GIFT CHAT': 'Dia de Abertura GIFT CHAT', 'Giorno in cui Inviare il DONO': 'Dia em que enviar o REGALO', + 'SPOSTATO': 'Você foi transferido para um novo navio !', 'Note': 'Notas', 'TEMPORANEA': 'TEMPORÁRIO', 'NAVE': 'NAVE', @@ -1072,6 +1131,47 @@ module.exports = { return date; }, + isMonToSat() { + const dayOfWeek = new Date(new Date()).getDay(); + return dayOfWeek >= 1 && dayOfWeek <= 6 + }, + + // var startTime = '15:10:10'; + // var endTime = '22:30:00'; + isBetweenTwoTime(startTime, endTime) { + + currentDate = new Date(); + + startDate = new Date(currentDate.getTime()); + startDate.setHours(startTime.split(":")[0]); + startDate.setMinutes(startTime.split(":")[1]); + startDate.setSeconds(startTime.split(":")[2]); + + endDate = new Date(currentDate.getTime()); + endDate.setHours(endTime.split(":")[0]); + endDate.setMinutes(endTime.split(":")[1]); + endDate.setSeconds(endTime.split(":")[2]); + + + valid = startDate < currentDate && endDate > currentDate; + + return valid; + }, + + getlimiti(mypos) { + + if (mypos.col < 0) { + mypos.col = 0; + } + + if (mypos.riga < 0) { + mypos.riga = 0; + mypos.col = 0; + } + + return mypos; + }, + getRigaColByPosUp(mypos) { if (mypos.numup > 0) { mypos.riga = mypos.riga - mypos.numup; @@ -1089,6 +1189,34 @@ module.exports = { } }, + getRigaColGenerica(idapp, riga, col, numup) { + mypos = { + idapp, + riga, + col, + numup + }; + + if (idapp === tools.AYNI) { + this.getRigaColByPosUp(mypos); + ris = this.getlimiti(mypos); + } + + return ris; + }, + + getRigaColSognatoreByDonatore(idapp, riga, col) { + return this.getRigaColGenerica(idapp, riga, col, 6); + }, + + getRigaColMediatoreByFuoco(idapp, riga, col) { + return this.getRigaColGenerica(idapp, riga, col, 3); + }, + + getRigaColSognatoreByMediatore(idapp, riga, col) { + return this.getRigaColGenerica(idapp, riga, col, 3); + }, + appendLeadingZeroes(n) { if (n <= 9) { return "0" + n; @@ -1375,6 +1503,15 @@ module.exports = { } } + if (table === 'listaingressos') { + if ('invitante_username' in fieldsvalue) { + return true; + } + if ('username' in fieldsvalue) { + return true; + } + } + if (table === 'navi') { if ('date_made_gift' in fieldsvalue) { return true; diff --git a/src/server/tools/shared_nodejs.js b/src/server/tools/shared_nodejs.js index b65bc3d..48965d8 100755 --- a/src/server/tools/shared_nodejs.js +++ b/src/server/tools/shared_nodejs.js @@ -49,7 +49,7 @@ module.exports = { }, fieldsUserToChange() { - return ['_id', 'username', 'email', 'name', 'surname', 'perm', 'date_reg', 'verified_email', 'ipaddr', 'lasttimeonline', 'profile', 'calcstat', 'news_on', 'aportador_solidario', 'made_gift', 'ind_order', 'numinvitati', 'numinvitatiattivi', 'qualified'] + return ['_id', 'index', 'username', 'email', 'name', 'surname', 'perm', 'date_reg', 'verified_email', 'ipaddr', 'lasttimeonline', 'profile', 'calcstat', 'news_on', 'aportador_solidario', 'made_gift', 'ind_order', 'old_order', 'numinvitati', 'numinvitatiattivi', 'qualified'] } };