Iscrizione Conacreis e Arcadei

This commit is contained in:
paoloar77
2022-10-29 12:37:50 +02:00
parent 663eb34cfa
commit 3b5d138d5d
11 changed files with 461 additions and 18 deletions

View File

@@ -0,0 +1,71 @@
p #{username} (#{name} #{surname}) si è appena Iscritto ad Arcadei Foundation 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 Email Secondaria:&nbsp;
strong #{iscritto.email2}<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 #{data_nascita}<br>
span Città di Nascita:&nbsp;
strong #{iscritto.born_city}<br>
span Provincia di Nascita:&nbsp;
strong #{iscritto.born_province}<br>
span Paese di Nascita:&nbsp;
strong #{iscritto.born_country}<br>
span Telefono:&nbsp;
strong #{iscritto.cell_phone}<br>
span Telefono2:&nbsp;
strong #{iscritto.cell_phone2}<br>
span Tipo di Documento :&nbsp;
strong #{iscritto.doctype}<br>
span Numero Documento :&nbsp;
strong #{iscritto.documentnumber}<br>
span Metodo di Pagamento :&nbsp;
strong #{iscritto.metodo_pagamento}<br>
span Quota scelta da versare :&nbsp;
strong #{iscritto.quota_versata}<br>
span Scrivi altre eventuali informazioni o comunicazioni:&nbsp;
strong #{iscritto.altre_comunicazioni}<br>
span Categorie d'Interesse :&nbsp;
strong #{iscritto.categorie_interesse}<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 Arcadei di ${name} ${surname} (${emailto}) su ${nomeapp}`

View File

@@ -0,0 +1,198 @@
const mongoose = require('mongoose').set('debug', false);
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 IscrittiArcadeiSchema = new Schema({
idapp: {
type: String,
},
userId: {
type: String,
},
numTesseraInterna: {
type: Number,
default: 0,
},
name: {
type: String,
trim: true,
},
surname: {
type: String,
trim: true,
},
email: {
type: String,
trim: true,
},
email2: {
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,
},
born_city: {
type: String,
trim: true,
},
born_province: {
type: String,
trim: true,
},
born_country: {
type: String,
trim: true,
},
cell_phone: {
type: String,
},
cell_phone2: {
type: String,
},
newsletter_on: {
type: Boolean,
},
terms: {
type: Boolean,
},
metodo_pagamento: {
type: Number,
},
doctype: {
type: String,
},
documentnumber: {
type: String,
},
ha_pagato: {
type: Boolean,
},
iscrizione_compilata: {
type: Boolean,
},
dateofreg: {
type: Date,
},
dateofapproved: {
type: Date,
},
codiceArcadei: {
type: String,
},
annoTesseramento: {
type: Number,
},
motivazioni: {
type: String,
},
categorie_interesse: [
{
type: Number,
}],
altre_comunicazioni: {
type: String,
},
come_ci_hai_conosciuto: {
type: String,
},
note: {
type: String,
},
quota_versata: {
type: Number,
},
});
IscrittiArcadeiSchema.pre('save', async function(next) {
if (this.isNew) {
const myrec = await IscrittiArcadei.findOne().limit(1).sort({numTesseraInterna: -1});
if (!!myrec) {
this.numTesseraInterna = myrec._doc.numTesseraInterna + 1;
} else {
this.numTesseraInterna = 0;
}
}
next();
});
var IscrittiArcadei = module.exports = mongoose.model('IscrittiArcadei', IscrittiArcadeiSchema);
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 IscrittiArcadei.find({idapp}).sort({dateofreg: -1}).limit(1);
if (!!lastrec) {
return lastrec[0];
} else {
return null;
}
};
module.exports.getNameSurnameByEmail = async function(idapp, email) {
return await IscrittiArcadei.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 IscrittiArcadei.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 IscrittiArcadei.find(myfind, (err, arrrec) => {
return arrrec;
});
};

View File

