- catalogo
- corretto logica del RefreshToken che non richiedeva il nuovo token, quindi scadeva tutte le volte, richiedendo sempre l'accesso !
This commit is contained in:
@@ -51,8 +51,11 @@
|
||||
"FRIEND_UNBLOCKED_YOU": "Hai riattivato %s.",
|
||||
"CIRCUIT_ACCEPT_NEWENTRY": "❇️👥 🧍♂️ Abilita Fiducia a %s nel '%s':",
|
||||
"CIRCUIT_ACCEPT_NEWENTRY_BYGROUP": "❇️👥 🧍♂️ Abilita Fiducia nel Circuito al gruppo %s:",
|
||||
"CIRCUIT_ACCEPT_NEWENTRY_CIRC": "❇️👥 🧍♂️ Fai entrare a %s nel '%s':",
|
||||
"CIRCUIT_ACCEPT_NEWENTRY_BYGROUP_CIRC": "❇️👥 🧍♂️ Fai entrare nel Circuito al gruppo %s:",
|
||||
"CIRCUIT_OPEN_RISITALIA": "Apri il Circuito RIS Italia e chiedi di entrare",
|
||||
"CIRCUIT_REQUEST_TO_ENTER": "%s è entrato nel %s (con %s iscritti) ed è in attesa di essere abilitato alla Fiducia\n🙎🏻♂️ Invitato da %s",
|
||||
"CIRCUIT_REQUEST_TO_ENTER_ASKMANAGER": "%s ha fatto richiesta di entrare nel %s (con %s iscritti)\n🙎🏻♂️ Invitato da %s",
|
||||
"CIRCUIT_ADMINS": "Gli amministratori del circuito sono %s:\n%s",
|
||||
"CIRCUIT_WHERE_IS_PRESENT": "\nAttualmente è presente in: %s",
|
||||
"CIRCUIT_REQUEST_TO_ENTER_WITH_GROUP": "il gruppo %s ha chiesto di entrare nel %s (con %s iscritti)",
|
||||
|
||||
@@ -63,7 +63,7 @@ const authenticate = (req, res, next) => {
|
||||
|
||||
}).catch((e) => {
|
||||
if (e === server_constants.RIS_CODE_HTTP_FORBIDDEN_TOKEN_EXPIRED) {
|
||||
return res.status(server_constants.RIS_CODE_HTTP_FORBIDDEN_TOKEN_EXPIRED).send();
|
||||
return res.status(server_constants.RIS_CODE_HTTP_FORBIDDEN_TOKEN_EXPIRED).send();
|
||||
}
|
||||
tools.mylog("ERR authenticate invalid Token =", e);
|
||||
res.status(server_constants.RIS_CODE_HTTP_INVALID_TOKEN).send();
|
||||
@@ -90,14 +90,18 @@ const authenticate_noerror = (req, res, next) => {
|
||||
req.access = access;
|
||||
req.code = ris.code;
|
||||
}
|
||||
// Vai avanti ad eseguire il codice, in ogni modo !
|
||||
next();
|
||||
if (ris.code === server_constants.RIS_CODE_HTTP_FORBIDDEN_TOKEN_EXPIRED) {
|
||||
return res.status(server_constants.RIS_CODE_HTTP_FORBIDDEN_TOKEN_EXPIRED).send();
|
||||
} else {
|
||||
// Vai avanti ad eseguire il codice, in ogni modo !
|
||||
next();
|
||||
}
|
||||
}).catch((e) => {
|
||||
req.user = null;
|
||||
req.token = null;
|
||||
req.access = null;
|
||||
req.code = 0;
|
||||
|
||||
|
||||
// Continua comunque !
|
||||
next();
|
||||
});
|
||||
|
||||
@@ -235,11 +235,11 @@ AccountSchema.statics.addtoSaldo = async function (myaccount, amount, mitt) {
|
||||
myaccount.totTransato = 0;
|
||||
}
|
||||
myaccount.totTransato += Math.abs(amount);
|
||||
|
||||
|
||||
if (!myaccount.numtransactions)
|
||||
myaccount.numtransactions = 0;
|
||||
myaccount.numtransactions++;
|
||||
|
||||
|
||||
myaccount.date_updated = new Date();
|
||||
|
||||
myaccountupdate.saldo = myaccount.saldo;
|
||||
@@ -255,7 +255,9 @@ AccountSchema.statics.addtoSaldo = async function (myaccount, amount, mitt) {
|
||||
// Calcola Saldo Pendente !
|
||||
await myaccount.calcPending(true);
|
||||
|
||||
return ris;
|
||||
const recupdated = await Account.findOne({ _id: myaccount.id });
|
||||
|
||||
return recupdated;
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -322,8 +324,9 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp,
|
||||
});
|
||||
|
||||
if (contocom) {
|
||||
myaccount.fidoConcesso = shared_consts.CIRCUIT_PARAMS.SCOPERTO_MIN_CONTO_COMUNITARIO;
|
||||
myaccount.qta_maxConcessa = shared_consts.CIRCUIT_PARAMS.SCOPERTO_MAX_CONTO_COMUNITARIO;
|
||||
myaccount.fidoConcesso = mycircuit.fido_scoperto_default_contocom || shared_consts.CIRCUIT_PARAMS.SCOPERTO_MIN_CONTO_COMUNITARIO;
|
||||
myaccount.qta_maxConcessa = mycircuit.qta_max_default_contocom || shared_consts.CIRCUIT_PARAMS.SCOPERTO_MAX_CONTO_COMUNITARIO;
|
||||
|
||||
} else {
|
||||
if (!mycircuit.fido_scoperto_default_grp)
|
||||
mycircuit.fido_scoperto_default_grp = shared_consts.CIRCUIT_PARAMS.SCOPERTO_MIN_GRP;
|
||||
@@ -343,7 +346,13 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp,
|
||||
myaccount.fidoConcesso = 0;
|
||||
}
|
||||
|
||||
return await myaccount.save();
|
||||
let acc = await myaccount.save();
|
||||
|
||||
if (mycircuit.creditodiPartenza && mycircuit.creditodiPartenza > 0) {
|
||||
acc = await Account.addtoSaldo(acc, mycircuit.creditodiPartenza, false);
|
||||
}
|
||||
|
||||
return acc;
|
||||
}
|
||||
|
||||
return myaccount;
|
||||
@@ -605,8 +614,12 @@ AccountSchema.statics.SetMinMaxPersonali = async function (idapp, fidoConcesso,
|
||||
}
|
||||
});
|
||||
|
||||
// Se aggiorno questi dati, allora devo aggiornare anche gli account del RIS Nazionale
|
||||
await Account.updateAccountCircuitoNazionaleByLimiti(idapp, circuitId, fidoConcesso, qta_maxConcessa);
|
||||
const circuit = await Circuit.findOne({ _id: circuitId });
|
||||
|
||||
if (!circuit.circuitoIndipendente) {
|
||||
// Se aggiorno questi dati, e non è un Circuito Indipendente, allora devo aggiornare anche gli account del RIS Nazionale
|
||||
await Account.updateAccountCircuitoNazionaleByLimiti(idapp, circuitId, fidoConcesso, qta_maxConcessa);
|
||||
}
|
||||
|
||||
} else {
|
||||
const ris = await Account.updateMany({ idapp, fidoConcesso: { $gt: 0 }, username: { "$nin": [null, ""] } },
|
||||
@@ -690,9 +703,9 @@ AccountSchema.statics.updateAccountCircuitoNazionaleByLimiti = async function (i
|
||||
} catch (e) {
|
||||
console.error('updateAccountCircuitoNazionaleByLimiti', e);
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
};
|
||||
|
||||
AccountSchema.statics.canEditAccountAdmins = async function (username, id) {
|
||||
@@ -736,7 +749,7 @@ AccountSchema.statics.removeAdminOfAccount = async function (idapp, username, ci
|
||||
// Rimuovi l'account
|
||||
AccountSchema.statics.removeAccount = async function (accountId) {
|
||||
|
||||
return await Account.deleteOne({ _id: accountId});
|
||||
return await Account.deleteOne({ _id: accountId });
|
||||
};
|
||||
|
||||
AccountSchema.statics.updateSaldoAndTransato_AllAccounts = async function (idapp) {
|
||||
|
||||
@@ -19,6 +19,9 @@ const CatProdSchema = new Schema({
|
||||
name: {
|
||||
type: String,
|
||||
},
|
||||
descr_estesa: {
|
||||
type: String,
|
||||
},
|
||||
img: {
|
||||
type: String,
|
||||
},
|
||||
|
||||
@@ -229,6 +229,22 @@ const CircuitSchema = new Schema({
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
askManagerToEnter: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
sendEmailAfterAskingToEnter: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
circuitoIndipendente: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
creditodiPartenza: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
});
|
||||
|
||||
CircuitSchema.pre('save', async function (next) {
|
||||
@@ -300,8 +316,15 @@ CircuitSchema.statics.getWhatToShow = function (idapp, username) {
|
||||
qta_max_default: 1,
|
||||
fido_scoperto_default_grp: 1,
|
||||
qta_max_default_grp: 1,
|
||||
fido_scoperto_default_contocom: 1,
|
||||
qta_max_default_contocom: 1,
|
||||
deperimento: 1,
|
||||
showAlways: 1,
|
||||
ignoreLimits: 1,
|
||||
askManagerToEnter: 1,
|
||||
sendEmailAfterAskingToEnter: 1,
|
||||
circuitoIndipendente: 1,
|
||||
creditodiPartenza: 1,
|
||||
transactionsEnabled: 1,
|
||||
status: 1,
|
||||
valuta_per_euro: 1,
|
||||
@@ -359,6 +382,11 @@ CircuitSchema.statics.getWhatToShow_Unknown = function (idapp, username) {
|
||||
regulation: 1,
|
||||
numMembers: 1,
|
||||
showAlways: 1,
|
||||
ignoreLimits: 1,
|
||||
askManagerToEnter: 1,
|
||||
sendEmailAfterAskingToEnter: 1,
|
||||
circuitoIndipendente: 1,
|
||||
creditodiPartenza: 1,
|
||||
systemUserId: 1,
|
||||
founderUserId: 1,
|
||||
nome_valuta: 1,
|
||||
@@ -367,6 +395,8 @@ CircuitSchema.statics.getWhatToShow_Unknown = function (idapp, username) {
|
||||
fido_scoperto_default: 1,
|
||||
fido_scoperto_default_grp: 1,
|
||||
qta_max_default_grp: 1,
|
||||
fido_scoperto_default_contocom: 1,
|
||||
qta_max_default_contocom: 1,
|
||||
qta_max_default: 1,
|
||||
valuta_per_euro: 1,
|
||||
symbol: 1,
|
||||
@@ -1093,6 +1123,9 @@ CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, prov
|
||||
totCircolante: 0,
|
||||
date_created: new Date(),
|
||||
admins: [{ username: useradmin }],
|
||||
askManagerToEnter: false,
|
||||
sendEmailAfterAskingToEnter: false,
|
||||
circuitoIndipendente: false,
|
||||
});
|
||||
|
||||
myrec = await circ.save();
|
||||
|
||||
60
src/server/models/collana.js
Executable file
60
src/server/models/collana.js
Executable file
@@ -0,0 +1,60 @@
|
||||
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 CollanaSchema = new Schema({
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
idCollana: {
|
||||
type: Number,
|
||||
},
|
||||
descrizione: {
|
||||
type: String,
|
||||
},
|
||||
Descrizione_Estesa: {
|
||||
type: String,
|
||||
},
|
||||
dataOra: {
|
||||
type: Date,
|
||||
},
|
||||
enabled: {
|
||||
type: Boolean,
|
||||
},
|
||||
enabledAlFresco: {
|
||||
type: Boolean,
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
var Collana = module.exports = mongoose.model('Collana', CollanaSchema);
|
||||
|
||||
module.exports.getFieldsForSearch = function () {
|
||||
return [
|
||||
{ field: 'descrizione', type: tools.FieldType.string },
|
||||
]
|
||||
};
|
||||
|
||||
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 Collana.find(myfind).sort({name: 1, surname: 1});
|
||||
};
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
@@ -58,8 +58,11 @@ const catalogo = new Schema(
|
||||
//++AddCATALOGO_FIELDS
|
||||
productTypes: [{ type: Number }],
|
||||
excludeproductTypes: [{ type: Number }],
|
||||
Editore: [{ type: String }],
|
||||
sort: { type: Number },
|
||||
editore: [{ type: String }],
|
||||
argomenti: [{ type: String }],
|
||||
idCollana: { type: Number },
|
||||
sort_field: { type: String },
|
||||
sort_dir: { type: Number },
|
||||
pdf: { type: Boolean },
|
||||
pdf_filename: { type: String },
|
||||
printable: { type: Boolean },
|
||||
@@ -282,7 +285,7 @@ MyElemSchema.statics.SetIdPageInsteadThePah = async function (idapp) {
|
||||
for (const [path, id] of Object.entries(pathToIdMap)) {
|
||||
if (path) {
|
||||
await MyElem.updateMany(
|
||||
{ idapp },
|
||||
{ idapp },
|
||||
{ path: path }, // Condizione per aggiornare dove il path corrisponde
|
||||
{
|
||||
$set: {
|
||||
@@ -329,7 +332,7 @@ MyElemSchema.statics.SetIdPageInsteadThePah = async function (idapp) {
|
||||
|
||||
for (const [oldpath, id] of Object.entries(pathToIdMap2)) {
|
||||
await MyElem.updateMany(
|
||||
{ idapp },
|
||||
{ idapp },
|
||||
{ oldpath: oldpath }, // Condizione per aggiornare dove il path corrisponde
|
||||
{
|
||||
$set: { idPage: id }
|
||||
@@ -358,7 +361,7 @@ MyElemSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
const arrrec = await MyElem.find(myfind).sort({ order: 1 });
|
||||
const arrrec = await MyElem.find(myfind).lean().sort({ order: 1 });
|
||||
|
||||
return arrrec;
|
||||
};
|
||||
@@ -368,32 +371,68 @@ MyElemSchema.statics.findallSchedeTemplate = async function (idapp) {
|
||||
|
||||
try {
|
||||
|
||||
const ris = await MyElem.find({ idapp });
|
||||
const ris = await MyElem.find({ idapp }).lean();
|
||||
|
||||
// Estrai le schede che hanno isTemplate = true
|
||||
const schedeTemplate = ris.flatMap(elem =>
|
||||
elem.catalogo && elem.catalogo.arrSchede ? elem.catalogo.arrSchede.filter(scheda => scheda.scheda?.isTemplate) : []
|
||||
elem.catalogo && elem.catalogo.arrSchede ?
|
||||
elem.catalogo.arrSchede
|
||||
.filter(scheda => scheda.scheda?.isTemplate)
|
||||
.map(scheda => ({
|
||||
...scheda, // mantieni i dati originali della scheda
|
||||
idPageOrig: elem.idPage // aggiungi l'idPage
|
||||
}))
|
||||
: []
|
||||
);
|
||||
|
||||
/*
|
||||
// Trova tutti i documenti in cui idapp corrisponde e contiene schede con isTemplate = true
|
||||
const ris = await MyElem.find(
|
||||
{ idapp },
|
||||
{ 'catalogo.arrSchede': { $elemMatch: { isTemplate: true } } }
|
||||
).populate('catalogo.arrSchede');
|
||||
|
||||
// Estrai solo le schede che hanno isTemplate = true
|
||||
const schedeTemplate = ris.flatMap(elem =>
|
||||
elem.catalogo.arrSchede.filter(scheda => scheda.isTemplate)
|
||||
);
|
||||
*/
|
||||
|
||||
return schedeTemplate;
|
||||
} catch (e) {
|
||||
console.error('Err', e);
|
||||
}
|
||||
};
|
||||
|
||||
// Ricerca tra tutte le schede, contenute in catalogo, se esiste un nome di template uguale,
|
||||
// se non lo trova allora è quello giusto per crearne uno nuovo
|
||||
MyElemSchema.statics.getNewFreeNameTemplate = async function (idapp, idPageOrig, nomeTemplate) {
|
||||
const MyElem = this;
|
||||
|
||||
try {
|
||||
const ris = await MyElem.find(
|
||||
{
|
||||
idapp,
|
||||
'catalogo.arrSchede.scheda.isTemplate': true,
|
||||
'catalogo.arrSchede.scheda.idPage': { $ne: idPageOrig }
|
||||
},
|
||||
{
|
||||
'catalogo.arrSchede.scheda.name': 1,
|
||||
'catalogo.arrSchede.scheda.isTemplate': 1,
|
||||
'catalogo.arrSchede.scheda.idPage': 1
|
||||
});
|
||||
|
||||
const existingNames = new Set(
|
||||
ris.flatMap(elem =>
|
||||
elem.catalogo?.arrSchede?.filter(scheda =>
|
||||
scheda.scheda?.isTemplate &&
|
||||
scheda.scheda?.idPage !== idPageOrig
|
||||
)
|
||||
.map(scheda => scheda.scheda?.name) || []
|
||||
)
|
||||
);
|
||||
|
||||
let ind = 2;
|
||||
let newNameTemplate;
|
||||
|
||||
do {
|
||||
newNameTemplate = `${nomeTemplate}_copia_${ind}`;
|
||||
ind++;
|
||||
} while (existingNames.has(newNameTemplate) && ind <= 1000);
|
||||
|
||||
return newNameTemplate;
|
||||
} catch (e) {
|
||||
console.error('Err', e);
|
||||
throw e; // Propagate the error
|
||||
}
|
||||
};
|
||||
|
||||
const MyElem = mongoose.model('MyElem', MyElemSchema);
|
||||
|
||||
MyElem.createIndexes((err) => {
|
||||
|
||||
@@ -129,8 +129,11 @@ const scheletroScheda = {
|
||||
productTypes: [{ type: Number }],
|
||||
excludeproductTypes: [{ type: Number }],
|
||||
editore: [{ type: String }],
|
||||
argomenti: [{ type: String }],
|
||||
idCollana: { type: Number },
|
||||
author: { type: String },
|
||||
sort: { type: Number },
|
||||
sort_field: { type: String },
|
||||
sort_dir: { type: Number },
|
||||
arrProdottiSpeciali: [{ type: String }],
|
||||
};
|
||||
|
||||
@@ -149,11 +152,7 @@ MySchedaSchema.statics.executeQueryTable = function (idapp, params, user) {
|
||||
};
|
||||
|
||||
MySchedaSchema.statics.findAllIdApp = async function (idapp) {
|
||||
const MyScheda = this;
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return await MyScheda.find(myfind);
|
||||
};
|
||||
|
||||
const MyScheda = mongoose.model('MyScheda', MySchedaSchema);
|
||||
|
||||
@@ -119,6 +119,7 @@ const productInfoSchema = new Schema({
|
||||
type: String,
|
||||
},
|
||||
idAuthors: [{ type: Schema.Types.ObjectId, ref: 'Author' }],
|
||||
idCollana: { type: Schema.Types.ObjectId, ref: 'Collana' },
|
||||
idPublisher: { type: Schema.Types.ObjectId, ref: 'Publisher' },
|
||||
collezione: {
|
||||
type: String,
|
||||
@@ -138,7 +139,9 @@ const productInfoSchema = new Schema({
|
||||
},
|
||||
|
||||
totVen: Number,
|
||||
totFat: Number,
|
||||
vLast3M: Number,
|
||||
fatLast3M: Number,
|
||||
vLast6M: Number,
|
||||
vLastY: Number,
|
||||
vLast2Y: Number,
|
||||
@@ -218,6 +221,14 @@ module.exports.findAllIdApp = async function (idapp, code, id) {
|
||||
as: 'authors'
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'collanas',
|
||||
localField: 'idCollana',
|
||||
foreignField: '_id',
|
||||
as: 'collana'
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'publishers',
|
||||
|
||||
@@ -402,6 +402,8 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
||||
destinatario += ' (' + username_mittente + ')'
|
||||
}
|
||||
|
||||
const circuit = await Circuit.findOne({ name: circuitname });
|
||||
|
||||
if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_NEW_REC) {
|
||||
newdescr = i18n.__('CIRCUIT_CREATED', sender, recnotif.paramsObj.circuitnameDest);
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_SETFIDO) {
|
||||
@@ -470,7 +472,12 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
||||
} else {
|
||||
newdescr = i18n.__('CIRCUIT_REQUEST_TO_ENTER', sender, '<strong>' + recnotif.paramsObj.circuitnameDest + '</strong>', numuserincircuit, aportador_solidario);
|
||||
|
||||
if (circuit.askManagerToEnter)
|
||||
newdescr = i18n.__('CIRCUIT_REQUEST_TO_ENTER_ASKMANAGER', sender, '<strong>' + recnotif.paramsObj.circuitnameDest + '</strong>', numuserincircuit, aportador_solidario);
|
||||
|
||||
}
|
||||
|
||||
|
||||
const myadmins = await Circuit.getListAdmins(recnotif.idapp, recnotif.paramsObj.circuitnameDest);
|
||||
recnotif.textaddTelegram += '\n' + i18n.__('CIRCUIT_ADMINS', myadmins.num, myadmins.str);
|
||||
recnotif.textaddTelegram += '\n' + i18n.__('CIRCUIT_WHERE_IS_PRESENT', await Circuit.getListCircuitsByUsername(recnotif.idapp, sender, recnotif.extrarec.groupname));
|
||||
|
||||
@@ -22,6 +22,9 @@ const SubCatProdSchema = new Schema({
|
||||
name: {
|
||||
type: String,
|
||||
},
|
||||
descr_estesa: {
|
||||
type: String,
|
||||
},
|
||||
img: {
|
||||
type: String,
|
||||
},
|
||||
|
||||
@@ -3014,6 +3014,7 @@ UserSchema.statics.setCircuitCmd = async function (idapp, usernameOrig, circuitn
|
||||
}
|
||||
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SET) {
|
||||
|
||||
if (groupname) {
|
||||
const foundIfCircuitInGroup = await MyGroup.ifCircuitAlreadyInGroup(idapp, groupname, circuitname);
|
||||
|
||||
@@ -3044,6 +3045,10 @@ UserSchema.statics.setCircuitCmd = async function (idapp, usernameOrig, circuitn
|
||||
};
|
||||
ris = await User.updateOne({ idapp, username: usernameOrig }, update);
|
||||
|
||||
// Elimina la richiesta:
|
||||
update = { $pull: { req_users: { username: { $in: [usernameOrig] } } } };
|
||||
await Circuit.updateOne({ idapp, name: circuitname }, update);
|
||||
|
||||
// Elimina eventualmente se era bloccato:
|
||||
update = { $pull: { refused_users: { username: { $in: [usernameOrig] } } } };
|
||||
await Circuit.updateOne({ idapp, name: circuitname }, update);
|
||||
@@ -3138,9 +3143,16 @@ UserSchema.statics.setCircuitCmd = async function (idapp, usernameOrig, circuitn
|
||||
},
|
||||
});
|
||||
|
||||
const thiscircuit = await Circuit.findOne({
|
||||
idapp,
|
||||
name: circuitname,
|
||||
});
|
||||
|
||||
if (value) {
|
||||
// Aggiungi intanto l'utente al Circuito (senza fido)
|
||||
ris = await this.addCircuitToUser(idapp, usernameOrig, circuitname, false);
|
||||
if (!thiscircuit.askManagerToEnter) {
|
||||
// Aggiungi intanto l'utente al Circuito (senza fido)
|
||||
ris = await this.addCircuitToUser(idapp, usernameOrig, circuitname, false);
|
||||
}
|
||||
|
||||
if (!foundIfAlreadyAskCircuit) {
|
||||
update = {
|
||||
@@ -3151,10 +3163,11 @@ UserSchema.statics.setCircuitCmd = async function (idapp, usernameOrig, circuitn
|
||||
},
|
||||
},
|
||||
};
|
||||
// Aggiungi la richiesta per ottenere il fido
|
||||
// Aggiungi la richiesta per ottenere il fido (o per entrare nel circuito)
|
||||
ris = await Circuit.updateOne({ idapp, name: circuitname }, update);
|
||||
|
||||
}
|
||||
|
||||
if (ris) {
|
||||
// Invia una notifica alla persona
|
||||
await tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, true, true, username_action, extrarec);
|
||||
|
||||
@@ -17,6 +17,7 @@ const ImportaDescr = require('../models/importadescr');
|
||||
const ImportaIsbn = require('../models/importaisbn');
|
||||
const ProductInfo = require('../models/productInfo');
|
||||
const CatProd = require('../models/catprod');
|
||||
const Collana = require('../models/collana');
|
||||
const Author = require('../models/author');
|
||||
const Publisher = require('../models/publisher');
|
||||
const SubCatProd = require('../models/subcatprod');
|
||||
@@ -842,6 +843,7 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
let risupdate = await ProductInfo.updateMany({ idapp }, {
|
||||
$set: {
|
||||
totVen: 0,
|
||||
totFat: 0,
|
||||
vLast3M: 0,
|
||||
vLast6M: 0,
|
||||
vLastY: 0,
|
||||
@@ -873,6 +875,8 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
// split versioneGM in array with separated ","
|
||||
let arrversGM = versGM.split(",").map(x => x.trim());
|
||||
|
||||
const recproductInfoAttuale = await ProductInfo.findOne({ idapp, code: productInfo.code });
|
||||
|
||||
let productInfo = {
|
||||
idapp: product.idapp,
|
||||
code: product.isbn ? product.isbn : product.code,
|
||||
@@ -882,13 +886,29 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
|
||||
// name: product.title,
|
||||
totVen: product.totVen || 0,
|
||||
totFat: product.totFat || 0,
|
||||
vLast3M: product.vLast3M || 0,
|
||||
fatLast3M: product.fatLast3M || 0,
|
||||
vLast6M: product.vLast6M || 0,
|
||||
vLastY: product.vLastY || 0,
|
||||
vLast2Y: product.vLast2Y || 0,
|
||||
rank3M: product.rank3M || 0,
|
||||
rank6M: product.rank6M || 0,
|
||||
rank1Y: product.rank1Y || 0,
|
||||
|
||||
}
|
||||
|
||||
// Aggiorna la collana solo se non è stata già impostata nel record attuale
|
||||
if (recproductInfoAttuale && !recproductInfoAttuale.idCollana && product.DescrizioneCollana) {
|
||||
productInfo.idCollana = product.IdCollana;
|
||||
|
||||
reccollana = await Collana.findOne({ idapp, idCollana }).lean();
|
||||
if (!reccollana) {
|
||||
// Non esiste questa collana, quindi la creo !
|
||||
reccoll = new Collana({ idapp, idCollana: product.IdCollana, descrizione: product.DescrizioneCollana });
|
||||
ris = await reccoll.save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (product.DataPubblicazione) {
|
||||
@@ -902,7 +922,7 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
|
||||
|
||||
// Update ProductInfo
|
||||
let risrecInfo = await ProductInfo.findOneAndUpdate({ code: productInfo.code }, { $set: productInfo }, { new: true, upsert: false });
|
||||
let risrecInfo = await ProductInfo.findOneAndUpdate({ idapp, code: productInfo.code }, { $set: productInfo }, { new: true, upsert: false });
|
||||
if (risrecInfo) {
|
||||
imported++;
|
||||
if (imported % 100 === 0)
|
||||
@@ -1023,7 +1043,7 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
name: product.title,
|
||||
description: product.description,
|
||||
short_descr: product.short_descr,
|
||||
publisher: product.Editore,
|
||||
publisher: product.editore,
|
||||
collezione: product.Collezione,
|
||||
// author: product.Autore ? product.Autore : '',
|
||||
link: product.link ? product.link : '',
|
||||
|
||||
@@ -72,6 +72,10 @@ router.post('/load', authenticate, async (req, res) => {
|
||||
}
|
||||
*/
|
||||
|
||||
if (data === null) {
|
||||
data = null;
|
||||
}
|
||||
|
||||
const users_in_circuit = await Circuit.getUsersSingleCircuit(idapp, req.user.username, data.name, data._id);
|
||||
|
||||
data = await getCircuitRecAdminsInfo(idapp, data);
|
||||
|
||||
@@ -75,6 +75,7 @@ const SubCatProd = require('../models/subcatprod');
|
||||
const Gasordine = require('../models/gasordine');
|
||||
const Product = require('../models/product');
|
||||
const Author = require('../models/author');
|
||||
const Collana = require('../models/collana');
|
||||
const Publisher = require('../models/publisher');
|
||||
const ProductInfo = require('../models/productInfo');
|
||||
const Scontistica = require('../models/scontistica');
|
||||
@@ -856,11 +857,27 @@ async function duplicatePage(pageId, newpath) {
|
||||
|
||||
// Duplica ogni elemento utilizzando il nuovo idPath
|
||||
const duplicates = elemsToDuplicate.map(elem => {
|
||||
|
||||
const catalogo = elem.catalogo;
|
||||
|
||||
for (const recscheda of catalogo.arrSchede) {
|
||||
if (recscheda.scheda?.isTemplate) {
|
||||
// Se è un template allora devo mettergli un altro ID !
|
||||
recscheda.scheda._id = new mongoose.Types.ObjectId();
|
||||
// recscheda.scheda.name = getNewFreeNameTemplate(recscheda.scheda?.name)
|
||||
}
|
||||
}
|
||||
|
||||
let newelem = { ...elem };
|
||||
|
||||
elem.catalogo = { ...catalogo };
|
||||
|
||||
const newElem = new MyElem({
|
||||
...elem, // Copia le proprietà dell'elemento
|
||||
_id: new mongoose.Types.ObjectId(), // Genera un nuovo ID
|
||||
idPage: newPage._id.toString() // Imposta il nuovo campo IdPage
|
||||
});
|
||||
|
||||
return newElem;
|
||||
});
|
||||
|
||||
@@ -1827,6 +1844,7 @@ function load(req, res, version) {
|
||||
let storehouses = Storehouse.findAllIdApp(idapp);
|
||||
let providers = Provider.findAllIdApp(idapp);
|
||||
let catprods = Product.getArrCatProds(idapp, shared_consts.PROD.BOTTEGA);
|
||||
let collane = Collana.findAllIdApp(idapp);
|
||||
let catprods_gas = Product.getArrCatProds(idapp, shared_consts.PROD.GAS);
|
||||
let subcatprods = SubCatProd.findAllIdApp(idapp);
|
||||
let gasordines = Gasordine.findAllIdApp(idapp);
|
||||
@@ -1939,6 +1957,7 @@ function load(req, res, version) {
|
||||
authors,
|
||||
publishers,
|
||||
myschedas,
|
||||
collane,
|
||||
]).then((arrdata) => {
|
||||
// console.table(arrdata);
|
||||
let myuser = req.user;
|
||||
@@ -2034,6 +2053,7 @@ function load(req, res, version) {
|
||||
authors: arrdata[49],
|
||||
publishers: arrdata[50],
|
||||
myschedas: arrdata[51],
|
||||
collane: arrdata[52],
|
||||
});
|
||||
|
||||
const prova = 1;
|
||||
|
||||
@@ -312,6 +312,7 @@ module.exports = {
|
||||
dataemail: await this.getdataemail(idapp),
|
||||
locale: lang,
|
||||
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||
strlinksito: tools.getHostByIdApp(idapp),
|
||||
emailto: emailto,
|
||||
qty: myrec.qty,
|
||||
mittente: decode(myrec.mittente),
|
||||
@@ -338,6 +339,7 @@ module.exports = {
|
||||
dataemail: await this.getdataemail(idapp),
|
||||
locale: lang,
|
||||
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||
strlinksito: tools.getHostByIdApp(idapp),
|
||||
emailto: emailto,
|
||||
msgbooking: '',
|
||||
participants: '',
|
||||
@@ -432,6 +434,7 @@ module.exports = {
|
||||
dataemail: await this.getdataemail(idapp),
|
||||
locale: lang,
|
||||
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||
strlinksito: tools.getHostByIdApp(idapp),
|
||||
event: recbooking.infoevent,
|
||||
participants: '',
|
||||
participantsLunch: '',
|
||||
@@ -470,6 +473,7 @@ module.exports = {
|
||||
dataemail: await this.getdataemail(idapp),
|
||||
locale: lang,
|
||||
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||
strlinksito: tools.getHostByIdApp(idapp),
|
||||
usernameorig: user.name + ' ' + user.surname,
|
||||
message: tools.convertTexttoHtml(recmsg.message),
|
||||
infoevent: recmsg.source.infoevent,
|
||||
@@ -529,6 +533,7 @@ module.exports = {
|
||||
dataemail: await this.getdataemail(idapp),
|
||||
locale: lang,
|
||||
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||
strlinksito: tools.getHostByIdApp(idapp),
|
||||
usernameorig: user.name + ' ' + user.surname,
|
||||
};
|
||||
|
||||
@@ -558,6 +563,7 @@ module.exports = {
|
||||
dataemail: await this.getdataemail(idapp),
|
||||
locale: lang,
|
||||
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||
strlinksito: tools.getHostByIdApp(idapp),
|
||||
};
|
||||
|
||||
mylocalsconf = this.setParamsForTemplate(user, mylocalsconf);
|
||||
@@ -795,6 +801,7 @@ module.exports = {
|
||||
idapp,
|
||||
locale: lang,
|
||||
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||
strlinksito: tools.getHostByIdApp(idapp),
|
||||
orders,
|
||||
baseurl: tools.getHostByIdApp(idapp),
|
||||
dataemail: await this.getdataemail(idapp),
|
||||
@@ -830,6 +837,7 @@ module.exports = {
|
||||
idapp,
|
||||
locale: lang,
|
||||
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||
strlinksito: tools.getHostByIdApp(idapp),
|
||||
orders,
|
||||
baseurl: tools.getHostByIdApp(idapp),
|
||||
dataemail: await this.getdataemail(idapp),
|
||||
@@ -875,6 +883,7 @@ module.exports = {
|
||||
idapp,
|
||||
locale: lang,
|
||||
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||
strlinksito: tools.getHostByIdApp(idapp),
|
||||
arrevents: myarrevents,
|
||||
baseurl: tools.getHostByIdApp(idapp),
|
||||
dataemail: await this.getdataemail(idapp),
|
||||
@@ -1030,6 +1039,7 @@ module.exports = {
|
||||
idapp,
|
||||
locale: lang,
|
||||
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||
strlinksito: tools.getHostByIdApp(idapp),
|
||||
arrevents: myarrevents,
|
||||
name: 'TestNome',
|
||||
surname: 'TestCognome',
|
||||
@@ -1067,6 +1077,7 @@ module.exports = {
|
||||
idapp,
|
||||
locale: userto.lang,
|
||||
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||
strlinksito: tools.getHostByIdApp(idapp),
|
||||
name: userto.name,
|
||||
surname: userto.surname,
|
||||
emailto: myemail,
|
||||
|
||||
@@ -1009,6 +1009,44 @@ const MyTelegramBot = {
|
||||
]);
|
||||
send_notif = true;
|
||||
}
|
||||
} else if (myfunc === shared_consts.CallFunz.RICHIESTA_CIRCUIT) {
|
||||
|
||||
if (groupname) {
|
||||
msg_notifpush = i18n.__({ phrase: 'CIRCUIT_ACCEPT_NEWENTRY_BYGROUP_CIRC', locale: langdest }, groupname);
|
||||
domanda = i18n.__({ phrase: 'CIRCUIT_ACCEPT_NEWENTRY_BYGROUP_CIRC', locale: langdest }, groupname) + '<br>' + struserinfomsg;
|
||||
|
||||
keyb = cl.getInlineKeyboard(myuser.lang, [
|
||||
{
|
||||
text: '✅ Fai entrare a ' + groupname,
|
||||
callback_data: InlineConferma.RISPOSTA_SI + myfunc + tools.SEP + myuser.username + tools.SEP + '' + tools.SEP + '' + tools.SEP +
|
||||
groupid + tools.SEP + groupname,
|
||||
},
|
||||
/*{
|
||||
text: '🚫 Rifiuta ' + groupname,
|
||||
callback_data: InlineConferma.RISPOSTA_NO + myfunc + tools.SEP + myuser.username + tools.SEP + '' + tools.SEP + '' + tools.SEP +
|
||||
groupid + tools.SEP + groupname,
|
||||
},*/
|
||||
]);
|
||||
send_notif = true;
|
||||
|
||||
} else {
|
||||
msg_notifpush = i18n.__({ phrase: 'CIRCUIT_ACCEPT_NEWENTRY_CIRC', locale: langdest }, myuser.username, name);
|
||||
domanda = i18n.__({ phrase: 'CIRCUIT_ACCEPT_NEWENTRY_CIRC', locale: langdest }, myuser.username, name) + '<br>' + struserinfomsg;
|
||||
|
||||
keyb = cl.getInlineKeyboard(myuser.lang, [
|
||||
{
|
||||
text: '✅ Fai entrare a ' + myuser.username,
|
||||
callback_data: InlineConferma.RISPOSTA_SI + myfunc + tools.SEP + myuser.username + tools.SEP + '' + tools.SEP + '' + tools.SEP +
|
||||
groupid,
|
||||
},
|
||||
/*{
|
||||
text: '🚫 Rifiuta ' + myuser.username,
|
||||
callback_data: InlineConferma.RISPOSTA_NO + myfunc + tools.SEP + myuser.username + tools.SEP + '' + tools.SEP + '' + tools.SEP +
|
||||
groupid,
|
||||
}, */
|
||||
]);
|
||||
send_notif = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Invia Msg
|
||||
@@ -4603,10 +4641,15 @@ if (true) {
|
||||
} else if (data.action === InlineConferma.RISPOSTA_SI + shared_consts.CallFunz.RICHIESTA_FIDO) {
|
||||
|
||||
if (circuit) {
|
||||
cmd = shared_consts.CIRCUITCMD.SETFIDO;
|
||||
// Aggiungilo nel Circuito
|
||||
// await User.setCircuitCmd(user.idapp, data.username, circuit.name, cmd, 0, username_action, { groupname: data.groupname });
|
||||
// Abiglitagli il Fido
|
||||
cmd = shared_consts.CIRCUITCMD.SETFIDO;
|
||||
await User.setCircuitCmd(user.idapp, data.username, circuit.name, cmd, 0, username_action, { groupname: data.groupname });
|
||||
}
|
||||
} else if (data.action === InlineConferma.RISPOSTA_SI + shared_consts.CallFunz.RICHIESTA_CIRCUIT) {
|
||||
|
||||
if (circuit) {
|
||||
// Aggiungilo nel Circuito
|
||||
cmd = shared_consts.CIRCUITCMD.SET;
|
||||
await User.setCircuitCmd(user.idapp, data.username, circuit.name, cmd, 0, username_action, { groupname: data.groupname });
|
||||
}
|
||||
} else if (data.action === InlineConferma.RISPOSTA_NO + shared_consts.CallFunz.RICHIESTA_CIRCUIT) {
|
||||
|
||||
@@ -1234,7 +1234,12 @@ module.exports = {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_REQUEST_TO_ENTER;
|
||||
// paramsObj.options = MessageOptions.Notify_OnlyToNotifinApp + MessageOptions.Notify_ByBotTelegram;
|
||||
const myuserdata = await User.getUserShortDataByUsername(idapp, username_action);
|
||||
telegrambot.askConfirmationUser(idapp, shared_consts.CallFunz.RICHIESTA_FIDO, myuserdata, usernameDest, circuitname,
|
||||
let cmdrichiesta = shared_consts.CallFunz.RICHIESTA_FIDO;
|
||||
if (mycircuit && mycircuit.askManagerToEnter) {
|
||||
cmdrichiesta = shared_consts.CallFunz.RICHIESTA_CIRCUIT;
|
||||
}
|
||||
|
||||
telegrambot.askConfirmationUser(idapp, cmdrichiesta, myuserdata, usernameDest, circuitname,
|
||||
myreccircuit._id, '', extrarec.groupname);
|
||||
onlysave = false;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.ADDADMIN) {
|
||||
|
||||
@@ -68,6 +68,7 @@ const Gasordine = require('../models/gasordine');
|
||||
const Scontistica = require('../models/scontistica');
|
||||
const Department = require('../models/department');
|
||||
const CatProd = require('../models/catprod');
|
||||
const Collana = require('../models/collana');
|
||||
const CatAI = require('../models/catai');
|
||||
const QueryAI = require('../models/queryai');
|
||||
const SubCatProd = require('../models/subcatprod');
|
||||
@@ -130,6 +131,8 @@ module.exports = {
|
||||
mytable = Category;
|
||||
else if (tablename === 'catprods')
|
||||
mytable = CatProd;
|
||||
else if (tablename === 'collanas')
|
||||
mytable = Collana;
|
||||
else if (tablename === 'catais')
|
||||
mytable = CatAI;
|
||||
else if (tablename === 'queryais')
|
||||
@@ -777,5 +780,14 @@ module.exports = {
|
||||
return null;
|
||||
},
|
||||
|
||||
checkIfTokenExpired(req, res) {
|
||||
let ret = null;
|
||||
|
||||
if (true) {
|
||||
res.status(408).send({});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -830,11 +830,17 @@ module.exports = {
|
||||
deperimento: 1,
|
||||
showAlways: 1,
|
||||
ignoreLimits: 1,
|
||||
askManagerToEnter: 1,
|
||||
sendEmailAfterAskingToEnter: 1,
|
||||
circuitoIndipendente: 1,
|
||||
creditodiPartenza: 1,
|
||||
status: 1,
|
||||
transactionsEnabled: 1,
|
||||
qta_max_default: 1,
|
||||
fido_scoperto_default_grp: 1,
|
||||
qta_max_default_grp: 1,
|
||||
fido_scoperto_default_contocom: 1,
|
||||
qta_max_default_contocom: 1,
|
||||
valuta_per_euro: 1,
|
||||
symbol: 1,
|
||||
idCity: 1,
|
||||
|
||||
Reference in New Issue
Block a user