- Iscrizione Conacreis

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

View File

@@ -3,6 +3,7 @@ p Ti avvisiamo che #{name} #{surname} ha appena cancellato la prenotazione per l
span #{participants}
span #{participantsLunch}
span #{participantsDinner}
span #{participantsDinnerShared}
p Cordiali Saluti
p Supporto #{nomeapp}

View File

@@ -0,0 +1,53 @@
p #{name} #{surname} si è appena Iscritto al Conacreis su #{nomeapp}
p Con i seguenti dati di accesso:
span Nome: 
strong #{iscritto.name}<br>
span Cognome:&nbsp;
strong #{iscritto.surname}<br>
span Email:&nbsp;
strong #{iscritto.email}<br>
span Codice Fiscale:&nbsp;
strong #{iscritto.fiscalcode}<br>
span Indirizzo di Residenza:&nbsp;
strong #{iscritto.residency_address}<br>
span Città di Residenza:&nbsp;
strong #{iscritto.residency_city}<br>
span Provincia:&nbsp;
strong #{iscritto.residency_province}<br>
span CAP:&nbsp;
strong #{iscritto.residency_zipcode}<br>
span Nazione:&nbsp;
strong #{iscritto.residency_country}<br>
span Data di Nascita:&nbsp;
strong #{iscritto.dateofbirth}<br>
span Cellulare:&nbsp;
strong #{iscritto.cell_phone}<br>
span Abilita le Newsletter? :&nbsp;
strong #{iscritto.newsletter_on}<br>
p <br>Saluti
style(type="text/css").
html, body {
padding: 0;
margin: 0;
}
p {
font-size: 1rem;
}
.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;
}

View File

@@ -0,0 +1 @@
=`Nuova Iscrizione Conacreis di ${name} ${surname} (${emailto}) su ${nomeapp}`

View File

@@ -3,6 +3,7 @@ p Ti confermiamo che #{name} #{surname} ha appena inviato una richiesta di preno
p #{participants}
p #{participantsLunch}
p #{participantsDinner}
p #{participantsDinnerShared}
p Messaggio: #{msgbooking}
p Cordiali Saluti

View File

@@ -3,6 +3,7 @@ p Ti confermiamo che #{name} #{surname} ha appena Modificato la sua prenotazione
p #{participants}
p #{participantsLunch}
p #{participantsDinner}
p #{participantsDinnerShared}
p Messaggio: #{msgbooking}
p Cordiali Saluti

View File

