diff --git a/server/controller/Servicio/liberacion.js b/server/controller/Servicio/liberacion.js index 78b5f44..017d782 100644 --- a/server/controller/Servicio/liberacion.js +++ b/server/controller/Servicio/liberacion.js @@ -7,6 +7,8 @@ const Programa = require('../../db/tablas/Programa'); const liberacion = async (body) => { let idServicio = validar.validarId(body.idServicio); + let correo = {}; + let update = { idStatus: 6 }; return Servicio.findOne({ where: { idServicio }, @@ -14,14 +16,14 @@ const liberacion = async (body) => { }) .then(async (res) => { if (!res) throw new Error('No existe este Servicio Social.'); - if (res.Programa.acatlan && !body.vistoBuenoAcatlan) - throw new Error( - 'El programa de este Servicio Solcial es Acatlán Contigo y no se envio la variable validando este servicio.' - ); + // if (res.Programa.acatlan && !body.vistoBuenoAcatlan) + // throw new Error( + // 'El programa de este Servicio Social es Acatlán Contigo y no se envio la variable validando este servicio.' + // ); switch (res.idStatus) { case 5: - let correo = correos.terminoValidado(res.Usuario.nombre); - + correo = correos.terminoValidado(res.Usuario.nombre); + if (body.vistoBuenoAcatlan) update.vistoBuenoAcatlan = true; return gmail(correo.subject, res.correo, correo.msj); case 1: case 2: @@ -44,12 +46,7 @@ const liberacion = async (body) => { throw new Error('Este Servicio Social esta cancelado.'); } }) - .then((res) => { - let update = { idStatus: 6 }; - - if (body.vistoBuenoAcatlan) update.vistoBuenoAcatlan = true; - return Servicio.update(update, { where: { idServicio } }); - }) + .then((res) => Servicio.update(update, { where: { idServicio } })) .then((res) => { return { message: diff --git a/server/controller/Servicio/rechazarAceptacion.js b/server/controller/Servicio/rechazarAceptacion.js index 7280879..186d1db 100644 --- a/server/controller/Servicio/rechazarAceptacion.js +++ b/server/controller/Servicio/rechazarAceptacion.js @@ -9,6 +9,7 @@ const cancelar = async (body) => { let idServicio = validar.validarId(body.idServicio); let mensaje = validar.validarAlfanumerico(body.mensaje, 'El mensaje', 800); let correoResponsable = {}; + let correoAlumno = {}; let emailResponsable = ''; return Servicio.findOne({ @@ -20,14 +21,12 @@ const cancelar = async (body) => { }) .then((res) => { if (!res) throw new Error('No existe este Servicio Social.'); - switch (res.idStatus) { case 1: - let correoAlumno = correos.preRegistroRechazadoAlumno( + correoAlumno = correos.preRegistroRechazadoAlumno( mensaje, res.Usuario.nombre ); - correoResponsable = correos.preRegistroRechazadoResponsable( mensaje, res.Usuario.nombre @@ -53,19 +52,15 @@ const cancelar = async (body) => { throw new Error('Este Servicio Social fue cancelado.'); } }) - .then((res) => { - return gmail( - correoResponsable.subject, - emailResponsable, - correoResponsable.msj - ); - }) - .then((res) => { - return Servicio.update( + .then((res) => + gmail(correoResponsable.subject, emailResponsable, correoResponsable.msj) + ) + .then((res) => + Servicio.update( { idStatus: 7, cartaAceptacion: '' }, { where: { idServicio } } - ); - }) + ) + ) .then((res) => { return { message: 'Se rechazo correctamente la Carta de Aceptación.' }; }); diff --git a/server/controller/Servicio/rechazarInforme.js b/server/controller/Servicio/rechazarInforme.js index 58054da..5043d35 100644 --- a/server/controller/Servicio/rechazarInforme.js +++ b/server/controller/Servicio/rechazarInforme.js @@ -9,6 +9,7 @@ const cancelar = async (body) => { let idServicio = validar.validarId(body.idServicio); let mensaje = validar.validarAlfanumerico(body.mensaje, 'El mensaje', 800); let correoResponsable = {}; + let correoAlumno = {}; let emailResponsable = ''; return Servicio.findOne({ @@ -22,11 +23,10 @@ const cancelar = async (body) => { if (!res) throw new Error('No existe este Servicio Social.'); switch (res.idStatus) { case 5: - let correoAlumno = correos.terminoRechazadoAlumno( + correoAlumno = correos.terminoRechazadoAlumno( mensaje, res.Usuario.nombre ); - correoResponsable = correos.terminoRechazadoResponsable( mensaje, res.Usuario.nombre @@ -53,19 +53,15 @@ const cancelar = async (body) => { throw new Error('Este Servicio Social fue cancelado.'); } }) - .then((res) => { - return gmail( - correoResponsable.subject, - emailResponsable, - correoResponsable.msj - ); - }) - .then((res) => { - return Servicio.update( - { idStatus: 9, informeGlobal: "" }, + .then((res) => + gmail(correoResponsable.subject, emailResponsable, correoResponsable.msj) + ) + .then((res) => + Servicio.update( + { idStatus: 9, informeGlobal: '' }, { where: { idServicio } } - ); - }) + ) + ) .then((res) => { return { message: 'Se rechazo correctamente el Informe Global.' }; }); diff --git a/server/controller/Servicio/rechazarTermino.js b/server/controller/Servicio/rechazarTermino.js index cc7cf44..95e0ee8 100644 --- a/server/controller/Servicio/rechazarTermino.js +++ b/server/controller/Servicio/rechazarTermino.js @@ -9,6 +9,7 @@ const cancelar = async (body) => { let idServicio = validar.validarId(body.idServicio); let mensaje = validar.validarAlfanumerico(body.mensaje, 'El mensaje', 800); let correoResponsable = {}; + let correoAlumno = {}; let emailResponsable = ''; return Servicio.findOne({ @@ -22,11 +23,10 @@ const cancelar = async (body) => { if (!res) throw new Error('No existe este Servicio Social.'); switch (res.idStatus) { case 5: - let correoAlumno = correos.terminoRechazadoAlumno( + correoAlumno = correos.terminoRechazadoAlumno( mensaje, res.Usuario.nombre ); - correoResponsable = correos.terminoRechazadoResponsable( mensaje, res.Usuario.nombre @@ -53,19 +53,15 @@ const cancelar = async (body) => { throw new Error('Este Servicio Social fue cancelado.'); } }) - .then((res) => { - return gmail( - correoResponsable.subject, - emailResponsable, - correoResponsable.msj - ); - }) - .then((res) => { - return Servicio.update( - { idStatus: 8, cartaTermino: "" }, + .then((res) => + gmail(correoResponsable.subject, emailResponsable, correoResponsable.msj) + ) + .then((res) => + Servicio.update( + { idStatus: 8, cartaTermino: '' }, { where: { idServicio } } - ); - }) + ) + ) .then((res) => { return { message: 'Se rechazo correctamente la Carta de Termino.' }; }); diff --git a/server/controller/Servicio/registro.js b/server/controller/Servicio/registro.js index 367f110..6dd750f 100644 --- a/server/controller/Servicio/registro.js +++ b/server/controller/Servicio/registro.js @@ -48,9 +48,7 @@ const registro = async (body) => { { where: { idUsuario } } ); }) - .then((res) => { - return Servicio.update({ idStatus: 2 }, { where: { idServicio } }); - }) + .then((res) => Servicio.update({ idStatus: 2 }, { where: { idServicio } })) .then((res) => { return { message: diff --git a/server/controller/Servicio/registroValidado.js b/server/controller/Servicio/registroValidado.js index 6fbe05c..73f1d50 100644 --- a/server/controller/Servicio/registroValidado.js +++ b/server/controller/Servicio/registroValidado.js @@ -15,6 +15,7 @@ const registroValidado = async (body) => { 200 ); let correoResponsable = {}; + let correoAlumno = {}; let emailResponsable = ''; return Servicio.findOne({ @@ -26,11 +27,9 @@ const registroValidado = async (body) => { }) .then((res) => { if (!res) throw new Error('No existe este Servicio Social.'); - switch (res.idStatus) { case 2: - let correoAlumno = correos.registroValidadoAlumno(res.Usuario.nombre); - + correoAlumno = correos.registroValidadoAlumno(res.Usuario.nombre); correoResponsable = correos.registroValidadoResponsable( res.Usuario.nombre ); @@ -63,20 +62,16 @@ const registroValidado = async (body) => { ); } }) - .then((res) => { - return gmail( - correoResponsable.subject, - emailResponsable, - correoResponsable.msj - ); - }) - .then((res) => { - return Servicio.update( + .then((res) => + gmail(correoResponsable.subject, emailResponsable, correoResponsable.msj) + ) + .then((res) => + Servicio.update( // { idStatus: 3, direccion, telefono, fechaNacimiento }, { idStatus: 4, direccion, telefono, fechaNacimiento }, { where: { idServicio } } - ); - }) + ) + ) .then((res) => { return { message: diff --git a/server/controller/Servicio/serviciosAdmin.js b/server/controller/Servicio/serviciosAdmin.js index 92e2b39..c693ae8 100644 --- a/server/controller/Servicio/serviciosAdmin.js +++ b/server/controller/Servicio/serviciosAdmin.js @@ -16,6 +16,7 @@ const serviciosAdmin = async (body) => { ? validar.validarNumeroCuenta(body.numeroCuenta) : ''; let where = {}; + let data = []; if (idStatus) where.idStatus = idStatus; return Servicio.findAll({ @@ -32,14 +33,14 @@ const serviciosAdmin = async (body) => { { model: Carrera }, { model: Status }, ], + order: [['updatedAt', 'DESC']], }).then((res) => { - let data = []; - for (let i = pagina * 25 - 25; i < res.length && i < pagina * 25; i++) data.push({ idServicio: res[i].idServicio, fechaInicio: res[i].fechaInicio, fechaFin: res[i].fechaFin, + createdAt: res[i].createdAt, Usuario: { idUsuario: res[i].Usuario.idUsuario, usuario: res[i].Usuario.usuario, diff --git a/server/controller/Servicio/serviciosResponsable.js b/server/controller/Servicio/serviciosResponsable.js index 864b301..e759a45 100644 --- a/server/controller/Servicio/serviciosResponsable.js +++ b/server/controller/Servicio/serviciosResponsable.js @@ -18,6 +18,7 @@ const serviciosResponsable = async (body) => { ? validar.validarNumeroCuenta(body.numeroCuenta) : ''; let where = { [Op.and]: [{ idStatus: { [Op.ne]: 10 } }] }; + let data = []; if (idStatus) where[Op.and].push({ idStatus }); return Usuario.findOne({ where: { idUsuario } }) @@ -40,11 +41,10 @@ const serviciosResponsable = async (body) => { { model: Carrera }, { model: Status }, ], + order: [['updatedAt', 'DESC']], }); }) .then((res) => { - let data = []; - for (let i = pagina * 25 - 25; i < res.length && i < pagina * 25; i++) data.push({ idServicio: res[i].idServicio,