- Iscrizione Conacreis
This commit is contained in:
@@ -24,6 +24,8 @@ span Cellulare:
|
||||
strong #{iscritto.cell_phone}<br>
|
||||
span Abilita le Newsletter? :
|
||||
strong #{iscritto.newsletter_on}<br>
|
||||
span Metodo di Pagamento :
|
||||
strong #{metodo_pagamento}<br>
|
||||
p <br>Saluti
|
||||
|
||||
style(type="text/css").
|
||||
|
||||
127
src/server/models/cash.js
Executable file
127
src/server/models/cash.js
Executable file
@@ -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 };
|
||||
68
src/server/models/cashCategory.js
Executable file
68
src/server/models/cashCategory.js
Executable file
@@ -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;
|
||||
});
|
||||
}
|
||||
71
src/server/models/cashSubCategory.js
Executable file
71
src/server/models/cashSubCategory.js
Executable file
@@ -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;
|
||||
});
|
||||
}
|
||||
@@ -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,
|
||||
},
|
||||
|
||||
@@ -112,6 +112,9 @@ const MyEventSchema = new Schema({
|
||||
internal: {
|
||||
type: Boolean,
|
||||
},
|
||||
note: {
|
||||
type: String,
|
||||
},
|
||||
deleted: {
|
||||
type: Boolean,
|
||||
},
|
||||
|
||||
@@ -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 })
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
// }
|
||||
|
||||
@@ -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 });
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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]] },
|
||||
|
||||
@@ -1974,6 +1974,10 @@ module.exports = {
|
||||
this.loadApps();
|
||||
|
||||
return this.MYAPPS;
|
||||
}
|
||||
},
|
||||
|
||||
getPaymentTypesById(idmetodo) {
|
||||
return shared_consts.PaymentTypes[idmetodo]
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user