- Gallery
- Popupedit semplificato
This commit is contained in:
@@ -531,36 +531,26 @@ router.patch('/chval', authenticate, async (req, res) => {
|
|||||||
let flotta = null;
|
let flotta = null;
|
||||||
let strflotta = '';
|
let strflotta = '';
|
||||||
|
|
||||||
if (mydata.table === 'navi') {
|
|
||||||
if (!!id) {
|
|
||||||
recoldnave = await mytable.findOne({_id: ObjectID(id)});
|
|
||||||
|
|
||||||
let mypos = {
|
|
||||||
idapp,
|
|
||||||
riga: recoldnave.riga,
|
|
||||||
col: recoldnave.col,
|
|
||||||
numup: 3,
|
|
||||||
};
|
|
||||||
tools.getRigaColByPosUp(mypos);
|
|
||||||
mydatamsg = {
|
|
||||||
navemediatore: {riga: mypos.riga, col: mypos.col},
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!!fieldsvalue.riga) {
|
|
||||||
flotta = await Flotta.getFlottaByRigaColDonatore(idapp,
|
|
||||||
fieldsvalue.riga, fieldsvalue.col);
|
|
||||||
if (!!flotta) {
|
|
||||||
strflotta = Flotta.getStrFlotta(flotta);
|
|
||||||
}
|
|
||||||
myuser = await User.findByIndOrder(idapp, recoldnave.ind_order);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shared_consts.TABLES_UPDATE_LASTMODIFIED.includes(mydata.table)) {
|
if (shared_consts.TABLES_UPDATE_LASTMODIFIED.includes(mydata.table)) {
|
||||||
fieldsvalue.date_updated = new Date();
|
fieldsvalue.date_updated = new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const numobj = tools.getNumObj(fieldsvalue);
|
||||||
|
if (numobj === 1 && fieldsvalue['_id']) {
|
||||||
|
const myrec = await mytable.findById(id);
|
||||||
|
const myidDel = myrec['_id'];
|
||||||
|
myrec['_id'] = fieldsvalue['_id'];
|
||||||
|
return await mytable.insertMany(myrec).then((ris) => {
|
||||||
|
if (ris) {
|
||||||
|
return mytable.deleteMany( {_id: myidDel } ).then((risdel) => {
|
||||||
|
return res.send({code: server_constants.RIS_CODE_OK, msg: ''});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return res.status(404).send();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
await mytable.findByIdAndUpdate(id, {$set: fieldsvalue}).then(async (rec) => {
|
await mytable.findByIdAndUpdate(id, {$set: fieldsvalue}).then(async (rec) => {
|
||||||
// tools.mylogshow(' REC TO MODIFY: ', rec);
|
// tools.mylogshow(' REC TO MODIFY: ', rec);
|
||||||
if (!rec) {
|
if (!rec) {
|
||||||
@@ -568,52 +558,6 @@ router.patch('/chval', authenticate, async (req, res) => {
|
|||||||
} else {
|
} else {
|
||||||
let addmsg = '';
|
let addmsg = '';
|
||||||
|
|
||||||
if (mydata.table === 'navi' && ('made_gift' in fieldsvalue)) {
|
|
||||||
|
|
||||||
if (fieldsvalue['made_gift'] && !rec.received_gift) {
|
|
||||||
if (mydata.tipomsg) {
|
|
||||||
|
|
||||||
if (!!myuser) {
|
|
||||||
mydatamsg.tipomsg = tools.TipoMsg.SEND_MSG_DONO_RICEVUTO_CORRETTAMENTE;
|
|
||||||
const rismsg = await telegrambot.getMsgByTipoMsg(mydatamsg,
|
|
||||||
myuser.lang, myuser, false);
|
|
||||||
addmsg = rismsg.body;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await mytable.findByIdAndUpdate(id, {$set: {received_gift: true}});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!!unset) {
|
|
||||||
const risunset = await mytable.findByIdAndUpdate(id, {$unset: unset});
|
|
||||||
if (!!risunset) {
|
|
||||||
if ('date_made_gift' in unset) {
|
|
||||||
let addtext = strflotta +
|
|
||||||
` E' stato annullato l'invio del dono di ${myuser.name} ${myuser.surname} (${myuser.username}) da parte di ${req.user.name} ${req.user.surname} - [Posiz: ${fieldsvalue.riga}.${fieldsvalue.col}]`;
|
|
||||||
telegrambot.sendMsgTelegramToTheManagers(idapp, addtext, false);
|
|
||||||
tools.writeFlottaLog(idapp, addtext, flotta.riga,
|
|
||||||
flotta.col_prima);
|
|
||||||
|
|
||||||
if (!!recoldnave) {
|
|
||||||
if (!!recoldnave.date_made_gift) {
|
|
||||||
// Se l'utente aveva confermato il Dono, allora gli mando un msg che non è stato ricevuto ...
|
|
||||||
mydatamsg.tipomsg = tools.TipoMsg.SEND_MSG_DONO_NON_RICEVUTO;
|
|
||||||
const rismsg = await telegrambot.getMsgByTipoMsg(mydatamsg,
|
|
||||||
myuser.lang, myuser, false);
|
|
||||||
let mymsg = rismsg.body;
|
|
||||||
if (!!mymsg) {
|
|
||||||
await telegrambot.sendMsgTelegram(idapp, myuser.username,
|
|
||||||
mymsg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SEND_MSG_DONO_RICEVUTO_CORRETTAMENTE
|
|
||||||
|
|
||||||
if (mydata.notifBot) {
|
if (mydata.notifBot) {
|
||||||
// Send Notification to the BOT
|
// Send Notification to the BOT
|
||||||
await telegrambot.sendMsgTelegram(idapp, mydata.notifBot.un,
|
await telegrambot.sendMsgTelegram(idapp, mydata.notifBot.un,
|
||||||
@@ -632,22 +576,6 @@ router.patch('/chval', authenticate, async (req, res) => {
|
|||||||
if (camporequisiti) {
|
if (camporequisiti) {
|
||||||
await User.checkIfSbloccatiRequisiti(idapp, allData, id);
|
await User.checkIfSbloccatiRequisiti(idapp, allData, id);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (mydata.table === 'flotte') {
|
|
||||||
if (('date_start' in fieldsvalue) || ('date_close' in fieldsvalue)) {
|
|
||||||
await NavePersistente.changeField(idapp, rec, fieldsvalue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mydata.table === 'users') {
|
|
||||||
/*if ('saw_zoom_presentation' in fieldsvalue) {
|
|
||||||
if (fieldsvalue['saw_zoom_presentation']) {
|
|
||||||
const messaggio = tools.get__('ZOOM_CONFERMATO');
|
|
||||||
await telegrambot.sendMsgTelegram(idapp, myuser.username, messaggio);
|
|
||||||
await telegrambot.sendMsgTelegramToTheManagersAndZoomeri(idapp, `L\'utente ${rec.name} ${rec.surname} (${rec.username}) è stato confermato per aver visto lo Zoom di Benvenuto`);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if ('aportador_solidario' in fieldsvalue) {
|
if ('aportador_solidario' in fieldsvalue) {
|
||||||
let ind_order_ingr = mydata.ind_order_ingr;
|
let ind_order_ingr = mydata.ind_order_ingr;
|
||||||
@@ -693,43 +621,6 @@ router.patch('/chval', authenticate, async (req, res) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mydata.table === 'listaingressos') {
|
|
||||||
if ('invitante_username' in fieldsvalue) {
|
|
||||||
// SERVE SE CI METTO LE MINUSCOLE/MAIUSCOLE SBAGLIATE in invitante_username!
|
|
||||||
const myuserfound = await User.findByUsername(idapp,
|
|
||||||
fieldsvalue.invitante_username, false);
|
|
||||||
if (!!myuserfound) {
|
|
||||||
if (!!myuserfound._id && !myuserfound.deleted) {
|
|
||||||
fieldsvalue.invitante_username = await User.getUsernameById(idapp,
|
|
||||||
myuserfound._id);
|
|
||||||
//Aggiorna record !
|
|
||||||
const ris = await mytable.findByIdAndUpdate(id,
|
|
||||||
{$set: fieldsvalue});
|
|
||||||
if (!!ris) {
|
|
||||||
/*let fieldsv2 = {
|
|
||||||
aportador_solidario: fieldsvalue.invitante_username
|
|
||||||
};
|
|
||||||
|
|
||||||
//Aggiorna record !
|
|
||||||
await User.findByIdAndUpdate(myuserfound._id, { $set: fieldsv2 });
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// res.send({ code: server_constants.RIS_CODE_ERR, msg: 'Non aggiornato' });
|
|
||||||
// res.status(400).send();
|
|
||||||
// return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ('note' in fieldsvalue) {
|
|
||||||
// Aggiornalo anche in Graduatorie
|
|
||||||
await Graduatoria.findOneAndUpdate({
|
|
||||||
idapp,
|
|
||||||
idListaIngresso: id,
|
|
||||||
}, {$set: {note: fieldsvalue.note}}, {new: false});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tools.ModificheConsentite(mydata.table, fieldsvalue)) {
|
if (tools.ModificheConsentite(mydata.table, fieldsvalue)) {
|
||||||
let msg = '';
|
let msg = '';
|
||||||
if (mydata.table === 'users') {
|
if (mydata.table === 'users') {
|
||||||
@@ -754,17 +645,6 @@ router.patch('/chval', authenticate, async (req, res) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (mydata.table === 'navi') {
|
|
||||||
if ('made_gift' in fieldsvalue) {
|
|
||||||
if (!!fieldsvalue.riga) {
|
|
||||||
const navepers = await Nave.ricalcolaNave(idapp, null,
|
|
||||||
fieldsvalue.riga, fieldsvalue.col, true, index);
|
|
||||||
|
|
||||||
if (!!navepers)
|
|
||||||
await NavePersistente.aggiornaFlottaByNavePersistente(idapp,
|
|
||||||
navepers);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg !== '')
|
if (msg !== '')
|
||||||
@@ -1721,7 +1601,8 @@ function deleteFile(req, res, version) {
|
|||||||
try {
|
try {
|
||||||
console.log('Delete file ' + relativefile);
|
console.log('Delete file ' + relativefile);
|
||||||
// ++ Move in the folder application !
|
// ++ Move in the folder application !
|
||||||
let fullpathfile = tools.getdirByIdApp(idapp) + dirmain + '/' + relativefile;
|
let fullpathfile = tools.getdirByIdApp(idapp) + dirmain + '/' +
|
||||||
|
relativefile;
|
||||||
|
|
||||||
tools.delete(fullpathfile, (err) => {
|
tools.delete(fullpathfile, (err) => {
|
||||||
if (err) console.log('err', err);
|
if (err) console.log('err', err);
|
||||||
|
|||||||
@@ -2190,4 +2190,12 @@ module.exports = {
|
|||||||
return mystr.replace(/-/g, '/');
|
return mystr.replace(/-/g, '/');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getNumObj(obj) {
|
||||||
|
let count = 0;
|
||||||
|
for (let properties in obj) {
|
||||||
|
count = count + 1;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user