email da inviare ai clienti ...
This commit is contained in:
@@ -18,39 +18,35 @@
|
||||
- var baseimg = baseurl + '/'
|
||||
doctype html
|
||||
html
|
||||
head
|
||||
title Calendario Eventi
|
||||
- if (dataemail.title)
|
||||
head
|
||||
title dataemail.subject
|
||||
|
||||
//- 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")
|
||||
//- 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;
|
||||
}
|
||||
//- embdedded css allowed, but not sass
|
||||
style.
|
||||
.red {
|
||||
background-color: #E84C50;
|
||||
}
|
||||
|
||||
.full-width {
|
||||
width: 100%;
|
||||
}
|
||||
.full-width {
|
||||
width: 100%;
|
||||
}
|
||||
body(yahoofix)
|
||||
span(id='body_style', style='display:block')
|
||||
table(class="preheader", cellpadding="0", cellspacing="0", width="100%")
|
||||
tr
|
||||
td.webversion
|
||||
p non vedi le immagini?
|
||||
a(href=urlcal) Apri il Calendario
|
||||
|
||||
table(class="topHeader", cellpadding="0", cellspacing="0", width="100%")
|
||||
tr
|
||||
td
|
||||
table(cellpadding="0", cellspacing="0", align="center", summary="")
|
||||
tr
|
||||
td.logoContainer
|
||||
a(href=baseurl, title='logo')
|
||||
img.logo(src=baseurl+"/images/logo.png", height=dataemail.height_logo)
|
||||
- if (dataemail.height_logo)
|
||||
tr
|
||||
td
|
||||
table(cellpadding="0", cellspacing="0", align="center", summary="")
|
||||
tr
|
||||
td.logoContainer
|
||||
a(href=baseurl, title='logo')
|
||||
img.logo(src=baseurl+"/images/logo.png", height=dataemail.height_logo)
|
||||
|
||||
tr
|
||||
td.testomail
|
||||
@@ -61,17 +57,17 @@ html
|
||||
td.clpromo
|
||||
p!= dataemail.textpromo
|
||||
|
||||
- if (dataemail.templ.content)
|
||||
table(cellpadding="0", cellspacing="0", width="95%", align="center")
|
||||
tr
|
||||
td(class="textIniContainer", valign="top")
|
||||
p!=dataemail.templ.content
|
||||
- if (dataemail.templ.img)
|
||||
img(src=baseimg + dataemail.templ.img, alt="", class="myimg")
|
||||
- if (dataemail.templ.content2)
|
||||
p!=dataemail.templ.content2
|
||||
- if (dataemail.templ.img2)
|
||||
img(src=baseimg + dataemail.templ.img2, alt="", class="myimg")
|
||||
- if (dataemail.templ.content)
|
||||
table(cellpadding="0", cellspacing="0", width="95%", align="center")
|
||||
tr
|
||||
td(class="textIniContainer", valign="top")
|
||||
p!=dataemail.templ.content
|
||||
- if (dataemail.templ.img)
|
||||
img(src=baseimg + dataemail.templ.img, alt="", class="myimg")
|
||||
- if (dataemail.templ.content2)
|
||||
p!=dataemail.templ.content2
|
||||
- if (dataemail.templ.img2)
|
||||
img(src=baseimg + dataemail.templ.img2, alt="", class="myimg")
|
||||
|
||||
table(cellpadding="0", cellspacing="0", width="640", align="center")
|
||||
- if (dataemail.templ.options.includes('SHOW_EVENTS'))
|
||||
@@ -201,10 +197,6 @@ html
|
||||
td(class="whitespace", height="20")
|
||||
p
|
||||
|
||||
tr
|
||||
td(class="whitespace", height="20")
|
||||
p
|
||||
|
||||
// Social Media
|
||||
table.socialMedia(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
|
||||
tr
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
body, #body_style {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: #E9F2F9;
|
||||
background: #E9F2F9 !important;
|
||||
color: #5b656e;
|
||||
}
|
||||
|
||||
|
||||
@@ -235,7 +235,7 @@ module.exports.getOrdersCartByQuery = async function (query) {
|
||||
.populate({
|
||||
path: 'userId',
|
||||
model: 'User',
|
||||
select: '_id name surname username profile'
|
||||
select: '_id name surname username profile email lang'
|
||||
})
|
||||
.lean();
|
||||
|
||||
|
||||
@@ -22,14 +22,15 @@ const Product = require('../models/product');
|
||||
const Order = require('../models/order');
|
||||
const Variant = require('../models/variant');
|
||||
|
||||
const sendemail = require('../sendemail');
|
||||
const CartClass = require('../modules/Cart')
|
||||
const Cart = require('../models/cart');
|
||||
const OrdersCart = require('../models/orderscart');
|
||||
|
||||
//GET orders
|
||||
router.get('/:userId', authenticate, function (req, res, next) {
|
||||
let userId = req.body.userId
|
||||
let idapp = req.body.idapp
|
||||
let userId = req.body.userId;
|
||||
let idapp = req.body.idapp;
|
||||
OrdersCart.getOrdersCartByUserId(userId, idapp, 0, false)
|
||||
.then((cart) => {
|
||||
|
||||
@@ -39,6 +40,36 @@ router.get('/:userId', authenticate, function (req, res, next) {
|
||||
res.status(400).send(e);
|
||||
})
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
router.post('/sendmail', authenticate, async function (req, res, next) {
|
||||
const idOrdersCart = req.body.idOrdersCart;
|
||||
const idapp = req.body.idapp;
|
||||
const test = req.body.test;
|
||||
const previewonly = req.body.previewonly;
|
||||
const templemail_id = req.body.templemail_id;
|
||||
|
||||
try {
|
||||
// Invia Email
|
||||
let myOrderCart = await OrdersCart.getOrdersCartById(idOrdersCart);
|
||||
if (myOrderCart) {
|
||||
const userto = myOrderCart.user;
|
||||
let emailto = userto.email;
|
||||
|
||||
if (userto && emailto) {
|
||||
const emailsend = await sendemail.sendEmail_byTemplate (idapp, userto, previewonly, emailto, templemail_id, test);
|
||||
|
||||
return res.send({ code: server_constants.RIS_CODE_OK, emailsend });
|
||||
}
|
||||
}
|
||||
|
||||
return res.send({ code: server_constants.RIS_CODE_OK, emailsend: false });
|
||||
|
||||
} catch (e) {
|
||||
console.error('err:', e);
|
||||
res.status(400).send(e);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@@ -62,6 +62,9 @@ module.exports = {
|
||||
if (replyTo === '')
|
||||
replyTo = mylocalsconf.dataemail.email_reply;
|
||||
|
||||
if (!replyTo)
|
||||
replyTo = '';
|
||||
|
||||
const paramemail = {
|
||||
message: {
|
||||
from: mylocalsconf.dataemail.from, // sender address
|
||||
@@ -645,7 +648,7 @@ module.exports = {
|
||||
return mylocalsconf;
|
||||
},
|
||||
|
||||
getdataemail: async (idapp) => {
|
||||
getdataemail: async (idapp, templemail_id) => {
|
||||
// console.log('getdataemail');
|
||||
const mydata = {
|
||||
content_after_events: await Settings.getValDbSettings(idapp, 'TEXT_AFTER_EV'),
|
||||
@@ -667,7 +670,7 @@ module.exports = {
|
||||
pwd_from: await Settings.getValDbSettings(idapp, 'PWD_FROM'),
|
||||
email_service: await Settings.getValDbSettings(idapp, 'EMAIL_SERVICE_SEND'),
|
||||
email_port: await Settings.getValDbSettings(idapp, 'EMAIL_PORT'),
|
||||
templemail_id: await Settings.getValDbSettings(idapp, 'TEMPLEMAIL_ID'),
|
||||
templemail_id: templemail_id ? templemail_id : await Settings.getValDbSettings(idapp, 'TEMPLEMAIL_ID'),
|
||||
};
|
||||
|
||||
// console.log(mydata.templemail_id);
|
||||
@@ -990,7 +993,6 @@ module.exports = {
|
||||
arrevents: myarrevents,
|
||||
name: 'TestNome',
|
||||
surname: 'TestCognome',
|
||||
subject: '',
|
||||
emailto: myemail,
|
||||
baseurl: tools.getHostByIdApp(idapp),
|
||||
hashemail: tools.getHash(myemail),
|
||||
@@ -1001,6 +1003,8 @@ module.exports = {
|
||||
|
||||
mylocalsconf.dataemail = await this.getdataemail(idapp);
|
||||
|
||||
mylocalsconf.dataemail.subject = mylocalsconf.dataemail && mylocalsconf.dataemail.templ ? mylocalsconf.dataemail.templ.subject : '',
|
||||
|
||||
this.replacefields(mylocalsconf);
|
||||
|
||||
const smtpTransport = this.getTransport(mylocalsconf);
|
||||
@@ -1013,6 +1017,45 @@ module.exports = {
|
||||
|
||||
},
|
||||
|
||||
sendEmail_byTemplate: async function (idapp, userto, previewonly, emailto, templemail_id, test) {
|
||||
|
||||
// const myarrevents = await MyEvent.getLastEvents(idapp);
|
||||
const myemail = emailto;
|
||||
if (myemail) {
|
||||
let mylocalsconf = {
|
||||
idapp,
|
||||
locale: userto.lang,
|
||||
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||
name: userto.name,
|
||||
surname: userto.surname,
|
||||
emailto: myemail,
|
||||
baseurl: tools.getHostByIdApp(idapp),
|
||||
hashemail: tools.getHash(myemail),
|
||||
};
|
||||
|
||||
if (test) {
|
||||
mylocalsconf.emailto = await Settings.getValDbSettings(idapp, 'EMAIL_TEST');
|
||||
}
|
||||
|
||||
mylocalsconf.dataemail = await this.getdataemail(idapp, templemail_id);
|
||||
|
||||
this.replacefields(mylocalsconf);
|
||||
|
||||
mylocalsconf.subject = mylocalsconf.dataemail.templ.subject;
|
||||
|
||||
const smtpTransport = this.getTransport(mylocalsconf);
|
||||
|
||||
console.log('-> Invio Email ' + mylocalsconf.subject + ' a', mylocalsconf.emailto, 'in corso...');
|
||||
const risult = await this.sendEmail_base('newsletter/' + userto.lang, mylocalsconf.emailto, mylocalsconf, '', smtpTransport, previewonly);
|
||||
console.log(' ...email inviata?', risult);
|
||||
|
||||
return risult;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
},
|
||||
|
||||
testemailHtml: async function (idapp, lang, email, myuser) {
|
||||
|
||||
let mytitle = 'Prova msg';
|
||||
|
||||
Reference in New Issue
Block a user