cambio de boton
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
const connection = require('../conf/connection.js');
|
||||
const express = require('express');
|
||||
|
||||
|
||||
var app = express()
|
||||
|
||||
function query(consulta) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
connection.query(`${consulta}`, (error, results, files) => {
|
||||
if (error) reject(error);
|
||||
resolve(results);
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
app.get('/getFactura', async(req, res) => {
|
||||
try {
|
||||
|
||||
let idPersona = req.query.idPersona;
|
||||
|
||||
let sqlString = `SELECT * FROM persona WHERE validarPago = true and requiereFactura = true order by participacion;`;
|
||||
let pagados = await query(sqlString);
|
||||
|
||||
//console.log(pagados);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for(indice in pagados){
|
||||
|
||||
sqlString = `SELECT * FROM asistencia where idPersona = ${pagados[indice].idPersona};`;
|
||||
let asistenciaPersona = await query ( sqlString );
|
||||
|
||||
let actividad = [];
|
||||
let estudiosPractica = [];
|
||||
let recorridos = [];
|
||||
|
||||
for( indiceAsistencia in asistenciaPersona ){
|
||||
sqlString = `SELECT * FROM evento where idEvento = ${ asistenciaPersona[indiceAsistencia].idEvento }; `;
|
||||
let eventoPersona = await query ( sqlString );
|
||||
|
||||
if( eventoPersona[0].tipoEvento === 'Actividad' ) actividad.push(eventoPersona[0]);
|
||||
if( eventoPersona[0].tipoEvento === 'Estudios de practica' ) estudiosPractica.push(eventoPersona[0]);
|
||||
if( eventoPersona[0].tipoEvento === 'Recorridos' ) recorridos.push(eventoPersona[0]);
|
||||
|
||||
}
|
||||
|
||||
pagados[indice].actividad = actividad;
|
||||
pagados[indice].estudiosPractica = estudiosPractica;
|
||||
pagados[indice].recorridos = recorridos;
|
||||
|
||||
sqlString = `Select * from factura where idPersona = ${pagados[indice].idPersona}`;
|
||||
let facturaDatos = await query ( sqlString );
|
||||
pagados[indice].facturaDatos = facturaDatos;
|
||||
|
||||
}
|
||||
|
||||
res.status(200).json({error: false, msj: '', datos: pagados });
|
||||
|
||||
|
||||
}
|
||||
catch(error){
|
||||
console.log(error);
|
||||
res.status(400).json({ error: true, msj: `Sucedio un error al traer a las personas inscritas msj: ${error}` });
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = app;
|
||||
+1
-1
@@ -20,6 +20,6 @@ app.use(require('./rechazarPago'));
|
||||
|
||||
app.use(require('./getRechazados'));
|
||||
app.use(require('./getPagados'));
|
||||
|
||||
app.use(require('./getFactura'));
|
||||
|
||||
module.exports = app;
|
||||
+69
-1
@@ -1,5 +1,8 @@
|
||||
const connection = require('../conf/connection.js');
|
||||
const express = require('express');
|
||||
var path = require('path');
|
||||
const nodemailer = require("nodemailer");
|
||||
const fs = require("fs");
|
||||
|
||||
|
||||
var app = express()
|
||||
@@ -13,14 +16,79 @@ function query(consulta) {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function sendEmail( destination ) {
|
||||
|
||||
// Generate test SMTP service account from ethereal.email
|
||||
// Only needed if you don't have a real mail account for testing
|
||||
let testAccount = await nodemailer.createTestAccount();
|
||||
|
||||
// create reusable transporter object using the default SMTP transport
|
||||
let transporter = nodemailer.createTransport({
|
||||
service: "Gmail",
|
||||
port: 587,
|
||||
secure: false, // true for 465, false for other ports
|
||||
auth: {
|
||||
user: 'asinea103@fa.unam.mx', // generated ethereal user
|
||||
pass: 'As1n34103++'
|
||||
},
|
||||
});
|
||||
|
||||
// send mail with defined transport object
|
||||
let info = await transporter.sendMail({
|
||||
from: '"ASINEA 2020" <asinea103@fa.unam.mx>', // sender address
|
||||
to: `"${destination}"`, // list of receivers
|
||||
subject: "Problemas con tu comprobante de pago ASINEA 2020", // Subject line
|
||||
text: `
|
||||
Hola,
|
||||
|
||||
Hemos tenido problemas para visualizar el comprobante de pago que adjuntó en la plataforma de registro, por lo que su inscripción no ha podido ser validada.
|
||||
|
||||
Le pedimos, por favor, ingresar y hacer nuevamente el envío del mismo para poder continuar con el proceso de inscripción.
|
||||
|
||||
Cualquier duda puede ponerse en contacto con nosotros
|
||||
`, // plain text body
|
||||
|
||||
|
||||
});
|
||||
|
||||
console.log("Message sent: %s", info.messageId);
|
||||
// Message sent: <b658f8ca-6296-ccf4-8306-87d57a0b4321@example.com>
|
||||
|
||||
// Preview only available when sending through an Ethereal account
|
||||
console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
|
||||
// Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou...
|
||||
}
|
||||
|
||||
app.post('/rechazarPago', async(req, res) => {
|
||||
try {
|
||||
let data = req.body;
|
||||
if( typeof( data.idPersona) === 'undefined' )
|
||||
res.status(200).json({ error: true, msj: `No se encotro el ID de la persona en los datos: ${error}` });
|
||||
|
||||
let sqlQuery = `update persona persona set rechazado = true where idPersona = ${data.idPersona};`;
|
||||
let sqlQuery = `update persona persona set envioComprobante = false where idPersona = ${data.idPersona};`;
|
||||
await query(sqlQuery);
|
||||
|
||||
|
||||
sqlQuery = `select * from persona where idPersona = ${data.idPersona};`;
|
||||
let datos = await query(sqlQuery);
|
||||
datos = datos[0];
|
||||
|
||||
if(datos.requiereFactura === true){
|
||||
sqlQuery = `delet * from factura where idPersona = ${data.idPersona};`;
|
||||
await query(sqlQuery);
|
||||
|
||||
sqlQuery = `update persona set requiereFactura = false where idPersona = ${data.idPersona};`;
|
||||
await query(sqlQuery);
|
||||
}
|
||||
|
||||
|
||||
await sendEmail( datos.correo );
|
||||
|
||||
|
||||
|
||||
|
||||
res.status(200).json({ error: false, msj: "exito"});
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user