@@ -17,7 +17,7 @@ const MyElemSchema = new Schema({
type: String,
},
type: {
type: String,
type: Number,
},
title: {
type: String,
@@ -25,6 +25,24 @@ const MyElemSchema = new Schema({
container: {
type: String,
},
container2: {
type: String,
},
container3: {
type: String,
},
number: {
type: String,
},
imgback: {
type: String,
},
ratio: {
type: String,
},
containerHtml: {
type: String,
},
size: {
type: String,
},
@@ -35,6 +53,18 @@ const MyElemSchema = new Schema({
height: {
type: Number,
},
heightimg: {
type: Number,
},
widthimg: {
type: Number,
},
width: {
type: Number,
},
link: {
type: String,
},
onlyif_logged: {
type: Boolean,
},
@@ -47,6 +77,25 @@ const MyElemSchema = new Schema({
class: {
type: String,
},
styleadd: {
type: String,
},
list: [
{
imagefile: {
type: String
},
order: {
type: Number
},
alt: {
type: String
},
description: {
type: String
}
}
],
});
MyElemSchema.statics.getFieldsForSearch = function () {
@@ -64,9 +113,7 @@ MyElemSchema.statics.findAllIdApp = async function (idapp) {
const myfind = { idapp };
return await MyElem.find(myfind, (err, arrrec) => {
return arrrec
});
return await MyElem.find(myfind).sort({ order: 1 });
};
const MyElem = mongoose.model('MyElem', MyElemSchema);

View File

@@ -39,6 +39,7 @@ const {MyEvent} = require('../models/myevent');
const {Contribtype} = require('../models/contribtype');
const {PaymentType} = require('../models/paymenttype');
const {Discipline} = require('../models/discipline');
const {MyElem} = require('../models/myelem');
const {Skill} = require('../models/skill');
const {Good} = require('../models/good');
const {StatusSkill} = require('../models/statusSkill');

View File

@@ -0,0 +1,82 @@
const express = require('express');
const router = express.Router();
const IscrittiArcadei = require('../models/iscrittiArcadei');
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').set('debug', false)
// POST /iscritti_arcadei
router.post('/', async (req, res) => {
tools.mylog("POST /iscritti_arcadei");
const body = req.body;
body.email = body.email.toLowerCase();
const iscritti = new IscrittiArcadei(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.username) || 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 IscrittiArcadei.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 + ': ' + tools.getNomeCognomeEUserNameByUser(iscritti));
await tools.snooze(10000);
res.status(400).send({ code: server_constants.RIS_CODE_BANIP, msg: '' });
return 1;
}
}
}
}
}
return iscritti.save()
.then(async () => {
await sendemail.sendEmail_IscrizioneArcadei(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

@@ -238,7 +238,7 @@ module.exports = {
// 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);
await telegrambot.notifyIscrizioneToTelegram(telegrambot.phase.ISCRIZIONE_CONACREIS, mylocalsconf, 'MSG_ISCRITTO_CONACREIS');
tools.sendNotifToAdmin('Iscrizione Conacreis : ' + mylocalsconf.name + ' ' + mylocalsconf.surname + ' (' + mylocalsconf.username + ')');
@@ -247,6 +247,38 @@ module.exports = {
}
},
sendEmail_IscrizioneArcadei: 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),
emailto: emailto,
iscritto,
metodo_pagamento: tools.getPaymentTypesById(iscritto.metodo_pagamento),
data_nascita: tools.getstrDate_DD_MM_YYYY(iscritto.dateofbirth)
};
mylocalsconf = this.setParamsForTemplate(iscritto, mylocalsconf);
this.sendEmail_base('iscrizione_arcadei/' + lang, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
// Send to the Admin an Email
this.sendEmail_base('admin/iscrizione_arcadei/' + tools.LANGADMIN, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
await telegrambot.notifyIscrizioneToTelegram(telegrambot.phase.ISCRIZIONE_ARCADEI, mylocalsconf, 'MSG_ISCRITTO_ARCADEI');
tools.sendNotifToAdmin('Iscrizione Arcadei : ' + mylocalsconf.name + ' ' + mylocalsconf.surname + ' (' + mylocalsconf.username + ')');
if (tools.isManagAndAdminDifferent(idapp)) {
this.sendEmail_base('admin/iscrizione_arcadei/' + tools.LANGADMIN, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
}
},
sendEmail_RequestNewPassword: async function (lang, user, emailto, idapp, tokenforgot) {
let mylocalsconf = {

View File

@@ -124,6 +124,7 @@ myLoad().then(ris => {
const mygroups_router = require('./router/mygroups_router');
const circuits_router = require('./router/circuits_router');
const iscrittiConacreis_router = require('./router/iscrittiConacreis_router');
const iscrittiArcadei_router = require('./router/iscrittiArcadei_router');
const site_router = require('./router/site_router');
const admin_router = require('./router/admin_router');
const products_router = require('./router/products_router');
@@ -184,6 +185,7 @@ myLoad().then(ris => {
app.use('/mygroup', mygroups_router);
app.use('/circuit', circuits_router);
app.use('/iscritti_conacreis', iscrittiConacreis_router);
app.use('/iscritti_arcadei', iscrittiArcadei_router);
app.use('/report', report_router);
app.use('/site', site_router);
app.use('/admin', admin_router);

View File

@@ -505,6 +505,7 @@ const txt = {
'🚫 Ci dispiace ma non sei stato Verificato correttamente dal tuo invitante %s.<br>Contattalo per farti abilitare !',
MSG_APORTADOR_NOT_CONFIRMED: emo.EXCLAMATION_MARK + '🚫 %s Non è stato Abilitato !',
MSG_ISCRITTO_CONACREIS: emo.FIRE + '[%] Si è appena Iscritto al Conacreis "%s"',
MSG_ISCRITTO_ARCADEI: emo.FIRE + '[%] Si è appena Iscritto ad Arcadei "%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',
@@ -696,6 +697,7 @@ const MyTelegramBot = {
phase: {
REGISTRATION: 1,
ISCRIZIONE_CONACREIS: 2,
ISCRIZIONE_ARCADEI: 4,
},
getAppTelegram: function() {
@@ -805,13 +807,13 @@ const MyTelegramBot = {
},
notifyIscrizioneToTelegram: async function(phase, mylocalsconf) {
notifyIscrizioneToTelegram: async function(phase, mylocalsconf, msg) {
let langdest = mylocalsconf.iscritto.lang;
let NameFrom = `${mylocalsconf.iscritto.name} ${mylocalsconf.iscritto.surname}`;
let nomeapp = tools.getHostByIdApp(mylocalsconf.idapp);
let text = printf(getstr(langdest, 'MSG_ISCRITTO_CONACREIS'), nomeapp, NameFrom);
let text = printf(getstr(langdest, msg), nomeapp, NameFrom);
let addtext = '';

View File

@@ -1211,7 +1211,7 @@ module.exports = {
} catch (e) {
console.error('sendNotificationByCircuit: ', e);
return {ris: null, inviato: false} ;
return {ris: null, inviato: false};
}
},
@@ -1317,20 +1317,24 @@ module.exports = {
},
ConvertHTMLToPlainText(strHTML) {
return strHTML.replace(/<[^>]+>/g, '');
if (strHTML)
return strHTML.replace(/<[^>]+>/g, '');
return '';
},
convertHTMLtoText(myhtml) {
let msg = myhtml;
msg = msg.replace('&quot;', '"');
msg = msg.replace(/<strong>/g, '');
msg = msg.replace(/<\/strong>/g, '');
msg = msg.replace(/<em>/g, '');
msg = msg.replace(/<\/em>/g, '');
msg = msg.replace('&gt;', '>');
msg = msg.replace('&lt;', '<');
msg = msg.replace('&amp;', '&');
msg = msg.replace('<br>', '\n');
if (msg) {
msg = msg.replace('&quot;', '"');
msg = msg.replace(/<strong>/g, '');
msg = msg.replace(/<\/strong>/g, '');
msg = msg.replace(/<em>/g, '');
msg = msg.replace(/<\/em>/g, '');
msg = msg.replace('&gt;', '>');
msg = msg.replace('&lt;', '<');
msg = msg.replace('&amp;', '&');
msg = msg.replace('<br>', '\n');
}
return msg;
},

View File

@@ -63,6 +63,7 @@ const Department = require('../models/department');
const ShareWithUs = require('../models/sharewithus');
const Site = require('../models/site');
const IscrittiConacreis = require('../models/iscrittiConacreis');
const IscrittiArcadei = require('../models/iscrittiArcadei');
const Group = require('../models/group');
const {Todo} = require('../models/todo');
const Hours = require('../models/hours');
@@ -105,6 +106,8 @@ module.exports = {
mytable = Site;
else if (tablename === 'iscritticonacreis')
mytable = IscrittiConacreis;
else if (tablename === 'iscrittiarcadei')
mytable = IscrittiArcadei;
else if (tablename === 'groups')
mytable = Group;
else if (tablename === 'todos')