- Aggiornamento template mail (tramite i campi in HTML)

- Aggiornato Carrello
This commit is contained in:
Surya Paolo
2023-12-28 00:50:35 +01:00
parent 15d831eecc
commit f23047bcd5
10 changed files with 96 additions and 29 deletions

View File

@@ -27,9 +27,12 @@ html
p   p  
tr tr
td(class="emailContainer", valign="top") td(class="emailContainer", valign="top")
- var mioheader = orders.storehouse.email_html_header
p Ciao #{username}, if (mioheader)
p Ti confermiamo che hai appena inviato un'ordine di prenotazione dei seguenti prodotti: p!= mioheader
else
p Ciao #{username},
p Ti confermiamo che hai appena inviato un'ordine di prenotazione dei seguenti prodotti:
tr tr
td(class="whitespace", height="10") td(class="whitespace", height="10")
@@ -93,9 +96,20 @@ html
tr tr
td(class="whitespace", height="10") td(class="whitespace", height="10")
p Ti arriverà una email quando i prodotti saranno disponibili per poterli venire a ritirare. tr
p Il pagamento potrai farlo direttamente in sede. td
p Grazie Mille - var miomakeorder = orders.storehouse.email_html_makeorder
if (miomakeorder)
p!= miomakeorder
else
p Ti arriverà una email quando i prodotti saranno disponibili per poterli venire a ritirare.
p Il pagamento, se non diversamente comunicato, potrai farlo direttamente in sede.
- var miofooter = orders.storehouse.email_html_footer
if (miofooter)
p!= miofooter
else
p Grazie Mille
table.footer(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center") table.footer(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
tr tr

View File

@@ -88,14 +88,26 @@ html
td(class="sectionContent", valign="top") td(class="sectionContent", valign="top")
p Totale: #{TotalPriceProduct} € p Totale: #{TotalPriceProduct} €
p Note Aggiuntive: #{note} if (note)
p Note Aggiuntive: #{note}
p.sectionContentTitle.boldhigh.sectionTotal Totale Ordine: #{totalPrice} € p.sectionContentTitle.boldhigh.sectionTotal Totale Ordine: #{totalPrice} €
tr tr
td(class="whitespace", height="10") td(class="whitespace", height="10")
p Puoi pertanto venire a ritirarli direttamente in sede. tr
p Grazie Mille td
- var miordconfirmed = orders.storehouse.email_html_order_confirmed
if (miordconfirmed)
p!= miordconfirmed
else
p Puoi pertanto venire a ritirarli direttamente in sede, negli orari che ti sono stati indicati.
- var miofooter = orders.storehouse.email_html_footer
if (miofooter)
p!= miofooter
else
p Grazie Mille
table.footer(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center") table.footer(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
tr tr

View File

@@ -589,7 +589,9 @@ module.exports.getmsgorderTelegram = async function (ordersCart) {
msg += '<br>'; msg += '<br>';
msg += '<br>Totale Prodotti: ' + ordersCart.totalQty + ordersCart.totalQtyPreordered; let totqta = ordersCart.totalQty + ordersCart.totalQtyPreordered;
msg += '<br>Totale Prodotti: ' + totqta;
msg += '<br>Totale Ordine: ' + ordersCart.totalPrice + ' € 💰'; msg += '<br>Totale Ordine: ' + ordersCart.totalPrice + ' € 💰';

View File

@@ -40,15 +40,22 @@ const storehouseSchema = new Schema({
website: { website: {
type: String, type: String,
}, },
stockQty: { // in magazzino email_html_header: {
type: Number, type: String,
default: 0, default: '',
}, },
bookableQty: { // Quantità prenotabili email_html_footer: {
type: Number, type: String,
default: 0, default: '',
},
email_html_makeorder: {
type: String,
default: '',
},
email_html_order_confirmed: {
type: String,
default: '',
}, },
}); });
var Storehouse = module.exports = mongoose.model('Storehouse', storehouseSchema); var Storehouse = module.exports = mongoose.model('Storehouse', storehouseSchema);

View File

