✨✨✨ AGGIORNAMENTO SITO ✨✨✨
👉🏻 E' possibile ora visualizzare la Posizione Reale d'imbarco di quando si verrà aggiunti alle prossime Navi Definitive. Le posizioni verranno aggiornate ogni ora in automatico! 👉🏻 Ora gli imbarchi comprendono anche le navi provvisorie, pertanto è possibile annullarli oppure cambiare l'Invitante, dalla lista imbarchi. 👉🏻 E' ora possibile spostare gli invitati solo se si hanno piu' di 2 invitati per ogni Nave già partita. 👨🏻💻 Per i Tutor: 👉🏻- Sostituzioni : Cliccando su "Cerca il Primo Disponibile" vi suggerirà in automatico il primo passeggero disponibile per la sostituzione. ✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨
This commit is contained in:
@@ -13,6 +13,7 @@ const { authenticate, authenticate_noerror } = require('../middleware/authentica
|
||||
|
||||
const { ObjectID } = require('mongodb');
|
||||
const { ListaIngresso } = require('../models/listaingresso');
|
||||
const { Graduatoria } = require('../models/graduatoria');
|
||||
|
||||
const mongoose = require('mongoose');
|
||||
const cfgserver = mongoose.model('cfgserver');
|
||||
@@ -223,6 +224,8 @@ function getTableByTableName(tablename) {
|
||||
mytable = NavePersistente;
|
||||
else if (tablename === 'listaingressos')
|
||||
mytable = ListaIngresso;
|
||||
else if (tablename === 'graduatorias')
|
||||
mytable = Graduatoria;
|
||||
|
||||
return mytable
|
||||
}
|
||||
@@ -442,6 +445,8 @@ router.patch('/chval', authenticate, async (req, res) => {
|
||||
res.status(400).send();
|
||||
return false;
|
||||
}
|
||||
} else if ('deleted' in fieldsvalue) {
|
||||
await telegrambot.sendMsgTelegramToTheManagers(idapp, `L\'utente ${rec.name} ${rec.surname} (${rec.username}) è stato cancellato (nascosto) da ${req.user.name} ${req.user.surname}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -512,6 +517,32 @@ router.patch('/chval', authenticate, async (req, res) => {
|
||||
|
||||
});
|
||||
|
||||
router.patch('/askfunz', authenticate, async (req, res) => {
|
||||
// const idapp = req.body.idapp;
|
||||
const id = req.body.data.id;
|
||||
const ind_order = req.body.data.ind_order;
|
||||
const username = req.body.data.username;
|
||||
const idapp = req.body.idapp;
|
||||
const mydata = req.body.data;
|
||||
|
||||
let entra = false;
|
||||
if (!entra) {
|
||||
// If I change my record...
|
||||
if ((!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm) && !User.isTutor(req.user.perm)) && !(req.user._id.toString() === id)) {
|
||||
// If without permissions, exit
|
||||
return res.status(404).send({ code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: '' });
|
||||
}
|
||||
}
|
||||
|
||||
if (mydata.myfunc === shared_consts.CallFunz.DAMMI_PRIMO_UTENTE_LIBERO) {
|
||||
const userfree = await Graduatoria.getFirstUserGradFree(idapp);
|
||||
|
||||
if (!!userfree)
|
||||
return res.send({ code: server_constants.RIS_CODE_OK, out: userfree });
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
router.patch('/callfunz', authenticate, async (req, res) => {
|
||||
// const idapp = req.body.idapp;
|
||||
const id = req.body.data.id;
|
||||
@@ -528,7 +559,7 @@ router.patch('/callfunz', authenticate, async (req, res) => {
|
||||
}
|
||||
if (!entra) {
|
||||
// If I change my record...
|
||||
if ((!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm) && !User.isTutor(req.user.perm)) && !(req.user._id.toString() === id) && !tools.ModificheConsentite(mydata.table, fieldsvalue)) {
|
||||
if ((!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm) && !User.isTutor(req.user.perm)) && !(req.user._id.toString() === id)) {
|
||||
// If without permissions, exit
|
||||
return res.status(404).send({ code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: '' });
|
||||
}
|
||||
@@ -555,7 +586,7 @@ router.patch('/callfunz', authenticate, async (req, res) => {
|
||||
if (!!myusernuovo) {
|
||||
|
||||
if (!mydata.data.AddImbarco && !!mianavedasost && mianavedasost.ind_order > 0) {
|
||||
// Controlla prima se è in una Nave Temporanea, allora lo elimina dalla Nave Temporanea
|
||||
// Controlla prima se è in una Nave Temporanea, allora lo elimina dalla PRIMA Nave Temporanea
|
||||
|
||||
miaarrnavi = await Nave.getArrPosizioniByUsername(idapp, username);
|
||||
if (miaarrnavi) {
|
||||
@@ -566,7 +597,7 @@ router.patch('/callfunz', authenticate, async (req, res) => {
|
||||
ind_order: -1
|
||||
};
|
||||
|
||||
let ris = await Nave.findByIdAndUpdate(mianave.id, { $set: fieldsvalue });
|
||||
let ris = await Nave.findByIdAndUpdate(mianave._id, { $set: fieldsvalue });
|
||||
if (!!ris) {
|
||||
rimosso++;
|
||||
break; // Rimuovilo solo 1 !
|
||||
@@ -580,31 +611,45 @@ router.patch('/callfunz', authenticate, async (req, res) => {
|
||||
if (!!mianavedasost && mianavedasost.ind_order >= 0) {
|
||||
|
||||
// Metti campo 'delete': true su ListaIngresso
|
||||
olduseringresso = await ListaIngresso.findOne({ idapp, ind_order: mianavedasost.ind_order });
|
||||
olduseringresso = await ListaIngresso.findById(mianavedasost.idListaIngresso);
|
||||
if (!!olduseringresso) {
|
||||
let fieldsvalue = {
|
||||
date_deleted: new Date(),
|
||||
deleted: true
|
||||
};
|
||||
const risul = await ListaIngresso.findByIdAndUpdate(olduseringresso.id, { $set: fieldsvalue }, { new: false });
|
||||
const risul = await ListaIngresso.findByIdAndUpdate(mianavedasost.idListaIngresso, { $set: fieldsvalue }, { new: false });
|
||||
if (!!risul) {
|
||||
const myrecuser = await ListaIngresso.getIngrEUserByFilter(idapp, {
|
||||
idapp,
|
||||
username: username_da_sostituire,
|
||||
_id: ObjectID(mianavedasost.idListaIngresso)
|
||||
});
|
||||
|
||||
if (!!myrecuser) {
|
||||
const risdel = await ListaIngresso.deleteOne({ _id: olduseringresso.id });
|
||||
|
||||
if (!!risdel) {
|
||||
await actions.doOtherThingsAfterDeleted('listaingressos', myrecuser, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!!myuservecchio) {
|
||||
// Se ha gia delle altre navi, non cancellarlo!
|
||||
Nave.checkIfMadeGift(idapp, )
|
||||
const noncanc = await Nave.findOne({idapp, ind_order: mianavedasost.ind_order, made_gift: true });
|
||||
if (!await Nave.checkIfMadeGift(idapp, myuservecchio.username)) {
|
||||
|
||||
|
||||
if (mydata.data.deleteUser && !!mianavedasost && mianavedasost.ind_order > 0) {
|
||||
// Metti Deleted allo User
|
||||
fieldsvalue = {
|
||||
deleted: true,
|
||||
date_deleted: new Date(),
|
||||
};
|
||||
await User.findByIdAndUpdate(myuservecchio.id, { $set: fieldsvalue });
|
||||
await telegrambot.sendMsgTelegramToTheManagers(idapp, `L\'utente ${myuservecchio.name} ${myuservecchio.surname} (${myuservecchio.username}) è stato cancellato (nascosto) perchè sostituito (da ${req.user.name} ${req.user.surname} )`);
|
||||
if (mydata.data.deleteUser && !!mianavedasost && mianavedasost.ind_order > 0) {
|
||||
// Metti Deleted allo User
|
||||
fieldsvalue = {
|
||||
deleted: true,
|
||||
date_deleted: new Date(),
|
||||
};
|
||||
await User.findByIdAndUpdate(myuservecchio.id, { $set: fieldsvalue });
|
||||
await telegrambot.sendMsgTelegramToTheManagers(idapp, `L\'utente ${myuservecchio.name} ${myuservecchio.surname} (${myuservecchio.username}) è stato cancellato (nascosto) perchè sostituito (da ${req.user.name} ${req.user.surname} )`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -626,8 +671,17 @@ router.patch('/callfunz', authenticate, async (req, res) => {
|
||||
ind_order = myingr.ind_order;
|
||||
|
||||
await myingr.save();
|
||||
|
||||
}
|
||||
|
||||
// Togliolo dalla Graduatoria!
|
||||
const mygrad = await Graduatoria.findOneAndUpdate({
|
||||
idapp,
|
||||
idListaIngresso: myingr._id
|
||||
}, { $set: { ind_order: -1 } }, { new: false });
|
||||
|
||||
|
||||
|
||||
// Aggiorna la Nave con il Nuovo
|
||||
fieldsvalue = {
|
||||
ind_order
|
||||
@@ -635,7 +689,6 @@ router.patch('/callfunz', authenticate, async (req, res) => {
|
||||
|
||||
const dachi = req.user.name + ' ' + req.user.surname;
|
||||
|
||||
|
||||
return await Nave.findByIdAndUpdate(mianavedasost.id, { $set: fieldsvalue })
|
||||
.then(async (rec) => {
|
||||
// tools.mylogshow(' REC TO MODIFY: ', rec);
|
||||
@@ -703,11 +756,26 @@ router.patch('/callfunz', authenticate, async (req, res) => {
|
||||
|
||||
} else if (mydata.myfunc === shared_consts.CallFunz.CANCELLA_IMBARCO) {
|
||||
|
||||
await ListaIngresso.remove({ idapp, username, ind_order });
|
||||
const myrec = await ListaIngresso.getIngrEUserByFilter(idapp, { idapp, _id: ObjectID(mydata.data.id) });
|
||||
|
||||
return res.send({ code: server_constants.RIS_CODE_OK });
|
||||
if (!!myrec) {
|
||||
const risdel = await ListaIngresso.deleteOne({ _id: mydata.data.id });
|
||||
|
||||
if (!!risdel) {
|
||||
return await actions.doOtherThingsAfterDeleted('listaingressos', myrec, false)
|
||||
.then((ris) => {
|
||||
|
||||
if (!!ris)
|
||||
// tools.mylog('DELETED Others things ...');
|
||||
return res.send({ code: server_constants.RIS_CODE_OK, msg: '' });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return res.send({ code: server_constants.RIS_CODE_ERR });
|
||||
|
||||
} catch (e) {
|
||||
console.log(e.message);
|
||||
res.status(400).send();
|
||||
@@ -800,27 +868,10 @@ router.delete('/delrec/:table/:id', authenticate, async (req, res) => {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if (cancellato) {
|
||||
// Do extra things after deleted
|
||||
return actions.doOtherThingsAfterDeleted(tablename, myrec).then(async (ris) => {
|
||||
if (ris) {
|
||||
|
||||
if (notifBot) {
|
||||
// Send Notification to the BOT
|
||||
let nomerecord = '';
|
||||
if ((tablename === 'users') || (tablename === 'extralist')) {
|
||||
nomerecord = myrec.name + ' ' + myrec.surname + ' (' + myrec.username + ')';
|
||||
}
|
||||
|
||||
addtext = 'Eliminato il Record "' + nomerecord + '" dalla tabella ' + tablename + '\n' +
|
||||
'Eseguito da ' + req.user.name + ' ' + req.user.surname + ' \n';
|
||||
await telegrambot.sendMsgTelegramToTheManagers(idapp, addtext);
|
||||
}
|
||||
|
||||
tools.mylog('DELETED Others things ...');
|
||||
return res.send({ code: server_constants.RIS_CODE_OK, msg: '' });
|
||||
}
|
||||
});
|
||||
return actions.doOtherThingsAfterDeleted(tablename, myrec, notifBot);
|
||||
}
|
||||
|
||||
res.send({ code: server_constants.RIS_CODE_ERR, msg: '' });
|
||||
@@ -878,10 +929,6 @@ router.post('/duprec/:table/:id', authenticate, (req, res) => {
|
||||
});
|
||||
|
||||
|
||||
function doOtherThingsAfterDeleted() {
|
||||
|
||||
}
|
||||
|
||||
router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) => {
|
||||
const userId = req.params.userId;
|
||||
const idapp = req.params.idapp;
|
||||
|
||||
Reference in New Issue
Block a user