ultima modificacion antes de seguridad
|
Before Width: | Height: | Size: 466 KiB After Width: | Height: | Size: 466 KiB |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 278 KiB After Width: | Height: | Size: 278 KiB |
|
After Width: | Height: | Size: 348 B |
|
After Width: | Height: | Size: 341 B |
|
After Width: | Height: | Size: 342 B |
|
After Width: | Height: | Size: 341 B |
|
After Width: | Height: | Size: 335 B |
|
After Width: | Height: | Size: 332 B |
|
After Width: | Height: | Size: 332 B |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
@@ -0,0 +1,26 @@
|
||||
const connection = require('../conf/connection.js');
|
||||
const express = require('express')
|
||||
var app = express();
|
||||
|
||||
app.get('/cupo', async(req, res) => {
|
||||
let arr = [];
|
||||
connection.query(`Select * from conferencia;`, async(error, results, file) => {
|
||||
if (error) {
|
||||
res.status(200).json({ err: false });
|
||||
return;
|
||||
}
|
||||
await results.forEach(element => {
|
||||
if (element.idConferencia == 7)
|
||||
arr.push([element.nombre, 'ilimitado', 100000 - element.capacidad]);
|
||||
else
|
||||
arr.push([element.nombre, 150, 150 - element.capacidad]);
|
||||
|
||||
});
|
||||
res.status(200).json(arr);
|
||||
return;
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
module.exports = app;
|
||||
@@ -0,0 +1,10 @@
|
||||
const connection = require('../conf/connection.js');
|
||||
const express = require('express')
|
||||
var app = express();
|
||||
|
||||
|
||||
app.get('/descargar_pdf', (req, res) => {
|
||||
res.download(__dirname + `/../public/comprobante-${req.query.idPersona}.pdf`);
|
||||
})
|
||||
|
||||
module.exports = app;
|
||||
@@ -0,0 +1,10 @@
|
||||
var qr = require('qr-image');
|
||||
let i_m = async function(persona) {
|
||||
|
||||
var qr_svg = await qr.image(`${persona}`, { type: 'png' });
|
||||
await qr_svg.pipe(require('fs').createWriteStream(__dirname + `/Imagenes/persona_${persona}.png`));
|
||||
|
||||
// var svg_string = qr.imageSync(`${persona}`, { type: 'png' });
|
||||
return
|
||||
}
|
||||
module.exports = i_m;
|
||||
@@ -2,275 +2,41 @@ const connection = require('../conf/connection.js');
|
||||
const express = require('express')
|
||||
var app = express();
|
||||
|
||||
var conferencias = {
|
||||
dia1: {
|
||||
conf1: {
|
||||
nombre: "",
|
||||
fecha: "",
|
||||
asistir: false
|
||||
},
|
||||
conf2: {
|
||||
nombre: "",
|
||||
fecha: "",
|
||||
asistir: false
|
||||
},
|
||||
conf3: {
|
||||
nombre: "",
|
||||
fecha: "",
|
||||
asistir: false
|
||||
}
|
||||
},
|
||||
dia2: {
|
||||
conf1: {
|
||||
nombre: "",
|
||||
fecha: "",
|
||||
asistir: false
|
||||
},
|
||||
conf2: {
|
||||
nombre: "",
|
||||
fecha: "",
|
||||
asistir: false
|
||||
},
|
||||
conf3: {
|
||||
nombre: "",
|
||||
fecha: "",
|
||||
asistir: false
|
||||
}
|
||||
},
|
||||
dia4: {
|
||||
conf1: {
|
||||
nombre: "",
|
||||
fecha: "",
|
||||
asistir: false
|
||||
},
|
||||
conf2: {
|
||||
nombre: "",
|
||||
fecha: "",
|
||||
asistir: false
|
||||
},
|
||||
conf3: {
|
||||
nombre: "",
|
||||
fecha: "",
|
||||
asistir: false
|
||||
}
|
||||
},
|
||||
dia5: {
|
||||
conf1: {
|
||||
nombre: "",
|
||||
fecha: "",
|
||||
asistir: false
|
||||
},
|
||||
conf2: {
|
||||
nombre: "",
|
||||
fecha: "",
|
||||
asistir: false
|
||||
},
|
||||
conf3: {
|
||||
nombre: "",
|
||||
fecha: "",
|
||||
asistir: false
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
app.get('/getConferencias', (req, res) => {
|
||||
|
||||
|
||||
connection.query(`select * from conferencia ;`, function(error, results, fields) {
|
||||
if (error) {
|
||||
res.status(400).json({ err: true, mjs: 'error en la consulta de conferencia' });
|
||||
connection.end();
|
||||
throw error;
|
||||
|
||||
}
|
||||
|
||||
conferencias.dia1.conf1.nombre = results[0].nombre;
|
||||
conferencias.dia1.conf1.fecha = results[0].fecha;
|
||||
conferencias.dia1.conf2.nombre = results[1].nombre;
|
||||
conferencias.dia1.conf2.fecha = results[1].fecha;
|
||||
conferencias.dia1.conf3.nombre = results[2].nombre;
|
||||
conferencias.dia1.conf3.fecha = results[2].fecha;
|
||||
|
||||
conferencias.dia2.conf1.nombre = results[3].nombre;
|
||||
conferencias.dia2.conf1.fecha = results[3].fecha;
|
||||
conferencias.dia2.conf2.nombre = results[4].nombre;
|
||||
conferencias.dia2.conf2.fecha = results[4].fecha;
|
||||
conferencias.dia2.conf3.nombre = results[5].nombre;
|
||||
conferencias.dia2.conf3.fecha = results[5].fecha;
|
||||
|
||||
conferencias.dia4.conf1.nombre = results[6].nombre;
|
||||
conferencias.dia4.conf1.fecha = results[6].fecha;
|
||||
conferencias.dia4.conf2.nombre = results[7].nombre;
|
||||
conferencias.dia4.conf2.fecha = results[7].fecha;
|
||||
conferencias.dia4.conf3.nombre = results[8].nombre;
|
||||
conferencias.dia4.conf3.fecha = results[8].fecha;
|
||||
|
||||
conferencias.dia5.conf1.nombre = results[9].nombre;
|
||||
conferencias.dia5.conf1.fecha = results[9].fecha;
|
||||
conferencias.dia5.conf2.nombre = results[10].nombre;
|
||||
conferencias.dia5.conf2.fecha = results[10].fecha;
|
||||
conferencias.dia5.conf3.nombre = results[11].nombre;
|
||||
conferencias.dia5.conf3.fecha = results[11].fecha;
|
||||
|
||||
connection.query(`select * from asistencia where idPersona='${req.body.idPersona}'
|
||||
and idConferencia='${results[0].idConferencia}' ;`, function(error, results, fields) {
|
||||
console.log(req.body);
|
||||
connection.query(`select * from conferencia ;`,
|
||||
function(error, results, fields) {
|
||||
if (error) {
|
||||
res.status(400).json({ err: true, mjs: 'error en la consulta de conferencia' });
|
||||
connection.end();
|
||||
throw error;
|
||||
return;
|
||||
|
||||
}
|
||||
if (results.length > 0)
|
||||
conferencias.dia1.conf1.asistir = true;
|
||||
|
||||
connection.query(`select * from asistencia a join conferencia c on a.idConferencia=c.idConferencia where a.idPersona=${req.query.idPersona}`,
|
||||
async(error2, results2, file2) => {
|
||||
if (error2) {
|
||||
res.status(400).json({ err: true, mjs: 'error en la consulta de conferencia' });
|
||||
connection.end();
|
||||
return;
|
||||
|
||||
}
|
||||
let data = {
|
||||
conf: results,
|
||||
activas: []
|
||||
}
|
||||
for (let index = 0; index < results2.length; index++) {
|
||||
data.activas.push(results2[index].idConferencia)
|
||||
|
||||
}
|
||||
//console.log(results);
|
||||
//console.log(results2);
|
||||
res.status(200).json(data);
|
||||
return;
|
||||
});
|
||||
|
||||
});
|
||||
connection.query(`select * from asistencia where idPersona='${req.body.idPersona}'
|
||||
and idConferencia='${results[1].idConferencia}' ;`, function(error, results, fields) {
|
||||
if (error) {
|
||||
res.status(400).json({ err: true, mjs: 'error en la consulta de conferencia' });
|
||||
connection.end();
|
||||
throw error;
|
||||
|
||||
}
|
||||
if (results.length > 0)
|
||||
conferencias.dia1.conf2.asistir = true;
|
||||
|
||||
});
|
||||
connection.query(`select * from asistencia where idPersona='${req.body.idPersona}'
|
||||
and idConferencia='${results[2].idConferencia}' ;`, function(error, results, fields) {
|
||||
if (error) {
|
||||
res.status(400).json({ err: true, mjs: 'error en la consulta de conferencia' });
|
||||
connection.end();
|
||||
throw error;
|
||||
|
||||
}
|
||||
if (results.length > 0)
|
||||
conferencias.dia1.conf3.asistir = true;
|
||||
|
||||
});
|
||||
|
||||
|
||||
connection.query(`select * from asistencia where idPersona='${req.body.idPersona}'
|
||||
and idConferencia='${results[3].idConferencia}' ;`, function(error, results, fields) {
|
||||
if (error) {
|
||||
res.status(400).json({ err: true, mjs: 'error en la consulta de conferencia' });
|
||||
connection.end();
|
||||
throw error;
|
||||
|
||||
}
|
||||
if (results.length > 0)
|
||||
conferencias.dia2.conf1.asistir = true;
|
||||
|
||||
});
|
||||
connection.query(`select * from asistencia where idPersona='${req.body.idPersona}'
|
||||
and idConferencia='${results[4].idConferencia}' ;`, function(error, results, fields) {
|
||||
if (error) {
|
||||
res.status(400).json({ err: true, mjs: 'error en la consulta de conferencia' });
|
||||
connection.end();
|
||||
throw error;
|
||||
|
||||
}
|
||||
if (results.length > 0)
|
||||
conferencias.dia2.conf2.asistir = true;
|
||||
|
||||
});
|
||||
connection.query(`select * from asistencia where idPersona='${req.body.idPersona}'
|
||||
and idConferencia='${results[5].idConferencia}' ;`, function(error, results, fields) {
|
||||
if (error) {
|
||||
res.status(400).json({ err: true, mjs: 'error en la consulta de conferencia' });
|
||||
connection.end();
|
||||
throw error;
|
||||
|
||||
}
|
||||
if (results.length > 0)
|
||||
conferencias.dia2.conf3.asistir = true;
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
connection.query(`select * from asistencia where idPersona='${req.body.idPersona}'
|
||||
and idConferencia='${results[6].idConferencia}' ;`, function(error, results, fields) {
|
||||
if (error) {
|
||||
res.status(400).json({ err: true, mjs: 'error en la consulta de conferencia' });
|
||||
connection.end();
|
||||
throw error;
|
||||
|
||||
}
|
||||
if (results.length > 0)
|
||||
conferencias.dia4.conf1.asistir = true;
|
||||
|
||||
});
|
||||
connection.query(`select * from asistencia where idPersona='${req.body.idPersona}'
|
||||
and idConferencia='${results[7].idConferencia}' ;`, function(error, results, fields) {
|
||||
if (error) {
|
||||
res.status(400).json({ err: true, mjs: 'error en la consulta de conferencia' });
|
||||
connection.end();
|
||||
throw error;
|
||||
|
||||
}
|
||||
if (results.length > 0)
|
||||
conferencias.dia4.conf2.asistir = true;
|
||||
|
||||
});
|
||||
connection.query(`select * from asistencia where idPersona='${req.body.idPersona}'
|
||||
and idConferencia='${results[8].idConferencia}' ;`, function(error, results, fields) {
|
||||
if (error) {
|
||||
res.status(400).json({ err: true, mjs: 'error en la consulta de conferencia' });
|
||||
connection.end();
|
||||
throw error;
|
||||
|
||||
}
|
||||
if (results.length > 0)
|
||||
conferencias.dia4.conf3.asistir = true;
|
||||
|
||||
});
|
||||
|
||||
|
||||
connection.query(`select * from asistencia where idPersona='${req.body.idPersona}'
|
||||
and idConferencia='${results[9].idConferencia}' ;`, function(error, results, fields) {
|
||||
if (error) {
|
||||
res.status(400).json({ err: true, mjs: 'error en la consulta de conferencia' });
|
||||
connection.end();
|
||||
throw error;
|
||||
|
||||
}
|
||||
if (results.length > 0)
|
||||
conferencias.dia5.conf1.asistir = true;
|
||||
|
||||
});
|
||||
connection.query(`select * from asistencia where idPersona='${req.body.idPersona}'
|
||||
and idConferencia='${results[10].idConferencia}' ;`, function(error, results, fields) {
|
||||
if (error) {
|
||||
res.status(400).json({ err: true, mjs: 'error en la consulta de conferencia' });
|
||||
connection.end();
|
||||
throw error;
|
||||
|
||||
}
|
||||
if (results.length > 0)
|
||||
conferencias.dia5.conf2.asistir = true;
|
||||
|
||||
});
|
||||
connection.query(`select * from asistencia where idPersona='${req.body.idPersona}'
|
||||
and idConferencia='${results[11].idConferencia}' ;`, function(error, results, fields) {
|
||||
if (error) {
|
||||
res.status(400).json({ err: true, mjs: 'error en la consulta de conferencia' });
|
||||
connection.end();
|
||||
throw error;
|
||||
|
||||
}
|
||||
if (results.length > 0)
|
||||
conferencias.dia5.conf3.asistir = true;
|
||||
|
||||
});
|
||||
// console.log(req.body.idPersona);
|
||||
res.status(200).json(conferencias);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
module.exports = app;
|
||||
@@ -0,0 +1,13 @@
|
||||
const connection = require('../conf/connection.js');
|
||||
const fs = require('fs');
|
||||
const express = require('express')
|
||||
var app = express();
|
||||
var pdf = require('./pdf.js');
|
||||
const path = require('path');
|
||||
app.get('/get_pdf', async(req, res) => {
|
||||
await pdf(req.query.idPersona);
|
||||
res.status(200).json({ err: false, msj: " listo" });
|
||||
|
||||
})
|
||||
//pdf(req.query.idPersona).then(res.status(200).json({ err: false, msj: 'exito' }));
|
||||
module.exports = app;
|
||||
@@ -0,0 +1,13 @@
|
||||
const express = require('express')
|
||||
|
||||
var app = express();
|
||||
var i_m = require('./g_img.js');
|
||||
|
||||
|
||||
app.get('/get_qr', async(req, res) => {
|
||||
|
||||
i_m(req.query.idPersona);
|
||||
res.status(200).json({ err: false });
|
||||
})
|
||||
|
||||
module.exports = app;
|
||||
@@ -5,5 +5,9 @@ app.use(require('./registro'));
|
||||
app.use(require('./registroPersona'));
|
||||
app.use(require('./loggin'));
|
||||
app.use(require('./getConferencias'));
|
||||
app.use(require('./get_pdf'));
|
||||
app.use(require('./descargar_pdf'));
|
||||
app.use(require('./get_qr'));
|
||||
app.use(require('./verificarConferencia'));
|
||||
app.use(require('./cupo'));
|
||||
module.exports = app;
|
||||
@@ -4,24 +4,29 @@ const bcrypt = require('bcryptjs');
|
||||
var app = express();
|
||||
|
||||
app.post('/loggin', async(req, res) => {
|
||||
if (!req.body.correo || req.body.correo == "") {
|
||||
res.status(400).json({ error: true, msj: "faltan datos" });
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(req.body);
|
||||
connection.query(`SELECT idPersona from persona where correo = '${req.body.correo}' `,
|
||||
function(error, results, fields) {
|
||||
if (error) {
|
||||
res.status(400).json({ err: true, mjs: 'error en la verificacion del correo' });
|
||||
throw error;
|
||||
return;
|
||||
|
||||
}
|
||||
if (results.length == 0) {
|
||||
res.status(400).json({ err: true, mjs: 'Correo no registrado' });
|
||||
throw error;
|
||||
return;
|
||||
|
||||
} else {
|
||||
connection.query(`select * from persona where correo = '${req.body.correo}'`,
|
||||
async function(e, r, f) {
|
||||
if (e) {
|
||||
res.status(200).json({ err: true, mjs: 'error en la verificacion del de la contraseña' });
|
||||
throw error;
|
||||
return;
|
||||
|
||||
}
|
||||
let po = r[0].password;
|
||||
@@ -29,11 +34,11 @@ app.post('/loggin', async(req, res) => {
|
||||
//console.log(r, `'${req.body.correo}' and password= '${req.body.password}'`);
|
||||
let ban = bcrypt.compareSync(req.body.password, po);
|
||||
if (ban == true) {
|
||||
res.status(200).json({ err: false, mjs: 'Bienvenido', idPersona: r[0].idPersona, nombre: r[0].nombre });
|
||||
res.status(200).json({ err: false, mjs: `Bienvenid@ ${r[0].nombre}`, idPersona: r[0].idPersona });
|
||||
return;
|
||||
} else {
|
||||
res.status(400).json({ err: true, mjs: 'Datos Incorrectos' });
|
||||
throw error;
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -42,12 +47,4 @@ app.post('/loggin', async(req, res) => {
|
||||
|
||||
|
||||
|
||||
module.exports = app;
|
||||
|
||||
|
||||
|
||||
// {
|
||||
// "correo": "daniel.adrian.ramirez.george@gmail.com",
|
||||
// "password": "georgechido"
|
||||
|
||||
//
|
||||
module.exports = app;
|
||||
@@ -1,160 +1,114 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const PDFDocument = require('./pdfkit-tables');
|
||||
const doc = new PDFDocument();
|
||||
doc.pipe(fs.createWriteStream('comprobante.pdf'));
|
||||
// Embed a font, set the font size, and render some text
|
||||
const connection = require('../conf/connection.js');
|
||||
const path = require('path');
|
||||
var i_m = require('./g_img.js');
|
||||
|
||||
// Add an image, constrain it to a given size, and center it vertically and horizontally
|
||||
let g_pdf = async function(idPersona) {
|
||||
|
||||
|
||||
const doc = new PDFDocument({ size: 'A4' });
|
||||
doc.pipe(fs.createWriteStream(__dirname + `/../public/comprobante-${idPersona}.pdf`));
|
||||
|
||||
|
||||
let inicio = 120;
|
||||
|
||||
|
||||
|
||||
const table0 = {
|
||||
headers: ['Word', 'Comment', 'Summary'],
|
||||
rows: [
|
||||
['Apple', 'Not this one', 'la gravida ultrices. Fusce vitae pulvinar magna.'],
|
||||
['Tire', 'Smells like funny', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla viverra at ligula gravida ultrices. Fusce vitae pulvinar magna.']
|
||||
]
|
||||
};
|
||||
doc.image(__dirname + '/Imagenes/logo_unam.png', inicio, 30, { scale: 0.04 });
|
||||
|
||||
doc.table(table0, {
|
||||
prepareHeader: () => doc.font('Helvetica-Bold'),
|
||||
prepareRow: (row, i) => doc.font('Helvetica').fontSize(12)
|
||||
});
|
||||
doc.font('Times-Roman')
|
||||
.fontSize(10)
|
||||
.text('UNIVERSIDAD NACIONAL AUTONOMA DE MEXICO', inicio + 60, 40);
|
||||
doc.font('Times-Roman')
|
||||
.fontSize(10)
|
||||
.text('FACULTAD DE ESTUDIOS SUPERIORES ACATLÁN', inicio + 66, 50);
|
||||
doc.font('Times-Roman')
|
||||
.fontSize(10)
|
||||
.text('JORNADA DE INSERCIÓN LABORAL', inicio + 95, 60);
|
||||
|
||||
const table1 = {
|
||||
headers: ['Country', 'Conversion rate', 'Trend'],
|
||||
rows: [
|
||||
['Switzerland', '12%', '+1.12%'],
|
||||
['France', '67%', '-0.98%'],
|
||||
['England', '33%', '+4.44%']
|
||||
]
|
||||
};
|
||||
doc.image(__dirname + '/Imagenes/Fesa.jpg', inicio + 305, 30, { scale: 0.05 });
|
||||
// Add another page
|
||||
|
||||
doc.moveDown().table(table1, 100, 350, { width: 300 });
|
||||
doc.font('Times-Roman')
|
||||
.fontSize(8)
|
||||
.text('COMPROBANTE DE INSCRIPCIÓN', inicio + 120, 80);
|
||||
|
||||
doc.end();
|
||||
// let inicio = 120;
|
||||
// doc.image('Imagenes/logo_unam.png', inicio, 30, { scale: 0.04 });
|
||||
doc.moveTo(70, 110)
|
||||
.lineTo(542, 110);
|
||||
|
||||
// doc.font('Times-Roman')
|
||||
// .fontSize(10)
|
||||
// .text('UNIVERSIDAD NACIONAL AUTONOMA DE MEXICO', inicio + 60, 40);
|
||||
// doc.font('Times-Roman')
|
||||
// .fontSize(10)
|
||||
// .text('FACULTAD DE ESTUDIOS SUPERIORES ACATLÁN', inicio + 66, 50);
|
||||
// doc.font('Times-Roman')
|
||||
// .fontSize(10)
|
||||
// .text('JORNADA DE INSERCIÓN LABORAL', inicio + 95, 60);
|
||||
let marg = 70;
|
||||
|
||||
// doc.image('Imagenes/Fesa.jpg', inicio + 305, 30, { scale: 0.05 });
|
||||
// // Add another page
|
||||
doc.image(__dirname + `/Imagenes/persona_${idPersona}.png`, marg, 120, { scale: 0.85 });
|
||||
|
||||
// doc.font('Times-Roman')
|
||||
// .fontSize(8)
|
||||
// .text('COMPROBANTE DE INSCRIPCIÓN', inicio + 120, 80);
|
||||
const table0 = {
|
||||
headers: ['Nombre', 'Correo'],
|
||||
rows: []
|
||||
};
|
||||
|
||||
// let marg = 70;
|
||||
// doc.image('Imagenes/qr_ejemplo.png', marg, 120, { scale: 0.50 });
|
||||
|
||||
|
||||
// // doc.moveTo(marg + 100, 120)
|
||||
// // .lineTo(marg + 200, 120)
|
||||
// // .stroke();
|
||||
doc.font('Times-Roman')
|
||||
.fontSize(13)
|
||||
.text('CONFERENCIAS', inicio + 142, 240);
|
||||
|
||||
|
||||
|
||||
var table1 = {
|
||||
headers: ['Nombre', 'Fecha ', 'Hora'],
|
||||
rows: []
|
||||
};
|
||||
connection.query(`select * from persona where idPersona=${idPersona}`,
|
||||
(erro, results, file) => {
|
||||
if (erro) {
|
||||
res.status(400).json({ mjs: "Error en traer los datos del alumno" });
|
||||
return;
|
||||
}
|
||||
table0.rows.push([results[0].nombre + " " + results[0].apellidos, results[0].correo]);
|
||||
doc.moveDown().table(table0, 200, 150, { width: 300 });
|
||||
});
|
||||
connection.query(`select * from asistencia a join conferencia c on a.idConferencia=c.idConferencia where idPersona=${idPersona}`,
|
||||
(erro, results, file) => {
|
||||
if (erro) {
|
||||
res.status(400).json({ mjs: "error en las conferencias" });
|
||||
return;
|
||||
}
|
||||
//console.log(results)
|
||||
for (let index = 0; index < results.length; index++) {
|
||||
let po = results[index].fecha;
|
||||
let dia = po.getDate();
|
||||
let mes = po.getMonth();
|
||||
let anio = po.getFullYear();
|
||||
let hora = po.getHours();
|
||||
let min = po.getMinutes();
|
||||
if (hora < 10) {
|
||||
let aux = `0${hora}`;
|
||||
hora = aux;
|
||||
|
||||
}
|
||||
if (min < 10) {
|
||||
let aux = `0${min}`;
|
||||
min = aux;
|
||||
|
||||
}
|
||||
if (dia < 10) {
|
||||
let aux = `0${dia}`;
|
||||
dia = aux;
|
||||
|
||||
}
|
||||
if (mes < 10) {
|
||||
let aux = `0${mes}`;
|
||||
mes = aux;
|
||||
|
||||
}
|
||||
let uno = `${dia}/${mes}/${anio}`;
|
||||
let dos = `${hora}:${min}`;
|
||||
table1.rows.push([results[index].nombre, uno, dos])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// doc.addPage()
|
||||
// .fontSize(25)
|
||||
// .text('Here is some vector graphics...', 100, 100);
|
||||
|
||||
|
||||
|
||||
// // Draw a triangle
|
||||
// doc.save()
|
||||
// .moveTo(100, 110)
|
||||
// .lineTo(100, 110)
|
||||
// .lineTo(100, 150)
|
||||
// .fill("#FF3300");
|
||||
|
||||
// // Apply some transforms and render an SVG path with the 'even-odd' fill rule
|
||||
// doc.scale(0.6)
|
||||
// .translate(470, -380)
|
||||
// .path('M 250,75 L 323,301 131,161 369,161 177,301 z')
|
||||
// .fill('red', 'even-odd')
|
||||
// .restore();
|
||||
|
||||
// // Add some text with annotations
|
||||
// // doc.addPage()
|
||||
// // .fillColor("blue")
|
||||
// // .text('Here is a link!', 100, 100)
|
||||
// // .underline(100, 100, 160, 27, { color: "#0000FF" })
|
||||
// // .link(100, 100, 160, 27, 'http://google.com/');
|
||||
|
||||
// // Finalize PDF file
|
||||
// doc.end();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// const PDFDocument = require('pdfkit');
|
||||
// var fs = require('fs');
|
||||
// // Create a document
|
||||
// const doc = new PDFDocument;
|
||||
|
||||
// // Pipe its output somewhere, like to a file or HTTP response
|
||||
// // See below for browser usage
|
||||
// doc.pipe(fs.createWriteStream('output.pdf'));
|
||||
|
||||
// // Embed a font, set the font size, and render some text
|
||||
// doc.font('fonts/PalatinoBold.ttf')
|
||||
// .fontSize(25)
|
||||
// .text('Some text with an embedded font!', 100, 100);
|
||||
|
||||
// // Add an image, constrain it to a given size, and center it vertically and horizontally
|
||||
// doc.image('path/to/image.png', {
|
||||
// fit: [250, 300],
|
||||
// align: 'center',
|
||||
// valign: 'center'
|
||||
// });
|
||||
|
||||
// // Add another page
|
||||
// doc.addPage()
|
||||
// .fontSize(25)
|
||||
// .text('Here is some vector graphics...', 100, 100);
|
||||
|
||||
// // Draw a triangle
|
||||
// doc.save()
|
||||
// .moveTo(100, 150)
|
||||
// .lineTo(100, 250)
|
||||
// .lineTo(200, 250)
|
||||
// .fill("#FF3300");
|
||||
|
||||
// // Apply some transforms and render an SVG path with the 'even-odd' fill rule
|
||||
// doc.scale(0.6)
|
||||
// .translate(470, -380)
|
||||
// .path('M 250,75 L 323,301 131,161 369,161 177,301 z')
|
||||
// .fill('red', 'even-odd')
|
||||
// .restore();
|
||||
|
||||
// // Add some text with annotations
|
||||
// doc.addPage()
|
||||
// .fillColor("blue")
|
||||
// .text('Here is a link!', 100, 100)
|
||||
// .underline(100, 100, 160, 27, { color: "#0000FF" })
|
||||
// .link(100, 100, 160, 27, 'http://google.com/');
|
||||
|
||||
// // Finalize PDF file
|
||||
// doc.end
|
||||
}
|
||||
doc.moveDown().table(table1, 70, 270, { width: 470 });
|
||||
doc.end();
|
||||
});
|
||||
return;
|
||||
}
|
||||
module.exports = g_pdf;
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
'use strict ';
|
||||
|
||||
const PDFDocument = require('pdfkit');
|
||||
|
||||
|
||||
@@ -5,28 +5,30 @@ var app = express()
|
||||
|
||||
app.post('/registro', async(req, res) => {
|
||||
let body = req.body;
|
||||
|
||||
console.log(req.body);
|
||||
await body.alta.forEach(element => {
|
||||
connection.query(`Select capacidad from conferencia where idConferencia=${element};`,
|
||||
(error, results, fields) => {
|
||||
if (error) {
|
||||
res.status(400).json({ msj: `Error al actualizar la asistencia` });
|
||||
throw error;
|
||||
return;
|
||||
}
|
||||
if (results[0].capacidad < 1) {
|
||||
res.status(400).json({ msj: `Capacidad llena de la conferencia ${element}` });
|
||||
throw error;
|
||||
return;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
await body.alta.forEach(element => {
|
||||
connection.query(`INSERT INTO asistencia VALUES(null,${element},${body.idPersona},false)`,
|
||||
console.log('alta');
|
||||
connection.query(`INSERT INTO asistencia VALUES(null,${element},${body.idPersona},false);`,
|
||||
(error, results, fields) => {
|
||||
if (error) {
|
||||
res.status(400).json({ msj: `Error al actualizar la asistencia` });
|
||||
throw error;
|
||||
return;
|
||||
}
|
||||
|
||||
});
|
||||
@@ -35,22 +37,30 @@ app.post('/registro', async(req, res) => {
|
||||
function(error, results, fields) {
|
||||
if (error) {
|
||||
res.status(400).json({ err: true, msj: 'Error en la actualizacion de asistencia' });
|
||||
throw error;
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
await body.baja.forEach(element => {
|
||||
connection.query(`update conferencia set capacidad=capacidad+1 where idConferencia=${element};`,
|
||||
function(error, results, fields) {
|
||||
if (error) {
|
||||
res.status(400).json({ err: true, msj: 'Error en la actualizacion de asistencia' });
|
||||
return;
|
||||
}
|
||||
});
|
||||
connection.query(`delete from asistencia where idConferencia=${element} and idPersona=${body.idPersona};`,
|
||||
(error, results, fields) => {
|
||||
if (error) {
|
||||
res.status(400).json({ msj: `Error al actualizar eliminar la asistencia` });
|
||||
throw error;
|
||||
return;
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
await res.status(200).json({ err: false, msj: 'exito' });
|
||||
return;
|
||||
});
|
||||
|
||||
module.exports = app
|
||||
@@ -4,18 +4,18 @@ const bcrypt = require('bcryptjs');
|
||||
var app = express()
|
||||
|
||||
app.post('/registroPersona', async(req, res) => {
|
||||
//console.log(req.body.correo);
|
||||
console.log(req.body);
|
||||
|
||||
var pass = await bcrypt.hash(req.body.password, 10);
|
||||
//console.log(pass);
|
||||
|
||||
connection.query(`SELECT * from persona where correo='${req.body.correo}'; `, async function(error, results, fields) {
|
||||
if (error) {
|
||||
res.status(200).json({ err: true, mjs: 'error en la comprobacion del correo' });
|
||||
connection.end();
|
||||
throw error;
|
||||
|
||||
return;
|
||||
}
|
||||
// console.log(results.length);
|
||||
// console.log(results.length);
|
||||
|
||||
if (results.length == 0) {
|
||||
|
||||
@@ -27,7 +27,7 @@ app.post('/registroPersona', async(req, res) => {
|
||||
if (e) {
|
||||
res.status(200).json({ err: true, mjs: 'error al registrar en la base' });
|
||||
connection.end();
|
||||
throw error;
|
||||
return;
|
||||
|
||||
}
|
||||
let id = 2;
|
||||
@@ -40,11 +40,11 @@ app.post('/registroPersona', async(req, res) => {
|
||||
mjs: 'error al registrar en select '
|
||||
});
|
||||
connection.end();
|
||||
throw error;
|
||||
return;
|
||||
}
|
||||
// console.log(r);
|
||||
//id = r[0];
|
||||
res.status(200).json({ err: false, idPerosna: r[0].idPersona, msj: 'Registro completo' });
|
||||
res.status(200).json({ err: false, idPersona: r[0].idPersona, msj: 'Registro completo' });
|
||||
|
||||
return;
|
||||
});
|
||||
|
||||
@@ -1,29 +1,25 @@
|
||||
const connection = require('../conf/connection.js');
|
||||
const express = require('express');
|
||||
const express = require('express')
|
||||
var app = express();
|
||||
|
||||
|
||||
app.get('/verificarConferencia', (req, res) => {
|
||||
|
||||
console.log(req.body.idConferencia);
|
||||
connection.query(`Select capacidad from conferencia where idConferencia=${req.body.idConferencia};`,
|
||||
function(error, results, fields) {
|
||||
if (error) {
|
||||
res.status(200).json({ err: 'error' });
|
||||
throw error;
|
||||
}
|
||||
if (results[0].capacidad > 0) {
|
||||
res.status(200).json({ res: true });
|
||||
return;
|
||||
} else {
|
||||
res.status(200).json({ res: false });
|
||||
app.get('/verificarConferencia', async(req, res) => {
|
||||
if (!req.query.idConferencia || req.query.idConferencia == "") {
|
||||
res.status(400).json({ err: true, msj: "Faltan datos" })
|
||||
return;
|
||||
}
|
||||
connection.query(`select capacidad from conferencia where idConferencia=${req.query.idConferencia};`,
|
||||
(err, results, file) => {
|
||||
if (err) {
|
||||
res.status(400).json({ err: true, msj: "error en el select" })
|
||||
return;
|
||||
}
|
||||
// console.log(results);
|
||||
if (results[0].capacidad > 0)
|
||||
res.status(200).json({ err: false, cap: true });
|
||||
else
|
||||
res.status(200).json({ err: false, cap: false });
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
pp = (req, res) => {
|
||||
|
||||
}
|
||||
module.exports = app;
|
||||