diff --git a/emails/admin/added_to_newsletter/it/html.pug b/emails/admin/added_to_newsletter/it/html.pug
new file mode 100644
index 0000000..dc4e177
--- /dev/null
+++ b/emails/admin/added_to_newsletter/it/html.pug
@@ -0,0 +1,3 @@
+p #{name} #{surname} si è appena iscritto alla Newsletter di #{nomeapp} con email:
+ strong #{emailto}
+p
Saluti
diff --git a/emails/admin/added_to_newsletter/it/subject.pug b/emails/admin/added_to_newsletter/it/subject.pug
new file mode 100644
index 0000000..768a5d8
--- /dev/null
+++ b/emails/admin/added_to_newsletter/it/subject.pug
@@ -0,0 +1 @@
+=`${name} ${surname} si è appena iscritto alla Newsletter con email: ${emailto} su ${nomeapp}`
diff --git a/server/models/operator.js b/server/models/operator.js
index 435a1c2..414c3e9 100644
--- a/server/models/operator.js
+++ b/server/models/operator.js
@@ -19,16 +19,35 @@ const OperatorSchema = new Schema({
username: {
type: String,
},
+ name: {
+ type: String,
+ trim: true,
+ },
+ surname: {
+ type: String,
+ trim: true,
+ },
+ email: {
+ type: String,
+ trim: true,
+ },
cell: {
type: String,
- },
- webpage: {
- type: String,
+ trim: true,
},
img: {
type: String,
},
- skype: {
+ qualification: { // President, Vice-President, ecc...
+ type: String,
+ },
+ disciplines: {
+ type: String,
+ },
+ certifications: {
+ type: String,
+ },
+ webpage: {
type: String,
},
days_working: {
@@ -37,15 +56,26 @@ const OperatorSchema = new Schema({
facebook: {
type: String,
},
- disciplines: {
+ info: {
+ type: String,
+ },
+ intro: {
type: String,
},
offers: {
type: String,
},
+ skype: {
+ type: String,
+ },
});
+OperatorSchema.statics.getFieldsForSearch = function () {
+ return ['name', 'surname', 'email', 'cell']
+};
+
OperatorSchema.statics.executeQueryTable = function (idapp, params) {
+ params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, idapp, params);
};
@@ -54,6 +84,9 @@ OperatorSchema.statics.findAllIdApp = function (idapp) {
const myfind = { idapp };
+ // Extract only the Teacher where in the users table the field permissions is set 'Teacher' bit.
+
+
return Operator.find(myfind, (err, arrrec) => {
return arrrec
});
diff --git a/server/models/user.js b/server/models/user.js
index 927a348..051cd12 100644
--- a/server/models/user.js
+++ b/server/models/user.js
@@ -34,6 +34,9 @@ var UserSchema = new mongoose.Schema({
message: '{VALUE} is not a valid email'
}*/
},
+ cell: {
+ type: String,
+ },
idapp: {
type: String,
required: true,
@@ -359,7 +362,7 @@ UserSchema.statics.getUsersListByParams = function (params) {
*/
UserSchema.statics.getFieldsForSearch = function () {
- return ['name', 'surname', 'email']
+ return ['name', 'surname', 'email', 'cell']
};
UserSchema.statics.executeQueryTable = function (idapp, params) {
diff --git a/server/router/index_router.js b/server/router/index_router.js
index fe0c0e7..ec44dba 100644
--- a/server/router/index_router.js
+++ b/server/router/index_router.js
@@ -208,7 +208,7 @@ router.patch('/chval', authenticate, (req, res) => {
const mytable = getTableByTableName(mydata.table);
const fieldsvalue = mydata.fieldsvalue;
- tools.mylogshow('PATCH CHVAL: ', id);
+ tools.mylogshow('PATCH CHVAL: ', id, fieldsvalue);
if (!User.isAdmin(req.user) && !User.isManager(req.user)) {
// If without permissions, exit
diff --git a/server/router/newsletter_router.js b/server/router/newsletter_router.js
index 4de22a5..85342d7 100644
--- a/server/router/newsletter_router.js
+++ b/server/router/newsletter_router.js
@@ -4,6 +4,8 @@ const express = require('express');
const router = express.Router();
const request = require('superagent');
+const sendemail = require('../sendemail');
+
const newsletter = [
{
name: 'Paolo',
@@ -41,8 +43,17 @@ const newsletter = [
router.post('/', (req, res) => {
idwebsite = req.body.idwebsite;
+ idapp = req.body.idapp;
locale = req.body.locale;
+ const user = {
+ email: req.body.email,
+ name: req.body.firstName,
+ surname: req.body.lastName,
+ };
+
+ sendemail.sendEmail_Newsletter(locale, user, idapp);
+
request
.post('https://' + newsletter[idwebsite].mailchimpInstance + '.api.mailchimp.com/3.0/lists/' + newsletter[idwebsite].listUniqueId + '/members/')
.set('Content-Type', 'application/json;charset=utf-8')
diff --git a/server/sendemail.js b/server/sendemail.js
index f759706..3a6d1c4 100644
--- a/server/sendemail.js
+++ b/server/sendemail.js
@@ -30,7 +30,7 @@ function checkifSendEmail() {
module.exports = {
- sendEmail_base: function (template, user, to, mylocalsconf, replyTo) {
+ sendEmail_base: function (template, to, mylocalsconf, replyTo) {
console.log('mylocalsconf', mylocalsconf);
@@ -135,13 +135,13 @@ module.exports = {
emailto: emailto,
};
- this.sendEmail_base('registration/' + lang, user, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
+ this.sendEmail_base('registration/' + lang, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
// Send to the Admin an Email
- this.sendEmail_base('admin/registration/' + lang, user, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
+ this.sendEmail_base('admin/registration/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
if (tools.isManagAndAdminDifferent(idapp)) {
- this.sendEmail_base('admin/registration/' + lang, user, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
+ this.sendEmail_base('admin/registration/' + lang, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
}
},
sendEmail_RequestNewPassword: function (lang, emailto, idapp, tokenforgot) {
@@ -154,7 +154,7 @@ module.exports = {
emailto: emailto,
};
- this.sendEmail_base('resetpwd/' + lang, user, emailto, mylocalsconf, '');
+ this.sendEmail_base('resetpwd/' + lang, emailto, mylocalsconf, '');
},
sendEmail_Booking: function (res, lang, emailto, user, idapp, recbooking) {
@@ -184,13 +184,13 @@ module.exports = {
texthtml = 'makebooking';
}
- this.sendEmail_base('booking/'+texthtml+'/' + lang, user, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
+ this.sendEmail_base('booking/'+texthtml+'/' + lang, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
// Send Email also to the Admin
- this.sendEmail_base('admin/'+texthtml+'/' + lang, user, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
+ this.sendEmail_base('admin/'+texthtml+'/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
if (tools.isManagAndAdminDifferent(idapp)) {
- this.sendEmail_base('admin/'+texthtml+'/' + lang, user, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
+ this.sendEmail_base('admin/'+texthtml+'/' + lang, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
}
},
@@ -213,13 +213,13 @@ module.exports = {
if (recbooking.numpeople > 1)
mylocalsconf.participants = recbooking.numpeople.toString() + ' ' + res.__("partecipanti");
- this.sendEmail_base('booking/cancelbooking/' + lang, user, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
+ this.sendEmail_base('booking/cancelbooking/' + lang, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
// Send Email also to the Admin
- this.sendEmail_base('admin/cancelbooking/' + lang, user, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
+ this.sendEmail_base('admin/cancelbooking/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
if (tools.isManagAndAdminDifferent(idapp)) {
- this.sendEmail_base('admin/cancelbooking/' + lang, user, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
+ this.sendEmail_base('admin/cancelbooking/' + lang, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
}
},
@@ -240,10 +240,29 @@ module.exports = {
strlinkreply: tools.getHostByIdApp(idapp) + '/messages/' + recmsg._id
};
- return this.sendEmail_base('msg/sendmsg/' + lang, user, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
+ return this.sendEmail_base('msg/sendmsg/' + lang, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
// Send Email also to the Admin
- // this.sendEmail_base('admin/sendmsg/' + lang, user, tools.getAdminEmailByIdApp(idapp), mylocalsconf);
+ // this.sendEmail_base('admin/sendmsg/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf);
+ },
+ sendEmail_Newsletter: function (lang, user, idapp) {
+
+ console.log('idapp', idapp, tools.getNomeAppByIdApp(idapp));
+
+ mylocalsconf = {
+ locale: lang,
+ nomeapp: tools.getNomeAppByIdApp(idapp),
+ name: user.name,
+ surname: user.surname,
+ emailto: user.email,
+ };
+
+ // Send to the Admin an Email
+ this.sendEmail_base('admin/added_to_newsletter/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
+
+ if (tools.isManagAndAdminDifferent(idapp)) {
+ this.sendEmail_base('admin/added_to_newsletter/' + lang, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
+ }
},
diff --git a/server/tools/shared_nodejs.js b/server/tools/shared_nodejs.js
index 1943a0b..812acd6 100644
--- a/server/tools/shared_nodejs.js
+++ b/server/tools/shared_nodejs.js
@@ -1,9 +1,9 @@
module.exports = {
Permissions: {
- Normal: 0,
Admin: 1,
Manager: 2,
+ Teacher: 4,
},
MessageOptions: {
@@ -12,7 +12,7 @@ module.exports = {
},
fieldsUserToChange() {
- return ['username', 'email', 'name', 'surname', 'perm', 'date_reg', 'verified_email', 'img', 'ipaddr', 'lasttimeonline']
+ return ['username', 'email', 'cell', 'name', 'surname', 'perm', 'date_reg', 'verified_email', 'img', 'ipaddr', 'lasttimeonline']
}
};