Errore in visualizzazione degli eventi ! non si vedevano piu!

This commit is contained in:
Paolo Arena
2021-06-24 15:55:38 +02:00
parent 9d5eda50ae
commit 10e9da805e
3 changed files with 88 additions and 59 deletions

View File

@@ -32,6 +32,18 @@ span Abilita le Newsletter? : 
strong #{iscritto.newsletter_on}<br>
span Metodo di Pagamento :&nbsp;
strong #{metodo_pagamento}<br>
span Motivazioni sul perchè intendi iscriverti alla CNM:&nbsp;
strong #{iscritto.motivazioni}<br>
span Descrivi le tue competenze e professionalità:&nbsp;
strong #{iscritto.competenze_professionalita}<br>
span Cosa potresti offrire?:&nbsp;
strong #{iscritto.cosa_potrei_offrire}<br>
span Cosa vorresti ricevere? (cosa ti aspetti?):&nbsp;
strong #{iscritto.cosa_vorrei_ricevere}<br>
span Scrivi altre eventuali informazioni o comunicazioni:&nbsp;
strong #{iscritto.altre_comunicazioni}<br>
span Come ci hai conosciuto?:&nbsp;
strong #{iscritto.come_ci_hai_conosciuto}<br>
p <br>Saluti
style(type="text/css").

View File

@@ -2,17 +2,17 @@ const mongoose = require('mongoose');
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;
mongoose.level = "F";
mongoose.level = 'F';
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const {ObjectID} = require('mongodb');
const { Settings } = require('./settings');
const {Settings} = require('./settings');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
schema.options.usePushEach = true
schema.options.usePushEach = true;
});
const MyEventSchema = new Schema({
@@ -121,7 +121,8 @@ const MyEventSchema = new Schema({
note: {
type: String,
},
pagefooter: [{
pagefooter: [
{
type: String,
}],
deleted: {
@@ -138,115 +139,132 @@ const MyEventSchema = new Schema({
},
});
MyEventSchema.statics.findAllIdApp = function (socioresidente, idapp) {
MyEventSchema.statics.findAllIdApp = function(socioresidente, idapp) {
const Event = this;
let query = []
let query = [];
if (socioresidente) {
query = [
{
$match: {
idapp,
}
}
]
$or: [
{deleted: {$exists: false}},
{deleted: {$exists: true, $eq: false}}],
},
},
];
} else {
query = [
{
$match: {
idapp,
$and: [
{
$or: [
{ $or: [{ internal: { $exists: false } }, { internal: { $exists: true, $eq: false } }] },
{deleted: {$exists: false}},
{deleted: {$exists: true, $eq: false}},
],
}
}
]
},
{
$or: [
{internal: {$exists: false}},
{internal: {$exists: true, $eq: false}}],
},
],
},
},
];
}
query.push({ $sort: { dateTimeStart: 1 } })
query.push({$sort: {dateTimeStart: 1}});
return Event
.aggregate(query)
.then((arrrec) => {
return arrrec
})
return Event.aggregate(query).then((arrrec) => {
return arrrec;
});
};
MyEventSchema.statics.getLastEvents = async function (idapp) {
MyEventSchema.statics.getLastEvents = async function(idapp) {
const Event = this;
const lastn = await Settings.getValDbSettings(idapp, 'SHOW_LAST_N_EV', 1);
const query = [
{ $match: { idapp, dateTimeStart: { $gte: tools.IncDateNow(-1000 * 60 * 60 * 24) } } },
{
$match: {
idapp,
dateTimeStart: {$gte: tools.IncDateNow(-1000 * 60 * 60 * 24)},
$or: [
{deleted: {$exists: false}},
{deleted: {$exists: true, $eq: false}}],
},
},
{
$lookup: {
from: 'operators',
localField: 'teacher',
foreignField: 'username',
as: 'op1'
}
as: 'op1',
},
},
{
$lookup: {
from: 'operators',
localField: 'teacher2',
foreignField: 'username',
as: 'op2'
}
as: 'op2',
},
},
{
$lookup: {
from: 'operators',
localField: 'teacher3',
foreignField: 'username',
as: 'op3'
}
as: 'op3',
},
},
{
$lookup: {
from: 'operators',
localField: 'teacher4',
foreignField: 'username',
as: 'op4'
}
as: 'op4',
},
{ "$addFields": { "contribtype": { "$toObjectId": "$contribtype" } } },
},
{'$addFields': {'contribtype': {'$toObjectId': '$contribtype'}}},
{
$lookup: {
from: 'contribtypes',
localField: 'contribtype',
foreignField: '_id',
as: 'contrib'
}
as: 'contrib',
},
{ $sort: { dateTimeStart: 1 } }
},
{$sort: {dateTimeStart: 1}},
];
return Event
.aggregate(query)
.then((arrrec) => {
return Event.aggregate(query).then((arrrec) => {
// console.table(arrrec);
if (lastn > 0) {
return arrrec.slice(0, lastn);
} else {
return arrrec
return arrrec;
}
})
});
};
MyEventSchema.statics.getFieldsForSearch = function () {
return [{ field: 'short_tit', type: tools.FieldType.string },
{ field: 'title', type: tools.FieldType.string },
{ field: 'teacher', type: tools.FieldType.string },
{ field: 'details', type: tools.FieldType.string }]
MyEventSchema.statics.getFieldsForSearch = function() {
return [
{field: 'short_tit', type: tools.FieldType.string},
{field: 'title', type: tools.FieldType.string},
{field: 'teacher', type: tools.FieldType.string},
{field: 'details', type: tools.FieldType.string}];
};
MyEventSchema.statics.executeQueryTable = function (idapp, params) {
MyEventSchema.statics.executeQueryTable = function(idapp, params) {
params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, idapp, params);
};
@@ -256,7 +274,6 @@ if (tools.INITDB_FIRSTIME) {
// MyEventSchema.index({ short_tit: 'text', title: 'text', teacher: 'text', details: 'text' });
}
const MyEvent = mongoose.model('MyEvent', MyEventSchema);
module.exports = { MyEvent };
module.exports = {MyEvent};

View File

@@ -203,9 +203,9 @@ module.exports = {
tools.sendNotifToAdmin('Nuova Registrazione Utente: ' + mylocalsconf.name + ' ' + mylocalsconf.surname + ' (' + mylocalsconf.username + ')');
if (tools.isManagAndAdminDifferent(idapp)) {
this.sendEmail_base('admin/registration/' + tools.LANGADMIN, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
}
// if (tools.isManagAndAdminDifferent(idapp)) {
// this.sendEmail_base('admin/registration/' + tools.LANGADMIN, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
// }
},
sendEmail_IscrizioneConacreis: async function (lang, emailto, iscritto, idapp) {