From 2bb8df7caa5c112ca2a4b011ae519778f989b8e7 Mon Sep 17 00:00:00 2001 From: DanielRamirezGe Date: Wed, 9 Oct 2019 15:15:04 -0500 Subject: [PATCH] Se agrego la funcion de pase de lista --- routes/get_excel.js | 11 +++++++++ routes/index.js | 2 ++ routes/paseLista.js | 50 +++++++++++++++++++++++++++++++++++++++ routes/registroPersona.js | 6 ++--- 4 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 routes/get_excel.js create mode 100644 routes/paseLista.js diff --git a/routes/get_excel.js b/routes/get_excel.js new file mode 100644 index 0000000..014b069 --- /dev/null +++ b/routes/get_excel.js @@ -0,0 +1,11 @@ +var wb = XLSX.utils.book_new(); +wb.Props = { + Title: "SheetJS Tutorial", + Subject: "Test", + Author: "Red Stapler", + CreatedDate: new Date(2017, 12, 19) +}; + + +/ * Agregar la hoja de trabajo al libro de trabajo * / +XLSX.utils.book_append_sheet(wb, ws, ws_name); \ No newline at end of file diff --git a/routes/index.js b/routes/index.js index 7d29fe2..367fb42 100644 --- a/routes/index.js +++ b/routes/index.js @@ -11,5 +11,7 @@ app.use(require('./get_qr')); app.use(require('./verificarConferencia')); app.use(require('./cupo')); app.use(require('./loginAdmin')); +app.use(require('./paseLista')); + module.exports = app; \ No newline at end of file diff --git a/routes/paseLista.js b/routes/paseLista.js new file mode 100644 index 0000000..06d2249 --- /dev/null +++ b/routes/paseLista.js @@ -0,0 +1,50 @@ +const connection = require('../conf/connection.js'); +const express = require('express') +var app = express(); +app.get('/paseLista', async(req, res) => { + var datetime = await new Date(); + var mayor = new Date(); + var menor = new Date(); + await mayor.setMinutes(datetime.getMinutes() + 30); + await menor.setMinutes(datetime.getMinutes() - 30); + console.log(mayor); + menor = menor.getFullYear() + '-' + + ('00' + (menor.getMonth() + 1)).slice(-2) + '-' + + ('00' + menor.getDate()).slice(-2) + ' ' + + ('00' + menor.getHours()).slice(-2) + ':' + + ('00' + menor.getMinutes()).slice(-2) + ':' + + ('00' + menor.getSeconds()).slice(-2); + mayor = mayor.getFullYear() + '-' + + ('00' + (mayor.getMonth() + 1)).slice(-2) + '-' + + ('00' + mayor.getDate()).slice(-2) + ' ' + + ('00' + mayor.getHours()).slice(-2) + ':' + + ('00' + mayor.getMinutes()).slice(-2) + ':' + + ('00' + mayor.getSeconds()).slice(-2); + console.log(menor); + console.log(mayor); + await connection.query(`select idConferencia from conferencia where fecha>='${menor}' and fecha<='${mayor}';`, + (error, results, fiel) => { + if (error) { + res.status(400).json({ error: true, msj: 'Error en la consulta de la fecha ' }); + return; + } + console.log(results.length); + if (results.length == 0) { + res.status(200).json({ msj: "No hay ninguna conferencia aun" }); + return; + } + let id = results[0].idConferencia; + connection.query(`update asistencia set asistencia=true where idConferencia=${id} and idPersona=${req.query.idPersona};`, + (error, results, fiel) => { + if (error) { + res.status(400).json({ error: true, msj: 'Error al actualizar la asistencia ' }); + return; + } + res.status(200).json({ error: false, msj: 'Bienvenido' }); + return; + }); + + + }); +}) +module.exports = app; \ No newline at end of file diff --git a/routes/registroPersona.js b/routes/registroPersona.js index 2dddbba..8a2a7ba 100644 --- a/routes/registroPersona.js +++ b/routes/registroPersona.js @@ -9,7 +9,7 @@ app.post('/registroPersona', async(req, res) => { //console.log(req.body); var pass = await bcrypt.hash(req.body.password, 10); - //console.log(pass); + console.log(pass); let mail = await validator.isEmail(req.body.correo); if (!mail) { @@ -41,9 +41,9 @@ app.post('/registroPersona', async(req, res) => { res.status(400).json({ err: true, mjs: 'Datos incorrectos en Carrera' }); return; } - console.log(req.body.correo); + //console.log(req.body.correo); connection.query(`SELECT * from persona where correo='${req.body.correo}'; `, async function(error, results, fields) { - console.log(results); + // console.log(results); if (error) { res.status(400).json({ err: true, mjs: 'error en la comprobacion del correo' });