Modificacion para agegar la descarga de participantes de eventos
This commit is contained in:
@@ -56,6 +56,7 @@ export class EmailController {
|
||||
@Param('id') idEvento: number,
|
||||
@Res() res: Response,
|
||||
) {
|
||||
console.log('entro en el controller')
|
||||
return this.emailService.getParticipantesExcel(idEvento, res);
|
||||
}
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ export class EmailService {
|
||||
}
|
||||
|
||||
async getParticipantesExcel(idEvento: number, res: Response) {
|
||||
console.log('entro a la funcion')
|
||||
const participantes = await this.participanteRepository
|
||||
.createQueryBuilder('participante')
|
||||
.innerJoin('participante.eventosParticipante', 'eventoParticipante')
|
||||
@@ -93,6 +94,8 @@ export class EmailService {
|
||||
{ header: 'Apellido Materno', key: 'apellido_materno', width: 20 },
|
||||
];
|
||||
|
||||
console.log(participantes);
|
||||
|
||||
// 3. Insertar datos
|
||||
participantes.forEach((p) => {
|
||||
worksheet.addRow({
|
||||
@@ -117,6 +120,7 @@ export class EmailService {
|
||||
'attachment; filename=participantes.xlsx',
|
||||
);
|
||||
|
||||
|
||||
await workbook.xlsx.write(res);
|
||||
res.end();
|
||||
}
|
||||
@@ -136,8 +140,8 @@ export class EmailService {
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const row = data[i] as Row;
|
||||
|
||||
if (row.Email == undefined) {
|
||||
return res.status(400).json({ message: `El correo del renglon ${i + 2} puede estar vacio o ser undefined`, solucion: `Seleccione el renglon donde ocurre el problema y borre todo lo de este renglon, Aunque parezca que el renglon esta vacio puede que haya un espacio en algun campo y esto genera que el sistema haga la lectura de este renglon` });
|
||||
if(row.Email == undefined){
|
||||
return res.status(400).json({ message: `El correo del renglon ${ i + 2} puede estar vacio o ser undefined`, solucion: `Seleccione el renglon donde ocurre el problema y borre todo lo de este renglon, Aunque parezca que el renglon esta vacio puede que haya un espacio en algun campo y esto genera que el sistema haga la lectura de este renglon`});
|
||||
}
|
||||
|
||||
// Carga el PDF pre-diseñado en un documento PDF editable
|
||||
@@ -194,7 +198,7 @@ export class EmailService {
|
||||
const fechaCursoWidth = font.widthOfTextAtSize(fechaCurso, 20);
|
||||
|
||||
const centerXFechaCurso = (width - fechaCursoWidth) / 2;
|
||||
const centerYFechaCurso = (height - 20) sheet_to_json/ 2;
|
||||
const centerYFechaCurso = (height - 20) / 2;
|
||||
|
||||
primeraPagina.drawText(fechaCurso, {
|
||||
x: centerXFechaCurso,
|
||||
@@ -227,6 +231,7 @@ export class EmailService {
|
||||
return res.status(200).json({ message: 'Constancias enviadas con éxito' });
|
||||
}
|
||||
|
||||
|
||||
formatoFecha(fecha: Date) {
|
||||
const fechaLimpia = format(fecha, 'dd/MM/yyyy');
|
||||
return fechaLimpia;
|
||||
|
||||
@@ -32,7 +32,7 @@ export class EventosController {
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@Post()
|
||||
postEvento(@Body() nuevoEvento: crearEventoDto){
|
||||
return this.eventoService.postEvento(nuevoEvento)
|
||||
return this.eventoService.postEvento(nuevoEvento)
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@@ -44,7 +44,7 @@ export class EventosController {
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@Delete(':id')
|
||||
deleteEvento(@Param('id', ParseIntPipe)id: number){
|
||||
return this.eventoService.deleteEventoParticipante(id)
|
||||
return this.eventoService.deleteEventoParticipante(id)
|
||||
}
|
||||
|
||||
@Get(':id/cupos')
|
||||
|
||||
Reference in New Issue
Block a user