31 lines
970 B
JavaScript
31 lines
970 B
JavaScript
|
var express = require('express');
|
||
|
var router = new express.Router();
|
||
|
var mail = require('../mail.js');
|
||
|
var database = require('../database.js');
|
||
|
var template = require('../template.js');
|
||
|
|
||
|
// Escrito de cambios en méto de pago del cliente
|
||
|
router.post('/paymentUpdate', function(request, response) {
|
||
|
database.pool.query('SELECT Cliente, `e-mail` AS email FROM Clientes WHERE Id_Cliente = ?', [request.body.user], function(error, rs) {
|
||
|
var params = {
|
||
|
clientName: rs[0].Cliente
|
||
|
};
|
||
|
|
||
|
template.getTemplate('paymentUpdate', params, function(body) {
|
||
|
var data = {
|
||
|
recipient: rs[0].email,
|
||
|
subject: 'Cambios en las condiciones de pago',
|
||
|
body: body
|
||
|
};
|
||
|
|
||
|
if (mail.send(data)) {
|
||
|
response.json({status: "OK"});
|
||
|
} else {
|
||
|
response.json({status: "ERROR"});
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
|
||
|
module.exports = router;
|