a
This commit is contained in:
parent
881cce54fc
commit
b8a0bbcf3b
@ -147,6 +147,103 @@ console.log(params, req.user.level);
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
validateInscription: async (req, res, next) => {
|
||||||
|
const params = extractParamsFromRequest(req, res, {});
|
||||||
|
const user = req.user;
|
||||||
|
|
||||||
|
console.log('validar inscription:', params);
|
||||||
|
console.log('usuario:', user);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const inscription = await eventInscriptionService._getInscriptionById(inscriptionId);
|
||||||
|
console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>><Inscripcion a borrar:');
|
||||||
|
console.log(inscription);
|
||||||
|
/* if (!inscription || (inscription.userId !== user.id))
|
||||||
|
return handleResultResponse("Inscription no encontrada", null, params, res, httpStatus.NOT_FOUND);
|
||||||
|
|
||||||
|
//Borramos inscripcion y descontamos asistentes
|
||||||
|
if (await eventInscriptionService._deleteInscription(inscription.id) > 0) {
|
||||||
|
console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>><Inscripcion borrada');
|
||||||
|
const EventOrReservationChangeId = ((inscription.reservationId) ? inscription.reservationId : ((inscription.overflowEventId) ? inscription.overflowEventId : inscription.eventId));
|
||||||
|
let NewConfirmed = 0;
|
||||||
|
let marketingListId = null;
|
||||||
|
|
||||||
|
if (inscription.reservationId != null) {
|
||||||
|
console.log('Tengo reservation>>>>>>>>>>>>>>>>>>', inscription.reservationId);
|
||||||
|
NewConfirmed = await eventInscriptionService._getCountInscriptionsWithReservation(EventOrReservationChangeId)
|
||||||
|
marketingListId = (await eventReservationService._getReservaById(EventOrReservationChangeId)).marketing_list;
|
||||||
|
}
|
||||||
|
else if (inscription.overflowEventId != null) {
|
||||||
|
console.log('Tengo overflow>>>>>>>>>>>>>>>>>>', inscription.overflowEventId);
|
||||||
|
NewConfirmed = await eventInscriptionService._getCountInscriptionsWithOverflowEventId(EventOrReservationChangeId);
|
||||||
|
marketingListId = (await eventService._getEvent(EventOrReservationChangeId)).marketing_list;
|
||||||
|
}
|
||||||
|
else if (inscription.eventId != null) {
|
||||||
|
NewConfirmed = await eventInscriptionService._getCountInscriptionsWithoutReservationAndOverflow(EventOrReservationChangeId);
|
||||||
|
marketingListId = (await eventService._getEvent(EventOrReservationChangeId)).marketing_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Actualizamos aforo del evento o de la reserva
|
||||||
|
if (inscription.reservationId != null) {
|
||||||
|
console.log('>>>>>>>>>>>>>>Voy a actualizar aforo reserva', EventOrReservationChangeId);
|
||||||
|
console.log('>>>>>>>>>>>>>> ', NewConfirmed);
|
||||||
|
if (!await eventReservationService._updateConfirmedReservation(EventOrReservationChangeId, NewConfirmed))
|
||||||
|
return handleResultResponse("Error al eliminar inscripción, no puedo cambiar confirmados a la reserva asociada", null, params, res, httpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log('>>>>>>>>>>>>>>Voy a actualizar aforo evento', EventOrReservationChangeId);
|
||||||
|
console.log('>>>>>>>>>>>>>> ', NewConfirmed);
|
||||||
|
if (!await eventService._updateConfirmedEvent(EventOrReservationChangeId, NewConfirmed))
|
||||||
|
return handleResultResponse("Error al eliminar inscripción, no puedo cambiar confirmados a la inscripcion", null, params, res, httpStatus.NOT_FOUND);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Eliminamos miembro de la lista de mailchimp a la que está asociado
|
||||||
|
await eventInscriptionService._deleteMember(marketingListId, inscription.marketing_memberId);
|
||||||
|
|
||||||
|
/*Mandar correo de confirmacion de desinscripcion
|
||||||
|
var headerMail = {
|
||||||
|
to: user.email,
|
||||||
|
name: user.name + ' ' + user.surname,
|
||||||
|
subject: ((member.validated) ? 'Entrada' : 'Lista de espera') + ' para el congreso ' + dataInscription.event.name + ' confirmada'
|
||||||
|
}
|
||||||
|
|
||||||
|
var bodyMail = {
|
||||||
|
tipoEntrada: (member.validated) ? 'Entrada' : 'Lista de espera',
|
||||||
|
descriptionEntrada: member.description,
|
||||||
|
qrCode: qrCode,
|
||||||
|
color: qrConfig.color,
|
||||||
|
codeTicket: member.code_ticket,
|
||||||
|
eventName: dataInscription.event.name,
|
||||||
|
dateInscription: moment(dataInscription.event.init_date).format('D [de] MMMM [de] YYYY'),
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Mandamos mail con entrada>>>>>>>>>>>>>>>>>>>>>>>>>>>');
|
||||||
|
console.log(headerMail, bodyMail);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (member.validated)
|
||||||
|
emailHelper.sendTicket(headerMail, bodyMail)
|
||||||
|
else
|
||||||
|
emailHelper.sendListaEspera(headerMail, bodyMail);
|
||||||
|
} catch (error) {
|
||||||
|
console.log('No se ha podido mandar email con entrada');
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return handleResultResponse("Inscripción validada", null, params, res, httpStatus.OK);
|
||||||
|
//}
|
||||||
|
// else
|
||||||
|
// return handleResultResponse("No se pudo eliminar inscripción", null, params, res, httpStatus.NOT_FOUND);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
return handleResultResponse("Error al validar inscripción", null, params, res, httpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
deleteInscription: async (req, res, next) => {
|
deleteInscription: async (req, res, next) => {
|
||||||
const params = extractParamsFromRequest(req, res, {});
|
const params = extractParamsFromRequest(req, res, {});
|
||||||
const user = req.user;
|
const user = req.user;
|
||||||
@ -199,6 +296,38 @@ console.log('>>>>>>>>>>>>>> ', NewConfirmed);
|
|||||||
//Eliminamos miembro de la lista de mailchimp a la que está asociado
|
//Eliminamos miembro de la lista de mailchimp a la que está asociado
|
||||||
await eventInscriptionService._deleteMember(marketingListId, inscription.marketing_memberId);
|
await eventInscriptionService._deleteMember(marketingListId, inscription.marketing_memberId);
|
||||||
|
|
||||||
|
/*Mandar correo de confirmacion de desinscripcion
|
||||||
|
var headerMail = {
|
||||||
|
to: user.email,
|
||||||
|
name: user.name + ' ' + user.surname,
|
||||||
|
subject: ((member.validated) ? 'Entrada' : 'Lista de espera') + ' para el congreso ' + dataInscription.event.name + ' confirmada'
|
||||||
|
}
|
||||||
|
|
||||||
|
var bodyMail = {
|
||||||
|
tipoEntrada: (member.validated) ? 'Entrada' : 'Lista de espera',
|
||||||
|
descriptionEntrada: member.description,
|
||||||
|
qrCode: qrCode,
|
||||||
|
color: qrConfig.color,
|
||||||
|
codeTicket: member.code_ticket,
|
||||||
|
eventName: dataInscription.event.name,
|
||||||
|
dateInscription: moment(dataInscription.event.init_date).format('D [de] MMMM [de] YYYY'),
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Mandamos mail con entrada>>>>>>>>>>>>>>>>>>>>>>>>>>>');
|
||||||
|
console.log(headerMail, bodyMail);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (member.validated)
|
||||||
|
emailHelper.sendTicket(headerMail, bodyMail)
|
||||||
|
else
|
||||||
|
emailHelper.sendListaEspera(headerMail, bodyMail);
|
||||||
|
} catch (error) {
|
||||||
|
console.log('No se ha podido mandar email con entrada');
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return handleResultResponse("Inscripción eliminada", null, params, res, httpStatus.DELETEOK);
|
return handleResultResponse("Inscripción eliminada", null, params, res, httpStatus.DELETEOK);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -360,14 +360,6 @@ routes.get('/admin/events/:eventId/partners/:entityId/reservations',
|
|||||||
eventReservationController.find(),
|
eventReservationController.find(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
routes.post('/admin/reservations',
|
|
||||||
isAdministratorUser,
|
|
||||||
//SchemaValidator(eventValidation.ReservationInputType, true),
|
|
||||||
eventReservationController.create(),
|
|
||||||
|
|
||||||
);
|
|
||||||
|
|
||||||
routes.get('/admin/reservations/:id',
|
routes.get('/admin/reservations/:id',
|
||||||
isAdministratorUser,
|
isAdministratorUser,
|
||||||
//SchemaValidator(eventValidation.ReservationInputType, true),
|
//SchemaValidator(eventValidation.ReservationInputType, true),
|
||||||
@ -379,12 +371,26 @@ routes.get('/admin/reservations/:id',
|
|||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
routes.post('/admin/reservations',
|
||||||
|
isAdministratorUser,
|
||||||
|
//SchemaValidator(eventValidation.ReservationInputType, true),
|
||||||
|
eventReservationController.create(),
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
routes.put('/admin/reservations/:id',
|
routes.put('/admin/reservations/:id',
|
||||||
isAdministratorUser,
|
isAdministratorUser,
|
||||||
//SchemaValidator(eventValidation.ReservationInputType, true),
|
//SchemaValidator(eventValidation.ReservationInputType, true),
|
||||||
eventReservationController.update(),
|
eventReservationController.update(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//Valida una inscripción
|
||||||
|
routes.put('/admin/inscriptions/:id',
|
||||||
|
isAdministratorUser,
|
||||||
|
//SchemaValidator(eventValidation.ReservationInputType, true),
|
||||||
|
eventController.validateInscription,
|
||||||
|
);
|
||||||
|
|
||||||
// Borrar reserva
|
// Borrar reserva
|
||||||
routes.delete('/admin/reservations/:id',
|
routes.delete('/admin/reservations/:id',
|
||||||
isAdministratorUser,
|
isAdministratorUser,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user