Lista Navi
This commit is contained in:
@@ -62,9 +62,14 @@ router.post('/msgnave', authenticate, async (req, res) => {
|
||||
try {
|
||||
|
||||
let ris = null;
|
||||
if (mydata.tipomsg === tools.TipoMsg.SEND_MSG_SINGOLO)
|
||||
ris = await telegrambot.sendMsgTelegram(idapp, mydata.username, mydata.msgpar1, true); // Anche a STAFF
|
||||
else
|
||||
if (mydata.tipomsg === tools.TipoMsg.SEND_MSG_SINGOLO) {
|
||||
let mymsg = '';
|
||||
if (!!mydata.username_mitt) {
|
||||
mymsg = '[' + tools.getres__('MSG_SEND_FROM', res) + ' ' + mydata.username_mitt + ']:' + tools.ACAPO;
|
||||
}
|
||||
mymsg += mydata.msgpar1;
|
||||
ris = await telegrambot.sendMsgTelegram(idapp, mydata.username, mymsg, true, mydata.username_mitt); // Anche a STAFF
|
||||
} else
|
||||
ris = await telegrambot.sendMsgTelegramToNave(idapp, mydata);
|
||||
|
||||
if (ris)
|
||||
@@ -73,38 +78,60 @@ router.post('/msgnave', authenticate, async (req, res) => {
|
||||
res.send({ code: server_constants.RIS_CODE_ERR, ris: null });
|
||||
|
||||
|
||||
}catch (e) {
|
||||
} catch (e) {
|
||||
res.status(400).send(e);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
router.post('/getnave', authenticate, async (req, res) => {
|
||||
const idapp = req.body.idapp;
|
||||
const riga = req.body.riga;
|
||||
const col = req.body.col;
|
||||
const riga1don = req.body.riga1don;
|
||||
const col1don = req.body.col1don;
|
||||
const ind_order = req.body.ind_order;
|
||||
|
||||
const nave = await NavePersistente.findByRigaCol(idapp, riga, col);
|
||||
if (!!nave) {
|
||||
nave._doc.rec = await Nave.getNaveByRigaCol(idapp, riga1don, col1don);
|
||||
if (ind_order >= 0)
|
||||
nave._doc.ind_order = ind_order;
|
||||
|
||||
nave._doc.listadonatoridelsognatore = await Nave.getDonatoridelSognatore(idapp, riga1don, col1don);
|
||||
}
|
||||
|
||||
const navi_partenza = await NavePersistente.findAllIdApp(idapp);
|
||||
|
||||
ris = { nave, navi_partenza };
|
||||
|
||||
if (ris)
|
||||
res.send({ code: server_constants.RIS_CODE_OK, ris });
|
||||
else
|
||||
res.status(400).send(e);
|
||||
|
||||
});
|
||||
|
||||
router.post('/getnavi', authenticate, async (req, res) => {
|
||||
const idapp = req.body.idapp;
|
||||
|
||||
let arrnavi = [];
|
||||
let test = false;
|
||||
if (test) {
|
||||
let indriga = 7;
|
||||
let indcol = 49;
|
||||
arrnavi.push({ riga: indriga, col: indcol });
|
||||
|
||||
} else {
|
||||
|
||||
for (let indriga = 4; indriga <= 9; indriga++) {
|
||||
let numcol = Math.pow(2, indriga - 1);
|
||||
|
||||
let quanti = Math.ceil(numcol / 8);
|
||||
|
||||
for (let indquanti = 1; indquanti <= quanti; indquanti++) {
|
||||
arrnavi.push({ riga: indriga, col: (indquanti * 8) - 7 });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
let arrnavi = await NavePersistente.findAllIdApp(idapp);
|
||||
|
||||
for (nave of arrnavi) {
|
||||
nave.rec = await Nave.getNaveByRigaCol(idapp, nave.riga, nave.col);
|
||||
//nave.rec = await Nave.getNaveByRigaCol(idapp, nave.riga, nave.col);
|
||||
nave._doc.rec = {
|
||||
donatore: {},
|
||||
mediatore: null
|
||||
};
|
||||
|
||||
let riganave = nave.riga;
|
||||
let colnave = nave.col;
|
||||
// if (riganave < 4) {
|
||||
// riganave = 4;
|
||||
// colnave = 1;
|
||||
// }
|
||||
// nave._doc.rec.donatore.navepersistente = await NavePersistente.findByRigaColByDonatore(idapp, riganave, colnave, 0);
|
||||
nave._doc.rec.donatore.navepersistente = await NavePersistente.findOne({ idapp, riga: riganave, col: colnave });
|
||||
}
|
||||
|
||||
const navi_partenza = await NavePersistente.findAllIdApp(idapp);
|
||||
|
||||
@@ -395,9 +395,9 @@ router.patch('/chval', authenticate, async (req, res) => {
|
||||
} else {
|
||||
if (mydata.notifBot) {
|
||||
// Send Notification to the BOT
|
||||
telegrambot.sendMsgTelegram(idapp, mydata.notifBot.un, mydata.notifBot.txt);
|
||||
await telegrambot.sendMsgTelegram(idapp, mydata.notifBot.un, mydata.notifBot.txt);
|
||||
addtext = '[Msg Inviato a ' + mydata.notifBot.un + ']:' + '\n' + mydata.notifBot.txt;
|
||||
telegrambot.sendMsgTelegramToTheManagers(idapp, addtext);
|
||||
await telegrambot.sendMsgTelegramToTheManagers(idapp, addtext);
|
||||
}
|
||||
|
||||
if (mydata.table === 'users') {
|
||||
|
||||
@@ -109,6 +109,8 @@ router.post('/', async (req, res) => {
|
||||
|
||||
recuser = await User.findByCellAndNameSurname(user.idapp, user.profile.cell, user.name, user.surname);
|
||||
if (recuser) {
|
||||
console.log('UTENTE GIA ESISTENTE:\n');
|
||||
console.log(user);
|
||||
// User already registered!
|
||||
res.status(400).send({ code: server_constants.RIS_CODE_USER_ALREADY_EXIST, msg: '' });
|
||||
return 1;
|
||||
@@ -451,6 +453,9 @@ router.post('/dbop', authenticate, async (req, res) => {
|
||||
}
|
||||
}
|
||||
|
||||
// Pulisci gli added se era stato cancellato dalla nave
|
||||
await Nave.pulisciNonPresenzeInNave(idapp);
|
||||
|
||||
const data = await Nave.getLastRigaCol(idapp);
|
||||
await Nave.setRiga(idapp, data.riga);
|
||||
await Nave.setCol(idapp, data.col + 1);
|
||||
@@ -471,6 +476,8 @@ router.post('/dbop', authenticate, async (req, res) => {
|
||||
} else if (mydata.dbop === 'visuListaIngressoNuovi') {
|
||||
const mystr = await ListaIngresso.showListaOrd(idapp, true);
|
||||
ris = { mystr };
|
||||
} else if (mydata.dbop === 'visuNaviUtentiEliminati') {
|
||||
ris = await Nave.visuNaviUtentiEliminati(idapp);
|
||||
} else if (mydata.dbop === 'initListaIngresso') {
|
||||
// const aaa = await User.updateMany({ idapp }, { $set: { 'profile.nationality': 'IT' } });
|
||||
|
||||
@@ -515,7 +522,7 @@ router.post('/dbop', authenticate, async (req, res) => {
|
||||
const myarrrec = await Nave.find({ idapp, ind_order: rec.ind_order }).sort({ riga: 1, col: 1 });
|
||||
let indextess = 1;
|
||||
for (let ind = 0; ind < myarrrec.length; ind++) {
|
||||
if (myarrrec[ind].num_tess !== indextess) {
|
||||
if (myarrrec[ind].num_tess !== indextess && myarrrec[ind].num_tess === 1) {
|
||||
myarrrec[ind].num_tess = indextess;
|
||||
const risu = await Nave.findOneAndUpdate({ _id: myarrrec[ind]._id }, { $set: { num_tess: myarrrec[ind].num_tess } }, { new: false });
|
||||
num++;
|
||||
|
||||
Reference in New Issue
Block a user