Lista Doni Navi 3
This commit is contained in:
@@ -4,6 +4,7 @@ const _ = require('lodash');
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const { ListaIngresso } = require('./listaingresso');
|
||||
const { NavePersistente } = require('./navepersistente');
|
||||
const { Settings } = require('./settings');
|
||||
const { User } = require('./user');
|
||||
|
||||
@@ -76,15 +77,21 @@ const NaveSchema = new mongoose.Schema({
|
||||
type: Number,
|
||||
default: 1
|
||||
},
|
||||
note: {
|
||||
type: String
|
||||
},
|
||||
provvisoria: {
|
||||
type: Boolean
|
||||
},
|
||||
note: {
|
||||
/* note_bot: {
|
||||
type: String
|
||||
},
|
||||
note_interne: {
|
||||
type: String
|
||||
}
|
||||
},
|
||||
tutor: {
|
||||
type: String
|
||||
}*/
|
||||
});
|
||||
|
||||
NaveSchema.statics.getTotInLista = async function (idapp) {
|
||||
@@ -419,15 +426,10 @@ function getQueryProj(myfilter) {
|
||||
username: 1,
|
||||
'profile.paymenttypes': 1,
|
||||
'profile.email_paypal': 1,
|
||||
date_start: 1,
|
||||
date_gift_chat_open: 1,
|
||||
made_gift: 1,
|
||||
link_chat: 1,
|
||||
sent_msg_howto_make_gift: 1,
|
||||
date_made_gift: 1,
|
||||
provvisoria: 1,
|
||||
note: 1,
|
||||
note_interne: 1,
|
||||
received_gift: 1,
|
||||
date_received_gift: 1,
|
||||
num_tess: 1,
|
||||
@@ -436,6 +438,14 @@ function getQueryProj(myfilter) {
|
||||
riga: 1,
|
||||
col: 1,
|
||||
created: 1,
|
||||
date_start: 1,
|
||||
date_gift_chat_open: 1,
|
||||
link_chat: 1,
|
||||
provvisoria: 1,
|
||||
note_bot: 1,
|
||||
note_interne: 1,
|
||||
tutor: 1,
|
||||
tutor_namesurname: 1,
|
||||
};
|
||||
|
||||
const query = [
|
||||
@@ -527,8 +537,7 @@ NaveSchema.statics.getPlaccaGenerica = async function (idapp, riga, col, offset,
|
||||
try {
|
||||
let recsognatori = await Nave.findSognatoriByFuoco(idapp, riga, col, offset);
|
||||
let recmediatore = await Nave.findMediatoreByFuoco(idapp, riga, col, offset);
|
||||
|
||||
let primofuoco = getPrimoFuocoByIndCol(col);
|
||||
let navepersistente = await NavePersistente.findByRigaColByDonatore(idapp, riga, col, offset);
|
||||
|
||||
mystr = tools.ACAPO;
|
||||
|
||||
@@ -562,7 +571,7 @@ NaveSchema.statics.getPlaccaGenerica = async function (idapp, riga, col, offset,
|
||||
|
||||
let arrdonatori = [];
|
||||
// let numcol = Math.pow(2, indriga - 1);
|
||||
primofuoco = getPrimoFuocoByIndCol(col * Math.pow(2, offset));
|
||||
let primofuoco = getPrimoFuocoByIndCol(col * Math.pow(2, offset));
|
||||
|
||||
let ind = 1;
|
||||
for (let indcol = primofuoco; indcol < primofuoco + 8; indcol++) {
|
||||
@@ -589,6 +598,7 @@ NaveSchema.statics.getPlaccaGenerica = async function (idapp, riga, col, offset,
|
||||
res = {
|
||||
recsognatori,
|
||||
recmediatore,
|
||||
navepersistente,
|
||||
arrdonatori
|
||||
};
|
||||
|
||||
@@ -624,6 +634,7 @@ NaveSchema.statics.getPlaccaPerDonatore = async function (idapp, riga, col, solo
|
||||
NaveSchema.statics.getPlaccaPerMediatore = async function (idapp, riga, col, solorecord, rec) {
|
||||
const Nave = this;
|
||||
rec.mediatore = await Nave.getPlaccaGenerica(idapp, riga, col, tools.Placca.SONOACQUA, solorecord);
|
||||
rec.mediatore.navepersistente = await NavePersistente.findByRigaColByDonatore(idapp, riga, col, -tools.Placca.SONOACQUA);
|
||||
|
||||
rec.mediatore.arrterra = await Nave.getArrTerra(idapp, riga, col);
|
||||
rec.mediatore.arraria = await Nave.getArrAria(idapp, riga, col);
|
||||
@@ -681,6 +692,7 @@ NaveSchema.statics.getNavePos = async function (idapp, riga, col, solorecord) {
|
||||
await Nave.findRecByRigaColParent(idapp, riga, col, 1)];
|
||||
|
||||
let recmediatore = await Nave.findByRigaCol(idapp, riga, col, true);
|
||||
let recnavepersistente = await NavePersistente.findByRigaCol(idapp, riga, col, 0);
|
||||
|
||||
|
||||
mystr = '🌈SOGNATORE: ';
|
||||
@@ -746,15 +758,17 @@ NaveSchema.statics.getNavePos = async function (idapp, riga, col, solorecord) {
|
||||
let data = "";
|
||||
let mystrtemp = '';
|
||||
if (primofuoco) {
|
||||
data = '💬 Giorno di Apertura GIFT CHAT: ' + tools.getstrDateLong(primofuoco.date_gift_chat_open) + tools.ACAPO;
|
||||
data += "🎁 Giorno in cui Inviare il DONO : " + tools.getstrDateLong(primofuoco.date_start) + tools.ACAPO;
|
||||
if (!!recmediatore.note)
|
||||
data += "Note: " + recmediatore.note + tools.ACAPO;
|
||||
data = '💬 Giorno di Apertura GIFT CHAT: ' + tools.getstrDateLong(recnavepersistente.date_gift_chat_open) + tools.ACAPO;
|
||||
|
||||
if (!!recnavepersistente.tutor_namesurname)
|
||||
data += 'Il Mediatore sarà contattato 1 giorno prima dal Tutor ' + recnavepersistente.tutor_namesurname + tools.ACAPO;
|
||||
|
||||
data += "🎁 Giorno in cui Inviare il DONO : " + tools.getstrDateLong(recnavepersistente.date_start) + tools.ACAPO;
|
||||
if (!!recnavepersistente.note_bot)
|
||||
data += "Note: " + recnavepersistente.note_bot + tools.ACAPO;
|
||||
data += tools.ACAPO;
|
||||
|
||||
data += 'Il Mediatore sarà contattato 1 giorno prima dal Tutor' + tools.ACAPO;
|
||||
|
||||
if (primofuoco.provvisoria)
|
||||
if (recnavepersistente.provvisoria)
|
||||
mystrtemp = 'TEMPORANEA ';
|
||||
} else
|
||||
data = "";
|
||||
@@ -803,6 +817,8 @@ async function Fuochi8Completati(idapp, params) {
|
||||
NaveSchema.statics.getArrPosizioniByIndOrder = async function (idapp, ind_order) {
|
||||
const Nave = this;
|
||||
|
||||
|
||||
|
||||
arrposizioni = await Nave.find({ 'idapp': idapp, ind_order }).sort({ riga: 1, col: 1 });
|
||||
|
||||
return arrposizioni;
|
||||
@@ -826,7 +842,9 @@ NaveSchema.statics.showListaOrd = async function (idapp) {
|
||||
let mystr = '';
|
||||
let conta = 1;
|
||||
for (const rec of arrrec) {
|
||||
mystr += '[' + conta + '] [' + rec.riga + '.' + rec.col + '] ' + rec.ind_order + ' ' + rec.name + ' ' + rec.surname + ' (' + tools.getstrDateShort(rec.date_start) + ')\n';
|
||||
let recnavepersistente = await NavePersistente.findByRigaColByDonatore(idapp, rec.riga, rec.col, 0);
|
||||
|
||||
mystr += '[' + conta + '] [' + rec.riga + '.' + rec.col + '] ' + rec.ind_order + ' ' + rec.name + ' ' + rec.surname + ' (' + tools.getstrDateShort(recnavepersistente.date_start) + ')\n';
|
||||
conta++;
|
||||
}
|
||||
|
||||
@@ -841,6 +859,19 @@ NaveSchema.statics.getLastRigaCol = async function (idapp) {
|
||||
async function addRecordNaveByParams(params, siRitesse) {
|
||||
const { ListaIngresso } = require('./listaingresso');
|
||||
|
||||
let mypos = {
|
||||
idapp: params.idapp,
|
||||
riga: params.riga,
|
||||
col: params.col,
|
||||
numup: -3
|
||||
};
|
||||
tools.getRigaColByPosUp(mypos);
|
||||
|
||||
params.riga1don = mypos.riga;
|
||||
params.col1don = mypos.col;
|
||||
|
||||
await NavePersistente.addRecordNavePersistenteByParams(params);
|
||||
|
||||
if (!siRitesse) {
|
||||
// Check if Exist:
|
||||
const giapresente = await Nave.findOne({
|
||||
@@ -863,10 +894,7 @@ async function addRecordNaveByParams(params, siRitesse) {
|
||||
ind_order: params.ind_order,
|
||||
riga: params.riga,
|
||||
col: params.col,
|
||||
date_start: params.date_start,
|
||||
date_gift_chat_open: params.date_gift_chat_open,
|
||||
num_tess: params.num_tess,
|
||||
provvisoria: params.provvisoria,
|
||||
});
|
||||
myNave.created = new Date();
|
||||
|
||||
@@ -1040,9 +1068,10 @@ NaveSchema.statics.generaNave = async function (idapp, mydata) {
|
||||
let myNave = new Nave({ idapp, indprimario: 0, ind_order: 0, riga: 0, col: 0 });
|
||||
myNave.created = new Date();
|
||||
myNave.parent_id = ObjectID("5e592aecbfd0b75f3021d9c9");
|
||||
myNave.date_start = params.date_start;
|
||||
await myNave.save();
|
||||
|
||||
await NavePersistente.addRecordNavePersistenteByParams({ idapp, riga: 0, col: 0, riga1don: 0, col1don: 0 });
|
||||
|
||||
const userFondo = await User.findByIndOrder(idapp, 0);
|
||||
if (!userFondo || userFondo === undefined) {
|
||||
await telegrambot.sendMsgTelegramToTheAdmin(idapp, 'Devi creare l\'utente FONDO , con ind_order = 0 ! ');
|
||||
|
||||
Reference in New Issue
Block a user