From 624f929c56c332d2ea71135e17c965f34b05367b Mon Sep 17 00:00:00 2001 From: Paolo Arena Date: Thu, 10 Oct 2019 21:08:12 +0200 Subject: [PATCH] - Booking: added modify a booking (+ emails). --- .../it/html.pug | 1 + .../it/subject.pug | 0 emails/admin/modifybooking/it/html.pug | 30 +++++++++++++++++++ emails/admin/modifybooking/it/subject.pug | 1 + emails/booking/makebooking/it/html.pug | 1 + emails/booking/modifybooking/it/html.pug | 30 +++++++++++++++++++ emails/booking/modifybooking/it/subject.pug | 1 + server/models/booking.js | 6 +++- server/sendemail.js | 12 ++++++-- server/tools/general.js | 4 +-- 10 files changed, 81 insertions(+), 5 deletions(-) rename emails/admin/{makebookingadmin => makebooking}/it/html.pug (95%) rename emails/admin/{makebookingadmin => makebooking}/it/subject.pug (100%) create mode 100644 emails/admin/modifybooking/it/html.pug create mode 100644 emails/admin/modifybooking/it/subject.pug create mode 100644 emails/booking/modifybooking/it/html.pug create mode 100644 emails/booking/modifybooking/it/subject.pug diff --git a/emails/admin/makebookingadmin/it/html.pug b/emails/admin/makebooking/it/html.pug similarity index 95% rename from emails/admin/makebookingadmin/it/html.pug rename to emails/admin/makebooking/it/html.pug index 8c52df2..24e7ab7 100644 --- a/emails/admin/makebookingadmin/it/html.pug +++ b/emails/admin/makebooking/it/html.pug @@ -1,6 +1,7 @@ p Ciao, p Ti confermiamo che #{name} #{surname} ha appena inviato una richiesta di prenotazione per l'evento #{event} span #{participants} +p Messaggio: #{msgbooking} p Cordiali Saluti p Supporto #{nomeapp} diff --git a/emails/admin/makebookingadmin/it/subject.pug b/emails/admin/makebooking/it/subject.pug similarity index 100% rename from emails/admin/makebookingadmin/it/subject.pug rename to emails/admin/makebooking/it/subject.pug diff --git a/emails/admin/modifybooking/it/html.pug b/emails/admin/modifybooking/it/html.pug new file mode 100644 index 0000000..c1c787f --- /dev/null +++ b/emails/admin/modifybooking/it/html.pug @@ -0,0 +1,30 @@ +p Ciao, +p Ti confermiamo che #{name} #{surname} ha appena Modificato la sua prenotazione per l'evento #{event} +span #{participants} +p Messaggio: #{msgbooking} + +p Cordiali Saluti +p Supporto #{nomeapp} + +style(type="text/css"). + html, body { + padding: 0; + margin: 0; + } + + .divbtn { + display: flex; + align-items: center; + justify-content: center; + } + + .btn-lg { + padding: 5px; + margin: 5px; + font-size: 26px; + cursor: pointer; + color: white; + background: #027be3 !important; + border-radius: 28px; + + } diff --git a/emails/admin/modifybooking/it/subject.pug b/emails/admin/modifybooking/it/subject.pug new file mode 100644 index 0000000..4c6b715 --- /dev/null +++ b/emails/admin/modifybooking/it/subject.pug @@ -0,0 +1 @@ +=`${name} ${surname} ha modificato la prenotazione per l'evento ${eventtextplain}` diff --git a/emails/booking/makebooking/it/html.pug b/emails/booking/makebooking/it/html.pug index a7fd2ce..fb0b073 100644 --- a/emails/booking/makebooking/it/html.pug +++ b/emails/booking/makebooking/it/html.pug @@ -1,6 +1,7 @@ p Ciao #{name}, p Ti confermiamo che hai appena inviato una richiesta di prenotazione per l'evento #{event} span #{participants} +p Messaggio: #{msgbooking} p Cordiali Saluti p Supporto #{nomeapp} diff --git a/emails/booking/modifybooking/it/html.pug b/emails/booking/modifybooking/it/html.pug new file mode 100644 index 0000000..a216d41 --- /dev/null +++ b/emails/booking/modifybooking/it/html.pug @@ -0,0 +1,30 @@ +p Ciao #{name}, +p Ti confermiamo che hai modificato la prenotazione per l'evento #{event} +span #{participants} +p Messaggio: #{msgbooking} + +p Cordiali Saluti +p Supporto #{nomeapp} + +style(type="text/css"). + html, body { + padding: 0; + margin: 0; + } + + .divbtn { + display: flex; + align-items: center; + justify-content: center; + } + + .btn-lg { + padding: 5px; + margin: 5px; + font-size: 26px; + cursor: pointer; + color: white; + background: #027be3 !important; + border-radius: 28px; + + } diff --git a/emails/booking/modifybooking/it/subject.pug b/emails/booking/modifybooking/it/subject.pug new file mode 100644 index 0000000..a3b750f --- /dev/null +++ b/emails/booking/modifybooking/it/subject.pug @@ -0,0 +1 @@ +=`Aggiornamento della Prenotazione per l'evento ${eventtextplain}` diff --git a/server/models/booking.js b/server/models/booking.js index 9b30c93..ca80f41 100644 --- a/server/models/booking.js +++ b/server/models/booking.js @@ -33,6 +33,10 @@ const bookingSchema = new Schema({ datebooked: { type: Date, }, + modified: { + type: Boolean, + default: false + }, booked: { type: Boolean, }, @@ -43,7 +47,7 @@ bookingSchema.statics.findAllByUserIdAndIdApp = function (userId, idapp) { const Booking = this; return Booking.find({userId, idapp, booked: true}, (err, arrbooked) => { - console.log('ris Booking:', arrbooked); + // console.log('ris Booking:', arrbooked); return arrbooked }); }; diff --git a/server/sendemail.js b/server/sendemail.js index 5c43bd7..5c7bdf7 100644 --- a/server/sendemail.js +++ b/server/sendemail.js @@ -148,6 +148,7 @@ module.exports = { surname: user.surname, emailto: emailto, participants: '', + msgbooking: recbooking.msgbooking, eventtextplain: tools.removeSpecialCharForEmail(recbooking.infoevent), event: recbooking.infoevent, }; @@ -155,10 +156,17 @@ module.exports = { if (recbooking.numpeople > 1) mylocalsconf.participants = recbooking.numpeople.toString() + ' ' + res.__("partecipanti"); - this.sendEmail_base('booking/makebooking/' + lang, user, emailto, mylocalsconf); + let texthtml = ''; + if (recbooking.modified) { + texthtml = 'modifybooking'; + }else { + texthtml = 'makebooking'; + } + + this.sendEmail_base('booking/'+texthtml+'/' + lang, user, emailto, mylocalsconf); // Send Email also to the Admin - this.sendEmail_base('admin/makebooking/' + lang, user, tools.getAdminEmailByIdApp(idapp), mylocalsconf); + this.sendEmail_base('admin/'+texthtml+'/' + lang, user, tools.getAdminEmailByIdApp(idapp), mylocalsconf); }, sendEmail_CancelBooking: function (res, lang, emailto, user, idapp, recbooking) { diff --git a/server/tools/general.js b/server/tools/general.js index 46947d0..2f6d959 100644 --- a/server/tools/general.js +++ b/server/tools/general.js @@ -73,11 +73,11 @@ module.exports = { }, allfieldBooking: function () { - return ['idapp', 'userId', 'id_bookedevent', 'numpeople', 'msgbooking', 'infoevent', 'datebooked', 'booked'] + return ['idapp', 'userId', 'id_bookedevent', 'numpeople', 'msgbooking', 'modified', 'infoevent', 'datebooked', 'booked'] }, allfieldBookingChange: function () { - return ['numpeople', 'msgbooking', 'infoevent', 'datebooked', 'booked'] + return ['numpeople', 'msgbooking', 'modified', 'infoevent', 'datebooked', 'booked'] }, allfieldProjectWithId: function () {