terminar back
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 466 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 41 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 278 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
@@ -265,7 +265,7 @@ app.get('/getConferencias', (req, res) => {
|
||||
conferencias.dia5.conf3.asistir = true;
|
||||
|
||||
});
|
||||
console.log(req.body.idPersona);
|
||||
// console.log(req.body.idPersona);
|
||||
res.status(200).json(conferencias);
|
||||
});
|
||||
|
||||
|
||||
+18
-17
@@ -1,46 +1,47 @@
|
||||
const connection = require('../conf/connection.js');
|
||||
const express = require('express')
|
||||
|
||||
const bcrypt = require('bcryptjs');
|
||||
var app = express();
|
||||
|
||||
app.post('/loggin', (req, res) => {
|
||||
app.post('/loggin', async(req, res) => {
|
||||
|
||||
connection.query(`SELECT idPersona from persona where correo = '${req.body.correo}' `,
|
||||
function(error, results, fields) {
|
||||
if (error) {
|
||||
res.status(200).json({ err: true, mjs: 'error en la verificacion del correo' });
|
||||
res.status(400).json({ err: true, mjs: 'error en la verificacion del correo' });
|
||||
throw error;
|
||||
|
||||
}
|
||||
if (results.length == 0) {
|
||||
res.status(200).json({ err: true, mjs: 'Correo no registrado' });
|
||||
res.status(400).json({ err: true, mjs: 'Correo no registrado' });
|
||||
throw error;
|
||||
|
||||
} else {
|
||||
connection.query(`SELECT * from persona where correo = '${req.body.correo}' and pasword= '${req.body.password}'`,
|
||||
function(e, r, f) {
|
||||
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;
|
||||
|
||||
}
|
||||
//console.log(r, `'${req.body.correo}' and pasword= '${req.body.password}'`);
|
||||
if (r.length == 0) {
|
||||
res.status(200).json({ err: true, mjs: 'Datos Incorrectos' });
|
||||
throw error;
|
||||
|
||||
} else {
|
||||
// console.log(r[0].idPersona);
|
||||
let po = r[0].password;
|
||||
//console.log(r[0]);
|
||||
//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 });
|
||||
return;
|
||||
} else {
|
||||
res.status(400).json({ err: true, mjs: 'Datos Incorrectos' });
|
||||
throw error;
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
module.exports = app;
|
||||
|
||||
|
||||
@@ -49,4 +50,4 @@ module.exports = app;
|
||||
// "correo": "daniel.adrian.ramirez.george@gmail.com",
|
||||
// "password": "georgechido"
|
||||
|
||||
// }
|
||||
//
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
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
|
||||
|
||||
// Add an image, constrain it to a given size, and center it vertically and horizontally
|
||||
|
||||
|
||||
|
||||
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.table(table0, {
|
||||
prepareHeader: () => doc.font('Helvetica-Bold'),
|
||||
prepareRow: (row, i) => doc.font('Helvetica').fontSize(12)
|
||||
});
|
||||
|
||||
const table1 = {
|
||||
headers: ['Country', 'Conversion rate', 'Trend'],
|
||||
rows: [
|
||||
['Switzerland', '12%', '+1.12%'],
|
||||
['France', '67%', '-0.98%'],
|
||||
['England', '33%', '+4.44%']
|
||||
]
|
||||
};
|
||||
|
||||
doc.moveDown().table(table1, 100, 350, { width: 300 });
|
||||
|
||||
doc.end();
|
||||
// let inicio = 120;
|
||||
// doc.image('Imagenes/logo_unam.png', inicio, 30, { scale: 0.04 });
|
||||
|
||||
// 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);
|
||||
|
||||
// doc.image('Imagenes/Fesa.jpg', inicio + 305, 30, { scale: 0.05 });
|
||||
// // Add another page
|
||||
|
||||
// doc.font('Times-Roman')
|
||||
// .fontSize(8)
|
||||
// .text('COMPROBANTE DE INSCRIPCIÓN', inicio + 120, 80);
|
||||
|
||||
// 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.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
|
||||
@@ -0,0 +1,121 @@
|
||||
'use strict';
|
||||
|
||||
const PDFDocument = require('pdfkit');
|
||||
|
||||
class PDFDocumentWithTables extends PDFDocument {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
}
|
||||
|
||||
table(table, arg0, arg1, arg2) {
|
||||
let startX = this.page.margins.left,
|
||||
startY = this.y;
|
||||
let options = {};
|
||||
|
||||
if ((typeof arg0 === 'number') && (typeof arg1 === 'number')) {
|
||||
startX = arg0;
|
||||
startY = arg1;
|
||||
|
||||
if (typeof arg2 === 'object')
|
||||
options = arg2;
|
||||
} else if (typeof arg0 === 'object') {
|
||||
options = arg0;
|
||||
}
|
||||
|
||||
const columnCount = table.headers.length;
|
||||
const columnSpacing = options.columnSpacing || 15;
|
||||
const rowSpacing = options.rowSpacing || 5;
|
||||
const usableWidth = options.width || (this.page.width - this.page.margins.left - this.page.margins.right);
|
||||
|
||||
const prepareHeader = options.prepareHeader || (() => {});
|
||||
const prepareRow = options.prepareRow || (() => {});
|
||||
const computeRowHeight = (row) => {
|
||||
let result = 0;
|
||||
|
||||
row.forEach((cell) => {
|
||||
const cellHeight = this.heightOfString(cell, {
|
||||
width: columnWidth,
|
||||
align: 'left'
|
||||
});
|
||||
result = Math.max(result, cellHeight);
|
||||
});
|
||||
|
||||
return result + rowSpacing;
|
||||
};
|
||||
|
||||
const columnContainerWidth = usableWidth / columnCount;
|
||||
const columnWidth = columnContainerWidth - columnSpacing;
|
||||
const maxY = this.page.height - this.page.margins.bottom;
|
||||
|
||||
let rowBottomY = 0;
|
||||
|
||||
this.on('pageAdded', () => {
|
||||
startY = this.page.margins.top;
|
||||
rowBottomY = 0;
|
||||
});
|
||||
|
||||
// Allow the user to override style for headers
|
||||
prepareHeader();
|
||||
|
||||
// Check to have enough room for header and first rows
|
||||
if (startY + 3 * computeRowHeight(table.headers) > maxY)
|
||||
this.addPage();
|
||||
|
||||
// Print all headers
|
||||
table.headers.forEach((header, i) => {
|
||||
this.text(header, startX + i * columnContainerWidth, startY, {
|
||||
width: columnWidth,
|
||||
align: 'left'
|
||||
});
|
||||
});
|
||||
|
||||
// Refresh the y coordinate of the bottom of the headers row
|
||||
rowBottomY = Math.max(startY + computeRowHeight(table.headers), rowBottomY);
|
||||
|
||||
// Separation line between headers and rows
|
||||
this.moveTo(startX, rowBottomY - rowSpacing * 0.5)
|
||||
.lineTo(startX + usableWidth, rowBottomY - rowSpacing * 0.5)
|
||||
.lineWidth(2)
|
||||
.stroke();
|
||||
|
||||
table.rows.forEach((row, i) => {
|
||||
const rowHeight = computeRowHeight(row);
|
||||
|
||||
// Switch to next page if we cannot go any further because the space is over.
|
||||
// For safety, consider 3 rows margin instead of just one
|
||||
if (startY + 3 * rowHeight < maxY)
|
||||
startY = rowBottomY + rowSpacing;
|
||||
else
|
||||
this.addPage();
|
||||
|
||||
// Allow the user to override style for rows
|
||||
prepareRow(row, i);
|
||||
|
||||
// Print all cells of the current row
|
||||
row.forEach((cell, i) => {
|
||||
this.text(cell, startX + i * columnContainerWidth, startY, {
|
||||
width: columnWidth,
|
||||
align: 'left'
|
||||
});
|
||||
});
|
||||
|
||||
// Refresh the y coordinate of the bottom of this row
|
||||
rowBottomY = Math.max(startY + rowHeight, rowBottomY);
|
||||
|
||||
// Separation line between rows
|
||||
this.moveTo(startX, rowBottomY - rowSpacing * 0.5)
|
||||
.lineTo(startX + usableWidth, rowBottomY - rowSpacing * 0.5)
|
||||
.lineWidth(1)
|
||||
.opacity(0.7)
|
||||
.stroke()
|
||||
.opacity(1); // Reset opacity after drawing the line
|
||||
});
|
||||
|
||||
this.x = startX;
|
||||
this.moveDown();
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = PDFDocumentWithTables;
|
||||
@@ -5,6 +5,7 @@ var app = express()
|
||||
|
||||
app.post('/registro', async(req, res) => {
|
||||
let body = req.body;
|
||||
|
||||
await body.alta.forEach(element => {
|
||||
connection.query(`Select capacidad from conferencia where idConferencia=${element};`,
|
||||
(error, results, fields) => {
|
||||
|
||||
@@ -6,9 +6,9 @@ var app = express()
|
||||
app.post('/registroPersona', async(req, res) => {
|
||||
//console.log(req.body.correo);
|
||||
|
||||
var pass = await bcrypt.hash(req.body.pasword, 10);
|
||||
var pass = await bcrypt.hash(req.body.password, 10);
|
||||
//console.log(pass);
|
||||
connection.query(`SELECT * from persona where correo='${req.body.correo}'; `, function(error, results, fields) {
|
||||
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();
|
||||
@@ -19,7 +19,7 @@ app.post('/registroPersona', async(req, res) => {
|
||||
|
||||
if (results.length == 0) {
|
||||
|
||||
connection.query(`insert into persona values (${req.body.est}, '${req.body.noCuenta}', ${req.body.promedio},
|
||||
await connection.query(`insert into persona values (${req.body.est}, '${req.body.noCuenta}', ${req.body.promedio},
|
||||
'${req.body.nombre}', '${req.body.apellidos}', '${req.body.sexo}', ${req.body.edad}, '${req.body.correo}',
|
||||
'${req.body.nivelIngles}', '${req.body.comunidad}' , '${pass}', '${req.body.facultdad}' , '${req.body.gradoAcademico}',
|
||||
'${req.body.nombrePrograma}' , ${req.body.semestre}, ${req.body.titulado} );`,
|
||||
@@ -30,9 +30,25 @@ app.post('/registroPersona', async(req, res) => {
|
||||
throw error;
|
||||
|
||||
}
|
||||
res.status(200).json({ err: false, msj: 'Registro completo' });
|
||||
let id = 2;
|
||||
connection.query(`select idPersona from persona where correo='${req.body.correo}';`,
|
||||
|
||||
function(e, r, f) {
|
||||
if (e) {
|
||||
res.status(200).json({
|
||||
err: true,
|
||||
mjs: 'error al registrar en select '
|
||||
});
|
||||
connection.end();
|
||||
throw error;
|
||||
}
|
||||
// console.log(r);
|
||||
//id = r[0];
|
||||
res.status(200).json({ err: false, idPerosna: r[0].idPersona, msj: 'Registro completo' });
|
||||
|
||||
return;
|
||||
});
|
||||
|
||||
return;
|
||||
});
|
||||
|
||||
} else {
|
||||
@@ -56,7 +72,7 @@ module.exports = app;
|
||||
// "correo" : "slllls@ga.cdsdsdsom",
|
||||
// "nivelIngles" : "Avanzado",
|
||||
// "comunidad" : "UNAM",
|
||||
// "pasword" : "sasa8s88sa8",
|
||||
// "password" : "sasa8s88sa8",
|
||||
// "facultdad" : "La mas chida",
|
||||
// "gradoAcademico" : "Licenciatura",
|
||||
// "nombrePrograma" : "carpintero",
|
||||
|
||||
Reference in New Issue
Block a user