actualizacoion proyecto final

This commit is contained in:
DanielRamirezGe
2020-02-25 20:35:39 -06:00
parent 2516bc07e9
commit d7f1cb2c9b
20 changed files with 3037 additions and 23 deletions
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
+1858
View File
File diff suppressed because it is too large Load Diff
+7 -1
View File
@@ -13,8 +13,14 @@
"author": "",
"license": "ISC",
"dependencies": {
"bcrypt": "^4.0.0",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.17.1"
"express": "^4.17.1",
"express-fileupload": "^1.1.6",
"node-wget": "^0.4.3",
"pdfkit": "^0.11.0",
"qr-image": "^3.2.0",
"sendmail": "^1.6.1"
}
}
+21
View File
@@ -0,0 +1,21 @@
const connection = require('../conf/connection.js');
const express = require('express')
var app = express();
var qr = require('./qr.js');
app.get('/crear_pdf', async(req, res) => {
await qr(req.query.id_persona).then((p) => {
// console.log(req.query);
// console.log(p);
//res.download(__dirname + `/../files/lista-${req.query.id_persona}.pdf`);
res.status(200).json({ error: false, msj: "exito" });
}).catch((err) => {
console.log(err);
res.status(400).json({ error: true, msj: "Error al crear el comprobante", type: err });
});
})
module.exports = app;
+255
View File
@@ -0,0 +1,255 @@
const connection = require('../conf/connection.js');
const express = require('express');
const bcrypt = require('bcrypt');
var app = express()
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;
}
app.post('/datos_personales', async(req, res) => {
let body = req.body;
console.log(body);
try {
let n_correo = depurado(body.correo);
let cad = `select * from persona where correo='${n_correo}';`;
let respuesta = await query(cad);
if (respuesta.length != 0) {
res.status(400).json({ error: false, msj: "El correo ya se encuentra registrado" });
return;
}
let curp = body.curp;
curp = depurado(curp);
cad = `select * from persona where curp='${curp}';`;
respuesta = await query(cad);
if (respuesta.length != 0) {
res.status(400).json({ error: false, msj: "El CURP ya esta registrado" });
return;
}
let n_nombre = depurado(body.nombre);
let n_apellido_p = depurado(body.apellido_p);
let n_apellido_m = depurado(body.apellido_m);
let n_curp = curp;
let n_genero = depurado(body.genero);
let n_edad = body.edad;
let n_telefono = depurado(body.telefono);
let n_password = await bcrypt.hash(body.password, 10);
let n_comunidad = depurado(body.comunidad);
let n_situacion = depurado(body.situacion);
let n_universidad = depurado(body.univrsidad);
// console.log(n_pasword);
// CREATE TABLE `persona` (
// `id_persona` integer PRIMARY KEY NOT NULL AUTO_INCREMENT,
// `nombre` varchar(100),
// `apellidp_p` varchar(100),
// `apellidp_m` varchar(100),
// `curp` varchar(200),
// `edad` integer,
// `genero` varchar(10),
// `telefono` varchar(50),
// `correo` varchar(100),
// `pasword` varchar(300),
// `comunidad` varchar(50),
// `situacion_academica` varchar(50)
// );
cad = `insert into persona values (null,'${n_nombre}', '${n_apellido_p}', '${n_apellido_m}', '${n_curp}', ${n_edad}, '${n_genero}',
'${n_telefono}','${n_correo}', '${n_password}', '${n_comunidad}', '${n_situacion}' ,'${ n_universidad}' );`;
respuesta = query(cad);
respuesta.then(async() => {
cad = `select id_persona from persona where correo='${n_correo}'`;
let n_res = await query(cad);
console.log(n_res);
let id_persona = n_res[0].id_persona;
if (n_situacion == 'Alumno') {
try {
let n_cuenta = null;
if (body.cuenta != undefined)
n_cuenta = depurado(body.cuenta.toString());
let n_year = depurado(body.año.toString());
let n_participacion = depurado(body.participacion);
if (n_cuenta != null)
cad = `insert into alumno values( ${id_persona}, '${n_cuenta}', '${n_year}' ) ;`;
else
cad = `insert into alumno values( ${id_persona}, null, '${n_year}' ) ;`;
let n_ans = query(cad);
n_ans.then(async() => {
if (body.conversatorio != undefined) {
let con = body.conversatorio;
cad = `insert into asistencia values(null, ${id_persona}, ${con.id_evento}, false, false , false , false, false, '${con.participacion}' );`;
let n_q = await query(cad);
cad = `update evento set cupo= cupo-1 where id_evento=${con.id_evento};`;
n_q = await query(cad);
}
if (body.taller_a != undefined) {
let ta = body.taller_a;
cad = `insert into asistencia values(null, ${id_persona}, ${ta.id_evento}, false, false , false , false, false, '${ta.participacion}' );`;
let n_q = await query(cad);
cad = `update evento set cupo= cupo-1 where id_evento=${ta.id_evento};`;
n_q = await query(cad);
}
if (body.taller_p != undefined) {
let ta = body.taller_p;
cad = `insert into asistencia values(null, ${id_persona}, ${ta.id_evento}, false, false , false , false, false, '${ta.participacion}');`;
let n_q = await query(cad);
cad = `update evento set cupo= cupo-1 where id_evento=${ta.id_evento};`;
n_q = await query(cad);
}
if (body.visitas != undefined) {
let ta = body.visitas;
cad = `insert into asistencia values(null, ${id_persona}, ${ta.id_evento}, false, false , false , false, false, '${ta.participacion}');`;
let n_q = await query(cad);
cad = `update evento set cupo= cupo-1 where id_evento=${ta.id_evento};`;
n_q = await query(cad);
}
if (body.magistral != undefined) {
let ta = body.magistral;
cad = `insert into asistencia values(null, ${id_persona}, ${ta.id_evento}, false, false , false , false, false, '${ta.participacion}' );`;
let n_q = await query(cad);
cad = `update evento set cupo= cupo-1 where id_evento=${ta.id_evento};`;
n_q = await query(cad);
}
return res.status(200).json({ err: false, msj: "Exito", id_persona: id_persona });
}).catch(async(err) => {
console.log(err);
//se deberia borrar el registro anterio de persona;
return res.status(400).json({ err: true, msj: "Error al insirtar en la base en alumno", type: err });
})
} catch (err) {
//se deberia borrar el registro anterio de persona;
console.log(err);
return res.status(400).json({ err: true, msj: "Error al insirtar en la base en alumno", type: err });
}
} else if (n_situacion == 'Académico') {
try {
let n_grado = depurado(body.grado);
let n_asignatura = depurado(body.asignatura);
let n_participacion = depurado(body.participacion);
cad = `insert into academico values(${id_persona}, '${n_grado}', '${n_asignatura}' );`;
let n_ans = query(cad);
n_ans.then(async() => {
if (body.conversatorio != undefined) {
let con = body.conversatorio;
cad = `insert into asistencia values(null, ${id_persona}, ${con.id_evento}, false, false , false , false, false, '${con.participacion}');`;
let n_q = await query(cad);
cad = `update evento set cupo= cupo-1 where id_evento=${con.id_evento};`;
n_q = await query(cad);
}
if (body.taller_a != undefined) {
let ta = body.taller_a;
cad = `insert into asistencia values(null, ${id_persona}, ${ta.id_evento}, false, false , false , false, false, '${ta.participacion}' );`;
let n_q = await query(cad);
cad = `update evento set cupo= cupo-1 where id_evento=${ta.id_evento};`;
n_q = await query(cad);
}
if (body.taller_p != undefined) {
let ta = body.taller_p;
cad = `insert into asistencia values(null, ${id_persona}, ${ta.id_evento}, false, false , false , false, false, '${ta.participacion}' );`;
let n_q = await query(cad);
cad = `update evento set cupo= cupo-1 where id_evento=${ta.id_evento};`;
n_q = await query(cad);
}
if (body.visitas != undefined) {
let ta = body.visitas;
cad = `insert into asistencia values(null, ${id_persona}, ${ta.id_evento}, false, false , false , false, false, '${ta.participacion}' );`;
let n_q = await query(cad);
cad = `update evento set cupo= cupo-1 where id_evento=${ta.id_evento};`;
n_q = await query(cad);
}
if (body.magistral != undefined) {
let ta = body.magistral;
cad = `insert into asistencia values(null, ${id_persona}, ${ta.id_evento}, false, false , false , false, false, '${ta.participacion}' );`;
let n_q = await query(cad);
cad = `update evento set cupo= cupo-1 where id_evento=${ta.id_evento};`;
n_q = await query(cad);
}
return res.status(200).json({ err: false, msj: "Exito", id_persona: id_persona });
}).catch(async err => {
//se deberia borrar el registro anterio de persona;
//se deberia borrar el registro anterio de persona;
console.log(err);
return res.status(400).json({ err: true, msj: "Error al insertar en la base en academico", type: err });
})
} catch (err) {
//se deberia borrar el registro anterio de persona;
console.log(err);
return res.status(400).json({ err: true, msj: "Error al insertar en la base en academico", type: err });
}
} else {
res.status(200).json({ error: false, msj: "Exito", id_persona: id_persona });
return;
}
}).catch(async err => {
console.log("entro ...", err);
//se deberia borrar el registro anterio de persona;
res.status(400).json({ error: true, msj: "Error al registrar en la base de datos", type: err });
return;
})
} catch (err) {
console.log("afuera ", err);
res.status(400).json({ error: true, msj: err });
}
});
module.exports = app
+10
View File
@@ -0,0 +1,10 @@
const connection = require('../conf/connection.js');
const express = require('express')
var app = express();
app.get('/descargar_cartel', (req, res) => {
res.download(__dirname + `/../files/carta_aceptacion-${req.query.id_persona}.docx`);
})
module.exports = app;
+10
View File
@@ -0,0 +1,10 @@
const connection = require('../conf/connection.js');
const express = require('express')
var app = express();
app.get('/descargar_cartel', (req, res) => {
res.download(__dirname + `/../files/comprobante_pago-${req.query.id_persona}.docx`);
})
module.exports = app;
+83
View File
@@ -0,0 +1,83 @@
const connection = require('../conf/connection.js');
const express = require('express');
const bcrypt = require('bcrypt');
const sendmail = require('sendmail')();
var app = express()
var randomstring = require("randomstring");
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) {
cadena = cadena.replace(/'/g, "''");
cadena = cadena.replace(/;/g, "m");
return cadena;
} else
return null;
}
app.get('/enviar_email', async(req, res) => {
let id_persona;
try {
let n = req.query.correo;
console.log(req.query);
console.log(req.query, n);
n = depurado(n);
let cad = `select id_persona from persona where correo='${n}'`;
let respuesta = await query(cad);
console.log("depurado: ", n);
console.log("respuesta: ", respuesta);
if (respuesta.length == 0)
return res.status(400).json({ error: true, msj: "El correo aún no se ha registrado" });
else
id_persona = respuesta[0].id_persona;
} catch (err) {
console.log("afuera ", err);
res.status(400).json({ error: true, msj: "error al verificar el correo" });
}
try {
let nueva = randomstring.generate({
length: 10,
charset: 'alphanumeric'
});
let n_pasword = await bcrypt.hash(nueva, 10);
let cad = `update persona set password='${n_pasword}' where id_persona=${id_persona};`;
let respuesta = query(cad);
respuesta.then(() => {
let correo = req.query.correo;
sendmail({
from: 'conversatorios.asinea2020@fa.unam.mx',
to: `${correo}`,
subject: 'Recuperacion de contraseña ASINE',
html: `Estimado usuario su nueva contraseña es: ${nueva}`,
}, function(err, reply) {
console.log(err && err.stack);
console.dir(reply);
});
}).catch(() => {
return res.status(400).json({ error: true, msj: "error al actualizar la contraseña" });
})
res.status(200).json({ error: false, msj: "exito" });
} catch (err) {
return res.status(400).json({ error: true, msj: "error al encriptar la contraseña" });
}
})
module.exports = app
+11
View File
@@ -0,0 +1,11 @@
const connection = require('../conf/connection.js');
const express = require('express')
var app = express();
app.get('/get_pdf', (req, res) => {
res.download(__dirname + `/../files/lista-${req.query.id_persona}.pdf`);
})
module.exports = app;
+9
View File
@@ -1,4 +1,13 @@
var express = require('express')
var app = express()
app.use(require('./datos_personales'));
app.use(require('./login_persona'));
app.use(require('./crear_pdf'));
app.use(require('./get_pdf'));
app.use(require('./traer_datos'));
app.use(require('./traer_persona'));
//app.use(require('./crear_qr'));
module.exports = app;
+76
View File
@@ -0,0 +1,76 @@
const connection = require('../conf/connection.js');
const express = require('express');
const bcrypt = require('bcrypt');
var app = express()
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) {
cadena = cadena.replace(/'/g, "''");
cadena = cadena.replace(/;/g, "m");
return cadena;
} else
return null;
}
app.post('/loggin_admin', async(req, res) => {
try {
let data = req.body;
let usuario = depurado(data.usuario);
//console.log(usuario, " lksaldksjdlasd");
let cad = `select * from admin where usuario='${data.usuario}'`;
let respuesta = query(cad);
// console.log(respuesta);
respuesta.then(async r => {
// console.log(r, r.length);
if (r.length == 0) {
res.status(400).json({ error: false, msj: "Usuario o contraseña invalidos" });
return;
} else {
let pass = data.password;
//console.log(pass);
let n_pasword = await bcrypt.hash(pass, 10);
//console.log(data);
// console.log(n_pasword);
let ban = bcrypt.compareSync(data.password, r[0].password);
if (ban == true) {
res.status(200).json({ error: false, msj: "bienvenido", mesa: r[0].nombre_mesa, id_admin: r[0].id_admin });
return;
} else {
res.status(400).json({ error: false, msj: "Usuario o contraseña invalidos" });
return;
}
}
}).catch(err => {
res.status(400).json({ error: true, msj: err });
return;
})
} catch (err) {
console.log("afuera ", err);
res.status(400).json({ error: true, msj: err });
return;
}
});
module.exports = app
+79
View File
@@ -0,0 +1,79 @@
const connection = require('../conf/connection.js');
const express = require('express');
const bcrypt = require('bcrypt');
var app = express()
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) {
cadena = cadena.replace(/'/g, "''");
cadena = cadena.replace(/;/g, "m");
return cadena;
} else
return null;
}
app.post('/login_persona', async(req, res) => {
try {
let data = req.body;
let usuario = depurado(data.correo);
//console.log(usuario, " lksaldksjdlasd");
console.log(usuario);
let cad = `select * from persona where correo='${usuario}';`;
console.log(cad);
let respuesta = query(cad);
// console.log(respuesta);
respuesta.then(async r => {
// console.log(r, r.length);
if (r.length == 0) {
res.status(400).json({ error: false, msj: "Usuario o contraseña invalidos" });
return;
} else {
let pass = data.password;
//console.log(pass);
let n_pasword = await bcrypt.hash(pass, 10);
//console.log(data);
console.log(n_pasword);
let ban = bcrypt.compareSync(data.password, r[0].password);
if (ban == true) {
return res.status(200).json({ error: false, msj: "Bienvenido", data: r[0] });
} else {
res.status(400).json({ error: false, msj: "Usuario o contraseña invalidos" });
return;
}
}
}).catch(err => {
res.status(400).json({ error: true, msj: err });
return;
})
} catch (err) {
console.log("afuera ", err);
res.status(400).json({ error: true, msj: err });
return;
}
});
module.exports = app
+75
View File
@@ -0,0 +1,75 @@
'use strict';
const connection = require('../conf/connection.js');
const express = require('express');
var qr = require('qr-image');
const fs = require('fs');
const PDFDocument = require('pdfkit');
function query(consulta) {
return new Promise(function(resolve, reject) {
connection.query(`${consulta}`, (error, results, files) => {
if (error) reject(error);
resolve(results);
});
})
}
let c_pdf = function(id_persona) {
return new Promise(async function(resolve, reject) {
let doc = new PDFDocument();
// let cad = `select * from persona where id_persona=${id_persona}`;
// let resp = await query(cad);
// let data = resp[var i_m = require('./g_img.js');0];
doc.pipe(fs.createWriteStream(__dirname + `/../files/lista-${id_persona}.pdf`));
doc.image(qr.imageSync(`${id_persona}`, { type: 'png' }), {
fit: [250, 300],
align: 'center',
valign: 'center'
});
doc.end();
resolve({ "docx": `${id_persona}.pdf` })
});
}
let g_pdf = async function(idPersona) {
// console.log("datos: ", req.query);
let inicio = 120;
let id_persona = idPersona;
c_pdf(id_persona)
//await doc
// .fontSize(25)
// .text('Some text with an embedded font!', 100, 100);
// await doc.font('Times-Roman')
// .fontSize(10)
// .text(`${data.nombre} ${ data.apellido_p} ${data.apellido_m}: ${data.id_persona}`, inicio + 60, 40);
//return res.download(__dirname + `/../files/lista-${req.query.id_persona}.pdf`);
//return
.then(data => {
//res.download(__dirname + `/../files/comprobante_pago-${req.query.id_persona}.docx`);
console.log(data)
})
.catch(err => {
console.log(err);
return;
})
// console.log(data);
};
module.exports = g_pdf;
+103
View File
@@ -0,0 +1,103 @@
const connection = require('../conf/connection.js');;
const express = require('express');
const fileUpload = require('express-fileupload');
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;
}
app.post('/subir_archivo', async(req, res) => {
try {
console.log(req.files);
if (req.files.comprobante_pago != undefined) {
let sampleFile = req.files.comprobante_pago;
let nombreCortado = sampleFile.name.split('.');
let extencion = nombreCortado[nombreCortado.length - 1];
let extensionValidas = ['pdf', 'jpg', 'jpeg', 'png'];
if (extensionValidas.indexOf(extencion) < 0) {
return res.status(400).json({
error: true,
msj: "Extensión invalida del archivo de comprobante_pago"
});
}
}
if (req.files.carta_aceptacion != undefined) {
let sampleFile = req.files.carta_aceptacion;
let nombreCortado = sampleFile.name.split('.');
let extencion = nombreCortado[nombreCortado.length - 1];
let extensionValidas = ['docx', 'doc', 'odt'];
if (extensionValidas.indexOf(extencion) < 0) {
return res.status(400).json({
error: true,
msj: "Extensión invalida del archivo de carta_aceptacion"
});
}
}
} catch (err) {
console.log(err);
return res.status(400).json({
error: true,
msj: "error al verificar la extensión"
});
}
try {
if (req.files.comprobante_pago != undefined) {
let sampleFile = req.files.comprobante_pago;
sampleFile.mv(`files/comprobante_pago-${req.body.id_persona}.docx`, function(err) {
if (err)
return res.status(400).json({ error: true, msj: "Error al registrar el cartel" });
});
}
} catch (err) {
res.status(400).json({ error: true, msj: "Error al subir el archivo de comprobante_pago", type: err });
return;
}
try {
if (req.files.carta_aceptacion != undefined) {
let sampleFile = req.files.carta_aceptacion;
sampleFile.mv(`files/carta_aceptacion-${req.body.id_persona}.docx`, function(err) {
if (err)
return res.status(400).json({ error: true, msj: "Error al registrar el carta_aceptacion" });
});
}
} catch (err) {
res.status(400).json({ error: true, msj: "Error al subir el archivo carta de aceptacion", type: err });
return;
}
res.status(200).json({ error: false, msj: "exito " });
return;
});
module.exports = app
+48
View File
@@ -0,0 +1,48 @@
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('/traer_datos', async(req, res) => {
try {
let cad = `select nombre from universidad;`;
let uni = await query(cad);
//console.log(respuesta);
cad = `select * from evento where tipo_evento='Conversatorio';`;
let con = await query(cad);
cad = `select * from evento where tipo_evento='Taller alumno';`;
let t_a = await query(cad);
cad = `select * from evento where tipo_evento='Taller profesor';`;
let t_p = await query(cad);
cad = `select * from evento where tipo_evento='Visitas guiadas';`;
let v_g = await query(cad);
cad = `select * from evento where tipo_evento='Dialogo magistral';`;
let d_m = await query(cad);
res.status(200).json({ error: false, msj: "exito", universidad: uni, conversatorio: con, taller_alumno: t_a, taller_profesor: t_p, visita: v_g, dialogo: d_m });
return;
} catch (err) {
return res.status(400).json({ error: true, msj: "Error al traer los datos" });
}
});
module.exports = app;
+183
View File
@@ -0,0 +1,183 @@
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('/traer_persona', async(req, res) => {
data = { alumno: [], academico: [] };
try {
let cad = `select * from persona;`;
let r = query(cad);
r.then(async(p) => {
for (let i = 0; i < p.length; i++) {
if (p[i].situacion_academica == 'Alumno') {
let aux = {}
cad = `select e.*, asi.* from evento as e inner join asistencia as asi where asi.id_persona=${p[i].id_persona} and e.id_evento=asi.id_evento`;
let n_ans = await query(cad);
console.log(p[i]);
aux.id_persona = p[i].id_persona;
aux.nombre = p[i].nombre;
aux.apellido_p = p[i].apellido_p;
aux.apellido_m = p[i].apellido_m;
aux.comunidad = p[i].comunidad;
aux.conversatorio_ponente = 'No';
aux.conversatorio_asistente = 'No';
aux.taller = 'No';
aux.visita = 'No';
aux.magistral = 'No';
let ext = true;
if (aux.comunidad == 'UNAM')
ext = false;
let tot = 0;
for (let j = 0; j < n_ans.length; j++) {
console.log(aux.nombre, " ", aux.comunidad, " ", tot, " ", ext, " ", n_ans[j].tipo_de_participacion);
if (n_ans[j].tipo_evento == 'Conversatorio') {
if (n_ans[j].tipo_de_participacion == 'Video') {
if (ext == true)
tot += 700;
else
tot += 100;
aux.conversatorio_ponente = 'Video: ' + n_ans[j].nombre_evento;
} else
if (n_ans[j].tipo_de_participacion == 'Ensayo') {
if (ext == true)
tot += 700;
else
tot += 100;
aux.conversatorio_ponente = 'Ensayo: ' + n_ans[j].nombre_evento;
} else {
aux.conversatorio_asistente = n_ans[j].nombre_evento;
if (ext == true)
tot += 200;
else
tot += 100;
}
}
if (n_ans[j].tipo_evento == 'Taller alumno') {
if (ext == true)
tot += 900;
else
tot += 200;
aux.taller = n_ans[j].nombre_evento;
}
if (n_ans[j].tipo_evento == 'Visitas guiadas') {
if (ext == true)
tot += 500;
else
tot += 500;
aux.visita = n_ans[j].nombre_evento;
}
if (n_ans[j].tipo_evento == 'Dialogo magistral') {
aux.magistral = n_ans[j].nombre_evento;
}
aux.pago = tot;
}
data.alumno.push(aux);
console.log(" ");
console.log(" ");
}
if (p[i].situacion_academica == 'Académico') {
let aux = {}
cad = `select e.*, asi.* from evento as e inner join asistencia as asi where asi.id_persona=${p[i].id_persona} and e.id_evento=asi.id_evento`;
let n_ans = await query(cad);
aux.id_persona = p[i].id_persona;
aux.nombre = p[i].nombre;
aux.apellido_p = p[i].apellido_p;
aux.apellido_m = p[i].apellido_m;
aux.comunidad = p[i].comunidad;
aux.conversatorio_ponente = 'No';
aux.conversatorio_asistente = 'No';
aux.taller = 'No';
aux.visita = 'No';
aux.magistral = 'No';
let tot = 0;
let ext = true;
if (aux.comunidad == 'UNAM')
ext = false;
for (let j = 0; j < n_ans.length; j++) {
if (n_ans[j].tipo_evento == 'Conversatorio') {
if (n_ans[j].tipo_de_participacion == 'Ponente') {
if (ext == true)
tot += 1000;
else
tot += 500;
aux.conversatorio_ponente = n_ans[j].nombre_event;
} else {
aux.conversatorio_asistente = n_ans[j].nombre_evento;
if (ext == true)
tot += 1300;
else
tot += 650;
}
}
if (n_ans[j].tipo_evento == 'Taller profesor') {
if (ext == true)
tot += 1500;
else
tot += 750;
aux.taller = n_ans[j].nombre_evento;
}
if (n_ans[j].tipo_evento == 'Visitas guiadas') {
if (ext == true)
tot += 500;
else
tot += 500;
aux.visita = n_ans[j].nombre_evento;
}
if (n_ans[j].tipo_evento == 'Dialogo magistral') {
aux.magistral = n_ans[j].nombre_evento;
}
aux.pago = tot;
}
data.academico.push(aux);
}
}
console.log(p);
res.status(200).json({ error: false, datos: data });
})
} catch (err) {
return res.status(400).json({ error: true, msj: "Error al traer los datos" });
}
});
module.exports = app;
+209 -22
View File
@@ -1,36 +1,44 @@
drop database asinea;
Create Database asinea;
use asinea;
CREATE TABLE `admin` (
`id_admin` integer PRIMARY KEY NOT NULL,
`id_admin` integer PRIMARY KEY NOT NULL AUTO_INCREMENT,
`usuario` varchar(100),
`password` varchar(300)
);
CREATE TABLE `universidad` (
`id_universidad` integer PRIMARY KEY NOT NULL AUTO_INCREMENT,
`nombre` varchar(250)
);
CREATE TABLE `persona` (
`id_persona` integer PRIMARY KEY NOT NULL AUTO_INCREMENT,
`nombre` varchar(100),
`apellidp_p` varchar(100),
`apellidp_m` varchar(100),
`apellido_p` varchar(100),
`apellido_m` varchar(100),
`curp` varchar(200),
`edad` integer,
`genero` varchar(10),
`telefono` varchar(50),
`correo` varchar(100),
`pasword` varchar(300),
`password` varchar(300),
`comunidad` varchar(50),
`situacion_academica` varchar(50)
`situacion_academica` varchar(50),
`universidad` varchar(150)
);
CREATE TABLE `alumnos` (
CREATE TABLE `alumno` (
`id_persona` integer PRIMARY KEY NOT NULL,
`numero_cuenta` varchar(20),
`año_curso` varchar(20),
`tipo_de_participacion` varchar(50)
`año_curso` varchar(20)
);
CREATE TABLE `academico` (
`id_persona` integer PRIMARY KEY NOT NULL,
`grado_academico` varchar(50),
`aignatura_imparte` varchar(50),
`tipo_de_participacion` varchar(50)
`aignatura_imparte` varchar(50)
);
CREATE TABLE `evento` (
@@ -48,26 +56,205 @@ CREATE TABLE `asistencia` (
`asistencia_1` boolean,
`asistencia_2` boolean,
`asistencia_3` boolean,
`asistencia_4` boolean
`asistencia_4` boolean,
`tipo_de_participacion` varchar(50)
);
CREATE TABLE `factura` (
`id_factura` integer PRIMARY KEY NOT NULL AUTO_INCREMENT,
`id_persona` int,
`rfc` varchar(100),
`domicilio` varchar(120),
`telefono` varchar(30),
`correo` varchar(70)
`rfc` varchar(255),
`domicilio` varchar(255),
`telefono` varchar(255),
`correo` varchar(255)
);
ALTER TABLE `persona` ADD FOREIGN KEY (`id_persona`) REFERENCES `factura` (`id_persona`);
ALTER TABLE `factura` ADD FOREIGN KEY (`id_persona`) REFERENCES `persona` (`id_persona`);
ALTER TABLE `asistencia` ADD FOREIGN KEY (`id_persona`) REFERENCES `academico` (`id_persona`);
ALTER TABLE `asistencia` ADD FOREIGN KEY (`id_persona`) REFERENCES `persona` (`id_persona`);
ALTER TABLE `asistencia` ADD FOREIGN KEY (`id_persona`) REFERENCES `alumnos` (`id_persona`);
ALTER TABLE `evento` ADD FOREIGN KEY (`id_evento`) REFERENCES `asistencia` (`id_evento`);
ALTER TABLE `alumnos` ADD FOREIGN KEY (`id_persona`) REFERENCES `persona` (`id_persona`);
ALTER TABLE `alumno` ADD FOREIGN KEY (`id_persona`) REFERENCES `persona` (`id_persona`);
ALTER TABLE `academico` ADD FOREIGN KEY (`id_persona`) REFERENCES `persona` (`id_persona`);
ALTER TABLE `asistencia` ADD FOREIGN KEY (`id_evento`) REFERENCES `evento` (`id_evento`);
insert into evento values (null, 'Conversatorio', 'Mesa 1: Nuestra imagen actual', 200);
insert into evento values (null, 'Conversatorio', 'Mesa 2: Territorios de aprendizaje', 200);
insert into evento values (null, 'Conversatorio', 'Mesa 3: Construir el futuro', 200);
insert into evento values (null, 'Taller alumno', 'Taller 1: HIST + EST Historia + Estructuras', 20);
insert into evento values (null, 'Taller alumno', 'Taller 2: de Muros de Tierra', 20);
insert into evento values (null, 'Taller alumno', 'Taller 3: Reconstruyendo el pasado', 20);
insert into evento values (null, 'Taller alumno', 'Taller 4: Modulación paramétrica y criterios de fabricación digital', 20);
insert into evento values (null, 'Taller alumno', 'Taller 5: Construcción con tierra cruda. Bahareque y Tapial con alternativas de construcción', 20);
insert into evento values (null, 'Taller alumno', 'Taller 6: Maquetas Arquitectónicas', 20);
insert into evento values (null, 'Taller alumno', 'Taller 7: LMSE [Laboratorio de Materiales y Sistemas Estructurales]', 20);
insert into evento values (null, 'Taller alumno', 'Taller 8: Habitar el género en el taller de arquitectura', 20);
insert into evento values (null, 'Taller alumno', 'Taller 9: Taller Urbanismo Táctico e Infraestructura verde para caminar la ciudad', 20);
insert into evento values (null, 'Taller profesor', 'Taller 1: Habitar el género en el taller de arquitectura', 20);
insert into evento values (null, 'Taller profesor', 'Taller 2: Construyendo modos de saber', 20);
insert into evento values (null, 'Visitas guiadas', 'Ruta Candela', 40);
insert into evento values (null, 'Visitas guiadas', 'Ruta Barragan', 0);
insert into evento values (null, 'Visitas guiadas', 'Ruta Centro', 40);
insert into evento values (null, 'Visitas guiadas', 'Ruta Norte', 40);
insert into evento values (null, 'Visitas guiadas', 'Ruta Oriente', 40);
insert into evento values (null, 'Visitas guiadas', 'Ruta Poniente', 40);
insert into evento values (null, 'Visitas guiadas', 'Ruta Sur', 40);
insert into evento values (null, 'Visitas guiadas', 'Ruta Polanco', 40);
insert into evento values (null, 'Dialogo magistral', 'Diálogo magistral 1: Experiencias escolares. El peso de la formación en la práctica profesional', 300);
insert into evento values (null, 'Dialogo magistral', 'Diálogo magistral 2: ¿Qué es ser arquitecto?', 300);
insert into universidad values (null ,'UNIVERSIDAD AUTÓNOMA DE BAJA CALIFORNIA');
insert into universidad values (null ,'UNIVERSIDAD IBEROAMÉRICANA, CAMPUS TIJUANA');
insert into universidad values (null ,'INSTITUTO TECNOLÓGICO DE LA PAZ');
insert into universidad values (null ,'UNIVERSIDAD DE SONORA');
insert into universidad values (null ,'INSTITUTO TECNOLÓGICO SUPERIOR DE CAJEME');
insert into universidad values (null ,'UNIVERSIDAD AUTÓNOMA DE SINALOA, CAMPUS CULIACÁN');
insert into universidad values (null ,'UNIVERSIDAD AUTÓNOMA DE SINALOA, CAMPUS MAZATLÁN');
insert into universidad values (null ,'INSTITUTO TECNOLÓGICO DE LOS MOCHIS');
insert into universidad values (null ,'INSTITUTO TECNOLÓGICO DE TIJUANA');
insert into universidad values (null ,'INSTITUTO TECNOLÓGICO DE MONTERREY');
insert into universidad values (null ,'UNIVERSIDAD AUTÓNOMA DE BAJA CALIFORNIA (CITEC) TIJUANA');
insert into universidad values (null ,'INSTITUTO TECNOLÓGICO DE CHIHUAHUA II');
insert into universidad values (null ,'INSTITUTO SUPERIOR DE ARQUITECTURA Y DISEÑO DE CHIHUAHUA');
insert into universidad values (null ,'UNIVERSIDAD AUTÓNOMA DE CIUDAD JUÁREZ');
insert into universidad values (null ,'INSTITUTO TECNOLÓGICO DE DURANGO');
insert into universidad values (null ,'UNIVERSIDAD JUÁREZ DEL ESTADO DE DURANGO');
insert into universidad values (null ,'UNIVERSIDAD LA SALLE LAGUNA');
insert into universidad values (null ,'UNIVERSIDAD AUTÓNOMA DE COAHUILA, UNIDAD TORREÓN');
insert into universidad values (null ,'CORPORATIVO UNIVERSITARIO DE CAPACITACIÓN PROFESIONAL A.C.');
insert into universidad values (null ,'UNIVERSIDAD AUTÓNOMA DE COAHUILA, Unidad Saltillo (Campus Arteaga).');
insert into universidad values (null ,'UNIVERSIDAD AUTÓNOMA DE NUEVO LEÓN ');
insert into universidad values (null ,'INSTITUTO TECNOLÓGICO DE MONTERREY');
insert into universidad values (null ,'UNIVERSIDAD DE MONTERREY ');
insert into universidad values (null ,'UNIVERSIDAD AUTONOMA DE TAMAULIPAS');
insert into universidad values (null ,'INSTITUTO DE ESTUDIOS SUPERIORES DE TAMAULIPAS');
insert into universidad values (null ,'UNIVERSIDAD MÉXICO AMÉRICANA DEL NORTE');
insert into universidad values (null ,'UNIVERSIDAD LA SALLE VICTORIA ');
insert into universidad values (null ,'INSTITUTO TECNOLÓGICO DE REYNOSA');
insert into universidad values (null ,'INSTITUTO TECNOLÓGICO DE TEPIC');
insert into universidad values (null ,'UNIVERSIDAD DE GUADALAJARA');
insert into universidad values (null ,'ITESM, CAMPUS GUADALAJARA');
insert into universidad values (null ,'UNIVERSIDAD DE COLIMA');
insert into universidad values (null ,'INSTITUTO TECNOLÓGICO DE COLIMA ');
insert into universidad values (null ,'UNIVERSIDAD MICHOACANA DE SAN NICOLÁS DE HIDALGO ');
insert into universidad values (null ,'INSTITUTO TECNOLÓGICO SUPERIOR DE FRESNILLO ');
insert into universidad values (null ,'INSTITUTO TECNOLÓGICO DE ZACATECAS ');
insert into universidad values (null ,'UNIVERSIDAD AUTÓNOMA DE AGUASCALIENTES ');
insert into universidad values (null ,'UNIVERSIDAD DE GUANAJUATO ');
insert into universidad values (null ,'UNIVERSIDAD DE LA SALLE BAJÍO A.C.');
insert into universidad values (null ,'UNIVERSIDAD IBEROAMERICANA DE LEÓN ');
insert into universidad values (null ,'UNIVERSIDAD LATINA DE MÉXICO ');
insert into universidad values (null ,'UNIVERSIDAD DE CELAYA');
insert into universidad values (null ,'UNIVERSIDAD AUTÓNOMA DE SAN LUIS POTOSÍ ');
insert into universidad values (null ,'INSTITUTO TECNOLÓGICO DE QUERETARO ');
insert into universidad values (null ,'INSTITUTO TECNOLÓGICO DE ESTUDIOS SUPERIORES MONTERREY');
insert into universidad values (null ,'UVM CAMPUS QUERETARO ');
insert into universidad values (null ,'INSTITUTO TECNOLÓGICO JOSÉ MARIO MOLINA PASQUEL Y HENRÍQUEZ, CAMPUS PUERTO VALLARTA ');
insert into universidad values (null ,'INSTITUTO TECNOLÓGICO MARIO MOLINA PASQUEL Y HENRÍQUEZ, CAMPUS EL GRULLO');
insert into universidad values (null ,'UNIVERSIDAD DE GUADALAJARA');
insert into universidad values (null ,'INSTITUTO TECNOLÓGICO DE ESTUDIOS SUPERIORES DE OCCIDENTE A.C');
insert into universidad values (null ,'UNIVERSIDAD ANÁHUAC QUERÉTARO');
insert into universidad values (null ,'CENTRO UNIVERSITARIO UTEG');
insert into universidad values (null ,'UNIVERSIDAD AUTÓNOMA METROPOLITANA, UNIDAD XOCHIMILCO ');
insert into universidad values (null ,'UNIVERSIDAD AUTÓNOMA METROPOLITANA, UNIDAD AZCAPOTZALCO');
insert into universidad values (null ,'UNIVERSIDAD IBEROAMERICANA CIUDAD DE MÉXICO');
insert into universidad values (null ,'ESCUELA DE ARQUITECTURA DE LA UNIVERSIDAD INTERCONTINENTAL ');
insert into universidad values (null ,'UNIVERSIDAD NACIONAL AUTÓNOMA DE MÉXICO CU');
insert into universidad values (null ,'UNIVERSIDAD NACIONAL AUTÓNOMA DE MÉXICO, FES ARAGÓN');
insert into universidad values (null ,'UNIVERSIDAD NACIONAL AUTÓNOMA DE MÉXICO, FES ACATLÁN');
insert into universidad values (null ,'INSTITUTO POLITÉCNICO NACIONAL');
insert into universidad values (null ,'UNIVERSIDAD ANÁHUAC MÉXICO, CAMPUS NORTE Y SUR.');
insert into universidad values (null ,'INSTITUTO TECNOLOGICO DE ESTUDIOS SUPERIORES MONTERREY.');
insert into universidad values (null ,'UNIVERSIDAD LA SALLE MÉXICO');
insert into universidad values (null ,'UNIVERSIDAD LATINOAMERICANA, CAMPUS FLORIDA');
insert into universidad values (null ,'UNIVERSIDAD AUTÓNOMA DEL ESTADO DE MÉXICO');
insert into universidad values (null ,'UNIVERSIDAD DEL VALLE DE MÉXICO, CAMPUS LOMAS VERDES');
insert into universidad values (null ,'UNIVERSIDAD DEL VALLE DE TOLUCA');
insert into universidad values (null ,'INSTITUTO UNIVERSITARIO DEL ESTADO DE MÉXICO');
insert into universidad values (null ,'ITESM, ESTADO DE MÉXICO');
insert into universidad values (null ,'INSTITUTO TECNOLOGICO DE ESTUDIOS SUPERIORES MONTERREY');
insert into universidad values (null ,'UNIVERSIDAD DE IXTLAHUACA CUI');
insert into universidad values (null ,'UNIVERSIDAD JUSTO SIERRA, CAMPUS CIEN METROS');
insert into universidad values (null ,'UNIVERSIDAD LATINOAMERICANA, CAMPUS NORTE');
insert into universidad values (null ,'TECNOLÓGICO DE ESTUDIOS SUPERIORES DE JOCOTITLÁN');
insert into universidad values (null ,'BENEMÉRITA UNIVERSIDAD AUTÓNOMA DE PUEBLA');
insert into universidad values (null ,'UNIVERSIDAD POPULAR AUTÓNOMA DEL ESTADO DE PUEBLA');
insert into universidad values (null ,'UNIVERSIDAD IBEROAMERICANA, PUEBLA');
insert into universidad values (null ,'UNIVERSIDAD DE LAS AMÉRICAS PUEBLA');
insert into universidad values (null ,'UNIVERSIDAD AUTÓNOMA DEL ESTADO DE MORELOS');
insert into universidad values (null ,'UNIVERSIDAD LA SALLE CUERNAVACA AC.');
insert into universidad values (null ,'UNIVERSIDAD AUTÓNOMA DE GUERRERO');
insert into universidad values (null ,'INSTITUTO TECNOLÓGICO DE ACAPULCO');
insert into universidad values (null ,'UNIVERSIDAD AMERICANA DE ACAPULCO');
insert into universidad values (null ,'UNIVERSIDAD LOYOLA DEL PACÍFICO');
insert into universidad values (null ,'UNIVERSIDAD INTERNACIONAL');
insert into universidad values (null ,'INSTITUTO TECNOLÓGICO DE ESTUDIOS SUPERIORES MONTERREY');
insert into universidad values (null ,'UNIVERSIDAD LA SALLE, PACHUCA');
insert into universidad values (null ,'INSTITUTO TECNOLÓGICO DE PACHUCA');
insert into universidad values (null ,'UNIVERSIDAD AUTÓNOMA DE TLAXCALA');
insert into universidad values (null ,'UNIVERSIDAD VERACRUZANA-REGIÓN TUXPAN');
insert into universidad values (null ,'UNIVERSIDAD GESTALT DE DISEÑO');
insert into universidad values (null ,'UNIVERSIDAD VERACRUZANA, REGIÓN XALAPA');
insert into universidad values (null ,'UNIVERSIDAD VERACRUZANA, REGION CÓRDOBA');
insert into universidad values (null ,'UNIVERSIDAD CRISTÓBAL COLÓN');
insert into universidad values (null ,'UNIVERSIDAD DEL VALLE DE MÉXICO, CAMPUS VILLA RICA');
insert into universidad values (null ,'UNIVERSIDAD DE SOTAVENTO');
insert into universidad values (null ,'UNIVERSIDAD AUTÓNOMA DE CHIAPAS');
insert into universidad values (null ,'UNIVERSIDAD DEL VALLE DEL GRIJALVA');
insert into universidad values (null ,'INSTITUTO DE ESTUDIOS SUPERIORES DE CHIAPAS');
insert into universidad values (null ,'UNIVERSIDAD JUÁREZ AUTÓNOMA DE TABASCO');
insert into universidad values (null ,'UNIVERSIDAD AUTONOMA “BENITO JUÁREZ” DE OAXACA');
insert into universidad values (null ,'UNIVERSIDAD AUTONOMA “BENITO JUÁREZ” DE OAXACA / CU');
insert into universidad values (null ,'INSTITUTO TECNOLÓGICO DE CHETUMAL ');
insert into universidad values (null ,'INSTITUTO TECNOLÓGICO DE CAMPECHE');
insert into universidad values (null ,'UNIVERSIDAD AUTÓNOMA DE YUCATÁN');
insert into universidad values (null ,'UNIVERSIDAD MARISTA DE MÉRIDA');
insert into universidad values (null ,'UNIVERSIDAD LA SALLE CANCÚN');
insert into universidad values (null ,'UNIVERSIDAD MODELO ');
insert into universidad values (null ,'UNIVERSIDAD ANÁHUAC MAYAB');
insert into universidad values (null ,'Otra');