ECommerce Ordini Email 1
This commit is contained in:
120
emails/ecommerce/makeorder/it/html.pug
Executable file
120
emails/ecommerce/makeorder/it/html.pug
Executable file
@@ -0,0 +1,120 @@
|
|||||||
|
doctype html
|
||||||
|
html
|
||||||
|
head
|
||||||
|
title Ordine Effettuato
|
||||||
|
|
||||||
|
//- import css/scss stylesheets
|
||||||
|
//- these file names will be replace by gulp with proper css file paths
|
||||||
|
link(rel="stylesheet", href="../sass/basic.scss")
|
||||||
|
link(rel="stylesheet", href="../sass/one/styles.scss")
|
||||||
|
|
||||||
|
//- embdedded css allowed, but not sass
|
||||||
|
style.
|
||||||
|
.red {
|
||||||
|
background-color: #E84C50;
|
||||||
|
}
|
||||||
|
|
||||||
|
.full-width {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
body(yahoofix, style="background: #ffffff")
|
||||||
|
- var baseimg = baseurl + '/statics/'
|
||||||
|
span(id='body_style', style='display:block')
|
||||||
|
table(cellpadding="10", cellspacing="0", width="600", align="center")
|
||||||
|
tr
|
||||||
|
td(class="whitespace", height="10")
|
||||||
|
p
|
||||||
|
tr
|
||||||
|
td(class="emailContainer", valign="top")
|
||||||
|
|
||||||
|
p Ciao #{name},
|
||||||
|
p Ti confermiamo che hai appena inviato un'ordine di prenotazione dei seguenti prodotti:
|
||||||
|
|
||||||
|
tr
|
||||||
|
td(class="whitespace", height="10")
|
||||||
|
p
|
||||||
|
|
||||||
|
- var totalPrice = orders.totalPrice
|
||||||
|
- var index = 0
|
||||||
|
|
||||||
|
each product in orders.items
|
||||||
|
- var descr = product._doc.order.product.name
|
||||||
|
- var img = product._doc.order.product.img
|
||||||
|
- var price = product._doc.order.price
|
||||||
|
- var qty = product._doc.order.quantity
|
||||||
|
- index = index + 1
|
||||||
|
|
||||||
|
table(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
|
||||||
|
tr
|
||||||
|
td(class="column", valign="center" width="40")
|
||||||
|
p.boldhigh #{index}.
|
||||||
|
|
||||||
|
td(class="column sectionArticleImage", valign="top" width="150")
|
||||||
|
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||||
|
tr
|
||||||
|
td
|
||||||
|
img(src=baseimg + img, alt="", width="150" height="150")
|
||||||
|
td(class="column", valign="top")
|
||||||
|
|
||||||
|
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||||
|
tr
|
||||||
|
td(class="sectionContentTitle boldhigh", valign="top")
|
||||||
|
p #{descr}
|
||||||
|
tr
|
||||||
|
td(class="sectionContent", valign="top")
|
||||||
|
p Prezzo: #{price} €
|
||||||
|
tr
|
||||||
|
td(class="sectionContent", valign="top")
|
||||||
|
p Quantità: #{qty}
|
||||||
|
|
||||||
|
p.sectionContentTitle.boldhigh.sectionTotal Totale Ordine: #{totalPrice} €
|
||||||
|
|
||||||
|
|
||||||
|
p Ti arriverà una email quando i prodotti saranno disponibili per poterli venire a ritirare.
|
||||||
|
p Il pagamento potrai farlo direttamente in sede.
|
||||||
|
p Grazie Mille
|
||||||
|
p
|
||||||
|
|
||||||
|
table.footer(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
|
||||||
|
tr
|
||||||
|
td(class="whitespace", height="10")
|
||||||
|
p
|
||||||
|
tr
|
||||||
|
td.firma
|
||||||
|
p!= dataemail.firma
|
||||||
|
|
||||||
|
tr
|
||||||
|
td.disclaimer
|
||||||
|
p!= dataemail.disclaimer_out
|
||||||
|
|
||||||
|
tr
|
||||||
|
td.bottom
|
||||||
|
p!= dataemail.disc_bottom_out
|
||||||
|
|
||||||
|
tr
|
||||||
|
td(class="whitespace", height="10")
|
||||||
|
p
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
1
emails/ecommerce/makeorder/it/subject.pug
Executable file
1
emails/ecommerce/makeorder/it/subject.pug
Executable file
@@ -0,0 +1 @@
|
|||||||
|
=`Ordine n. ${ordernumber} effettuato`
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
doctype html
|
doctype html
|
||||||
html
|
html
|
||||||
head
|
head
|
||||||
title One | Email template!
|
title Calendario Eventi
|
||||||
|
|
||||||
//- import css/scss stylesheets
|
//- import css/scss stylesheets
|
||||||
//- these file names will be replace by gulp with proper css file paths
|
//- these file names will be replace by gulp with proper css file paths
|
||||||
|
|||||||
@@ -208,6 +208,10 @@ p {
|
|||||||
padding: 0px 0px 5px 0;
|
padding: 0px 0px 5px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sectionTotal {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
.sectionContentSubTitle {
|
.sectionContentSubTitle {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: #0000ff;
|
color: #0000ff;
|
||||||
|
|||||||
@@ -47,6 +47,12 @@ const MyPageSchema = new Schema({
|
|||||||
onlyif_logged: {
|
onlyif_logged: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
},
|
},
|
||||||
|
only_residenti: {
|
||||||
|
type: Boolean,
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
imgback: {
|
imgback: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ module.exports.executeQueryTable = function (idapp, params) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.exports.getFieldsForSearch = function () {
|
module.exports.getFieldsForSearch = function () {
|
||||||
return [{field: 'note', type: tools.FieldType.string}]
|
return [{ field: 'note', type: tools.FieldType.string }]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -78,9 +78,14 @@ module.exports.getNewNumOrder = async function (uid, idapp) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.getOrdersCartByUserId = async function (uid, idapp) {
|
module.exports.getOrdersCartByUserId = async function (uid, idapp, numorder) {
|
||||||
let query = { userId: uid, idapp, status: { $gte: shared_consts.OrderStatus.CHECKOUT_SENT } }
|
let query = { userId: uid, idapp, status: { $gte: shared_consts.OrderStatus.CHECKOUT_SENT } }
|
||||||
const myorderscart = await OrdersCart.find(query);
|
let myorderscart = null;
|
||||||
|
if (numorder > 0) {
|
||||||
|
query = { userId: uid, idapp, numorder, status: { $gte: shared_consts.OrderStatus.CHECKOUT_SENT } }
|
||||||
|
}
|
||||||
|
|
||||||
|
myorderscart = await OrdersCart.find(query);
|
||||||
|
|
||||||
for (let ind = 0; ind < myorderscart.length; ind++) {
|
for (let ind = 0; ind < myorderscart.length; ind++) {
|
||||||
for (const idkey in myorderscart[ind].items) {
|
for (const idkey in myorderscart[ind].items) {
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ var ProjectSchema = new mongoose.Schema({
|
|||||||
viceRespUsername: {
|
viceRespUsername: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
|
vice2RespUsername: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
statusproj: {
|
statusproj: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 0
|
default: 0
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ var TodoSchema = new mongoose.Schema({
|
|||||||
descr: {
|
descr: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
|
note: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
priority: {
|
priority: {
|
||||||
type: Number,
|
type: Number,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ const shared_consts = require('../tools/shared_nodejs');
|
|||||||
const express = require('express');
|
const express = require('express');
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
|
const sendemail = require('../sendemail');
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
var server_constants = require('../tools/server_constants');
|
var server_constants = require('../tools/server_constants');
|
||||||
@@ -174,13 +175,15 @@ router.post('/:userId/cartstatus', authenticate, async function (req, res, next)
|
|||||||
let idapp = req.body.idapp;
|
let idapp = req.body.idapp;
|
||||||
let userId = req.params.userId;
|
let userId = req.params.userId;
|
||||||
let cart_id = req.body.cart_id;
|
let cart_id = req.body.cart_id;
|
||||||
|
const user = req.user;
|
||||||
let status = req.body.status;
|
let status = req.body.status;
|
||||||
|
|
||||||
const mycart = await Cart.getCartByUserId(userId, idapp);
|
const mycart = await Cart.getCartByUserId(userId, idapp);
|
||||||
|
const numorder = await OrdersCart.getNewNumOrder(userId, idapp);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!!mycart) {
|
if (!!mycart) {
|
||||||
if (status === shared_consts.OrderStatus.CHECKOUT_CONFIRMED) {
|
if (status === shared_consts.OrderStatus.CHECKOUT_SENT) {
|
||||||
// Porta tutto il Cart nell'Ordine
|
// Porta tutto il Cart nell'Ordine
|
||||||
const newOrderCart = new OrdersCart({
|
const newOrderCart = new OrdersCart({
|
||||||
idapp,
|
idapp,
|
||||||
@@ -190,25 +193,35 @@ router.post('/:userId/cartstatus', authenticate, async function (req, res, next)
|
|||||||
userId,
|
userId,
|
||||||
status,
|
status,
|
||||||
note: mycart.note,
|
note: mycart.note,
|
||||||
numorder: await OrdersCart.getNewNumOrder(userId, idapp),
|
numorder,
|
||||||
created_at: new Date(),
|
created_at: new Date(),
|
||||||
modify_at: new Date(),
|
modify_at: new Date(),
|
||||||
})
|
})
|
||||||
const myorderlist = OrdersCart.updateOrdersCartById(-1, newOrderCart, function (err, ris) {
|
return OrdersCart.updateOrdersCartById(-1, newOrderCart, function (err, ris) {
|
||||||
//if (err) return next(err)
|
//if (err) return next(err)
|
||||||
if (err)
|
if (err)
|
||||||
return res.send({ code: server_constants.RIS_CODE_ERR, status: 0 });
|
return res.send({ code: server_constants.RIS_CODE_ERR, status: 0 });
|
||||||
else {
|
else {
|
||||||
const myris = ris;
|
const myris = ris;
|
||||||
// Cancella il Cart appena salvato in OrdersCart
|
// Cancella il Cart appena salvato in OrdersCart
|
||||||
|
|
||||||
Cart.deleteCartByCartId(mycart.id)
|
Cart.deleteCartByCartId(mycart.id)
|
||||||
.then((ris) => {
|
.then((ris) => {
|
||||||
const orders = OrdersCart.getOrdersCartByUserId(userId, idapp)
|
|
||||||
|
const orders = OrdersCart.getOrdersCartByUserId(userId, idapp, numorder)
|
||||||
.then((orders) => {
|
.then((orders) => {
|
||||||
return res.send({ code: server_constants.RIS_CODE_OK, status: myris.status, orders });
|
if (!!orders) {
|
||||||
|
sendemail.sendEmail_OrderProduct(user.lang, idapp, orders[0], user)
|
||||||
|
.then((ris) => {
|
||||||
|
return res.send({
|
||||||
|
code: server_constants.RIS_CODE_OK,
|
||||||
|
status: myris.status,
|
||||||
|
orders: orders[0]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -227,6 +240,8 @@ router.post('/:userId/cartstatus', authenticate, async function (req, res, next)
|
|||||||
}) */
|
}) */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return res.send({ code: server_constants.RIS_CODE_ERR, status: 0 });
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return res.send({ code: server_constants.RIS_CODE_ERR, status: 0 });
|
return res.send({ code: server_constants.RIS_CODE_ERR, status: 0 });
|
||||||
|
|||||||
@@ -1157,7 +1157,7 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
|
|||||||
if (req.user) {
|
if (req.user) {
|
||||||
calcstat = User.calculateStat(idapp, req.user.username);
|
calcstat = User.calculateStat(idapp, req.user.username);
|
||||||
cart = Cart.getCartByUserId(req.user.id, idapp);
|
cart = Cart.getCartByUserId(req.user.id, idapp);
|
||||||
orderscart = OrdersCart.getOrdersCartByUserId(req.user.id, idapp);
|
orderscart = OrdersCart.getOrdersCartByUserId(req.user.id, idapp, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ const OrdersCart = require('../models/orderscart');
|
|||||||
router.get('/:userId', authenticate, function (req, res, next) {
|
router.get('/:userId', authenticate, function (req, res, next) {
|
||||||
let userId = req.body.userId
|
let userId = req.body.userId
|
||||||
let idapp = req.body.idapp
|
let idapp = req.body.idapp
|
||||||
OrdersCart.getOrdersCartByUserId(userId, idapp, function (err, cart) {
|
OrdersCart.getOrdersCartByUserId(userId, idapp, 0, function (err, cart) {
|
||||||
if (err) return next(err)
|
if (err) return next(err)
|
||||||
|
|
||||||
if (cart)
|
if (cart)
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ const { Discipline } = require('./models/discipline');
|
|||||||
const previewEmail = require('preview-email');
|
const previewEmail = require('preview-email');
|
||||||
const nodemailer = require("nodemailer");
|
const nodemailer = require("nodemailer");
|
||||||
|
|
||||||
|
const OrdersCart = require('./models/orderscart');
|
||||||
|
|
||||||
const { MyEvent } = require('./models/myevent');
|
const { MyEvent } = require('./models/myevent');
|
||||||
const { MailingList } = require('./models/mailinglist');
|
const { MailingList } = require('./models/mailinglist');
|
||||||
const { Newstosent } = require('./models/newstosent');
|
const { Newstosent } = require('./models/newstosent');
|
||||||
@@ -552,7 +554,36 @@ module.exports = {
|
|||||||
return smtpTransport;
|
return smtpTransport;
|
||||||
},
|
},
|
||||||
|
|
||||||
sendEmail_Newsletter_Events: async function (lang, idapp, id_newstosent) {
|
sendEmail_OrderProduct: async function (lang, idapp, orders, user) {
|
||||||
|
|
||||||
|
const msginizio = 'INIZIO - sendEmail_OrderProduct: ' + tools.getNomeAppByIdApp(idapp);
|
||||||
|
console.log(msginizio);
|
||||||
|
|
||||||
|
await telegrambot.sendMsgTelegramToTheManagers(idapp, msginizio);
|
||||||
|
|
||||||
|
mylocalsconf = {
|
||||||
|
idapp,
|
||||||
|
locale: lang,
|
||||||
|
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||||
|
orders,
|
||||||
|
baseurl: tools.getHostByIdApp(idapp),
|
||||||
|
dataemail: await this.getdataemail(idapp),
|
||||||
|
ordernumber: orders.numorder,
|
||||||
|
user
|
||||||
|
};
|
||||||
|
|
||||||
|
mylocalsconf.name = user.name;
|
||||||
|
mylocalsconf.surname = user.surname;
|
||||||
|
mylocalsconf.emailto = user.email;
|
||||||
|
mylocalsconf.hashemail = tools.getHash(user.email);
|
||||||
|
|
||||||
|
mylocalsconf = this.replacefields(mylocalsconf);
|
||||||
|
|
||||||
|
const esito = this.sendEmail_base('ecommerce/makeorder/' + lang, mylocalsconf.emailto, mylocalsconf, mylocalsconf.dataemail.email_reply);
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
sendEmail_Newsletter_Events: async function (lang, idapp, id_newstosent) {
|
||||||
|
|
||||||
const msginizio = 'INIZIO - sendEmail_Newsletter_Events: ' + tools.getNomeAppByIdApp(idapp);
|
const msginizio = 'INIZIO - sendEmail_Newsletter_Events: ' + tools.getNomeAppByIdApp(idapp);
|
||||||
console.log(msginizio);
|
console.log(msginizio);
|
||||||
|
|||||||
@@ -617,7 +617,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
allfieldTodo: function () {
|
allfieldTodo: function () {
|
||||||
return ['userId', 'pos', 'category', 'descr', 'priority', 'statustodo', 'assignedToUsers', 'created_at', 'groupId', 'modify_at',
|
return ['userId', 'pos', 'category', 'descr', 'note', 'priority', 'statustodo', 'assignedToUsers', 'created_at', 'groupId', 'modify_at',
|
||||||
'completed_at', 'expiring_at', 'enableExpiring', 'progress', 'modified', 'phase', 'assigned_to_userId', 'assignedToUsers', 'hoursplanned', 'hoursworked', 'start_date', 'themecolor', 'themebgcolor']
|
'completed_at', 'expiring_at', 'enableExpiring', 'progress', 'modified', 'phase', 'assigned_to_userId', 'assignedToUsers', 'hoursplanned', 'hoursworked', 'start_date', 'themecolor', 'themebgcolor']
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user