diff --git a/emails/admin/iscrizione_conacreis/it/html.pug b/emails/admin/iscrizione_conacreis/it/html.pug
index 90bb294..7fc88d7 100755
--- a/emails/admin/iscrizione_conacreis/it/html.pug
+++ b/emails/admin/iscrizione_conacreis/it/html.pug
@@ -24,6 +24,8 @@ span Cellulare:
strong #{iscritto.cell_phone}
span Abilita le Newsletter? :
strong #{iscritto.newsletter_on}
+span Metodo di Pagamento :
+ strong #{metodo_pagamento}
p
Saluti
style(type="text/css").
diff --git a/src/server/models/cash.js b/src/server/models/cash.js
new file mode 100755
index 0000000..4c91d04
--- /dev/null
+++ b/src/server/models/cash.js
@@ -0,0 +1,127 @@
+const mongoose = require('mongoose');
+const Schema = mongoose.Schema;
+
+const tools = require('../tools/general');
+
+const { ObjectID } = require('mongodb');
+
+mongoose.Promise = global.Promise;
+mongoose.level = "F";
+
+
+// Resolving error Unknown modifier: $pushAll
+mongoose.plugin(schema => {
+ schema.options.usePushEach = true
+});
+
+const CashSchema = new Schema({
+ idapp: {
+ type: String,
+ },
+ creatorUserId: {
+ type: String,
+ },
+ idCashCategory: {
+ type: String
+ },
+ idSubCashCategory: {
+ type: String
+ },
+ type: { // CashType: TYPE_IN, TYPE_OUT
+ type: Number
+ },
+ date_created: {
+ type: Date
+ },
+ date_payment: {
+ type: Date
+ },
+ descr: {
+ type: String,
+ },
+ price: {
+ type: Number
+ },
+ quantity: {
+ type: Number
+ },
+ total: {
+ type: Number
+ },
+ fromWalletUserId: { // walletCommonCash or any Member
+ type: String,
+ },
+ toWalletUserId: { // walletCommonCash or any Member
+ type: String,
+ },
+ walletStatus: { // WalletFinalStatusType: None: 0, InCommonCash: 1, InMyWallet : 2
+ type: Number,
+ },
+ walletTemporaryToUserId: { // WalletCommonCash
+ type: String,
+ },
+ walletCashId: {
+ type: String,
+ },
+ internal: {
+ type: Boolean,
+ default: false,
+ },
+ extra: {
+ type: Boolean,
+ default: false,
+ },
+ notes: {
+ type: String
+ },
+ confirmed: {
+ type: Boolean,
+ default: false,
+ },
+});
+
+var Cash = module.exports = mongoose.model('Cash', CashSchema);
+
+module.exports.getFieldsForSearch = function () {
+ return []
+};
+
+module.exports.executeQueryTable = function (idapp, params) {
+ params.fieldsearch = this.getFieldsForSearch();
+ return tools.executeQueryTable(this, idapp, params);
+};
+
+module.exports.findAllIdApp = async function (idapp) {
+ const myfind = { idapp };
+
+ return await Cash.find(myfind);
+};
+
+module.exports.getAllCash = function (query, sort, callback) {
+ Cash.find(query, null, sort, callback)
+}
+
+module.exports.getCashByUserId = function (userId, sort, callback) {
+ Cash.find({ userId }, null, sort, callback)
+}
+
+
+module.exports.getCashByID = function (id, callback) {
+ Cash.findById(id, callback);
+}
+
+module.exports.createCash = async function (Cash) {
+ const CashModel = new Cash(Cash);
+
+ return await CashModel.save(Cash)
+ .then((ris) => {
+ if (!!ris)
+ return ris._id;
+ return null;
+ });
+}
+
+
+// const Cash = mongoose.model('Cash', CashSchema);
+
+// module.exports = { Cash };
diff --git a/src/server/models/cashCategory.js b/src/server/models/cashCategory.js
new file mode 100755
index 0000000..1e18168
--- /dev/null
+++ b/src/server/models/cashCategory.js
@@ -0,0 +1,68 @@
+const mongoose = require('mongoose');
+const Schema = mongoose.Schema;
+
+const tools = require('../tools/general');
+
+const { ObjectID } = require('mongodb');
+
+mongoose.Promise = global.Promise;
+mongoose.level = "F";
+
+
+// Resolving error Unknown modifier: $pushAll
+mongoose.plugin(schema => {
+ schema.options.usePushEach = true
+});
+
+const CashCategorySchema = new Schema({
+ idapp: {
+ type: String,
+ },
+ descr: {
+ type: String,
+ },
+ notes: {
+ type: String
+ },
+});
+
+var CashCategory = module.exports = mongoose.model('CashCategory', CashCategorySchema);
+
+module.exports.getFieldsForSearch = function () {
+ return []
+};
+
+module.exports.executeQueryTable = function (idapp, params) {
+ params.fieldsearch = this.getFieldsForSearch();
+ return tools.executeQueryTable(this, idapp, params);
+};
+
+module.exports.findAllIdApp = async function (idapp) {
+ const myfind = { idapp };
+
+ return await CashCategory.find(myfind);
+};
+
+module.exports.getAllCashCategory = function (query, sort, callback) {
+ CashCategory.find(query, null, sort, callback)
+}
+
+module.exports.getCashCategoryByUserId = function (userId, sort, callback) {
+ CashCategory.find({ userId }, null, sort, callback)
+}
+
+
+module.exports.getCashCategoryByID = function (id, callback) {
+ CashCategory.findById(id, callback);
+}
+
+module.exports.createCashCategory = async function (CashCategory) {
+ const CashCategoryModel = new CashCategory(CashCategory);
+
+ return await CashCategoryModel.save(CashCategory)
+ .then((ris) => {
+ if (!!ris)
+ return ris._id;
+ return null;
+ });
+}
diff --git a/src/server/models/cashSubCategory.js b/src/server/models/cashSubCategory.js
new file mode 100755
index 0000000..a6db744
--- /dev/null
+++ b/src/server/models/cashSubCategory.js
@@ -0,0 +1,71 @@
+const mongoose = require('mongoose');
+const Schema = mongoose.Schema;
+
+const tools = require('../tools/general');
+
+const { ObjectID } = require('mongodb');
+
+mongoose.Promise = global.Promise;
+mongoose.level = "F";
+
+
+// Resolving error Unknown modifier: $pushAll
+mongoose.plugin(schema => {
+ schema.options.usePushEach = true
+});
+
+const CashSubCategorySchema = new Schema({
+ idapp: {
+ type: String,
+ },
+ idCashCategory: {
+ type: String,
+ },
+ descr: {
+ type: String,
+ },
+ notes: {
+ type: String
+ },
+});
+
+var CashSubCategory = module.exports = mongoose.model('CashSubCategory', CashSubCategorySchema);
+
+module.exports.getFieldsForSearch = function () {
+ return []
+};
+
+module.exports.executeQueryTable = function (idapp, params) {
+ params.fieldsearch = this.getFieldsForSearch();
+ return tools.executeQueryTable(this, idapp, params);
+};
+
+module.exports.findAllIdApp = async function (idapp) {
+ const myfind = { idapp };
+
+ return await CashSubCategory.find(myfind);
+};
+
+module.exports.getAllCashSubCategory = function (query, sort, callback) {
+ CashSubCategory.find(query, null, sort, callback)
+}
+
+module.exports.getCashSubCategoryByUserId = function (userId, sort, callback) {
+ CashSubCategory.find({ userId }, null, sort, callback)
+}
+
+
+module.exports.getCashSubCategoryByID = function (id, callback) {
+ CashSubCategory.findById(id, callback);
+}
+
+module.exports.createCashSubCategory = async function (CashSubCategory) {
+ const CashSubCategoryModel = new CashSubCategory(CashSubCategory);
+
+ return await CashSubCategoryModel.save(CashSubCategory)
+ .then((ris) => {
+ if (!!ris)
+ return ris._id;
+ return null;
+ });
+}
diff --git a/src/server/models/iscrittiConacreis.js b/src/server/models/iscrittiConacreis.js
index 96d44c8..9513ee3 100755
--- a/src/server/models/iscrittiConacreis.js
+++ b/src/server/models/iscrittiConacreis.js
@@ -57,24 +57,39 @@ const IscrittiConacreisSchema = new Schema({
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,
},
newsletter_on: {
type: Boolean,
},
- accetta_carta_costituzionale_on: {
- type: Boolean,
- },
terms: {
type: Boolean,
},
+ metodo_pagamento: {
+ type: Number,
+ },
iscrizione_compilata: {
type: Boolean,
},
dateofreg: {
type: Date,
},
+ dateofapproved: {
+ type: Date,
+ },
codiceConacreis: {
type: String,
},
diff --git a/src/server/models/myevent.js b/src/server/models/myevent.js
index 899917b..52390d5 100755
--- a/src/server/models/myevent.js
+++ b/src/server/models/myevent.js
@@ -112,6 +112,9 @@ const MyEventSchema = new Schema({
internal: {
type: Boolean,
},
+ note: {
+ type: String,
+ },
deleted: {
type: Boolean,
},
diff --git a/src/server/models/user.js b/src/server/models/user.js
index 7181adf..9b56c9e 100755
--- a/src/server/models/user.js
+++ b/src/server/models/user.js
@@ -270,6 +270,9 @@ const UserSchema = new mongoose.Schema({
come_ci_hai_conosciuto: {
type: Boolean,
},
+ socio: {
+ type: Boolean,
+ },
socioresidente: {
type: Boolean,
},
@@ -1445,7 +1448,7 @@ UserSchema.statics.isAdminByIdTeleg = async function (idapp, idtelegram) {
return await User.findOne({
idapp,
- username: 'paoloar77',
+ username: 'paoloarcnm',
'profile.manage_telegram': true,
'profile.teleg_id': idtelegram
}, { 'profile.teleg_id': 1 })
diff --git a/src/server/router/booking_router.js b/src/server/router/booking_router.js
index a9a4dbb..a1edaf9 100755
--- a/src/server/router/booking_router.js
+++ b/src/server/router/booking_router.js
@@ -40,7 +40,7 @@ router.post('/', authenticate, (req, res) => {
// console.log('fieldtochange', fieldtochange);
// Modify:
- return Booking.findOne({ id_bookedevent: id })
+ return Booking.findOne({ id_bookedevent: id, userId: req.user._id })
.then(trovato => {
// console.log('trovato', trovato);
if (trovato) {
diff --git a/src/server/router/index_router.js b/src/server/router/index_router.js
index ac9a382..53e609c 100755
--- a/src/server/router/index_router.js
+++ b/src/server/router/index_router.js
@@ -64,6 +64,9 @@ const Group = require('../models/group');
const { Todo } = require('../models/todo');
const Hours = require('../models/hours');
const Order = require('../models/order');
+const Cash = require('../models/cash');
+const CashCategory = require('../models/cashCategory');
+const CashSubCategory = require('../models/cashSubCategory');
const tools = require('../tools/general');
@@ -224,6 +227,12 @@ function getTableByTableName(tablename) {
mytable = Hours;
else if (tablename === 'orders')
mytable = Order;
+ else if (tablename === 'cashs')
+ mytable = Cash;
+ else if (tablename === 'cashCategorys')
+ mytable = CashCategory;
+ else if (tablename === 'cashSubCategorys')
+ mytable = CashSubCategory;
else if (tablename === 'producers')
mytable = Producer;
else if (tablename === 'carts')
@@ -1124,10 +1133,10 @@ router.post('/duprec/:table/:id', authenticate, (req, res) => {
});
-router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) => {
+router.get('/loadsite/:userId/:idapp', authenticate_noerror, (req, res) => {
const userId = req.params.userId;
const idapp = req.params.idapp;
- const sall = req.params.sall;
+ const sall = (User.isAdmin(req.user.perm) || User.isManager(req.user.perm) || User.isEditor(req.user.perm)) ? '1' : '0'
// var category = req.params.category;
@@ -1255,9 +1264,9 @@ router.get(process.env.LINK_CHECK_UPDATES, authenticate, async (req, res) => {
if (req.user) {
// If User is Admin, then send user Lists
- if (User.isAdmin(req.user.perm)) {
+ if (User.isAdmin(req.user.perm) || User.isEditor(req.user.perm) || User.isManager(req.user.perm)) {
// Send UsersList
- // usersList = User.getUsersList(req.user.idapp)
+ usersList = User.getUsersList(req.user.idapp);
// usersList = null;
}
}
diff --git a/src/server/router/iscrittiConacreis_router.js b/src/server/router/iscrittiConacreis_router.js
index f190d2a..86e9aa0 100755
--- a/src/server/router/iscrittiConacreis_router.js
+++ b/src/server/router/iscrittiConacreis_router.js
@@ -25,7 +25,7 @@ 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']);
+ const body = req.body;
body.email = body.email.toLowerCase();
const iscritti = new IscrittiConacreis(body);
@@ -67,7 +67,7 @@ router.post('/', async (req, res) => {
}
}
- return await iscritti.save()
+ return iscritti.save()
.then(async () => {
await sendemail.sendEmail_IscrizioneConacreis(iscritti.lang, iscritti.email, iscritti, iscritti.idapp);
// }
diff --git a/src/server/router/projects_router.js b/src/server/router/projects_router.js
index 5629311..4bacdfd 100755
--- a/src/server/router/projects_router.js
+++ b/src/server/router/projects_router.js
@@ -46,9 +46,8 @@ router.post('/', authenticate, (req, res) => {
let idobj = writeresult._id;
Project.findById(idobj)
.then(record => {
- // tools.mylog('REC SAVED :', record.descr);
- tools.sendNotificationToUser(record.userId, titolo + ' ' + record.descr, record.descr, '/todo/' + record._id, '', 'todo', [])
+ tools.sendNotificationToUser(record.userId, '[Progetto]: ' + record.descr, record.descr, '/todo/' + record._id, '', 'todo', [])
res.send({ record: record._doc });
diff --git a/src/server/router/users_router.js b/src/server/router/users_router.js
index 8bd68ea..6ca349f 100755
--- a/src/server/router/users_router.js
+++ b/src/server/router/users_router.js
@@ -293,94 +293,6 @@ router.post('/', async (req, res) => {
})
});
-// 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);
- })
-});
-
router.get('/:idapp/:username', async (req, res) => {
var username = req.params.username;
const idapp = req.params.idapp;
diff --git a/src/server/sendemail.js b/src/server/sendemail.js
index 207e43c..4517a69 100755
--- a/src/server/sendemail.js
+++ b/src/server/sendemail.js
@@ -210,6 +210,7 @@ module.exports = {
surname: iscritto.surname,
emailto: emailto,
iscritto,
+ metodo_pagamento: tools.getPaymentTypesById(iscritto.metodo_pagamento)
};
this.sendEmail_base('iscrizione_conacreis/' + lang, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
diff --git a/src/server/telegram/telegrambot.js b/src/server/telegram/telegrambot.js
index ec6c1ff..01e51c0 100755
--- a/src/server/telegram/telegrambot.js
+++ b/src/server/telegram/telegrambot.js
@@ -266,7 +266,7 @@ const MenuNoLogin = {
enUs: { menu: [[Menu.LANG], [Menu.enUs.ASSISTENZA]] },
};
-const MenuStandard = {
+const MenuStandard_AYNI = {
it: { menu: [[Menu.it.LAVAGNA, Menu.it.LINK_CONDIVIDERE], [Menu.it.ZOOM, Menu.it.ASSISTENZA], [Menu.LANG]] },
es: { menu: [[Menu.es.LAVAGNA, Menu.es.LINK_CONDIVIDERE], [Menu.es.ZOOM, Menu.es.ASSISTENZA], [Menu.LANG]] },
fr: { menu: [[Menu.fr.LAVAGNA, Menu.fr.LINK_CONDIVIDERE], [Menu.fr.ZOOM, Menu.fr.ASSISTENZA], [Menu.LANG]] },
diff --git a/src/server/tools/general.js b/src/server/tools/general.js
index d1fb788..185f12a 100755
--- a/src/server/tools/general.js
+++ b/src/server/tools/general.js
@@ -1974,6 +1974,10 @@ module.exports = {
this.loadApps();
return this.MYAPPS;
- }
+ },
+
+ getPaymentTypesById(idmetodo) {
+ return shared_consts.PaymentTypes[idmetodo]
+ },
};
diff --git a/src/server/tools/shared_nodejs.js b/src/server/tools/shared_nodejs.js
index cc7f394..8bf24d9 100755
--- a/src/server/tools/shared_nodejs.js
+++ b/src/server/tools/shared_nodejs.js
@@ -29,6 +29,25 @@ module.exports = {
REPORT_FILT_RESP: 1,
REPORT_FILT_ATTIVITA: 2,
+ PaymentTypes: [
+ 'Nessuno',
+ 'Bonifico Bancario',
+ 'Paypal',
+ 'In Contanti alla CNM'
+ ],
+
+ CashType: {
+ None: 0,
+ Incoming: 1,
+ Outcoming: 2,
+ },
+
+ WalletFinalStatusType: {
+ None: 0,
+ InCommonCash: 1,
+ InMyWallet: 2,
+ },
+
Permissions: {
Admin: 1,
Manager: 2,