From 7d0538f7aec9b3528ef863d13f2c164812dc2cf9 Mon Sep 17 00:00:00 2001 From: Paolo Arena Date: Mon, 4 May 2020 19:34:41 +0200 Subject: [PATCH] Aggiornamenti 2 --- emails/admin/registration/esEs/html.pug | 30 ++ emails/admin/registration/esEs/subject.pug | 1 + emails/registration/it/textold.pug | 13 + src/server/locales/enUs.json | 1 + src/server/locales/fr.json | 1 + src/server/locales/pt.json | 1 + src/server/locales/si.json | 1 + src/server/models/calzoom.js | 9 + src/server/models/listaingresso.js | 51 ++- src/server/models/nave.js | 50 ++- src/server/models/navepersistente.js | 21 ++ src/server/models/user.js | 387 ++++++++++++++++----- src/server/reg/registration.js | 2 +- src/server/router/api/actions.js | 2 +- src/server/router/booking_router.js | 2 +- src/server/router/dashboard_router.js | 57 +-- src/server/router/index_router.js | 81 ++++- src/server/router/myevent_router.js | 2 +- src/server/router/newsletter_router.js | 2 +- src/server/router/projects_router.js | 4 +- src/server/router/push_router.js | 2 +- src/server/router/sendmsg_router.js | 4 +- src/server/router/site_router.js | 7 + src/server/router/todos_router.js | 4 +- src/server/router/users_router.js | 33 +- src/server/sendemail.js | 2 +- src/server/telegram/telegrambot.js | 17 +- src/server/tools/general.js | 125 ++++--- src/server/tools/shared_nodejs.js | 7 + 29 files changed, 698 insertions(+), 221 deletions(-) create mode 100644 emails/admin/registration/esEs/html.pug create mode 100644 emails/admin/registration/esEs/subject.pug create mode 100644 emails/registration/it/textold.pug create mode 100644 src/server/locales/enUs.json create mode 100644 src/server/locales/fr.json create mode 100644 src/server/locales/pt.json create mode 100644 src/server/locales/si.json diff --git a/emails/admin/registration/esEs/html.pug b/emails/admin/registration/esEs/html.pug new file mode 100644 index 0000000..bf484f0 --- /dev/null +++ b/emails/admin/registration/esEs/html.pug @@ -0,0 +1,30 @@ +p #{name} #{surname} acaba de registrarse en #{nomeapp} +p Con los siguientes datos de acceso: +span Username:  + strong #{username}
+span Email:  + strong #{emailto}
+p
Saludos + +style(type="text/css"). + html, body { + padding: 0; + margin: 0; + } + + .divbtn { + display: flex; + align-items: center; + justify-content: center; + } + + .btn-lg { + padding: 5px; + margin: 5px; + font-size: 26px; + cursor: pointer; + color: white; + background: #027be3 !important; + border-radius: 28px; + + } diff --git a/emails/admin/registration/esEs/subject.pug b/emails/admin/registration/esEs/subject.pug new file mode 100644 index 0000000..562f56d --- /dev/null +++ b/emails/admin/registration/esEs/subject.pug @@ -0,0 +1 @@ +=`Nuevo registro de ${name} ${surname} (${username}) en ${nomeapp}` diff --git a/emails/registration/it/textold.pug b/emails/registration/it/textold.pug new file mode 100644 index 0000000..7c751a2 --- /dev/null +++ b/emails/registration/it/textold.pug @@ -0,0 +1,13 @@ +Benvenuto #{name} nel portale di #{nomeapp}! +I tuoi dati di accesso da ricordare sono: + Username: #{username} + + hai dimenticato la Password? + Trovala qui: #{forgetpwd} + + Email #{emailto} + +Per confermare la registrazione clicca su questo link: +#{strlinkreg} + +Potrai cosi' accedere al sito digitando i tuoi dati di accesso. diff --git a/src/server/locales/enUs.json b/src/server/locales/enUs.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/src/server/locales/enUs.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/src/server/locales/fr.json b/src/server/locales/fr.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/src/server/locales/fr.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/src/server/locales/pt.json b/src/server/locales/pt.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/src/server/locales/pt.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/src/server/locales/si.json b/src/server/locales/si.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/src/server/locales/si.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/src/server/models/calzoom.js b/src/server/models/calzoom.js index e9481af..5c67a10 100755 --- a/src/server/models/calzoom.js +++ b/src/server/models/calzoom.js @@ -25,9 +25,18 @@ const CalZoomSchema = new Schema({ typeconf: { type: String, }, + icon: { + type: String, + }, + color: { + type: String, + }, date_start: { type: Date }, + benvenuto: { + type: Boolean + }, date_end: { type: Date }, diff --git a/src/server/models/listaingresso.js b/src/server/models/listaingresso.js index 9060e6b..8705bdb 100755 --- a/src/server/models/listaingresso.js +++ b/src/server/models/listaingresso.js @@ -68,7 +68,7 @@ ListaIngressoSchema.statics.findByUsername = function (idapp, username) { ListaIngressoSchema.statics.getTotInLista = async function (idapp) { const ListaIngresso = this; - const myfind = { idapp }; + const myfind = { idapp, added: false, deleted: false }; return await ListaIngresso.count(myfind); }; @@ -100,6 +100,21 @@ ListaIngressoSchema.statics.findByIndOrderETess = function (idapp, ind_order, nu } }; +ListaIngressoSchema.statics.findAllByIndOrder = function (idapp, ind_order) { + const ListaIngresso = this; + + try { + return ListaIngresso.find({ + 'idapp': idapp, + 'ind_order': ind_order, + added: false, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }], + }); + } catch (e) { + + } +}; + ListaIngressoSchema.statics.deleteUserInListaIngresso = async function (idapp, ind_order) { const ListaIngresso = this; @@ -131,8 +146,8 @@ ListaIngressoSchema.statics.addUserInListaIngresso = async function (idapp, ind_ return await listaingresso.save().then(async (ris) => { if (addednowreal) { if (!!ris) { - msgtext = tools.gettranslate('ADDED_TOLISTAINGRESSO', lang); 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 } } @@ -153,7 +168,7 @@ ListaIngressoSchema.statics.addUserInListaIngresso = async function (idapp, ind_ return null; } catch (e) { - console.error(e); + console.error(e.message); } return null; }; @@ -180,6 +195,22 @@ function getQueryProj(myfilter, myobjField, myfilter2) { return query; } +ListaIngressoSchema.statics.getPosizioneInLista = async function (idapp, ind_order, num_tess) { + + arrrec = await ListaIngresso.getProssimiInLista(idapp, true); + + let posiz = 0; + let totposiz = arrrec.length; + + for (let ind = 0; ind < arrrec.length; ind++) { + if (arrrec[ind].ind_order === ind_order && arrrec[ind].num_tess === num_tess) { + posiz = ind; + } + } + + return { posiz: posiz + 1, totposiz, num_tess } + +}; ListaIngressoSchema.statics.showListaOrd = async function (idapp, solonuovi) { const ListaIngresso = this; @@ -274,6 +305,18 @@ ListaIngressoSchema.statics.getProssimiInLista = async function (idapp, solonuov for (const rec of arrlista) { rec.numinvitati = await User.getnumInvitati(idapp, rec.username); rec.numinvitatiattivi = await User.getnumInvitatiAttivi(idapp, rec.username); + + if (rec.num_tess > 2) { + rec.numinvitati = rec.numinvitati - (rec.num_tess - 1); + rec.numinvitatiattivi = rec.numinvitatiattivi - (rec.num_tess - 1); + } + if (rec.numinvitati < 0) { + rec.numinvitati = 0; + } + if (rec.numinvitatiattivi < 0) { + rec.numinvitatiattivi = 0; + } + if (rec.numinvitatiattivi > 2) rec.numinvitatiattivi = 2; } @@ -285,7 +328,7 @@ ListaIngressoSchema.statics.getProssimiInLista = async function (idapp, solonuov return arrlista; }).catch((e) => { - console.error(e); + console.error(e.message); return null }); diff --git a/src/server/models/nave.js b/src/server/models/nave.js index f42055d..15900c9 100755 --- a/src/server/models/nave.js +++ b/src/server/models/nave.js @@ -362,7 +362,7 @@ NaveSchema.statics.findGeneric = function (myrigacol) { } return null; }).catch((e) => { - console.error(e); + console.error(e.message); }); } @@ -591,7 +591,7 @@ NaveSchema.statics.getPlaccaGenerica = async function (idapp, riga, col, offset, } } catch (e) { - console.error(e); + console.error(e.message); } }; @@ -755,9 +755,9 @@ NaveSchema.statics.getNavePos = async function (idapp, riga, col, solorecord, in if (!!recnavepersistente.tutor_namesurname) data += '👤 ' + tools.get__('Tutor che affianchèra il Mediatore', lang) + ': "' + recnavepersistente.tutor_namesurname + '"' + tools.ACAPO; - data += '💬 ' + tools.get__('Giorno di Apertura GIFT CHAT', lang) + ': ' + tools.getstrDateLong(recnavepersistente.date_gift_chat_open) + tools.ACAPO; + data += '💬 ' + tools.get__('Giorno di Apertura GIFT CHAT', lang) + ': ' + tools.getstrDateLong(recnavepersistente.date_gift_chat_open, lang) + tools.ACAPO; - data += '🎁 ' + tools.get__('Giorno in cui Inviare il DONO', lang) + ' : ' + tools.getstrDateLong(recnavepersistente.date_start) + tools.ACAPO; + data += '🎁 ' + tools.get__('Giorno in cui Inviare il DONO', lang) + ' : ' + tools.getstrDateLong(recnavepersistente.date_start, lang) + tools.ACAPO; if (!!recnavepersistente.note_bot) data += tools.get__('Note', lang) + ": " + recnavepersistente.note_bot + tools.ACAPO; @@ -771,7 +771,7 @@ NaveSchema.statics.getNavePos = async function (idapp, riga, col, solorecord, in return mystr; } catch (e) { - console.error(e); + console.error(e.message); return ''; } @@ -955,7 +955,7 @@ async function addRecordNaveByParams(params, siRitesse) { return false; }).catch((e) => { - console.error(e); + console.error(e.message); }); } @@ -964,7 +964,7 @@ NaveSchema.statics.checkifDeveRitessersi = async function (recuser) { let deveritessersi = true; - arrrec = await Nave.find({ idapp: recuser.idapp, ind_order: recuser.ind_order }); + arrrec = await Nave.find({ idapp: recuser.idapp, ind_order: recuser.ind_order, num_tess: recuser.num_tess }); if (!!arrrec) { if ((arrrec.length % 2) === 0) { @@ -1009,11 +1009,11 @@ NaveSchema.statics.addUserFromListaIngresso_IntoNave = async function (init, ida if (!!recmediatore) { const ris = await Nave.checkifDeveRitessersi(recmediatore); if (ris.deveritessersi) { - console.log('Si deve ritesere: [riga=', params.riga, 'col', params.col, ']'); + console.log('Si deve ritessere: [riga=', params.riga, 'col', params.col, ']'); if (ris.deveritessersi) { params.ind_order = recmediatore.ind_order; params.id = recmediatore._id; - params.num_tess = ris.num_tess + 1; + params.num_tess = recmediatore.num_tess + 1; await addRecordNaveByParams(params, true); } @@ -1189,7 +1189,14 @@ NaveSchema.statics.getNaveByUser = async function (idapp, ind_order, lang, fuoco }; tools.getRigaColByPosUp(mypos); - 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); } @@ -1299,13 +1306,32 @@ NaveSchema.statics.ricalcolaNave = async function (idapp, nave, riga1don, col1do nave._doc.rec = nave.rec; } - }catch (e) { + } catch (e) { console.error(e.message); } return nave; -} +}; + +NaveSchema.statics.getNextNumTess = async function (idapp, ind_order) { + const Nave = this; + + const rec = await Nave.findOne({ idapp, ind_order }, { num_tess: 1 }).sort({ num_tess: -1 }); + if (!!rec) { + + if (rec.num_tess % 2 === 0) { + rec.num_tess++; + } else { + rec.num_tess += 2; + } + + return rec.num_tess + } else { + return 1; + } + +}; const Nave = mongoose.model('Nave', NaveSchema); diff --git a/src/server/models/navepersistente.js b/src/server/models/navepersistente.js index b201839..56be2ef 100755 --- a/src/server/models/navepersistente.js +++ b/src/server/models/navepersistente.js @@ -183,6 +183,27 @@ NavePersistenteSchema.statics.getListaNavi = function (idapp) { ).sort({ riga: 1, col: 1 }); }; +NavePersistenteSchema.statics.getLastNave = function (idapp) { + const NavePersistente = this; + + const myfind = { idapp, date_start: { $lte: tools.IncDateNow(0) }, provvisoria: false }; + + return NavePersistente.findOne(myfind, + { + index: 1, + riga: 1, + col: 1, + riga1don: 1, + col1don: 1, + date_start: 1, + provvisoria: 1, + DoniConfermati: 1, + DoniTotali: 1, + DoniMancanti: 1, + } + ).sort({ riga: -1, col: -1 }).limit(1); +}; + NavePersistenteSchema.statics.findByRigaColByDonatore = function (idapp, riga, col, offset) { const NavePersistente = this; diff --git a/src/server/models/user.js b/src/server/models/user.js index b3881cb..ae723e2 100755 --- a/src/server/models/user.js +++ b/src/server/models/user.js @@ -279,6 +279,14 @@ UserSchema.statics.isManager = function (perm) { } }; +UserSchema.statics.isTraduttrici = function (perm) { + try { + return ((perm & shared_consts.Permissions.Traduttrici) === shared_consts.Permissions.Traduttrici); + } catch (e) { + return false + } +}; + UserSchema.statics.isTutor = function (perm) { try { return ((perm & shared_consts.Permissions.Tutor) === shared_consts.Permissions.Tutor); @@ -324,10 +332,16 @@ UserSchema.statics.findByCredentials = function (idapp, username, password) { const User = this; let pwd = ""; - return User.findOne({ idapp, username: username }).then((user) => { + return User.findOne({ + idapp, username: username, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] + }).then((user) => { if (!user) { // Check if with email: - return User.findOne({ idapp, email: username.toLowerCase() }) + return User.findOne({ + idapp, email: username.toLowerCase(), + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] + }) } else { return !user.deleted ? user : null } @@ -361,6 +375,7 @@ UserSchema.statics.findByUsername = async function (idapp, username, alsoemail) return await User.findOne({ 'idapp': idapp, 'username': regexusername, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }], }).then(async (ris) => { if ((!ris) && (alsoemail)) { regexemail = new RegExp(["^", username.toLowerCase(), "$"].join(""), "i"); @@ -368,6 +383,7 @@ UserSchema.statics.findByUsername = async function (idapp, username, alsoemail) return User.findOne({ 'idapp': idapp, 'email': regexemail, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }], }); } return ris; @@ -380,6 +396,7 @@ UserSchema.statics.getUserShortDataByUsername = async function (idapp, username) const myrec = await User.findOne({ 'idapp': idapp, 'username': username, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }], }, { lang: 1, ind_order: 1, @@ -427,6 +444,7 @@ UserSchema.statics.getDownlineByUsername = async function (idapp, username) { const arrrec = await User.find({ 'idapp': idapp, 'aportador_solidario': username, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] }, { lang: 1, aportador_solidario: 1, @@ -473,24 +491,38 @@ UserSchema.statics.getnumInvitatiAttivi = function (idapp, username) { return User.countDocuments({ idapp, aportador_solidario: username, - $or: [ + $and: [ { - 'profile.special_req': true + $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: [ - { "$expr": { "$gt": [{ "$strLenCP": "$profile.my_dream" }, 10] } }, - { "$expr": { "$gt": [{ "$strLenCP": "$profile.email_paypal" }, 6] } } - ], - }] - }); + 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) { @@ -502,23 +534,29 @@ UserSchema.statics.isUserQualified7 = async function (idapp, username) { const myquery = { 'idapp': idapp, 'username': username, - $or: [ + $and: [ { - 'profile.special_req': true + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }], }, { - 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", + $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", + }] }] }; @@ -545,6 +583,7 @@ UserSchema.statics.getnumPaymentOk = function (idapp) { return User.count({ idapp, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }], 'profile.paymenttypes': { "$in": ['paypal'] }, $where: "this.profile.paymenttypes.length >= 1", 'profile.email_paypal': { $exists: true }, @@ -554,7 +593,7 @@ UserSchema.statics.getnumPaymentOk = function (idapp) { UserSchema.statics.getUsersNationalityQuery = function (idapp) { const query = [ { - $match: { idapp } + $match: { idapp, $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }], } }, { $group: { _id: "$profile.nationality", count: { $sum: 1 } } @@ -583,6 +622,7 @@ UserSchema.statics.getnumInvitati = function (idapp, username) { return User.count({ idapp, aportador_solidario: username, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }], }); }; @@ -628,13 +668,17 @@ UserSchema.statics.findByEmail = function (idapp, email) { return User.findOne({ 'idapp': idapp, 'email': email, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }], }); }; UserSchema.statics.getLastUser = function (idapp) { const User = this; - return User.findOne({ idapp }).sort({ ind_order: -1 }) + return User.findOne({ + idapp, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }], + }).sort({ ind_order: -1 }) }; UserSchema.statics.findByIndOrder = function (idapp, ind_order) { @@ -645,9 +689,10 @@ UserSchema.statics.findByIndOrder = function (idapp, ind_order) { return User.findOne({ idapp, ind_order, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }], }); } catch (e) { - console.error(e); + console.error(e.message); } }; @@ -684,7 +729,10 @@ UserSchema.methods.removeToken = function (token) { UserSchema.statics.getEmailByUsername = async function (idapp, username) { const User = this; - return await User.findOne({ idapp, username }) + return await User.findOne({ + idapp, username, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] + }) .then((arrrec) => { return ((arrrec) ? arrrec.email : ''); }).catch((e) => { @@ -695,7 +743,10 @@ UserSchema.statics.getEmailByUsername = async function (idapp, username) { UserSchema.statics.getUsernameById = async function (idapp, id) { const User = this; - return await User.findOne({ idapp, _id: id }, { username: 1 }) + return await User.findOne({ + idapp, _id: id, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] + }, { username: 1 }) .then((myuser) => { return ((myuser) ? myuser.username : ''); }).catch((e) => { @@ -706,19 +757,28 @@ UserSchema.statics.getUsernameById = async function (idapp, id) { UserSchema.statics.getUserById = function (idapp, id) { const User = this; - return User.findOne({ idapp, _id: id }) + return User.findOne({ + idapp, _id: id, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] + }) }; UserSchema.statics.getUserByAportador = function (idapp, aportador_solidario) { const User = this; - return User.findOne({ idapp, aportador_solidario }) + 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; - return await User.findOne({ idapp, username }) + return await User.findOne({ + idapp, username, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] + }) .then((rec) => { return ((rec) ? rec.aportador_solidario : ''); }).catch((e) => { @@ -729,7 +789,10 @@ UserSchema.statics.getAportadorSolidarioByUsername = async function (idapp, user UserSchema.statics.UserByIdTelegram = async function (idapp, teleg_id) { const User = this; - return await User.findOne({ idapp, 'profile.teleg_id': teleg_id }) + return await User.findOne({ + idapp, 'profile.teleg_id': teleg_id, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }], + }) .then((rec) => { return (!!rec) ? rec._doc : null; }).catch((e) => { @@ -740,7 +803,10 @@ UserSchema.statics.UserByIdTelegram = async function (idapp, teleg_id) { UserSchema.statics.UsersByIdTelegram = async function (idapp, teleg_id) { const User = this; - return await User.find({ idapp, 'profile.teleg_id': teleg_id }) + return await User.find({ + idapp, 'profile.teleg_id': teleg_id, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] + }) .then((rec) => { return (!!rec) ? rec._doc : null; }).catch((e) => { @@ -751,7 +817,10 @@ UserSchema.statics.UsersByIdTelegram = async function (idapp, teleg_id) { UserSchema.statics.TelegIdByUsername = async function (idapp, username) { const User = this; - return await User.findOne({ idapp, username }, { 'profile.teleg_id': 1 }) + return await User.findOne({ + idapp, username, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] + }, { 'profile.teleg_id': 1 }) .then((rec) => { return (!!rec) ? rec.profile.teleg_id : null; }).catch((e) => { @@ -839,7 +908,10 @@ UserSchema.statics.SetTelegramWasBlocked = async function (idapp, teleg_id) { UserSchema.statics.getNameSurnameByUsername = async function (idapp, username) { const User = this; - return await User.findOne({ idapp, username }, { name: 1, surname: 1 }) + return await User.findOne({ + idapp, username, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] + }, { name: 1, surname: 1 }) .then((rec) => { return (!!rec) ? `${rec.name} ${rec.surname}` : ''; }).catch((e) => { @@ -850,7 +922,10 @@ 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 }, + return await User.findOne({ + idapp, ind_order, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] + }, { idapp: 1, ind_order: 1, @@ -1005,7 +1080,10 @@ UserSchema.statics.executeQueryTable = function (idapp, params) { UserSchema.statics.findAllIdApp = function (idapp) { const User = this; - const myfind = { idapp }; + const myfind = { + idapp, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] + }; return User.find(myfind, (err, arrrec) => { return arrrec @@ -1054,23 +1132,76 @@ UserSchema.statics.getDashboard = async function (idapp, aportador_solidario, us } } - dashboard.arrposizioni = await Nave.getArrPosizioniByIndOrder(idapp, dashboard.myself.ind_order); + if (!!dashboard.myself.ind_order) + dashboard.arrposizioni = await Nave.getArrPosizioniByIndOrder(idapp, dashboard.myself.ind_order); + else + dashboard.arrposizioni = []; + if (!!dashboard.myself.ind_order) + dashboard.arrimbarchi = await ListaIngresso.findAllByIndOrder(idapp, dashboard.myself.ind_order); + else + dashboard.arrimbarchi = []; + + for (let myimbarco of dashboard.arrimbarchi) { + myimbarco._doc.posiz = await ListaIngresso.getPosizioneInLista(idapp, 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); } - // console.table(dashboard.arrnavi); + const arrnew = []; + + for (let mypos of dashboard.arrposizioni) { + // Controlla se è presente la Nave con il num_tess pari + + let trovato = false; + + if (mypos.num_tess % 2 !== 0) { + for (let myrec of dashboard.arrposizioni) { + if (myrec.num_tess === mypos.num_tess + 1) { + trovato = true + } + } + } else { + trovato = true; + } + if (!trovato) { + const mymediatore = mypos._doc.rec.mediatore.arrdonatori[7]; + if (!!mymediatore) { + const myrec = { + riga: mymediatore.riga, + col: mymediatore.col, + name: mypos._doc.rec.mediatore.recmediatore.name, + surname: mypos._doc.rec.mediatore.recmediatore.surname, + username: mypos._doc.rec.mediatore.recmediatore.username, + num_tess: mypos._doc.rec.mediatore.recmediatore.num_tess + 1, + rec: await Nave.getNaveByRigaCol(idapp, mymediatore.riga, mymediatore.col), + nave_partenza: {}, + }; + + myrec.nave_partenza = await NavePersistente.findByRigaColByDonatore(idapp, myrec.riga, myrec.col, 0); + + arrnew.push(myrec); + } + } + } + + dashboard.arrposizioni = [...dashboard.arrposizioni, ...arrnew]; + + // console.table(dashboard.arrnavi); return dashboard; } catch (e) { - console.error(e); + console.error(e.message); return false; } }; @@ -1101,6 +1232,7 @@ UserSchema.statics.findByCellAndNameSurname = function (idapp, cell, name, surna 'profile.cell': cell, 'name': name, 'surname': surname, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] }); }; @@ -1121,21 +1253,25 @@ UserSchema.statics.getUsersQualified = async function (idapp, numinvitati) { const arrusers = await User.find({ idapp, - $or: [ + $and: [ + { $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] }, { - '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] } } - ], + $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] } } + ], + }] }] }, { @@ -1164,21 +1300,25 @@ UserSchema.statics.visuUtentiNonInNavi = async function (idapp) { const arrusers = await User.find({ idapp, - $or: [ + $and: [ + { $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] }, { - '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] } } - ], + $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] } } + ], + }] }] }, { @@ -1202,24 +1342,60 @@ UserSchema.statics.visuUtentiNonInNavi = async function (idapp) { let numnoinlista = 0; let numeliminati = 0; let numsospesi = 0; + let strnavidoppie = ''; + let esiste = false; for (const user of arrusers) { - if (user.deleted) { - numeliminati++; - } else { + esiste = true; + if (!!user.deleted) { + if (user.deleted) { + numeliminati++; + esiste = false; + } + } + if (esiste) { + + let visualizza = false; + + // Controlla se ho un doppione nelle Navi ! + let mienavi = await Nave.find({ idapp, ind_order: user.ind_order }, { num_tess: 1 }); + + let strnavidoppie = []; + if (!!mienavi) { + strnavidoppie = mienavi.reduce((acc, currentValue, index, array) => { + if (array.indexOf(currentValue.num_tess) > -1 && !acc.includes(currentValue.num_tess)) + acc.push(currentValue.num_tess); + return acc; + }, []); + } + + if (strnavidoppie.length > 1) { + visualizza = true; + } + user.numinvitati = await User.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 }); let trovato = false; - if (!mianave) { + + if (!mianave) + visualizza = true; + + if (visualizza) { mystr += user.username + ' ' + user.name + ' ' + user.surname + ' [' + user.ind_order + '] [inv=' + user.numinvitati + ']' - noninnave++; trovato = true; - } else { - innave++; } + if (strnavidoppie.length > 1) { + mystr += ' NAVI DUPLICATE! ' + strnavidoppie.join(','); + } + if (!mianave) + noninnave++; + else + innave++; + + if (user.sospeso) { numsospesi++; } @@ -1422,7 +1598,10 @@ UserSchema.statics.getUsersRegDaily = function (idapp, nrec) { const query = [ { - $match: { idapp, date_reg: { $gte: tools.IncDateNow(-(1000 * 60 * 60 * 24 * nrec)) } } + $match: { + idapp, date_reg: { $gte: tools.IncDateNow(-(1000 * 60 * 60 * 24 * nrec)) }, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] + } }, { $group: { _id: { $dateToString: { format: "%Y-%m-%d", date: "$date_reg" } }, count: { $sum: 1 } } @@ -1434,12 +1613,35 @@ UserSchema.statics.getUsersRegDaily = function (idapp, nrec) { return query }; +UserSchema.statics.getUsersRegWeekly = function (idapp, nrec) { + + const query = [ + { + $match: { + idapp, date_reg: { $gte: tools.IncDateNow(-(1000 * 60 * 60 * 24 * nrec)) }, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] + } + }, + { + $group: { _id: { $dateToString: { format: "%Y-%U", date: "$date_reg" } }, count: { $sum: 1 } } + }, + { + $sort: { _id: 1 } + } + ]; + return query +}; + UserSchema.statics.getnumRegNDays = function (idapp, nrec) { const query = [ { - $match: { idapp, date_reg: { $lt: tools.IncDateNow(-(1000 * 60 * 60 * 24 * nrec)) } } + $match: { + idapp, + date_reg: { $lt: tools.IncDateNow(-(1000 * 60 * 60 * 24 * nrec)) }, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] + } }, { $group: { _id: { $dateToString: { format: "%Y-%m-%d", date: "$date_reg" } }, count: { $sum: 1 } } @@ -1471,6 +1673,16 @@ UserSchema.statics.calcRegDaily = async function (idapp) { }); }; +UserSchema.statics.calcRegWeekly = async function (idapp) { + const User = this; + + return User.aggregate(User.getUsersRegWeekly(idapp, 20 * 7)) + .then(ris => { + // console.table(ris); + return JSON.stringify(ris.slice(0, -1)); + }); +}; + if (tools.INITDB_FIRSTIME) { console.log(' createIndex User Index...'); @@ -1573,7 +1785,10 @@ UserSchema.statics.DbOp = async function (idapp, mydata) { await ListaIngresso.deleteMany({ idapp, added: false }); - arrusers = await User.find({ 'idapp': idapp }).sort({ ind_order: 1 }); + arrusers = await User.find({ + 'idapp': idapp, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] + }).sort({ ind_order: 1 }); let num = 0; num += await addUtentiInLista(idapp, 1, arrusers); @@ -1588,7 +1803,7 @@ UserSchema.statics.DbOp = async function (idapp, mydata) { } } catch (e) { - console.error(e); + console.error(e.message); } diff --git a/src/server/reg/registration.js b/src/server/reg/registration.js index ecf4adf..bc6d7e3 100755 --- a/src/server/reg/registration.js +++ b/src/server/reg/registration.js @@ -16,7 +16,7 @@ module.exports = { }; return jwt.sign(myobj, process.env.SIGNCODE).toString().substring(0, 180); } catch (e) { - console.error(e); + console.error(e.message); } }, diff --git a/src/server/router/api/actions.js b/src/server/router/api/actions.js index 8a1a777..7e03e6d 100755 --- a/src/server/router/api/actions.js +++ b/src/server/router/api/actions.js @@ -30,7 +30,7 @@ module.exports = { return Subscription.deleteOne({ userId: rec._id }) } } catch (e) { - console.error(e); + console.error(e.message); return false } return true; diff --git a/src/server/router/booking_router.js b/src/server/router/booking_router.js index 3e00071..dba508f 100755 --- a/src/server/router/booking_router.js +++ b/src/server/router/booking_router.js @@ -126,7 +126,7 @@ router.delete('/:id/:notify/:idapp', authenticate, (req, res) => { // res.send({ bookedevent: arrdata[0], eventlist: arrdata[1], operators: arrdata[2], wheres: arrdata[3], contribtype: arrdata[4] }); // }) // .catch((e) => { -// console.log(e); +// console.log(e.message); // res.status(400).send(e); // }); // diff --git a/src/server/router/dashboard_router.js b/src/server/router/dashboard_router.js index 6b36cef..8004aef 100755 --- a/src/server/router/dashboard_router.js +++ b/src/server/router/dashboard_router.js @@ -22,35 +22,40 @@ const _ = require('lodash'); const { ObjectID } = require('mongodb'); router.post('/', authenticate, async (req, res) => { - const idapp = req.body.idapp; - let username = req.body.username; + try { + const idapp = req.body.idapp; + let username = req.body.username; - if ((!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm)) && (username) !== req.user.username) { - // If without permissions, exit - return res.status(404).send({ code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: '' }); - } - let aportador_solidario = req.user.aportador_solidario; - let aportador_solidario_nome_completo = req.user.aportador_solidario_nome_completo; + if ((!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm)) && (username) !== req.user.username) { + // If without permissions, exit + return res.status(404).send({ code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: '' }); + } + let aportador_solidario = req.user.aportador_solidario; + let aportador_solidario_nome_completo = req.user.aportador_solidario_nome_completo; - // if (User.isAdmin(req.user.perm) || User.isManager(req.user.perm)) { - // const recuser = await User.findByUsername(idapp, username); - // if (recuser) { - // aportador_solidario_nome_completo = recuser.name + ' ' + recuser.surname; - // } - // } + // if (User.isAdmin(req.user.perm) || User.isManager(req.user.perm)) { + // const recuser = await User.findByUsername(idapp, username); + // if (recuser) { + // aportador_solidario_nome_completo = recuser.name + ' ' + recuser.surname; + // } + // } - if (username) { - aportador_solidario = await User.getAportadorSolidarioByUsername(idapp, username); - aportador_solidario_nome_completo = await User.getNameSurnameByUsername(idapp, username); - } else { - username = req.user.username; - } + if (username) { + aportador_solidario = await User.getAportadorSolidarioByUsername(idapp, username); + aportador_solidario_nome_completo = await User.getNameSurnameByUsername(idapp, username); + } else { + username = req.user.username; + } - const dashboard = await User.getDashboard(idapp, aportador_solidario, username, aportador_solidario_nome_completo); - if (dashboard) - res.send({ dashboard }); - else + const dashboard = await User.getDashboard(idapp, aportador_solidario, username, aportador_solidario_nome_completo); + if (dashboard) + res.send({ dashboard }); + else + res.status(400).send(e); + + } catch (e) { res.status(400).send(e); + } }); @@ -188,7 +193,7 @@ router.post('/getdoninavi', authenticate, async (req, res) => { else res.status(400).send(e); } catch (e) { - console.log(e) + console.log(e.message) } }); @@ -206,7 +211,7 @@ router.post('/getdata', authenticate, async (req, res) => { else res.status(400).send(e); } catch (e) { - console.log(e) + console.log(e.message) } }); diff --git a/src/server/router/index_router.js b/src/server/router/index_router.js index a56d768..6d385fc 100755 --- a/src/server/router/index_router.js +++ b/src/server/router/index_router.js @@ -55,6 +55,8 @@ const tools = require('../tools/general'); const server_constants = require('../tools/server_constants'); const actions = require('./api/actions'); +const shared_consts = require('../tools/shared_nodejs'); + UserCost = { FIELDS_REQUISITI: ['verified_email', 'profile.teleg_id', @@ -97,7 +99,7 @@ router.post(process.env.LINKVERIF_REG, (req, res) => { } } }).catch((e) => { - console.log(e); + console.log(e.message); res.status(400).send(); }); @@ -126,7 +128,7 @@ router.post(process.env.LINK_REQUEST_NEWPASSWORD, (req, res) => { }); } }).catch((e) => { - console.log(e); + console.log(e.message); res.status(400).send(); res.send({ code: server_constants.RIS_CODE_ERR, msg: e }); }); @@ -166,7 +168,7 @@ router.post(process.env.LINK_UPDATE_PWD, (req, res) => { }) } }).catch((e) => { - console.log(e); + console.log(e.message); res.status(400).send(); }); @@ -251,7 +253,7 @@ router.post('/settable', authenticate, (req, res) => { return res.send(rec); }).catch((e) => { - console.log(e); + console.log(e.message); res.status(400).send(e); }); @@ -270,7 +272,7 @@ router.post('/gettable', authenticate, (req, res) => { return res.send(ris); }).catch((e) => { - console.log(e); + console.log(e.message); res.status(400).send(e); }); @@ -370,7 +372,7 @@ router.patch('/chval', authenticate, async (req, res) => { // tools.mylogshow('PATCH CHVAL: ', id, fieldsvalue); // If I change my record... - if ((!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm) && !User.isTutor(req.user.perm)) && !(req.user._id.toString() === id) && !tools.ModificheConsentite(mydata.table, fieldsvalue)) { + if ((!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm) && !User.isTraduttrici(req.user.perm) && !User.isTutor(req.user.perm)) && !(req.user._id.toString() === id) && !tools.ModificheConsentite(mydata.table, fieldsvalue)) { // If without permissions, exit return res.status(404).send({ code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: '' }); } @@ -408,6 +410,23 @@ router.patch('/chval', authenticate, async (req, res) => { } } + if (mydata.table === 'users') { + if ('aportador_solidario' in fieldsvalue) { + 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); + //Aggiorna record ! + await mytable.findByIdAndUpdate(id, { $set: fieldsvalue }); + } + } 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') { @@ -454,17 +473,25 @@ router.patch('/callfunz', authenticate, async (req, res) => { const mydata = req.body.data; try { - // If I change my record... - if ((!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm) && !User.isTutor(req.user.perm)) && !(req.user._id.toString() === id) && !tools.ModificheConsentite(mydata.table, fieldsvalue)) { - // If without permissions, exit - return res.status(404).send({ code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: '' }); + let entra = false; + if (mydata.myfunc === shared_consts.CallFunz.AGGIUNGI_NUOVO_IMBARCO || + mydata.myfunc === shared_consts.CallFunz.CANCELLA_IMBARCO) { + entra = true + } + if (!entra) { + // If I change my record... + if ((!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm) && !User.isTutor(req.user.perm)) && !(req.user._id.toString() === id) && !tools.ModificheConsentite(mydata.table, fieldsvalue)) { + // If without permissions, exit + return res.status(404).send({ code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: '' }); + } } const myuser = await User.findOne({ idapp, ind_order }); let rimosso = 0; - if (mydata.myfunc === 345) { // SOSTITUISCI + + if (mydata.myfunc === shared_consts.CallFunz.SOSTITUISCI) { // SOSTITUISCI mianavedasost = await Nave.findOne({ idapp, riga: mydata.data.riga, col: mydata.data.col }); // Sostituisci l'Utente @@ -524,7 +551,7 @@ router.patch('/callfunz', authenticate, async (req, res) => { if (!rec) { return res.status(404).send(); } else { - if (mydata.notifBot) { + if (mydata.notifBot && !!navepersistente.link_chat) { // Send Notification to the BOT let messaggio = 'Sei stato Spostato in una Nuova Nave !'; @@ -557,9 +584,29 @@ router.patch('/callfunz', authenticate, async (req, res) => { res.status(400).send(); }) } + } 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 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); + + arrimbarchi = await ListaIngresso.findAllByIndOrder(idapp, ind_order); + 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 }); + + return res.send({ code: server_constants.RIS_CODE_OK }); + } } catch (e) { - console.log(e); + console.log(e.message); res.status(400).send(); } }); @@ -644,7 +691,7 @@ router.delete('/delrec/:table/:id', authenticate, async (req, res) => { tools.mylog('DELETED ', rec._id); }).catch((e) => { - console.log(e); + console.log(e.message); res.status(400).send(); }); } @@ -719,7 +766,7 @@ router.post('/duprec/:table/:id', authenticate, (req, res) => { }); }).catch((e) => { - console.error(e); + console.error(e.message); res.status(400).send(); }); }) @@ -800,7 +847,7 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) => }); }) .catch((e) => { - console.log(e); + console.log(e.message); res.status(400).send(e); }); @@ -850,7 +897,7 @@ router.get(process.env.LINK_CHECK_UPDATES, authenticate, async (req, res) => { }); }).catch((e) => { - console.log(e); + console.log(e.message); res.status(400).send({ code: server_constants.RIS_CODE_ERR, msg: e }); }); diff --git a/src/server/router/myevent_router.js b/src/server/router/myevent_router.js index 59f550b..599353b 100755 --- a/src/server/router/myevent_router.js +++ b/src/server/router/myevent_router.js @@ -106,7 +106,7 @@ router.get('/:userId/:idapp/:sall', authenticate, (req, res) => { return MyEvent.findAllByUserIdAndIdApp(userId, idapp, sall).then((recevent) => { res.send({ recevent }); }).catch((e) => { - console.log(e); + console.log(e.message); res.status(400).send(e); }); diff --git a/src/server/router/newsletter_router.js b/src/server/router/newsletter_router.js index 6d7b688..3927f82 100755 --- a/src/server/router/newsletter_router.js +++ b/src/server/router/newsletter_router.js @@ -207,7 +207,7 @@ async function ImportData(locale, idapp, strdata, settomailchimp) { return ris } catch (e) { - console.err(e); + console.err(e.message); } } diff --git a/src/server/router/projects_router.js b/src/server/router/projects_router.js index 0a752c9..3296f0e 100755 --- a/src/server/router/projects_router.js +++ b/src/server/router/projects_router.js @@ -128,7 +128,7 @@ router.get('/', (req, res) => { }).then((objprojects) => { res.send({ projects: objprojects.arrproj }); }).catch((e) => { - console.log(e); + console.log(e.message); res.status(400).send(e); }); }); @@ -159,7 +159,7 @@ router.get('/:userId', authenticate, (req, res) => { res.send({ projects: objprojects.arrproj }); }).catch((e) => { - console.log(e); + console.log(e.message); res.status(400).send(e); }); diff --git a/src/server/router/push_router.js b/src/server/router/push_router.js index 2848719..48d9325 100755 --- a/src/server/router/push_router.js +++ b/src/server/router/push_router.js @@ -97,7 +97,7 @@ async function SendMsgTo(idapp, username, params) { } }) .catch(e => { - console.error(e); + console.error(e.message); }) } } diff --git a/src/server/router/sendmsg_router.js b/src/server/router/sendmsg_router.js index f90d3f3..17f832a 100755 --- a/src/server/router/sendmsg_router.js +++ b/src/server/router/sendmsg_router.js @@ -77,7 +77,7 @@ router.post('/', authenticate, (req, res) => { }) }); }).catch((e) => { - console.log(e); + console.log(e.message); // res.status(400).send(e); return res.send({ code: server_constants.RIS_CODE_ERR, msg: '' }); }) @@ -106,7 +106,7 @@ router.get('/:username/:lastdataread/:idapp', authenticate, (req, res) => { // }); }).catch((e) => { - console.log(e); + console.log(e.message); res.status(400).send(e); }); diff --git a/src/server/router/site_router.js b/src/server/router/site_router.js index 6c980f2..4acec06 100755 --- a/src/server/router/site_router.js +++ b/src/server/router/site_router.js @@ -10,6 +10,8 @@ const { authenticate } = require('../middleware/authenticate'); const mongoose = require('mongoose'); const { User } = require('../models/user'); +const { Nave } = require('../models/nave'); +const { ListaIngresso } = require('../models/listaingresso'); const _ = require('lodash'); @@ -24,6 +26,8 @@ router.post('/load', async (req, res) => { let datastat = { num_reg: await User.getUsersRegistered(idapp), + num_passeggeri: await Nave.getTotInLista(idapp) + await ListaIngresso.getTotInLista(idapp), + num_imbarcati: await ListaIngresso.getTotInLista(idapp), email_non_verif: await User.getEmailNotVerified(idapp), num_teleg_attivo: await User.getUsersTelegramAttivo(idapp), num_teleg_pending: await User.getUsersTelegramPending(idapp), @@ -35,8 +39,11 @@ router.post('/load', async (req, res) => { arr_nations: await User.findAllDistinctNationality(idapp), numreg_untilday: await User.calcnumRegUntilDay(idapp), reg_daily: await User.calcRegDaily(idapp), + reg_weekly: await User.calcRegWeekly(idapp), lastsreg: await User.getLastUsers(idapp), checkuser: await User.checkUser(idapp, username), + // navi_partite: await Nave.getNaviPartite(idapp), + // navi_in_partenza: await Nave.getNaviInPartenza(idapp), }; diff --git a/src/server/router/todos_router.js b/src/server/router/todos_router.js index a38319d..db29c6b 100755 --- a/src/server/router/todos_router.js +++ b/src/server/router/todos_router.js @@ -135,7 +135,7 @@ router.get('/:userId', authenticate, (req, res) => { res.send({ todos: objtodos.arrtodos, categories: objtodos.arrcategories }); }).catch((e) => { - console.log(e); + console.log(e.message); res.status(400).send(e); }); @@ -185,7 +185,7 @@ router.get('/', (req, res) => { res.send({ todos: objtodos.arrtodos, categories: objtodos.arrcategories }); }).catch((e) => { - console.log(e); + console.log(e.message); res.status(400).send(e); }); diff --git a/src/server/router/users_router.js b/src/server/router/users_router.js index 1926609..ba9e997 100755 --- a/src/server/router/users_router.js +++ b/src/server/router/users_router.js @@ -141,12 +141,13 @@ router.post('/', async (req, res) => { user.ind_order = lastindorder + 1; const numero = user.name.slice(-1); - if ((numero === '2') || (numero === '3') || (numero === '4')) { + if ((numero === '2') || (numero === '3') || (numero === '4') || (numero === '5') || (numero === '6')) { recorig = await User.findByCellAndNameSurname(user.idapp, user.profile.cell, user.name.slice(0, -1), user.surname); if (!!recorig) { user.profile.teleg_id = recorig.profile.teleg_id; user.profile.saw_zoom_presentation = recorig.profile.saw_zoom_presentation; user.profile.saw_and_accepted = recorig.profile.saw_and_accepted; + user.profile.my_dream = recorig.profile.my_dream; user.profile.email_paypal = recorig.profile.email_paypal; user.profile.paymenttypes = recorig.profile.paymenttypes; let msgseconda = '!!! REGISTRATA '; @@ -465,7 +466,7 @@ router.post('/dbop', authenticate, async (req, res) => { } else if (mydata.dbop === 'visuListaNave') { mystr = await Nave.showListaOrd(idapp); ris = { mystr }; - } else if (mydata.dbop === 'visuUtentiNonInNavi') { + } else if (mydata.dbop === 'visuStat') { ris = await User.visuUtentiNonInNavi(idapp); } else if (mydata.dbop === 'pulisciNonPresenzeInNave') { mystr = await Nave.pulisciNonPresenzeInNave(idapp); @@ -616,12 +617,34 @@ router.post('/dbop', authenticate, async (req, res) => { ris = { num }; } else if (mydata.dbop === 'visuPlacca') { - const rec = {}; + + mystr = '✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨\n' + + 'ECCO LE NUOVE NAVI DEFINITIVE CHE APRONO DOMANI LA GIFT CHAT !!! DALLA ' + mydata.riga + '.' + mydata.col + ' ALLA ' + mydata.riga + '.' + (parseInt(mydata.col) + 7) +'\n' + + 'AUGURI ALLA NUOVA SOGNATRICE !!!\n' + + '✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨'; + + const visu_nave_Bot = await Settings.getValDbSettings(idapp, 'VISU_NAVE_BOT'); + + for (let ind = 0; ind < 8; ind++) { + mystr += await Nave.getNavePos(idapp, parseInt(mydata.riga), parseInt(mydata.col) + ind, false); + mystr += tools.ACAPO; + if (visu_nave_Bot && ind === 3) { + await telegrambot.sendMsgTelegramToTheAdmin(idapp, mystr, true); + mystr = ''; + } + } + + if (visu_nave_Bot) + await telegrambot.sendMsgTelegramToTheAdmin(idapp, mystr, true); + + ris = { mystr }; + + /*const rec = {}; const placca = await Nave.getPlaccaPerDonatore(idapp, parseInt(mydata.riga), parseInt(mydata.col), false, rec); telegrambot.sendMsgTelegramToTheAdmin(idapp, placca); - ris = { placca }; + ris = { placca };*/ } else if (mydata.dbop === 'visuNave') { mystr = await Nave.getNavePos(idapp, parseInt(mydata.riga), parseInt(mydata.col)); @@ -652,7 +675,7 @@ router.post('/dbop', authenticate, async (req, res) => { res.send(ris); } catch (e) { - console.log(e); + console.log(e.message); } } ); diff --git a/src/server/sendemail.js b/src/server/sendemail.js index 49b0287..d945ba9 100755 --- a/src/server/sendemail.js +++ b/src/server/sendemail.js @@ -656,7 +656,7 @@ module.exports = { this.sendEmail_Newsletter_Events("it", idapp, rec._id); }) .catch((e) => { - console.error(e); + console.error(e.message); }); } } diff --git a/src/server/telegram/telegrambot.js b/src/server/telegram/telegrambot.js index 445fee2..3d305d7 100755 --- a/src/server/telegram/telegrambot.js +++ b/src/server/telegram/telegrambot.js @@ -580,7 +580,7 @@ module.exports = { } return { nummsgsent, strout }; } catch (e) { - console.error(e); + console.error(e.message); return { nummsgsent, strout }; } }, @@ -927,7 +927,7 @@ class Telegram { } else if (MsgBot.PRINCIPE_AZZURRO.find((rec) => testo.indexOf(rec) > -1)) { risp = 'Chissà... Forse si!\nAnche se meglio averne un\'altro di scorta, nel caso il Principe non sia disponibile.'; } else if (MsgBot.AIUTO.find((rec) => testo.indexOf(rec) > -1)) { - risp = 'Clicca qui per entrare nella Chat AYNI - HELP di Supporto\n' + 'https://t.me/joinchat/C741mlVmB_RMcOUpNqWC8w' + '\n\nI miei colleghi umani ti aiuteranno a risolvere !'; + risp = 'Clicca qui per entrare nella Chat AYNI - HELP di Supporto\n' + 'https://t.me/joinchat/AL2qKE80rxDkgbeMGO-0bw' + '\n\nI miei colleghi umani ti aiuteranno a risolvere !'; } else if (MsgBot.SPOSAMI.find((rec) => testo.indexOf(rec) > -1)) { risp = 'No Grazie! Sono per la Libertà a Vita! ' + emo.JOY + '\nMa se vuoi possiamo conoscerci meglio!' + emo.DANCER + emo.FIRE; } else if (MsgBot.CHE_TEMPO_FA.find((rec) => testo.indexOf(rec) > -1)) { @@ -956,7 +956,7 @@ class Telegram { } else if (testo.length >= 10) { noanswer = true; risp = 'Questo messaggio è stato inviato alla Chat Help\nIo sono solo un Robot ' + emo.ROBOT_FACE + emo.JOY2 + '\n\nPer AIUTO, contatta la Chat AYNI - HELP'; - // risp += '\nClicca qui per entrare nella Chat AYNI - HELP di Supporto\n' + 'https://t.me/joinchat/C741mlVmB_RMcOUpNqWC8w' + '\n\nI miei colleghi umani ti aiuteranno a risolvere !'; + // risp += '\nClicca qui per entrare nella Chat AYNI - HELP di Supporto\n' + 'https://t.me/joinchat/AL2qKE80rxDkgbeMGO-0bw' + '\n\nI miei colleghi umani ti aiuteranno a risolvere !'; await local_sendMsgTelegramToTheManagers(this.idapp, testo, msg, rec.username_bo); } } @@ -1362,7 +1362,7 @@ class Telegram { mystr += emo.STARS + tools.get__('ZOOM_CONFERENCE', this.getlang(msg)) + emo.STARS + '\n\n'; - let pwd = 'Password: 123123'; + // let pwd = 'Password: 123123'; let index = 1; listazoom.forEach((evento) => { @@ -1375,13 +1375,14 @@ class Telegram { mystr += emo.CHECK_VERDE + ' ' + tools.get__('ZOOM_INIZIATO', this.getlang(msg)) + ' ' + emo.CHECK_VERDE + '\n'; } - mystr += `${emo.EYES} ${tools.getstrDateTimeShort(evento.date_start)} ${emo.EYES}`; + mystr += `${emo.EYES} ${tools.getstrDateTimeShort(evento.date_start, this.getlang(msg))} ${emo.EYES}`; mystr += `\n${evento.title}\n(${evento.note})\n\n`; if (nextzoom) { if (iniziata) { mystr += emo.FIRE + tools.get__('CLICCA_ENTRA', this.getlang(msg)) + ' ' + emo.FIRE + '\n'; mystr += tools.getlinkzoom(evento.id_conf_zoom) + '\n'; - mystr += pwd + '\n\n'; + mystr += '\n'; + //mystr += pwd + '\n\n'; } } @@ -1391,7 +1392,7 @@ class Telegram { if (!nextzoom && index > 1) { mystr += "✨✨✨✨✨✨✨✨✨✨✨✨\n" + - tools.get__('CLICCA_PER_ZOOM', this.getlang(msg)) + ':\n' + tools.getlinkzoom(listazoom[0].id_conf_zoom) + '\n' + "✨✨✨✨✨✨✨✨✨✨✨✨\n" + pwd + '\n\n'; + tools.get__('CLICCA_PER_ZOOM', this.getlang(msg)) + ':\n' + tools.getlinkzoom(listazoom[0].id_conf_zoom) + '\n' + "✨✨✨✨✨✨✨✨✨✨✨✨\n"; } return mystr @@ -1779,7 +1780,7 @@ class Telegram { } rec.start_write_msgall = false; } catch (e) { - console.error(e); + console.error(e.message); } } diff --git a/src/server/tools/general.js b/src/server/tools/general.js index 7e81207..e0b8757 100755 --- a/src/server/tools/general.js +++ b/src/server/tools/general.js @@ -51,7 +51,7 @@ 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/C741mlVmB_RMcOUpNqWC8w\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:\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à.", '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!', @@ -63,7 +63,7 @@ textlang = { 'INFO_LAVAGNA_SITO': 'Per vedere in dettaglio lo stato della tua Nave, sul sito AYNI, clicca sulle 3 linee in alto a sinistra ed accedi alla voce "Lavagna".\n', 'INFO_LINK_DA_CONDIVIDERE': 'Link da condividere ai tuoi invitati per farli registrare al sito di Ayni:\n\n%s', 'INFO_LINK_ZOOM': 'Link da condividere per partecipare allo Zoom (Conferenza OnLine):\n%s', - 'ZOOM_CONFERENCE': 'Qui trovi le date di programmazione agli Zoom:', + 'ZOOM_CONFERENCE': 'Ecco il programma delle Conferenze (Zoom) aperti a TUTTI:', "NON_VERIF": "Non Verificata", "VERIF": "Verificata", 'EMAIL': "Email", @@ -107,7 +107,7 @@ 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/C741mlVmB_RMcOUpNqWC8w\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:\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č.", '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!', @@ -163,7 +163,7 @@ 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/C741mlVmB_RMcOUpNqWC8w\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:\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..", '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!', @@ -216,7 +216,7 @@ 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/C741mlVmB_RMcOUpNqWC8w\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:\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.", '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!', @@ -272,7 +272,7 @@ 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/C741mlVmB_RMcOUpNqWC8w\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:\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.", '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!', @@ -325,46 +325,46 @@ textlang = { }, pt: { "L'Email è già stata Verificata": "", - "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\nHai dimenticato la Password per accedere al sito?\nhttps://ayni.gifteconomy.app/requestresetpwd\n\nChat AYNI BOT (questa):\nhttps://t.me/notevoleaynibot\n\nChat AYNI - EMPOWER: Entra ⛩ nella nostra Community 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 di Aiuto e Supporto: 'AYNI - HELP'\nDa Lunedì al Sabato (8:00 - 20:00)\nhttps://t.me/joinchat/C741mlVmB_RMcOUpNqWC8w\n1 - 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!', - 'NON_HAI_I_7_REQUISITI': 'Attenzione!\nAncora non hai i 7 Requisiti per Entrare nella Lista d\'Imbarco!', - 'HAI_I_9_REQUISITI': 'COMPLIMENTI!\nHai Completato TUTTI i 9 Passi della Guida! Grazie per Aiutare AYNI ad Espandersi!', - 'NON_HAI_I_9_REQUISITI': 'Ricorda che puoi Aiutare a far Crescere ed Espandere il Movimento, Condividendo con chiunque questo nostro viaggio!', - 'INFO_LA_MIA_LAVAGNA': '✨ Lista dei Passi: ✨ \n', - 'INFO_LAVAGNA_SITO_COMPLETARE': 'Per completare tutti i requisiti vai sul sito:\n%s\nPer vedere lo stato della tua Nave e dei tuoi invitati, clicca sulle 3 linee in alto a sinistra ed accedi alla voce "Lavagna".\n', - 'INFO_LAVAGNA_SITO': 'Per vedere in dettaglio lo stato della tua Nave, sul sito AYNI, clicca sulle 3 linee in alto a sinistra ed accedi alla voce "Lavagna".\n', - 'INFO_LINK_DA_CONDIVIDERE': 'Link da condividere ai tuoi invitati per farli registrare al sito di Ayni:\n\n%s', - 'INFO_LINK_ZOOM': 'Link da condividere per partecipare allo Zoom (Conferenza OnLine):\n%s', - 'ZOOM_CONFERENCE': 'Qui trovi le date di programmazione agli Zoom:', - "NON_VERIF": "Non Verificata", - "VERIF": "Verificata", + "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..", + '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!', + 'NON_HAI_I_7_REQUISITI': 'Atenção!\nVocê ainda não tem os 7 requisitos para entrar na lista de embarque!', + 'HAI_I_9_REQUISITI': 'FELICITAÇÕES!\nVocê completou TODAS as 9 etapas da condução! Obrigado por ajudar a AYNI a expandir!', + 'NON_HAI_I_9_REQUISITI': 'Lembre-se que pode ajudar o Movimento a crescer e expandir-se, partilhando a nossa jornada com todos!', + 'INFO_LA_MIA_LAVAGNA': '✨ Lista de etapas: ✨ \n', + 'INFO_LAVAGNA_SITO_COMPLETARE': 'Para completar todos os requisitos ir para o sitio:\n%s\nPer vedere lo stato della tua Nave e dei tuoi invitati, clicca sulle 3 linee in alto a sinistra ed accedi alla voce "Lavagna".\n', + 'INFO_LAVAGNA_SITO': 'Para ver em detalhe o estado do seu navio, no site da AYNI, clique nas 3 linhas no canto superior esquerdo e vá para "DashBoard"..\n', + 'INFO_LINK_DA_CONDIVIDERE': 'Links para partilhar com os seus convidados para que se registem no website da Ayni:\n\n%s', + 'INFO_LINK_ZOOM': 'Links para partilhar para participar na Zoom (Conferência Online):\n%s', + 'ZOOM_CONFERENCE': 'Aqui está o programa das Conferências (Zoom) aberto a TODOS:', + "NON_VERIF": "Não verificado", + "VERIF": "Verificado", 'EMAIL': "Email", 'BOT': "AYNI BOT", - 'EMAIL_NON_VERIF': "Email Non Verificata\nleggi la tua casella email e trova **\"Confermare la Registrazione a Ayni\"**
e clicca sul bottone **\"Verifica Registrazione\"**", - 'TELEGRAM_NOT_CONNECTED': "Telegram non associato al tuo account!", - 'NESSUN_INVITATO': 'Non hai invitato nessuno', - 'ZOOM_PARTECIPATO': 'Partecipazione ad almeno 1 Conferenza (Zoom)', - 'LINEE_GUIDA': 'Accettato le Linee Guida', - 'VIDEO_INTRO': 'Visto il Video di AYNI', - 'SCRITTO_SOGNO': 'Hai scritto il tuo Sogno', - 'PAYMENTS': 'Modalità di Pagamento (Obbligatorio Paypal)', - 'INVITATI': 'persone registrate che hai invitato', - 'INVITATI_ATTIVI': 'Invitati con i 7 Requisiti', - 'NONREG': 'Invitati non Registrati', - 'CLICCA_PER_ZOOM': 'AL GIORNO E ORA INDICATA, PER ENTRARE NELLA VIDEO-CONFERENZA, CLICCA QUI', - 'CLICCA_ENTRA': 'CLICCA QUI PER ENTRARE !', - 'ZOOM_INIZIATO': 'QUESTA CONFERENZA E\' INIZIATA!', - '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 !', - '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', + 'EMAIL_NON_VERIF': "Email Não verificado\nleia a sua caixa de correio e encontre **\"Confirmar o registo à Ayni\"**
e clique no botão **\"Verificação do registo\"**", + 'TELEGRAM_NOT_CONNECTED': "Telegrama não associado à sua conta!", + 'NESSUN_INVITATO': 'Você não convidou ninguém', + 'ZOOM_PARTECIPATO': 'Participação em pelo menos 1 Conferência (Zoom)', + 'LINEE_GUIDA': 'Directrizes Aceites', + 'VIDEO_INTRO': 'Ver o vídeo do AYNI', + 'SCRITTO_SOGNO': 'Você escreveu o seu sonho', + 'PAYMENTS': 'Formas de pagamento (Obrigatório Paypal)', + 'INVITATI': 'pessoas registadas que convidou', + 'INVITATI_ATTIVI': 'Convidado com os 7 Requisitos', + 'NONREG': 'Convidados não registados', + 'CLICCA_PER_ZOOM': 'PARA O DIA E HORA INDICADOS, PARA ENTRAR NA VÍDEO-CONFERÊNCIA, CLIQUE AQUI', + 'CLICCA_ENTRA': 'CLIQUE AQUI PARA ENTRAR !', + 'ZOOM_INIZIATO': 'ESTA CONFERÊNCIA JÁ COMEÇOU!', + 'SCEGLI_VOCE': 'escolha uma voz:', + 'INVITATI_LISTA': 'Os seus convidados (em verde com, pelo menos, os 7 primeiros requisitos)', + 'CIAO': 'Olá', + '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', 'SOGNATORE': 'SONHEIROS', 'MEDIATORE': 'MEDIATOR', 'DONATORI': 'DONATORES', @@ -1081,6 +1081,12 @@ module.exports = { mypos.riga = mypos.riga - mypos.numup; mypos.col = Math.ceil(mypos.col * (Math.pow(2, -mypos.numup))); } + if (mypos.riga < 1) { + mypos.riga = 1; + } + if (mypos.col < 1) { + mypos.col = 1; + } }, appendLeadingZeroes(n) { @@ -1090,6 +1096,25 @@ module.exports = { return n }, + getWeekDayByLang(date, lang) { + if (!lang) + lang = 'it'; + + const dayOfWeek = new Date(date).getDay(); + + const myday = { + it: ['Domenica', 'Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato'], + enUs: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], + fr: ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'], + es: ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'iernes', 'Sábado'], + pt: ['Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado'], + de: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'], + si: ['Nedelja', 'Ponedeljek', 'Torek', 'Sreda', 'četrtek', 'Petek', 'Sobota'], + } + + return isNaN(dayOfWeek) ? '' : myday[lang][dayOfWeek].substring(0, 3) + }, + getWeekDay(date) { //Create an array containing each day, starting with Sunday. const weekdays = [ @@ -1101,28 +1126,28 @@ module.exports = { return weekdays[day]; }, - getstrDateTimeShort(mydate) { + getstrDateTimeShort(mydate, lang) { if (mydate) { // console.log('getstrDate', mytimestamp) - return this.getWeekDay(mydate) + ' ' + this.appendLeadingZeroes(mydate.getDate()) + '/' + this.appendLeadingZeroes(mydate.getMonth() + 1) + ' ORE ' + this.appendLeadingZeroes(mydate.getHours()) + ':' + this.appendLeadingZeroes(mydate.getMinutes()); + return this.getWeekDayByLang(mydate, lang) + ' ' + this.appendLeadingZeroes(mydate.getDate()) + '/' + this.appendLeadingZeroes(mydate.getMonth() + 1) + ' ORE ' + this.appendLeadingZeroes(mydate.getHours()) + ':' + this.appendLeadingZeroes(mydate.getMinutes()); } else { return ''; } }, - getstrDateShort(mydate) { + getstrDateShort(mydate, lang) { if (mydate) { // console.log('getstrDate', mytimestamp) - return this.getWeekDay(mydate).substring(0, 3) + ' ' + this.appendLeadingZeroes(mydate.getDate()) + '/' + this.appendLeadingZeroes(mydate.getMonth() + 1); + return this.getWeekDayByLang(mydate, lang).substring(0, 3) + ' ' + this.appendLeadingZeroes(mydate.getDate()) + '/' + this.appendLeadingZeroes(mydate.getMonth() + 1); } else { return ''; } }, - getstrDateLong(mydate) { + getstrDateLong(mydate, lang) { if (mydate) { // console.log('getstrDate', mytimestamp) - return this.getWeekDay(mydate) + ' ' + this.appendLeadingZeroes(mydate.getDate()) + '/' + this.appendLeadingZeroes(mydate.getMonth() + 1) + '/' + mydate.getFullYear(); + return this.getWeekDayByLang(mydate, lang) + ' ' + this.appendLeadingZeroes(mydate.getDate()) + '/' + this.appendLeadingZeroes(mydate.getMonth() + 1) + '/' + mydate.getFullYear(); } else { return ''; } diff --git a/src/server/tools/shared_nodejs.js b/src/server/tools/shared_nodejs.js index 055d2c1..b65bc3d 100755 --- a/src/server/tools/shared_nodejs.js +++ b/src/server/tools/shared_nodejs.js @@ -24,6 +24,7 @@ module.exports = { Manager: 2, Teacher: 4, Tutor: 8, + Traduttrici: 16, }, MessageOptions: { @@ -41,6 +42,12 @@ module.exports = { OPZ1_2: 2, }, + CallFunz: { + SOSTITUISCI: 345, + AGGIUNGI_NUOVO_IMBARCO: 380, + CANCELLA_IMBARCO: 385, + }, + 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'] }