panel admin
This commit is contained in:
Binary file not shown.
Binary file not shown.
Generated
+95
@@ -23,6 +23,11 @@
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
|
||||
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8="
|
||||
},
|
||||
"append-field": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz",
|
||||
"integrity": "sha1-HjRA6RXwsSA9I3SOeO3XubW0PlY="
|
||||
},
|
||||
"aproba": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz",
|
||||
@@ -92,6 +97,11 @@
|
||||
"concat-map": "0.0.1"
|
||||
}
|
||||
},
|
||||
"buffer-from": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
|
||||
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A=="
|
||||
},
|
||||
"busboy": {
|
||||
"version": "0.3.1",
|
||||
"resolved": "https://registry.npmjs.org/busboy/-/busboy-0.3.1.tgz",
|
||||
@@ -120,6 +130,25 @@
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
|
||||
},
|
||||
"concat-stream": {
|
||||
"version": "1.6.2",
|
||||
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
|
||||
"integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
|
||||
"requires": {
|
||||
"buffer-from": "^1.0.0",
|
||||
"inherits": "^2.0.3",
|
||||
"readable-stream": "^2.2.2",
|
||||
"typedarray": "^0.0.6"
|
||||
}
|
||||
},
|
||||
"connect-busboy": {
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/connect-busboy/-/connect-busboy-0.0.2.tgz",
|
||||
"integrity": "sha1-rFyclmchcYheV2xmsr/ZXTuxEJc=",
|
||||
"requires": {
|
||||
"busboy": "*"
|
||||
}
|
||||
},
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
|
||||
@@ -484,6 +513,62 @@
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||
},
|
||||
"multer": {
|
||||
"version": "1.4.2",
|
||||
"resolved": "https://registry.npmjs.org/multer/-/multer-1.4.2.tgz",
|
||||
"integrity": "sha512-xY8pX7V+ybyUpbYMxtjM9KAiD9ixtg5/JkeKUTD6xilfDv0vzzOFcCp4Ljb1UU3tSOM3VTZtKo63OmzOrGi3Cg==",
|
||||
"requires": {
|
||||
"append-field": "^1.0.0",
|
||||
"busboy": "^0.2.11",
|
||||
"concat-stream": "^1.5.2",
|
||||
"mkdirp": "^0.5.1",
|
||||
"object-assign": "^4.1.1",
|
||||
"on-finished": "^2.3.0",
|
||||
"type-is": "^1.6.4",
|
||||
"xtend": "^4.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"busboy": {
|
||||
"version": "0.2.14",
|
||||
"resolved": "https://registry.npmjs.org/busboy/-/busboy-0.2.14.tgz",
|
||||
"integrity": "sha1-bCpiLvz0fFe7vh4qnDetNseSVFM=",
|
||||
"requires": {
|
||||
"dicer": "0.2.5",
|
||||
"readable-stream": "1.1.x"
|
||||
}
|
||||
},
|
||||
"dicer": {
|
||||
"version": "0.2.5",
|
||||
"resolved": "https://registry.npmjs.org/dicer/-/dicer-0.2.5.tgz",
|
||||
"integrity": "sha1-WZbAhrszIYyBLAkL3cCc0S+stw8=",
|
||||
"requires": {
|
||||
"readable-stream": "1.1.x",
|
||||
"streamsearch": "0.1.2"
|
||||
}
|
||||
},
|
||||
"isarray": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
|
||||
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8="
|
||||
},
|
||||
"readable-stream": {
|
||||
"version": "1.1.14",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
|
||||
"integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
|
||||
"requires": {
|
||||
"core-util-is": "~1.0.0",
|
||||
"inherits": "~2.0.1",
|
||||
"isarray": "0.0.1",
|
||||
"string_decoder": "~0.10.x"
|
||||
}
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "0.10.31",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
|
||||
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ="
|
||||
}
|
||||
}
|
||||
},
|
||||
"mysql": {
|
||||
"version": "2.18.1",
|
||||
"resolved": "https://registry.npmjs.org/mysql/-/mysql-2.18.1.tgz",
|
||||
@@ -878,6 +963,11 @@
|
||||
"mime-types": "~2.1.24"
|
||||
}
|
||||
},
|
||||
"typedarray": {
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
|
||||
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
|
||||
},
|
||||
"unpipe": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
|
||||
@@ -911,6 +1001,11 @@
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
||||
},
|
||||
"xtend": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
|
||||
"integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ=="
|
||||
},
|
||||
"yallist": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz",
|
||||
|
||||
@@ -14,10 +14,12 @@
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"bcrypt": "^5.0.0",
|
||||
"connect-busboy": "0.0.2",
|
||||
"cors": "^2.8.5",
|
||||
"dotenv": "^8.2.0",
|
||||
"express": "^4.17.1",
|
||||
"express-fileupload": "^1.2.0",
|
||||
"multer": "^1.4.2",
|
||||
"mysql": "^2.18.1",
|
||||
"nodemailer": "^6.4.11",
|
||||
"randomstring": "^1.1.5"
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
const connection = require('../conf/connection.js');;
|
||||
const express = require('express');
|
||||
const fileUpload = require('express-fileupload');
|
||||
var path = require('path');
|
||||
const nodemailer = require("nodemailer");
|
||||
const fs = require("fs");
|
||||
|
||||
var app = express()
|
||||
app.use(fileUpload());
|
||||
|
||||
function query(consulta) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
connection.query(`${consulta}`, (error, results, files) => {
|
||||
if (error) reject(error);
|
||||
resolve(results);
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function depurado(cadena) {
|
||||
if (cadena != null)
|
||||
return cadena.replace(/'/g, "''");
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function sendEmail( destination, idPersona ) {
|
||||
|
||||
// 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: "Ficha de deposito ASINEA 2020", // Subject line
|
||||
text: `
|
||||
La referencia tiene una vigencia de 3 días. En este lapso deberá enviar su comprobante para poder validar que el pago fue realizado correctamente
|
||||
|
||||
Una vez realizado el pago, deberá ingresar nuevamente a la plataforma y adjuntar el voucher o imagen del pago realizado con los siguientes datos:
|
||||
|
||||
-Número de referencia o convenio
|
||||
-Banco de procedencia
|
||||
-Fecha de la operación
|
||||
-Clave de rastreo
|
||||
-Cuenta de retiro
|
||||
-Cuenta de depósito e importe.
|
||||
|
||||
|
||||
De no tener estos datos, su pago no podrá ser rastreado.
|
||||
`, // plain text body
|
||||
attachments: [{ // file on disk as an attachment
|
||||
filename: 'ficha de deposito.pdf',
|
||||
path: `${path.join('./files/fichasDeposito', `ficha-${idPersona}.pdf`)}`// stream this file
|
||||
}]
|
||||
|
||||
});
|
||||
|
||||
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('/enviarFicha', async(req, res) => {
|
||||
|
||||
if ( req.files === null || req.files.fichaDeposito === null || typeof(req.files) === 'undefined' || typeof(req.files.fichaDeposito) === 'undefined' ) {
|
||||
res.status(400).json({error: true, msj: 'Falata seleccionar el archivo'});
|
||||
return;
|
||||
}
|
||||
try {
|
||||
console.log(req.files);
|
||||
if (req.files.fichaDeposito != undefined) {
|
||||
let sampleFile = req.files.fichaDeposito;
|
||||
let nombreCortado = sampleFile.name.split('.');
|
||||
let extencion = nombreCortado[nombreCortado.length - 1];
|
||||
let extensionValidas = ['pdf', 'jpg', 'jpeg', 'png', 'docx', 'doc', 'odt', 'pdf'];
|
||||
|
||||
if (extensionValidas.indexOf(extencion) < 0) {
|
||||
return res.status(400).json({
|
||||
error: true,
|
||||
msj: "Extensión invalida del archivo de fichaDeposito"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
return res.status(400).json({
|
||||
error: true,
|
||||
msj: "error al verificar la extensión"
|
||||
});
|
||||
}
|
||||
let idPersona = req.body.idPersona;
|
||||
let correo = req.body.correo;
|
||||
|
||||
try {
|
||||
|
||||
console.log(req.body)
|
||||
if (req.files.fichaDeposito != undefined) {
|
||||
let sampleFile = req.files.fichaDeposito;
|
||||
|
||||
sampleFile.mv( path.join('./files/fichasDeposito', `ficha-${idPersona}.pdf`), function(err) {
|
||||
if (err)
|
||||
return res.status(400).json({ error: true, msj: "Error al registrar el cartel" });
|
||||
|
||||
});
|
||||
await sendEmail('daniel.adrian.ramirez.george@gmail.com', idPersona);
|
||||
|
||||
let sqlString = `update persona set referenciaEnviada = true where idPersona=${idPersona}`;
|
||||
|
||||
await query(sqlString);
|
||||
|
||||
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
res.status(400).json({ error: true, msj: "Error al subir el archivo de comprobante_pago", type: err });
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
res.status(200).json({ error: false, msj: "exito " });
|
||||
return;
|
||||
|
||||
});
|
||||
|
||||
module.exports = app
|
||||
@@ -0,0 +1,63 @@
|
||||
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('/getPersonasInscritas', async(req, res) => {
|
||||
try {
|
||||
|
||||
let idPersona = req.query.idPersona;
|
||||
|
||||
let sqlString = `SELECT * FROM persona WHERE referenciaEnviada = false;`;
|
||||
let personasInscritas = await query(sqlString);
|
||||
|
||||
//console.log(personasInscritas);
|
||||
|
||||
|
||||
|
||||
for(indice in personasInscritas){
|
||||
|
||||
sqlString = `SELECT * FROM asistencia where idPersona = ${personasInscritas[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]);
|
||||
|
||||
}
|
||||
|
||||
personasInscritas[indice].actividad = actividad;
|
||||
personasInscritas[indice].estudiosPractica = estudiosPractica;
|
||||
personasInscritas[indice].recorridos = recorridos;
|
||||
}
|
||||
|
||||
res.status(200).json({error: false, msj: '', datos: personasInscritas });
|
||||
|
||||
|
||||
}
|
||||
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;
|
||||
@@ -0,0 +1,37 @@
|
||||
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('/getPersonasPendientes', async(req, res) => {
|
||||
try {
|
||||
|
||||
let idPersona = req.query.idPersona;
|
||||
|
||||
let sqlString = `SELECT * FROM persona WHERE referenciaEnviada = true and envioComprobante = false ;`;
|
||||
let personasInscritas = await query(sqlString);
|
||||
|
||||
//console.log(personasInscritas);
|
||||
|
||||
res.status(200).json({error: false, msj: '', datos: personasInscritas });
|
||||
|
||||
|
||||
}
|
||||
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;
|
||||
@@ -8,4 +8,8 @@ app.use(require('./getEscuelas'));
|
||||
app.use(require('./registro'));
|
||||
app.use(require('./getPersona'));
|
||||
|
||||
app.use(require('./getPersonasInscritas'));
|
||||
app.use(require('./enviarFicha'));
|
||||
app.use(require('./getPersonasPendientes'));
|
||||
|
||||
module.exports = app;
|
||||
@@ -30,16 +30,16 @@ app.post('/loginAdmin', async(req, res) => {
|
||||
let data = req.body;
|
||||
let usuario = depurado(data.usuario);
|
||||
//console.log(usuario, " lksaldksjdlasd");
|
||||
let cad = `select * from admin where usuario='${data.usuario}'`;
|
||||
let cad = `select * from admin where usuario='${data.correo}'`;
|
||||
let respuesta = query(cad);
|
||||
let pass = data.password;
|
||||
//console.log(pass);
|
||||
let n_pasword = await bcrypt.hash(pass, 10);
|
||||
//console.log(data);
|
||||
console.log(cad);
|
||||
console.log(n_pasword);
|
||||
// console.log(respuesta);
|
||||
respuesta.then(async r => {
|
||||
// console.log(r, r.length);
|
||||
console.log(r, r.length);
|
||||
if (r.length == 0) {
|
||||
res.status(400).json({ error: false, msj: "Usuario o contraseña invalidos" });
|
||||
return;
|
||||
|
||||
+10
-6
@@ -20,7 +20,11 @@ CREATE TABLE `asistencia` (
|
||||
);
|
||||
|
||||
|
||||
INSERT INTO admin VALUES (null, 'Administrador' , '$2b$10$tUzaWli0CUzGnoZ1saxSF.RRtxDcdgRP0tQOQdmqbVG1fiz4jCMLW');
|
||||
-- INSERT INTO admin VALUES (null, 'Administrador' , '$2b$10$tUzaWli0CUzGnoZ1saxSF.RRtxDcdgRP0tQOQdmqbVG1fiz4jCMLW');
|
||||
|
||||
|
||||
-- Asin34#2020
|
||||
INSERT INTO admin VALUES (null, 'Administrador' , '$2b$10$Kv7tMorEyGL934RK.oaQiOSaGiJr56JDT5PxgAcnVAdpIiYRyBAaS');
|
||||
|
||||
CREATE TABLE `persona` (
|
||||
`idPersona` integer PRIMARY KEY NOT NULL AUTO_INCREMENT,
|
||||
@@ -46,7 +50,7 @@ CREATE TABLE `persona` (
|
||||
`envioComprobante` boolean,
|
||||
`referenciaEnviada` boolean,
|
||||
`validarPago` boolean,
|
||||
`rechazado` boolean
|
||||
`rechazado` boolean,
|
||||
);
|
||||
|
||||
CREATE TABLE `evento` (
|
||||
@@ -276,16 +280,16 @@ insert into evento values (null, 'Estudios de practica', '8 ESTUDIO LEA Desmitif
|
||||
|
||||
insert into evento values (null, 'Estudios de practica', '9 ESTUDIO de Sitios mexicanos del patrimonio mundial.', 'Ambos', 30 , null,30 );
|
||||
|
||||
insert into evento values (null, 'Estudios de practica', 'Estudio 10 | Documentar arquitectura', 'Ambos', 20 , null, 20 );
|
||||
insert into evento values (null, 'Estudios de practica', '10 ESTUDIO Documentar arquitectura', 'Ambos', 20 , null, 20 );
|
||||
|
||||
insert into evento values (null, 'Estudios de practica', '11 ESTUDIO Sensorial | Sentido de los sentidos en el espacio abierto', 'Ambos', 20 , null,20 );
|
||||
insert into evento values (null, 'Estudios de practica', '11 ESTUDIO Sensorial Sentido de los sentidos en el espacio abierto', 'Ambos', 20 , null,20 );
|
||||
|
||||
|
||||
insert into evento values (null, 'Recorridos', 'Candela', 'Ambos', 100 , null, 100 );
|
||||
|
||||
insert into evento values (null, 'Recorridos', 'Campus Central C.U. UNAM', 'Ambos', 100 , null, 100 );
|
||||
insert into evento values (null, 'Recorridos', 'Campus Central C.U. UNAM Patrimonio Mundial de la UNESCO ', 'Ambos', 100 , null, 100 );
|
||||
|
||||
insert into evento values (null, 'Recorridos', 'Patrimonio Mundial de la UNESCO Museos de la UNAM', 'Ambos', 100 , null, 100 );
|
||||
insert into evento values (null, 'Recorridos', 'Museos de la UNAM', 'Ambos', 100 , null, 100 );
|
||||
|
||||
insert into evento values (null, 'Recorridos', 'Arquitectura Orgánica. Javier Senosiain', 'Ambos', 100 , null, 100 );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user