@@ -3,6 +3,7 @@ p Ti confermiamo che la prenotazione per l'evento "#{event}" è stata cancellata
p #{participants}
p #{participantsLunch}
p #{participantsDinner}
p #{participantsDinnerShared}
p Cordiali Saluti
p Supporto #{nomeapp}
@@ -12,7 +13,9 @@ style(type="text/css").
padding: 0;
margin: 0;
}
p {
font-size: 1rem;
}
.divbtn {
display: flex;
align-items: center;

View File

@@ -3,6 +3,7 @@ p Ti confermiamo che hai appena inviato una richiesta di prenotazione per l'even
p #{participants}
p #{participantsLunch}
p #{participantsDinner}
p #{participantsDinnerShared}
p Messaggio: #{msgbooking}
p #{msgreply_after_booking}
@@ -14,6 +15,9 @@ style(type="text/css").
padding: 0;
margin: 0;
}
p {
font-size: 1rem;
}
.divbtn {
display: flex;

View File

@@ -3,6 +3,7 @@ p Ti confermiamo che hai modificato la prenotazione per l'evento #{event}
p #{participants}
p #{participantsLunch}
p #{participantsDinner}
p #{participantsDinnerShared}
p Messaggio: #{msgbooking}
p Cordiali Saluti
@@ -14,6 +15,10 @@ style(type="text/css").
margin: 0;
}
p {
font-size: 1rem;
}
.divbtn {
display: flex;
align-items: center;

View File

@@ -36,6 +36,7 @@ html
p &nbsp;
- var totalPrice = orders.totalPrice
- var note = orders.note
- var index = 0
each product in orders.items
@@ -68,13 +69,15 @@ html
td(class="sectionContent", valign="top")
p Quantità: #{qty}
p.sectionContentTitle.boldhigh.sectionTotal Totale Ordine: #{totalPrice} €
p Note Aggiuntive: #{note}
p.sectionContentTitle.boldhigh.sectionTotal Totale Ordine: #{totalPrice} €
tr
td(class="whitespace", height="10")
p Ti arriverà una email quando i prodotti saranno disponibili per poterli venire a ritirare.
p Il pagamento potrai farlo direttamente in sede.
p Grazie Mille
p
table.footer(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
tr
@@ -102,6 +105,10 @@ style(type="text/css").
margin: 0;
}
p {
font-size: 1rem;
}
.divbtn {
display: flex;
align-items: center;

View File

@@ -0,0 +1,81 @@
doctype html
html
head
title Ordine Cancellato
//- import css/scss stylesheets
//- these file names will be replace by gulp with proper css file paths
link(rel="stylesheet", href="../sass/basic.scss")
link(rel="stylesheet", href="../sass/one/styles.scss")
//- embdedded css allowed, but not sass
style.
.red {
background-color: #E84C50;
}
.full-width {
width: 100%;
}
body(yahoofix, style="background: #ffffff")
- var baseimg = baseurl + '/statics/'
span(id='body_style', style='display:block')
table(cellpadding="10", cellspacing="0", width="600", align="center")
tr
td(class="whitespace", height="10")
p &nbsp;
tr
td(class="emailContainer", valign="top")
p Ciao #{name},
p L'ordine è stato Cancellato.
p Se è stato un errore, procedi a ripetere l'Ordine, ripartendo dalla lista prodotti.
p Grazie Mille
table.footer(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
tr
td(class="whitespace", height="10")
p &nbsp;
tr
td.firma
p!= dataemail.firma
tr
td.disclaimer
p!= dataemail.disclaimer_out
tr
td.bottom
p!= dataemail.disc_bottom_out
tr
td(class="whitespace", height="10")
p &nbsp;
style(type="text/css").
html, body {
padding: 0;
margin: 0;
}
p {
font-size: 1rem;
}
.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;
}

View File

@@ -0,0 +1 @@
=`Ordine n. ${ordernumber} Cancellato`

View File

@@ -0,0 +1,80 @@
doctype html
html
head
title Ordine Completato
//- import css/scss stylesheets
//- these file names will be replace by gulp with proper css file paths
link(rel="stylesheet", href="../sass/basic.scss")
link(rel="stylesheet", href="../sass/one/styles.scss")
//- embdedded css allowed, but not sass
style.
.red {
background-color: #E84C50;
}
.full-width {
width: 100%;
}
body(yahoofix, style="background: #ffffff")
- var baseimg = baseurl + '/statics/'
span(id='body_style', style='display:block')
table(cellpadding="10", cellspacing="0", width="600", align="center")
tr
td(class="whitespace", height="10")
p &nbsp;
tr
td(class="emailContainer", valign="top")
p Ciao #{name},
p L'ordine n. #{ordernumber} è stato Completato correttamente !
p Grazie Mille per aver contribuito a far crescere la Comunità
table.footer(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
tr
td(class="whitespace", height="10")
p &nbsp;
tr
td.firma
p!= dataemail.firma
tr
td.disclaimer
p!= dataemail.disclaimer_out
tr
td.bottom
p!= dataemail.disc_bottom_out
tr
td(class="whitespace", height="10")
p &nbsp;
style(type="text/css").
html, body {
padding: 0;
margin: 0;
}
p {
font-size: 1rem;
}
.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;
}

View File

@@ -0,0 +1 @@
=`Ordine n. ${ordernumber} Completato`

View File

@@ -0,0 +1,127 @@
doctype html
html
head
title Ordine Confermato
//- import css/scss stylesheets
//- these file names will be replace by gulp with proper css file paths
link(rel="stylesheet", href="../sass/basic.scss")
link(rel="stylesheet", href="../sass/one/styles.scss")
//- embdedded css allowed, but not sass
style.
.red {
background-color: #E84C50;
}
.full-width {
width: 100%;
}
body(yahoofix, style="background: #ffffff")
- var baseimg = baseurl + '/statics/'
span(id='body_style', style='display:block')
table(cellpadding="10", cellspacing="0", width="600", align="center")
tr
td(class="whitespace", height="10")
p &nbsp;
tr
td(class="emailContainer", valign="top")
p Ciao #{name},
p L'ordine dei seguenti prodotti è stato Confermato:
tr
td(class="whitespace", height="10")
p &nbsp;
- var totalPrice = orders.totalPrice
- var note = orders.note
- var index = 0
each product in orders.items
- var descr = product._doc.order.product.name
- var img = product._doc.order.product.img
- var price = product._doc.order.price
- var qty = product._doc.order.quantity
- index = index + 1
table(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
tr
td(class="column", valign="center" width="40")
p.boldhigh #{index}.
td(class="column sectionArticleImage", valign="top" width="150")
table(cellpadding="0", cellspacing="0", summary="", border="0")
tr
td
img(src=baseimg + img, alt="", width="150" height="150")
td(class="column", valign="top")
table(cellpadding="0", cellspacing="0", summary="", border="0")
tr
td(class="sectionContentTitle boldhigh", valign="top")
p #{descr}
tr
td(class="sectionContent", valign="top")
p Prezzo: #{price} €
tr
td(class="sectionContent", valign="top")
p Quantità: #{qty}
p Note Aggiuntive: #{note}
p.sectionContentTitle.boldhigh.sectionTotal Totale Ordine: #{totalPrice} €
tr
td(class="whitespace", height="10")
p Puoi pertanto venire a ritirarli direttamente in sede.
p Grazie Mille
table.footer(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
tr
td(class="whitespace", height="10")
p &nbsp;
tr
td.firma
p!= dataemail.firma
tr
td.disclaimer
p!= dataemail.disclaimer_out
tr
td.bottom
p!= dataemail.disc_bottom_out
tr
td(class="whitespace", height="10")
p &nbsp;
style(type="text/css").
html, body {
padding: 0;
margin: 0;
}
p {
font-size: 1rem;
}
.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;
}

View File

@@ -0,0 +1 @@
=`Ordine n. ${ordernumber} Confermato`

View File

@@ -0,0 +1,30 @@
p Ciao #{name},<br>Grazie per aver inviato la tua richiesta d'iscrizione come Socio alla Comunità Nuovo Mondo Rimini !
p Una volta effettuato il pagamento della quota associativa, completeremo l'iscrizione e t'invieremo la tessera Conacreis direttamente sulla tua casella email (#{iscritto.email}).
p Cordiali Saluti<br>Comunità Nuovo Mondo Rimini
style(type="text/css").
html, body {
padding: 0;
margin: 0;
}
p {
font-size: 1rem;
}
.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;
}

View File

@@ -0,0 +1 @@
=`Richiesta Iscrizione Socio alla Comunità Nuovo Mondo (${name} ${surname})`

View File

@@ -209,7 +209,7 @@ p {
}
.sectionTotal {
text-align: right;
text-align: center;
}
.sectionContentSubTitle {

View File

@@ -1,7 +1,10 @@
const tools = require('../tools/general');
// still in app.js
const node_env = process.env.NODE_ENV || 'production';
var file = `.env.${node_env}`;
// GLOBALI (Uguali per TUTTI)
process.env.LINKVERIF_REG = '/vreg';
process.env.LINK_REQUEST_NEWPASSWORD = '/requestnewpwd';
@@ -17,6 +20,8 @@ process.env.DATABASE = process.env.DATABASE || 'FreePlanet';
process.env.MONGODB_URI = process.env.DOMAIN + process.env.DATABASE;
/*
if (process.env.NODE_ENV === 'production') {
// ---------------- AMBIENTE DI PRODUZIONE !!!!!!!!!! --------------------
MYAPPS = [
@@ -100,22 +105,6 @@ if (process.env.NODE_ENV === 'production') {
pathreg_add:'',
abilitanave: false,
},
/*{
idapp: '7',
name: 'Ayni',
adminemail: 'ayni.gifteconomy@gmail.com',
manageremail: '',
replyTo: '',
host: 'https://ayni.gifteconomy.app',
portapp: '0',
dir: '/var/www/ayni.gifteconomy.app',
email_from: 'ayni.gifteconomy@gmail.com',
email_pwd: 'b72b121f6fb69f7c58a269f5b5110e179430cd6fa940a168c2c10b255aa75fd1ebql9yXWoH1LwANdHD7Yvw==',
telegram_key:'1037577457:AAGQbdIuYoB838v61ewJ0Hearx9UPpTBhMI',
telegram_bot_name: 'notevoleaynibot',
pathreg_add:'_ayni',
abilitanave: true,
},*/
{
idapp: '8',
name: 'CentrOlistico Rimini',
@@ -263,21 +252,6 @@ if (process.env.NODE_ENV === 'production') {
pathreg_add:'',
abilitanave: false,
},
/*{
idapp: '7',
name: 'Ayni (Server Test)',
adminemail: 'pao.loarena77@gmail.com',
manageremail: '',
host: 'https://test.gifteconomy.app',
portapp: '0',
dir: '/var/www/test.gifteconomy.app',
email_from: 'info.pianetalibero@gmail.com',
email_pwd: '2df135e2b6c02b2c68ec6bf6b103751fcb4dfc48c57d0acb302482358ee8141fmaDuooPabDvlThiBI2XMyA==',
telegram_key:'1011893908:AAEThZB3fVPw8P5gTCFgTEsDmY21DdbV1Cw',
telegram_bot_name: 'testnotevoleaynibot',
pathreg_add:'_ayni',
abilitanave: true,
},*/
{
idapp: '8',
name: 'CentrOlistico Rimini',
@@ -437,21 +411,6 @@ if (process.env.NODE_ENV === 'production') {
pathreg_add:'',
abilitanave: false,
},
/*{
idapp: '7',
name: 'Ayni',
adminemail: 'paolo.arena77@gmail.com',
manageremail: '',
host: 'http://localhost',
portapp: '8085',
dir: '',
email_from: 'info.pianetalibero@gmail.com',
email_pwd: '66ffeb915e71fada64ad5c26947dd087c262be3b343734a0447c6dee534b888aZcfbjXEuMBWKxvbh60cniw==',
telegram_bot_name: 'paotestlocalebot',
telegram_key:'353996190:AAEcEbfrm_zTK6mBKf8ye9j-PXt958SDxew',
pathreg_add:'_ayni',
abilitanave: true,
},*/
{
idapp: '8',
name: 'CentrOlistico Rimini',
@@ -517,3 +476,6 @@ if (process.env.NODE_ENV === 'production') {
];
}
*/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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

@@ -0,0 +1,83 @@
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const tools = require('../tools/general');
mongoose.Promise = global.Promise;
mongoose.level = "F";
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
schema.options.usePushEach = true
});
const SiteSchema = new Schema({
active: {
type: Boolean,
},
idapp: {
type: String,
},
name: {
type: String,
},
adminemail: {
type: String,
},
manageremail: {
type: String,
},
replyTo: {
type: String,
},
host: {
type: String,
},
portapp: {
type: String,
},
dir: {
type: String,
},
email_from: {
type: String,
},
email_pwd: {
type: String,
},
telegram_key: {
type: String,
},
telegram_bot_name: {
type: String,
},
pathreg_add: {
type: String,
},
});
var Site = module.exports = mongoose.model('Site', SiteSchema);
module.exports.getFieldsForSearch = function () {
return []
};
module.exports.executeQueryTable = async function (idapp, params) {
params.fieldsearch = this.getFieldsForSearch();
// return tools.executeQueryTable(this, null, params);
const myarr = await Site.find({});
return ({ count: myarr.length, rows: myarr })
};
module.exports.findAllIdApp = async function (idapp) {
const myfind = { active: true };
return await Site.find(myfind, (err, arrrec) => {
return arrrec
});
};

View File

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

View File

@@ -10,7 +10,6 @@ const { ObjectID } = require('mongodb');
const tools = require('../../tools/general');
const telegrambot = require('../../telegram/telegrambot');
module.exports = {
doOtherThingsAfterDeleted: async function (tablename, rec, notifBot, req) {

View File

@@ -19,9 +19,9 @@ const sendNotif = async (res, idapp, user, recbooking) => {
// Send Email
if (recbooking.booked)
return await sendemail.sendEmail_Booking(res, user.lang, user.email, user, idapp, recbooking);
return sendemail.sendEmail_Booking(res, user.lang, user.email, user, idapp, recbooking);
else
return await sendemail.sendEmail_CancelBooking(res, user.lang, user.email, user, idapp, recbooking);
return sendemail.sendEmail_CancelBooking(res, user.lang, user.email, user, idapp, recbooking);
};
router.post('/', authenticate, (req, res) => {
@@ -51,7 +51,7 @@ router.post('/', authenticate, (req, res) => {
// tools.mylog('booking:', booking);
// tools.mylog('already exist');
sendNotif(res, myrec.idapp, req.user, myrec);
res.send({ code: server_constants.RIS_CODE_OK, msg: '', id: id_bookedevent });
return res.send({ code: server_constants.RIS_CODE_OK, msg: '', id });
});
} else {
// save to database a new record
@@ -63,11 +63,14 @@ router.post('/', authenticate, (req, res) => {
Booking.findById(idobj)
.then((recbooking) => {
sendNotif(res, myrec.idapp, req.user, writeresult);
res.send({ code: server_constants.RIS_CODE_OK, msg: '', id: writeresult._id });
return res.send({ code: server_constants.RIS_CODE_OK, msg: '', id: writeresult._id });
});
});
}
})
}).catch((e) => {
console.error('Error', e);
res.status(400).send();
});
});
router.delete('/:id/:notify/:idapp', authenticate, (req, res) => {

View File

@@ -178,8 +178,10 @@ router.post('/:userId/cartstatus', authenticate, async function (req, res, next)
const user = req.user;
let status = req.body.status;
const mycart = await Cart.getCartByUserId(userId, idapp);
const numorder = await OrdersCart.getNewNumOrder(userId, idapp);
let statusOrderCart = await OrdersCart.getStatusCartByUserId(userId, idapp, numorder);
try {
if (!!mycart) {
@@ -205,7 +207,7 @@ router.post('/:userId/cartstatus', authenticate, async function (req, res, next)
const myris = ris;
// Cancella il Cart appena salvato in OrdersCart
Cart.deleteCartByCartId(mycart.id)
return Cart.deleteCartByCartId(mycart.id)
.then((ris) => {
const orders = OrdersCart.getOrdersCartByUserId(userId, idapp, numorder)
@@ -216,7 +218,7 @@ router.post('/:userId/cartstatus', authenticate, async function (req, res, next)
return res.send({
code: server_constants.RIS_CODE_OK,
status: myris.status,
orders: orders[0]
orders: orders
});
});
}
@@ -241,8 +243,71 @@ router.post('/:userId/cartstatus', authenticate, async function (req, res, next)
}
}
return res.send({ code: server_constants.RIS_CODE_OK, status: statusOrderCart });
} catch (e) {
return res.send({ code: server_constants.RIS_CODE_ERR, status: 0 });
}
});
//POST cart
router.post('/:userId/orderstatus', authenticate, async function (req, res, next) {
let idapp = req.body.idapp;
let userId = req.params.userId;
let order_id = req.body.order_id;
const user = req.user;
let status = req.body.status;
const orderCart = await OrdersCart.find({ idapp, _id: order_id });
if ((userId !== String(req.user._id)) && !User.isManager(req.user.perm)) {
// I'm trying to write something not mine!
return res.status(404).send({ code: server_constants.RIS_CODE_TODO_CREATING_NOTMYUSER });
}
try {
if (!!orderCart) {
let fields_to_update = { status };
if (status === shared_consts.OrderStatus.RECEIVED) {
fields_to_update = {
status,
completed_at: new Date()
}
}
await OrdersCart.findOneAndUpdate({ _id: order_id }, { $set: fields_to_update }
, { new: false })
.then((ris) => {
if (ris) {
let ordertype = '';
if (status === shared_consts.OrderStatus.ORDER_CONFIRMED) {
ordertype = 'order_confirmed';
} else if (status === shared_consts.OrderStatus.RECEIVED) {
ordertype = 'order_completed';
} else if (status === shared_consts.OrderStatus.CANCELED) {
ordertype = 'order_canceled';
}
if (ordertype !== '') {
sendemail.sendEmail_Order(user.lang, idapp, orderCart[0], user, ordertype)
.then((ris) => {
})
}
}
})
return res.send({ code: server_constants.RIS_CODE_OK, status });
}
} catch (e) {
return res.send({ code: server_constants.RIS_CODE_ERR, status: 0 });
}

View File

@@ -58,6 +58,8 @@ const OrdersCart = require('../models/orderscart');
const Storehouse = require('../models/storehouse');
const Department = require('../models/department');
const ShareWithUs = require('../models/sharewithus');
const Site = require('../models/site');
const IscrittiConacreis = require('../models/iscrittiConacreis');
const Group = require('../models/group');
const { Todo } = require('../models/todo');
const Hours = require('../models/hours');
@@ -210,6 +212,10 @@ function getTableByTableName(tablename) {
mytable = Department;
else if (tablename === 'sharewithus')
mytable = ShareWithUs;
else if (tablename === 'sites')
mytable = Site;
else if (tablename === 'iscritticonacreis')
mytable = IscrittiConacreis;
else if (tablename === 'groups')
mytable = Group;
else if (tablename === 'todos')
@@ -340,6 +346,21 @@ router.post('/gettable', authenticate, (req, res) => {
});
router.post('/getpage', async (req, res) => {
const params = req.body;
const idapp = req.body.idapp;
const mypath = params.path;
return MyPage.findOne({ idapp, path: mypath })
.then((ris) => {
return res.send({ mypage: ris });
}).catch((e) => {
console.log(e.message);
res.status(400).send(e);
});
});
router.patch('/setlang', authenticate, async (req, res) => {
const username = req.body.data.username;
@@ -381,7 +402,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.isTraduttrici(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.isEditor(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: '' });
}
@@ -1138,7 +1159,7 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
let newstosent = Promise.resolve([]);
let mailinglist = Promise.resolve([]);
let mypage = MyPage.findAllIdApp(idapp);
let mypage = MyPage.findOnlyStruttRec(idapp);
let calzoom = CalZoom.findAllIdApp(idapp);
let gallery = Gallery.findAllIdApp(idapp);
let producers = Producer.findAllIdApp(idapp);
@@ -1157,8 +1178,13 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
if (req.user) {
calcstat = User.calculateStat(idapp, req.user.username);
cart = Cart.getCartByUserId(req.user.id, idapp);
if (User.isManager(req.user.perm)) {
// Prende Tutti gli Ordini !
orderscart = OrdersCart.getOrdersCartByUserId("ALL", idapp, 0);
} else {
orderscart = OrdersCart.getOrdersCartByUserId(req.user.id, idapp, 0);
}
}
return Promise.all([bookedevent, eventlist, operators, wheres, contribtype, settings, permissions, disciplines, newstosent, mailinglist, mypage, gallery, paymenttype, calcstat, calzoom, producers, cart, storehouses, departments, orderscart, groups, resps, workers])

View File

@@ -0,0 +1,82 @@
const express = require('express');
const router = express.Router();
const IscrittiConacreis = require('../models/iscrittiConacreis');
const { ObjectID } = require('mongodb');
const sendemail = require('../sendemail');
const { Settings } = require('../models/settings');
const tools = require('../tools/general');
const shared_consts = require('../tools/shared_nodejs');
const server_constants = require('../tools/server_constants');
const telegrambot = require('../telegram/telegrambot');
const _ = require('lodash');
const { authenticate } = require('../middleware/authenticate');
const mongoose = require('mongoose');
// POST /iscritti_conacreis
router.post('/', async (req, res) => {
tools.mylog("POST /iscritti_conacreis");
const body = _.pick(req.body, ['idapp', 'userId', 'name', 'surname', 'email', 'fiscalcode', 'residency_address', 'residency_city', 'residency_province', 'residency_country', 'residency_zipcode', 'dateofbirth', 'cell_phone', 'newsletter_on', 'iscrizione_compilata', 'annoTesseramento', 'note', 'accetta_carta_costituzionale_on', 'terms']);
body.email = body.email.toLowerCase();
const iscritti = new IscrittiConacreis(body);
iscritti.ipaddr = tools.getiPAddressUser(req);
iscritti.lang = req.locale;
// tools.mylog("LANG PASSATO = " + iscritti.lang, "IDAPP", iscritti.idapp);
if (!tools.isAlphaNumeric(body.name)) {
await tools.snooze(5000);
res.status(400).send({ code: server_constants.RIS_CODE_USERNAME_NOT_VALID, msg: '' });
return 1;
}
if (tools.blockwords(body.email) || tools.blockwords(body.name) || tools.blockwords(body.surname)) {
// tools.writeIPToBan(iscritti.ipaddr + ': [' + iscritti.username + '] ' + iscritti.name + ' ' + iscritti.surname);
await tools.snooze(5000);
return res.status(404).send();
}
iscritti.dateofreg = new Date();
// Controlla se anche l'ultimo record era dallo stesso IP:
const lastrec = await IscrittiConacreis.getLastRec(body.idapp);
if (!!lastrec) {
if (process.env.LOCALE !== "1") {
if (lastrec.ipaddr === iscritti.ipaddr) {
// Se l'ha fatto troppo ravvicinato
if (lastrec.date_reg) {
let ris = tools.isdiffSecDateLess(lastrec.date_reg, 120);
if (ris) {
tools.writeIPToBan(iscritti.ipaddr + ': ' + iscritti.name + ' ' + iscritti.surname);
await tools.snooze(10000);
res.status(400).send({ code: server_constants.RIS_CODE_BANIP, msg: '' });
return 1;
}
}
}
}
}
return await iscritti.save()
.then(async () => {
await sendemail.sendEmail_IscrizioneConacreis(iscritti.lang, iscritti.email, iscritti, iscritti.idapp);
// }
return res.status(200).send();
}).catch((e) => {
console.error(e.message);
res.status(400).send(e);
})
});
module.exports = router;

View File

@@ -121,6 +121,8 @@ async function SendMsgToParam(idapp, params) {
invia = user.profile.socio;
}else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_SOCIO_RESIDENTE) {
invia = user.profile.socioresidente;
}else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_SOCIO_RESIDENTE) {
invia = user.profile.consiglio;
}else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_NON_SOCI) {
invia = !user.profile.socio;
}else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_PAOLO) {

View File

@@ -288,6 +288,95 @@ router.post('/', async (req, res) => {
return true;
});
}).catch((e) => {
console.error(e.message);
res.status(400).send(e);
})
});
// POST /users/iscriviti_conacreis
router.post('/iscriviti_conacreis', async (req, res) => {
tools.mylog("POST /users");
const body = _.pick(req.body, ['name', 'surname', 'email', 'fiscalcode', 'residency_address', 'residency_city', 'residency_province', 'residency_country', 'residency_zipcode', 'dateofbirth', 'cell_phone', 'newsletter_on']);
body.email = body.email.toLowerCase();
const user = new User(body);
user.ipaddr = tools.getiPAddressUser(req);
// tools.mylog("LANG PASSATO = " + user.lang, "IDAPP", user.idapp);
if (!tools.isAlphaNumeric(body.name)) {
await tools.snooze(5000);
res.status(400).send({ code: server_constants.RIS_CODE_USERNAME_NOT_VALID, msg: '' });
return 1;
}
if (tools.blockwords(body.email) || tools.blockwords(body.name) || tools.blockwords(body.surname)) {
// tools.writeIPToBan(user.ipaddr + ': [' + user.username + '] ' + user.name + ' ' + user.surname);
await tools.snooze(5000);
return res.status(404).send();
}
user.date_reg = new Date();
// Controlla se anche l'ultimo record era dallo stesso IP:
const lastrec = await User.getLastRec(body.idapp);
if (!!lastrec) {
if (process.env.LOCALE !== "1") {
if (lastrec.ipaddr === user.ipaddr) {
// Se l'ha fatto troppo ravvicinato
if (lastrec.date_reg) {
let ris = tools.isdiffSecDateLess(lastrec.date_reg, 120);
if (ris) {
tools.writeIPToBan(user.ipaddr + ': ' + user.name + ' ' + user.surname);
await tools.snooze(10000);
res.status(400).send({ code: server_constants.RIS_CODE_BANIP, msg: '' });
return 1;
}
}
}
}
}
return await user.save()
.then(async () => {
return await User.findByUsername(user.idapp, user.username, false)
.then((usertrovato) => {
// tools.mylog("TROVATO USERNAME ? ", user.username, usertrovato);
if (usertrovato !== null) {
return user.generateAuthToken(req);
} else {
res.status(400).send();
return 0;
}
})
.then(async (token) => {
// tools.mylog("passo il TOKEN: ", token);
if (recextra) {
recextra.registered = true;
recextra.username = user.username;
await recextra.save();
// await User.fixUsername(user.idapp, user.ind_order, user.username);
}
return token;
})
.then(async (token) => {
// tools.mylog("LINKREG = " + user.linkreg);
// Invia un'email all'utente
// tools.mylog('process.env.TESTING_ON', process.env.TESTING_ON);
console.log('res.locale', res.locale);
// if (!tools.testing()) {
await sendemail.sendEmail_Registration(user.lang, user.email, user, user.idapp, user.linkreg);
// }
res.header('x-auth', token).send(user);
return true;
});
}).catch((e) => {
console.error(e.message);
res.status(400).send(e);
})
});