@@ -55,6 +55,17 @@ class Cart {
return false; return false;
} }
isSameStorehouse(itemorder) {
if (this.items.length > 0) {
const mystorehouse = this.items[0].order.idStorehouse
return (mystorehouse ? mystorehouse._id.toString() === itemorder.idStorehouse : true);
} else {
return true;
}
}
async addqty(itemorder) { async addqty(itemorder) {
const myitem = this.items.find((rec) => rec.order._id.toString() === itemorder._id) const myitem = this.items.find((rec) => rec.order._id.toString() === itemorder._id)
if (!!myitem) { if (!!myitem) {

View File

@@ -67,6 +67,8 @@ router.post('/import', authenticate, async (req, res) => {
link: product.link, link: product.link,
idCatProds: [], idCatProds: [],
img: 'upload/products/' + product.code + '.jpg', img: 'upload/products/' + product.code + '.jpg',
weight: product.weight,
unit: tools.getIdUnitsByText(product.unit),
} }
if (product.cat_name) { if (product.cat_name) {

View File

@@ -85,14 +85,19 @@ router.post('/:userId', authenticate, async function (req, res, next) {
let newCart = CartClass.constructByCart(mycart); let newCart = CartClass.constructByCart(mycart);
// order = await Product.updateProductInOrder(order); // order = await Product.updateProductInOrder(order);
if (!nuovo) { if (!nuovo) {
if (addqty) { // Controlla se sto inserendo un prodotto con 2 Negozi, non permetterlo !
myord = await newCart.addqty(order); if (newCart.isSameStorehouse(order)) {
} else if (subqty) { if (addqty) {
myord = await newCart.subqty(order); myord = await newCart.addqty(order);
} else if (subqty) {
myord = await newCart.subqty(order);
} else {
const ind = newCart.addItem(order);
const arrord = await Order.getTotalOrderById(order._id);
myord = arrord ? arrord[0] : null;
}
} else { } else {
const ind = newCart.addItem(order); return res.send({ code: server_constants.RIS_CODE_ERR, cart: null, myord: null, msgerr: 'Non è possibile acquistare nello stesso ordine, su negozi differenti!' });
const arrord = await Order.getTotalOrderById(order._id);
myord = arrord ? arrord[0] : null;
} }
} else { } else {
await newCart.updatetotals(); await newCart.updatetotals();

View File

@@ -78,7 +78,7 @@ router.post('/', authenticate, async (req, res) => {
if (req.body.options !== null) { if (req.body.options !== null) {
tools.sendBackNotif(subscription, req.body.options); tools.sendBackNotif(subscription, req.body.options);
} }
console.log('Subscription saved... ') // console.log('Subscription saved... ')
return res.send({data: 'Subscription saved.'}); return res.send({data: 'Subscription saved.'});
} }
}); });

View File

@@ -824,8 +824,7 @@ module.exports = {
headers: vapidHeaders, headers: vapidHeaders,
}; };
console.log('************ INVIO WEBPUSH.SENDNOTIFICATION N° ', // console.log('************ INVIO WEBPUSH.SENDNOTIFICATION N° ', conta, '/', trovati, 'A', subscription.browser);
conta, '/', trovati, 'A', subscription.browser);
const pushPayload = JSON.stringify(payload); const pushPayload = JSON.stringify(payload);
@@ -4368,5 +4367,15 @@ module.exports = {
return Object.keys(obj).length === 0; return Object.keys(obj).length === 0;
}, },
getUnitsMeasure(unit, short) {
const unitrec = shared_consts.Units_Of_Measure_ListBox.find((rec) => rec.value === unit)
return unitrec ? (short ? unitrec.short : unitrec.label) : ''
},
getIdUnitsByText(unitstr) {
const unitrec = shared_consts.Units_Of_Measure_ListBox.find((rec) => rec.short === unitstr)
return unitrec ? unitrec.value : 0
},
}; };

View File

@@ -348,22 +348,27 @@ module.exports = {
Units_Of_Measure_ListBox: [ Units_Of_Measure_ListBox: [
{ {
label: '[Nessuno]', label: '[Nessuno]',
short: '',
value: 0, value: 0,
}, },
{ {
label: 'Grammi (g)', label: 'Grammi (g)',
short: 'g',
value: 1, value: 1,
}, },
{ {
label: 'Chili (kg)', label: 'Chili (kg)',
short: 'Kg',
value: 2, value: 2,
}, },
{ {
label: 'Litri (l)', label: 'Litri (L)',
short: 'L',
value: 3, value: 3,
}, },
{ {
label: 'Pezzi (p)', label: 'Pezzi (p)',
short: 'p',
value: 4, value: 4,
}, },
], ],