View File

@@ -189,12 +189,43 @@ module.exports = {
await telegrambot.notifyToTelegram(telegrambot.phase.REGISTRATION, mylocalsconf);
tools.sendNotifToAdmin('Nuova Registrazione Utente: ' . name + ' ' + surname + ' (' + username + ')');
tools.sendNotifToAdmin('Nuova Registrazione Utente: ' + mylocalsconf.name + ' ' + mylocalsconf.surname + ' (' + mylocalsconf.username + ')');
if (tools.isManagAndAdminDifferent(idapp)) {
this.sendEmail_base('admin/registration/' + tools.LANGADMIN, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
}
},
sendEmail_IscrizioneConacreis: async function (lang, emailto, iscritto, idapp) {
// console.log('idapp', idapp, tools.getNomeAppByIdApp(idapp));
let mylocalsconf = {
idapp,
dataemail: await this.getdataemail(idapp),
locale: lang,
nomeapp: tools.getNomeAppByIdApp(idapp),
strlinksito: tools.getHostByIdApp(idapp),
username: iscritto.username,
name: iscritto.name,
surname: iscritto.surname,
emailto: emailto,
iscritto,
};
this.sendEmail_base('iscrizione_conacreis/' + lang, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
// Send to the Admin an Email
this.sendEmail_base('admin/iscrizione_conacreis/' + tools.LANGADMIN, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
await telegrambot.notifyIscrizioneToTelegram(telegrambot.phase.ISCRIZIONE_CONACREIS, mylocalsconf);
tools.sendNotifToAdmin('Iscrizione Conacreis : ' + mylocalsconf.name + ' ' + mylocalsconf.surname);
if (tools.isManagAndAdminDifferent(idapp)) {
this.sendEmail_base('admin/iscrizione_conacreis/' + tools.LANGADMIN, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
}
},
sendEmail_RequestNewPassword: async function (lang, user, emailto, idapp, tokenforgot) {
let mylocalsconf = {
@@ -218,6 +249,7 @@ module.exports = {
tools.mylog('sendEmail_Booking');
tools.mylog('tools.getNomeAppByIdApp(idapp)', tools.getNomeAppByIdApp(idapp), idapp);
let mylocalsconf = {
idapp,
dataemail: await this.getdataemail(idapp),
@@ -229,24 +261,18 @@ module.exports = {
participants: '',
participantsLunch: '',
participantsDinner: '',
participantsDinnerShared: '',
msgbooking: tools.convertTexttoHtml(recbooking.msgbooking),
eventtextplain: tools.removeSpecialCharForEmail(recbooking.infoevent),
event: recbooking.infoevent,
};
return Settings.getValDbSettings(idapp, 'MSG_REPLY_AFTER_BOOKING').then((ris => {
return Settings.getValDbSettings(idapp, 'MSG_REPLY_AFTER_BOOKING')
.then(async (ris) => {
mylocalsconf.msgreply_after_booking = ris;
if (recbooking.numpeople > 0)
mylocalsconf.participants = recbooking.numpeople.toString() + ' ' + tools.getres__('partecipanti', res);
mylocalsconf = await this.preparaConfPerBooking(res, idapp, mylocalsconf, recbooking, 'Prenotazione');
if (recbooking.numpeopleLunch > 0)
mylocalsconf.participantsLunch = recbooking.numpeopleLunch.toString() + ' ' + tools.getres__('partecipanti a Pranzo', res);
if (recbooking.numpeopleDinner > 0)
mylocalsconf.participantsDinner = recbooking.numpeopleDinner.toString() + ' ' + tools.getres__('partecipanti a Cena', res);
let texthtml = '';
if (recbooking.modified) {
texthtml = 'modifybooking';
} else {
@@ -262,7 +288,45 @@ module.exports = {
this.sendEmail_base('admin/' + texthtml + '/' + tools.LANGADMIN, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
}
}));
});
},
preparaConfPerBooking: async function (res, idapp, mylocalsconf, recbooking, title) {
let texthtml = '';
let msgtelegram = title + ' Evento [' + mylocalsconf.name + ' ' + mylocalsconf.surname + '] ' + mylocalsconf.eventtextplain;
if (recbooking.modified) {
msgtelegram += ' (modificato) '
} else {
msgtelegram += ' (Nuovo)'
}
msgtelegram += '\n';
if (recbooking.numpeople > 0) {
mylocalsconf.participants = recbooking.numpeople.toString() + ' ' + tools.getres__('partecipanti', res);
msgtelegram += mylocalsconf.participants + '\n'
}
if (recbooking.numpeopleLunch > 0) {
mylocalsconf.participantsLunch = recbooking.numpeopleLunch.toString() + ' ' + tools.getres__('partecipanti a Pranzo', res);
msgtelegram += mylocalsconf.participantsLunch + '\n'
}
if (recbooking.numpeopleDinner > 0) {
mylocalsconf.participantsDinner = recbooking.numpeopleDinner.toString() + ' ' + tools.getres__('partecipanti a Cena', res);
msgtelegram += mylocalsconf.participantsDinner + '\n'
}
if (recbooking.numpeopleDinnerShared > 0) {
mylocalsconf.participantsDinnerShared = recbooking.numpeopleDinnerShared.toString() + ' ' + tools.getres__('partecipanti a Cena Condivisa', res);
msgtelegram += mylocalsconf.participantsDinnerShared + '\n'
}
telegrambot.sendMsgTelegramToTheManagers(idapp, msgtelegram);
return mylocalsconf;
},
@@ -282,17 +346,15 @@ module.exports = {
participants: '',
participantsLunch: '',
participantsDinner: '',
participantsDinnerShared: '',
eventtextplain: tools.removeSpecialCharForEmail(recbooking.infoevent),
};
if (recbooking.numpeople > 1)
mylocalsconf.participants = recbooking.numpeople.toString() + ' ' + tools.getres__('partecipanti', res);
mylocalsconf = await this.preparaConfPerBooking(res, idapp, mylocalsconf, recbooking, 'Cancellazione');
if (recbooking.numpeopleLunch > 1)
mylocalsconf.participantsLunch = recbooking.numpeopleLunch.toString() + ' ' + tools.getres__('partecipanti a Pranzo', res);
let msgtelegram = 'Cancellazione Evento [' + mylocalsconf.name + ' ' + mylocalsconf.surname + '] ' + mylocalsconf.eventtextplain;
if (recbooking.numpeopleDinner > 1)
mylocalsconf.participantsDinner = recbooking.numpeopleDinner.toString() + ' ' + tools.getres__('partecipanti a Cena', res);
telegrambot.sendMsgTelegramToTheManagers(idapp, msgtelegram);
this.sendEmail_base('booking/cancelbooking/' + lang, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
@@ -524,7 +586,7 @@ module.exports = {
host: mylocalsconf.dataemail.email_service,
port: mylocalsconf.dataemail.email_port,
secureConnection: false,
tls: {cipher:'SSLv3'},
tls: { cipher: 'SSLv3' },
auth: {
user: mylocalsconf.dataemail.from,
pass: mylocalsconf.dataemail.pwd_from
@@ -556,7 +618,7 @@ module.exports = {
sendEmail_OrderProduct: async function (lang, idapp, orders, user) {
const msginizio = 'INIZIO - sendEmail_OrderProduct: ' + tools.getNomeAppByIdApp(idapp);
const msginizio = 'Ordine n: ' + orders.numorder + ' ' + user.name + ' ' + user.surname + ' [' + tools.getNomeAppByIdApp(idapp) + ']';
console.log(msginizio);
await telegrambot.sendMsgTelegramToTheManagers(idapp, msginizio);
@@ -581,6 +643,38 @@ module.exports = {
const esito = this.sendEmail_base('ecommerce/makeorder/' + lang, mylocalsconf.emailto, mylocalsconf, mylocalsconf.dataemail.email_reply);
this.sendEmail_base('ecommerce/makeorder/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
},
sendEmail_Order: async function (lang, idapp, orders, user, ordertype) {
const msginizio = 'INIZIO - sendEmail_Order ' + ordertype + ': ' + tools.getNomeAppByIdApp(idapp);
console.log(msginizio);
await telegrambot.sendMsgTelegramToTheManagers(idapp, msginizio);
mylocalsconf = {
idapp,
locale: lang,
nomeapp: tools.getNomeAppByIdApp(idapp),
orders,
baseurl: tools.getHostByIdApp(idapp),
dataemail: await this.getdataemail(idapp),
ordernumber: orders.numorder,
user
};
mylocalsconf.name = user.name;
mylocalsconf.surname = user.surname;
mylocalsconf.emailto = user.email;
mylocalsconf.hashemail = tools.getHash(user.email);
mylocalsconf = this.replacefields(mylocalsconf);
const esito = this.sendEmail_base('ecommerce/' + ordertype + '/' + lang, mylocalsconf.emailto, mylocalsconf, mylocalsconf.dataemail.email_reply);
this.sendEmail_base('ecommerce/' + ordertype + '/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
},
sendEmail_Newsletter_Events: async function (lang, idapp, id_newstosent) {

View File

@@ -14,7 +14,6 @@ const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
const sendemail = require('./sendemail');
const cron = require('node-cron');
@@ -31,48 +30,6 @@ if ((process.env.NODE_ENV === 'production') || (process.env.NODE_ENV === 'test')
var http = require('http');
}
require('./models/todo');
require('./models/project');
require('./models/user');
require('./models/subscribers');
require('./models/cfgserver');
require('./models/booking');
require('./models/sendmsg');
require('./models/mailinglist');
require('./models/newstosent');
require('./models/mypage');
require('./models/calzoom');
const mysql_func = require('./mysql/mysql_func');
const { Newstosent } = require('./models/newstosent');
const index_router = require('./router/index_router');
const push_router = require('./router/push_router');
const newsletter_router = require('./router/newsletter_router');
const booking_router = require('./router/booking_router');
const dashboard_router = require('./router/dashboard_router');
const myevent_router = require('./router/myevent_router');
const subscribe_router = require('./router/subscribe_router');
const sendmsg_router = require('./router/sendmsg_router');
const email_router = require('./router/email_router');
const todos_router = require('./router/todos_router');
const test_router = require('./router/test_router');
const projects_router = require('./router/projects_router');
const report_router = require('./router/report_router');
const users_router = require('./router/users_router');
const site_router = require('./router/site_router');
const admin_router = require('./router/admin_router');
const products_router = require('./router/products_router');
const cart_router = require('./router/cart_router');
const orders_router = require('./router/orders_router');
const { ListaIngresso } = require('./models/listaingresso');
const { MyEvent } = require('./models/myevent');
const telegrambot = require('./telegram/telegrambot');
require('./db/mongoose');
console.log("DB: " + process.env.DATABASE);
@@ -83,16 +40,59 @@ var app = express();
const tools = require('./tools/general');
require('./models/cfgserver');
var mongoose = require('mongoose');
mongoose.set('debug', process.env.DEBUG);
const cfgserver = mongoose.model('cfgserver');
const { ObjectID } = require('mongodb');
app.use(express.static('views'));
myLoad().then(ris => {
const { User } = require('./models/user');
require('./models/todo');
require('./models/project');
require('./models/subscribers');
require('./models/booking');
require('./models/sendmsg');
require('./models/mailinglist');
require('./models/newstosent');
require('./models/mypage');
require('./models/calzoom');
const mysql_func = require('./mysql/mysql_func');
const index_router = require('./router/index_router');
const push_router = require('./router/push_router');
const newsletter_router = require('./router/newsletter_router');
const booking_router = require('./router/booking_router');
const dashboard_router = require('./router/dashboard_router');
const myevent_router = require('./router/myevent_router');
const subscribe_router = require('./router/subscribe_router');
const sendmsg_router = require('./router/sendmsg_router');
const email_router = require('./router/email_router');
const todos_router = require('./router/todos_router');
const test_router = require('./router/test_router');
const projects_router = require('./router/projects_router');
const report_router = require('./router/report_router');
const users_router = require('./router/users_router');
const iscrittiConacreis_router = require('./router/iscrittiConacreis_router');
const site_router = require('./router/site_router');
const admin_router = require('./router/admin_router');
const products_router = require('./router/products_router');
const cart_router = require('./router/cart_router');
const orders_router = require('./router/orders_router');
const { MyEvent } = require('./models/myevent');
app.use(express.static('views'));
// app.use(express.static(path.join(__dirname, 'client')));
app.use(bodyParser.json());
app.use(bodyParser.json());
// app.set('view engine', 'pug');
@@ -100,42 +100,43 @@ app.use(bodyParser.json());
// app.use(express.static(path.join(__dirname, 'public')));
i18n.configure({
i18n.configure({
locales: ['it', 'enUs', 'es', 'fr', 'pt', 'si'],
// cookie: 'cook',
directory: __dirname + '/locales'
});
});
app.use(cors({
app.use(cors({
exposedHeaders: ['x-auth'],
}));
}));
app.use(bodyParser.json());
app.use(bodyParser.json());
// app.use(express.cookieParser());
app.use(i18n.init);
app.use(i18n.init);
// Use Routes
app.use('/', index_router);
app.use('/subscribe', subscribe_router);
app.use('/sendmsg', sendmsg_router);
app.use('/push', push_router);
app.use('/news', newsletter_router);
app.use('/booking', booking_router);
app.use('/dashboard', dashboard_router);
app.use('/event', myevent_router);
app.use('/email', email_router);
app.use('/todos', todos_router);
app.use('/test', test_router);
app.use('/projects', projects_router);
app.use('/users', users_router);
app.use('/report', report_router);
app.use('/site', site_router);
app.use('/admin', admin_router);
app.use('/products', products_router);
app.use('/cart', cart_router);
app.use('/orders', orders_router);
app.use('/', index_router);
app.use('/subscribe', subscribe_router);
app.use('/sendmsg', sendmsg_router);
app.use('/push', push_router);
app.use('/news', newsletter_router);
app.use('/booking', booking_router);
app.use('/dashboard', dashboard_router);
app.use('/event', myevent_router);
app.use('/email', email_router);
app.use('/todos', todos_router);
app.use('/test', test_router);
app.use('/projects', projects_router);
app.use('/users', users_router);
app.use('/iscritti_conacreis', iscrittiConacreis_router);
app.use('/report', report_router);
app.use('/site', site_router);
app.use('/admin', admin_router);
app.use('/products', products_router);
app.use('/cart', cart_router);
app.use('/orders', orders_router);
// catch 404 and forward to error handler
// app.use(function (req, res, next) {
@@ -149,7 +150,7 @@ app.use('/orders', orders_router);
// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
if (app.get('env') === 'development') {
app.use(function (err, req, res, next) {
console.log('Error: ', err.message);
@@ -161,9 +162,9 @@ if (app.get('env') === 'development') {
// });
});
}
}
require('./telegram/telegrambot');
// require('./telegram/telegrambot');
// *** DB CONNECTIONS ***
@@ -175,15 +176,20 @@ require('./telegram/telegrambot');
// });
if ((process.env.NODE_ENV === 'production') || (process.env.NODE_ENV === 'test')) {
if ((process.env.NODE_ENV === 'production') || (process.env.NODE_ENV === 'test')) {
var httpsServer = https.createServer(credentials, app);
console.log("httpsServer: port ", port);
httpsServer.listen(port);
} else {
} else {
console.log("httpServer: port ", port);
var httpServer = http.createServer(app);
httpServer.listen(port);
}
}
mystart();
});
// app.use(throttle(1024 * 128)); // throttling bandwidth
@@ -193,7 +199,14 @@ if ((process.env.NODE_ENV === 'production') || (process.env.NODE_ENV === 'test')
// next()
// });
if (process.env.PROD !== 1) {
async function myLoad() {
return await tools.loadApps();
}
async function mystart() {
if (process.env.PROD !== 1) {
testmsgwebpush();
// tools.sendNotifToAdmin('Riparti', 'Riparti');
@@ -210,27 +223,34 @@ if (process.env.PROD !== 1) {
}
mycron();
}
}
await inizia();
await resetProcessingJob();
// ----------------- MAILCHIMP -----
const querystring = require('querystring');
const mailchimpClientId = 'xxxxxxxxxxxxxxxx';
const querystring = require('querystring');
const mailchimpClientId = 'xxxxxxxxxxxxxxxx';
app.get('/mailchimp/auth/authorize', function (req, res) {
app.get('/mailchimp/auth/authorize', function (req, res) {
res.redirect('https://login.mailchimp.com/oauth2/authorize?' +
querystring.stringify({
'response_type': 'code',
'client_id': mailchimpClientId,
'redirect_uri': 'http://127.0.0.1:3000/mailchimp/auth/callback'
}));
});
});
}
// -----------------
startserv();
function populateDBadmin() {
const cfgserv = [{
_id: new ObjectID(),
@@ -243,24 +263,12 @@ function populateDBadmin() {
let cfg = new cfgserver(cfgserv[0]).save();
}
function startserv() {
// populateDBadmin();
// Check if is Empty (new Server Data)
/*
cfgserver.countDocuments(function (err, count) {
if (!err && count === 0) {
populateDBadmin();
}
});
*/
}
function mycron() {
for (const app of MYAPPS) {
const sendemail = require('./sendemail');
for (const app of tools.getApps()) {
sendemail.checkifPendingNewsletter(app.idapp);
sendemail.checkifSentNewsletter(app.idapp);
@@ -268,13 +276,13 @@ function mycron() {
}
async function mycron_30min() {
for (const app of MYAPPS) {
for (const app of tools.getApps()) {
let enablecrontab = false;
enablecrontab = await Settings.getValDbSettings(app.idapp, tools.ENABLE_CRONTAB, false);
if (enablecrontab) {
ListaIngresso.Esegui_CronTab(app.idapp, {});
// ...
}
}
}
@@ -323,6 +331,8 @@ cron.schedule('*/60 * * * *', async () => {
async function resetProcessingJob() {
const { Newstosent } = require('./models/newstosent');
arrrec = await Newstosent.find({});
for (const rec of arrrec) {
@@ -338,25 +348,24 @@ async function resetProcessingJob() {
//});
async function inizia() {
if (process.env.NODE_ENV === 'production') {
await telegrambot.sendMsgTelegram(tools.AYNI, telegrambot.ADMIN_USER_SERVER, `Ciao ${telegrambot.ADMIN_USER_NAME_SERVER}!`);
await telegrambot.sendMsgTelegramByIdTelegram(tools.AYNI, telegrambot.ADMIN_IDTELEGRAM_SERVER, `Il Server ${process.env.DATABASE} è appena ripartito!`);
const telegrambot = require('./telegram/telegrambot');
// if (process.env.NODE_ENV === 'production') {
await telegrambot.sendMsgTelegram(tools.CNM, telegrambot.ADMIN_USER_SERVER, `Ciao ${telegrambot.ADMIN_USER_NAME_SERVER}!`);
await telegrambot.sendMsgTelegramByIdTelegram(tools.CNM, telegrambot.ADMIN_IDTELEGRAM_SERVER, `Il Server ${process.env.DATABASE} è appena ripartito!`);
await telegrambot.sendMsgTelegramByIdTelegram('2', telegrambot.ADMIN_IDTELEGRAM_SERVER, `Il Server ${process.env.DATABASE} è appena ripartito!`);
testo = 'Ciao Paolo!';
myid = await telegrambot.sendMsgTelegramByIdTelegram(tools.AYNI, telegrambot.ADMIN_IDTELEGRAM_SERVER, testo);
myid = await telegrambot.sendMsgTelegramByIdTelegram(tools.CNM, telegrambot.ADMIN_IDTELEGRAM_SERVER, testo);
}
// }
// testo = 'testo modificato';
// myid = await telegrambot.sendMsgTelegramByIdTelegram('7', telegrambot.ADMIN_IDTELEGRAM_SERVER, testo, myid, telegrambot.ADMIN_IDTELEGRAM_SERVER);
}
inizia();
resetProcessingJob();
//

View File

@@ -370,6 +370,7 @@ const txt = {
MSG_ERR_UNKNOWN_VERIFY_CODE: 'Errore durante il salvataggio sul Server. Riprovare piú tardi',
MSG_EXIT_TELEGRAM: 'L\'account è stato ora scollegato da questo Telegram BOT.',
MSG_APORTADOR_USER_REGISTERED: emo.FIRE + ' Si è appena Registrato "%s (n. %s)"\n(Invitato da %s)',
MSG_ISCRITTO_CONACREIS: emo.FIRE + ' Si è appena Iscritto al Conacreis "%s"',
MSG_MSG_SENT: emoji.get('envelope') + ' Messaggi Inviati !',
MSG_MSG_TOSENT: emoji.get('envelope') + ' Messaggi da Inviare',
MSG_MSG_INCORSO: emoji.get('envelope') + ' messaggi in corso... Inviati attualmente',
@@ -485,7 +486,8 @@ module.exports = {
ADMIN_USER_NAME_SERVER: 'Paolo',
phase: {
REGISTRATION: 1
REGISTRATION: 1,
ISCRIZIONE_CONACREIS: 2
},
getFormDaMostrare: function (idapp, myfunc, myuser) {
@@ -550,7 +552,19 @@ module.exports = {
},
sendMsgTelegramToTheManagers: async function (idapp, text, onlyintofile, MyForm = null) {
notifyIscrizioneToTelegram: async function (phase, mylocalsconf) {
let langdest = mylocalsconf.iscritto.lang;
let NameFrom = `${mylocalsconf.iscritto.name} ${mylocalsconf.iscritto.surname}`;
let text = printf(getstr(langdest, 'MSG_ISCRITTO_CONACREIS'), NameFrom);
let addtext = "";
await this.sendMsgTelegramToTheManagers(mylocalsconf.idapp, addtext + text);
},
sendMsgTelegramToTheManagers: async function (idapp, text, onlyintofile = false, MyForm = null) {
tools.writeManagersLog(text);
@@ -875,6 +889,8 @@ module.exports = {
},
sendMsgTelegram: async function (idapp, username, text, alsotomanagers, username_mitt) {
const { User } = require('../models/user');
const teleg_id = await User.TelegIdByUsername(idapp, username);
const cl = getclTelegByidapp(idapp);
let ris = null;
@@ -2634,6 +2650,7 @@ function getclTelegByidapp(idapp) {
}
if (!tools.testing()) {
// if (true) {
console.log('TELEGRAM STARTING.... ');
for (const idapp of appTelegram) {

View File

@@ -9,6 +9,9 @@ require('../config/config');
require('../models/subscribers');
const Site = require('../models/site');
const CryptoJS = require('crypto-js');
const Url = require('url-parse');
@@ -42,15 +45,20 @@ const keySize = 256;
const ivSize = 128;
const iterations = 100;
if (process.env.GCM_API_KEY !== "")
if (!!process.env.GCM_API_KEY && process.env.GCM_API_KEY !== "") {
webpush.setGCMAPIKey(process.env.GCM_API_KEY);
webpush.setVapidDetails(subject, publicVapidKey, privateVapidKey);
webpush.setVapidDetails(subject, publicVapidKey, privateVapidKey);
}
// console.log('setVapidDetails... config...');
// To Translate!
textlang = {
const textlang = {
it: {
"L'Email è già stata Verificata": "L'Email è già stata Verificata",
"Nuova Registrazione": "Nuova Registrazione",
@@ -58,6 +66,7 @@ textlang = {
"partecipanti": "partecipanti all'Evento",
"partecipanti a Pranzo": "partecipanti a Pranzo",
"partecipanti a Cena": "partecipanti a Cena",
"partecipanti a Cena Condivisa": "partecipanti a Cena Condivisa",
'TESTO_ASSISTENZA': "<strong><a href=\"%s\">👉 Per entrare nel Sito AYNI</a></strong>\n\n" +
"👉 <strong><a href=\"https://ayni.gifteconomy.app/requestresetpwd\">Hai dimenticato la password?</a></strong>\n\n" +
"👉 Entra nel Canale d'Informazione per Importanti Avvisi!\n<strong><a href=\"%s\">Canale AYNI-BIBLIO</a></strong>\n\n" +
@@ -474,6 +483,7 @@ textlang = {
module.exports = {
MYAPPS: [],
INITDB_FIRSTIME: true,
ACAPO: '\n',
@@ -637,11 +647,11 @@ module.exports = {
},
allfieldBooking: function () {
return ['idapp', 'userId', 'id_bookedevent', 'numpeople', 'numpeopleLunch', 'numpeopleDinner', 'msgbooking', 'modified', 'infoevent', 'datebooked', 'booked']
return ['idapp', 'userId', 'id_bookedevent', 'numpeople', 'numpeopleLunch', 'numpeopleDinner', 'numpeopleDinnerShared', 'msgbooking', 'modified', 'infoevent', 'datebooked', 'booked']
},
allfieldBookingChange: function () {
return ['numpeople', 'numpeopleLunch', 'numpeopleDinner', 'msgbooking', 'modified', 'infoevent', 'datebooked', 'booked']
return ['numpeople', 'numpeopleLunch', 'numpeopleDinner', 'numpeopleDinnerShared', 'msgbooking', 'modified', 'infoevent', 'datebooked', 'booked']
},
allfieldProjectWithId: function () {
@@ -844,8 +854,8 @@ module.exports = {
sendNotifToAdmin(title, msg, tag = '') {
const { User } = require('../models/user');
// console.log('nomeapp 1: ' , tools.getNomeAppByIdApp(1));
// console.log('nomeapp 2: ' , tools.getNomeAppByIdApp(2));
// console.log('nomeapp 1: ' , this.getNomeAppByIdApp(1));
// console.log('nomeapp 2: ' , this.getNomeAppByIdApp(2));
User.find({ username: 'paoloarcnm' }).then((arrusers) => {
if (arrusers !== null) {
@@ -906,7 +916,7 @@ module.exports = {
getNomeAppByIdApp: function (idapp) {
const myapp =
MYAPPS.find(item => item.idapp === idapp);
this.getApps().find(item => item.idapp === idapp);
if (myapp)
return myapp.name;
else
@@ -916,7 +926,7 @@ module.exports = {
getHostByIdApp: function (idapp) {
const myapp =
MYAPPS.find(item => item.idapp === idapp);
this.getApps().find(item => item.idapp === idapp);
if (myapp) {
let siteport = (myapp.portapp !== "0") ? (':' + myapp.portapp) : "";
@@ -926,14 +936,14 @@ module.exports = {
},
isAbilitaNave: function (idapp) {
const myapp = MYAPPS.find(item => item.idapp === idapp);
const myapp = this.getApps().find(item => item.idapp === idapp);
return myapp.abilitanave;
},
getdirByIdApp: function (idapp) {
const myapp =
MYAPPS.find(item => item.idapp === idapp);
this.getApps().find(item => item.idapp === idapp);
if (myapp) {
return myapp.dir;
} else
@@ -941,7 +951,7 @@ module.exports = {
},
getAdminEmailByIdApp: function (idapp) {
const myapp = MYAPPS.find((item) => item.idapp === idapp);
const myapp = this.getApps().find((item) => item.idapp === idapp);
if (myapp)
return myapp.adminemail;
else
@@ -949,7 +959,7 @@ module.exports = {
},
getreplyToEmailByIdApp: function (idapp) {
const myapp = MYAPPS.find((item) => item.idapp === idapp);
const myapp = this.getApps().find((item) => item.idapp === idapp);
if (myapp)
return myapp.replyTo;
else
@@ -957,7 +967,7 @@ module.exports = {
},
getpathregByIdApp: function (idapp, lang) {
const myapp = MYAPPS.find((item) => item.idapp === idapp);
const myapp = this.getApps().find((item) => item.idapp === idapp);
if (myapp)
return 'registration' + myapp.pathreg_add + '/' + lang;
else
@@ -970,30 +980,31 @@ module.exports = {
},
getManagerEmailByIdApp: function (idapp) {
const myapp = MYAPPS.find((item) => item.idapp === idapp);
const myapp = this.getApps().find((item) => item.idapp === idapp);
if (myapp)
return myapp.manageremail;
return !!myapp.manageremail ? myapp.manageremail : '';
else
return '';
},
getEmailByIdApp: function (idapp) {
const myapp = MYAPPS.find((item) => item.idapp === idapp);
const myapp = this.getApps().find((item) => item.idapp === idapp);
return (myapp) ? myapp.email_from : ''
},
getPwdByIdApp: function (idapp) {
const myapp = MYAPPS.find((item) => item.idapp === idapp);
const myapp = this.getApps().find((item) => item.idapp === idapp);
return (myapp) ? this.decryptdata(myapp.email_pwd) : ''
},
getTelegramBotNameByIdApp: function (idapp) {
const myapp = MYAPPS.find((item) => item.idapp === idapp);
const myapp = this.getApps().find((item) => item.idapp === idapp);
return (myapp) ? myapp.telegram_bot_name : ''
},
getTelegramKeyByIdApp: function (idapp) {
const myapp = MYAPPS.find((item) => item.idapp === idapp);
const myarr = this.getApps();
const myapp = myarr.find((item) => item.idapp === idapp);
return (myapp) ? myapp.telegram_key : ''
},
@@ -1953,6 +1964,16 @@ module.exports = {
dateToEpochStr(thedate) {
const time = new Date(thedate).getTime();
return new Date(time - (time % 86400000));
},
async loadApps() {
this.MYAPPS = await Site.findAllIdApp(0);
},
getApps() {
if (this.MYAPPS.length <= 0)
this.loadApps();
return this.MYAPPS;
}
};

View File

@@ -22,6 +22,7 @@ module.exports = Object.freeze({
RIS_CODE_OK: 1,
RIS_CODE_LOGIN_OK: 1,
RIS_ISCRIZIONE_OK: 5,
RIS_CODE_HTTP_INVALID_TOKEN: 403,
RIS_CODE_TOKEN_RESETPASSWORD_NOT_FOUND: -23,

View File

@@ -34,7 +34,7 @@ module.exports = {
Manager: 2,
Teacher: 4,
Tutor: 8,
Traduttrici: 16,
Editor: 16,
Zoomeri: 32,
Department: 64,
},
@@ -48,6 +48,7 @@ module.exports = {
SEND_TO_ALL: 1,
SEND_TO_SOCI: 2,
SEND_TO_SOCIO_RESIDENTE: 3,
SEND_TO_CONSIGLIO: 5,
SEND_TO_NON_SOCI: 10,
SEND_TO_PAOLO: 20
},
@@ -79,6 +80,14 @@ module.exports = {
CANCELED: 10,
},
OrderStatusView: {
CHECKOUT_SENT: 2,
ORDER_CONFIRMED: 3,
PAYED: 4,
RECEIVED: 6,
CANCELED: 10
},
fieldsUserToChange() {
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']