listo
This commit is contained in:
@@ -9,6 +9,7 @@ const Usuario = require('../../db/tablas/Usuario');
|
||||
|
||||
const get = async (body) => {
|
||||
let year = validar.validarNumero(body.year, 4);
|
||||
let path = `csv/${year}_cuestionario_alumno.csv`;
|
||||
|
||||
return Servicio.findAll({
|
||||
include: [
|
||||
@@ -22,16 +23,14 @@ const get = async (body) => {
|
||||
}).then((res) => {
|
||||
let data = [];
|
||||
let csvString = '';
|
||||
let path = `csv/${year}_cuestionarios_alumno.csv`;
|
||||
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
for (let i = 0; i < res.length; i++)
|
||||
data.push({
|
||||
idServicio: res[i].idServicio,
|
||||
clavePrograma: res[i].Programa.clavePrograma,
|
||||
usuario: res[i].Usuario.usuario,
|
||||
nombre: res[i].Usuario.nombre,
|
||||
idCuestionarioAlumno:
|
||||
res[i].CuestionarioAlumno.idCuestionarioAlumno,
|
||||
idCuestionarioAlumno: res[i].CuestionarioAlumno.idCuestionarioAlumno,
|
||||
sexo: res[i].CuestionarioAlumno.sexo,
|
||||
edad: res[i].CuestionarioAlumno.edad,
|
||||
servicioMedico: res[i].CuestionarioAlumno.servicioMedico,
|
||||
@@ -67,16 +66,12 @@ const get = async (body) => {
|
||||
p30: res[i].CuestionarioAlumno.p30,
|
||||
createdAt: res[i].CuestionarioAlumno.createdAt,
|
||||
});
|
||||
}
|
||||
try {
|
||||
fs.unlinkSync(path);
|
||||
} catch (err) {}
|
||||
csvString = convertArrayToCSV(data);
|
||||
fs.appendFile(path, csvString, (err) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
throw new Error('hubo un problema al crear el archivo csv.');
|
||||
}
|
||||
if (err) throw new Error(err);
|
||||
});
|
||||
return {
|
||||
message: `Se creo/actualizo correctamente el csv del cuestionario de programa del año ${year}`,
|
||||
|
||||
@@ -4,7 +4,6 @@ const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
const nuevo = async (body) => {
|
||||
let idServicio = validar.validarId(body.idServicio);
|
||||
|
||||
let sexo = body.sexo;
|
||||
let edad = body.edad;
|
||||
let servicioMedico = body.servicioMedico;
|
||||
@@ -43,52 +42,42 @@ const nuevo = async (body) => {
|
||||
p3 += body.p3[i];
|
||||
if (i < body.p3.length - 1) p3 += ',';
|
||||
}
|
||||
|
||||
for (let i = 0; i < body.p5.length; i++) {
|
||||
p5 += body.p5[i];
|
||||
if (i < body.p5.length - 1) p5 += ',';
|
||||
}
|
||||
|
||||
for (let i = 0; i < body.p8.length; i++) {
|
||||
p8 += body.p8[i];
|
||||
if (i < body.p8.length - 1) p8 += ',';
|
||||
}
|
||||
|
||||
for (let i = 0; i < body.p14.length; i++) {
|
||||
p14 += body.p14[i];
|
||||
if (i < body.p14.length - 1) p14 += ',';
|
||||
}
|
||||
|
||||
for (let i = 0; i < body.p15.length; i++) {
|
||||
p15 += body.p15[i];
|
||||
if (i < body.p15.length - 1) p15 += ',';
|
||||
}
|
||||
|
||||
for (let i = 0; i < body.p17.length; i++) {
|
||||
p17 += body.p17[i];
|
||||
if (i < body.p17.length - 1) p17 += ',';
|
||||
}
|
||||
|
||||
for (let i = 0; i < body.p21.length; i++) {
|
||||
p21 += body.p21[i];
|
||||
if (i < body.p21.length - 1) p21 += ',';
|
||||
}
|
||||
|
||||
for (let i = 0; i < body.p22.length; i++) {
|
||||
p22 += body.p22[i];
|
||||
if (i < body.p22.length - 1) p22 += ',';
|
||||
}
|
||||
|
||||
for (let i = 0; i < body.p23.length; i++) {
|
||||
p23 += body.p23[i];
|
||||
if (i < body.p23.length - 1) p23 += ',';
|
||||
}
|
||||
|
||||
for (let i = 0; i < body.p24.length; i++) {
|
||||
p24 += body.p24[i];
|
||||
if (i < body.p24.length - 1) p24 += ',';
|
||||
}
|
||||
|
||||
return Servicio.findOne({ where: { idServicio } })
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe este Servicio Social.');
|
||||
@@ -154,15 +143,13 @@ const nuevo = async (body) => {
|
||||
throw new Error('Este Servicio Social fue cancelado.');
|
||||
}
|
||||
})
|
||||
.then((res) => {
|
||||
return Servicio.update(
|
||||
.then((res) =>
|
||||
Servicio.update(
|
||||
{ idCuestionarioAlumno: res.idCuestionarioAlumno },
|
||||
{ where: { idServicio } }
|
||||
);
|
||||
})
|
||||
.then((res) => {
|
||||
return validar.validarPreTermino(idServicio);
|
||||
})
|
||||
)
|
||||
)
|
||||
.then((res) => validar.validarPreTermino(idServicio))
|
||||
.then((res) => {
|
||||
return { message: `Se guardaron tus respuestas correctamente. ${res}` };
|
||||
});
|
||||
|
||||
@@ -9,6 +9,7 @@ const Usuario = require('../../db/tablas/Usuario');
|
||||
|
||||
const get = async (body) => {
|
||||
let year = validar.validarNumero(body.year, 4);
|
||||
let path = `csv/${year}_cuestionario_programa.csv`;
|
||||
|
||||
return Servicio.findAll({
|
||||
include: [
|
||||
@@ -22,7 +23,6 @@ const get = async (body) => {
|
||||
}).then((res) => {
|
||||
let data = [];
|
||||
let csvString = '';
|
||||
let path = `csv/${year}_cuestionarios_programa.csv`;
|
||||
|
||||
for (let i = 0; i < res.length; i++)
|
||||
data.push({
|
||||
@@ -47,10 +47,7 @@ const get = async (body) => {
|
||||
} catch (err) {}
|
||||
csvString = convertArrayToCSV(data);
|
||||
fs.appendFile(path, csvString, (err) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
throw new Error('hubo un problema al crear el archivo csv.');
|
||||
}
|
||||
if (err) throw new Error(err);
|
||||
});
|
||||
return {
|
||||
message: `Se creo/actualizo correctamente el csv del cuestionario de programa del año ${year}`,
|
||||
|
||||
@@ -17,7 +17,6 @@ const nuevo = async (body) => {
|
||||
retroalimentacion += body.retroalimentacion[i];
|
||||
if (i < body.retroalimentacion.length - 1) retroalimentacion += ',';
|
||||
}
|
||||
|
||||
return Servicio.findOne({ where: { idServicio } })
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe este Servicio Social.');
|
||||
@@ -59,15 +58,13 @@ const nuevo = async (body) => {
|
||||
throw new Error('Este Servicio Social fue cancelado.');
|
||||
}
|
||||
})
|
||||
.then((res) => {
|
||||
return Servicio.update(
|
||||
.then((res) =>
|
||||
Servicio.update(
|
||||
{ idCuestionarioPrograma: res.idCuestionarioPrograma },
|
||||
{ where: { idServicio } }
|
||||
);
|
||||
})
|
||||
.then((res) => {
|
||||
return validar.validarPreTermino(idServicio);
|
||||
})
|
||||
)
|
||||
)
|
||||
.then((res) => validar.validarPreTermino(idServicio))
|
||||
.then((res) => {
|
||||
return { message: `Se guradaron tus respuestas correctamente. ${res}` };
|
||||
});
|
||||
|
||||
@@ -20,7 +20,10 @@ const cargaMasiva = async (file) => {
|
||||
let usuario = '';
|
||||
let clavePrograma = programas[i].clave;
|
||||
let acatlan = false;
|
||||
let busquedaPrograma = {};
|
||||
let busquedaPrograma = {
|
||||
where: { clavePrograma: programas[i].clave },
|
||||
include: [{ model: Usuario }],
|
||||
};
|
||||
|
||||
mensaje += `Linea ${i + 2}\n`;
|
||||
try {
|
||||
@@ -55,21 +58,8 @@ const cargaMasiva = async (file) => {
|
||||
});
|
||||
await gmail(correo.subject, usuario, correo.msj);
|
||||
}
|
||||
if (clavePrograma.substr(4) === '-12/20-91') acatlan = true;
|
||||
if (acatlan) {
|
||||
busquedaPrograma = {
|
||||
where: {
|
||||
clavePrograma: programas[i].clave,
|
||||
idUsuario: dataUsuario.idUsuario,
|
||||
},
|
||||
include: [{ model: Usuario }],
|
||||
};
|
||||
} else {
|
||||
busquedaPrograma = {
|
||||
where: { clavePrograma: programas[i].clave },
|
||||
include: [{ model: Usuario }],
|
||||
};
|
||||
}
|
||||
if (clavePrograma.substr(4, 7) === '-12/20-') acatlan = true;
|
||||
if (acatlan) busquedaPrograma.where.idUsuario = dataUsuario.idUsuario;
|
||||
await Programa.findOne(busquedaPrograma).then(async (res) => {
|
||||
let dataPrograma = res;
|
||||
|
||||
|
||||
@@ -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 = '';
|
||||
let idUsuario;
|
||||
|
||||
@@ -27,10 +28,8 @@ const cancelar = async (body) => {
|
||||
throw new Error(
|
||||
'Este Servicio Social ya fue finalizado, no se puede cancelar.'
|
||||
);
|
||||
|
||||
let correoAlumno = correos.canceladoAlumno(mensaje, res.Usuario.nombre);
|
||||
|
||||
idUsuario = res.idUsuario;
|
||||
correoAlumno = correos.canceladoAlumno(mensaje, res.Usuario.nombre);
|
||||
correoResponsable = correos.canceladoResponsable(
|
||||
mensaje,
|
||||
res.Usuario.nombre
|
||||
@@ -38,22 +37,16 @@ const cancelar = async (body) => {
|
||||
emailResponsable = res.Programa.Usuario.usuario;
|
||||
return gmail(correoAlumno.subject, res.correo, correoAlumno.msj);
|
||||
})
|
||||
.then((res) => {
|
||||
return gmail(
|
||||
correoResponsable.subject,
|
||||
emailResponsable,
|
||||
correoResponsable.msj
|
||||
);
|
||||
})
|
||||
.then((res) => {
|
||||
return Usuario.update(
|
||||
.then((res) =>
|
||||
gmail(correoResponsable.subject, emailResponsable, correoResponsable.msj)
|
||||
)
|
||||
.then((res) =>
|
||||
Usuario.update(
|
||||
{ activo: false, password: null },
|
||||
{ where: { idUsuario } }
|
||||
);
|
||||
})
|
||||
.then((res) => {
|
||||
return Servicio.update({ idStatus: 10 }, { where: { idServicio } });
|
||||
})
|
||||
)
|
||||
)
|
||||
.then((res) => Servicio.update({ idStatus: 10 }, { where: { idServicio } }))
|
||||
.then((res) => {
|
||||
return { message: 'Se cancelo correctamente este Servicio Social.' };
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@ const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
const cartaTermino = async (body, file) => {
|
||||
let idServicio = validar.validarId(body.idServicio);
|
||||
let path = `./server/uploads/${validar.validar(file, 'El archivo', 1000)}`;
|
||||
|
||||
return Servicio.findOne({
|
||||
where: { idServicio },
|
||||
@@ -14,12 +15,6 @@ const cartaTermino = async (body, file) => {
|
||||
throw new Error('Ya se subio la Carta de Aceptación.');
|
||||
switch (res.idStatus) {
|
||||
case 7:
|
||||
let path = `./server/uploads/${validar.validar(
|
||||
file,
|
||||
'El archivo',
|
||||
1000
|
||||
)}`;
|
||||
|
||||
return drive.uploadFile(
|
||||
path,
|
||||
`Carta_Aceptacion.pdf`,
|
||||
@@ -50,12 +45,12 @@ const cartaTermino = async (body, file) => {
|
||||
);
|
||||
}
|
||||
})
|
||||
.then((res) => {
|
||||
return Servicio.update(
|
||||
.then((res) =>
|
||||
Servicio.update(
|
||||
{ cartaAceptacion: res, idStatus: 1 },
|
||||
{ where: { idServicio } }
|
||||
);
|
||||
})
|
||||
)
|
||||
)
|
||||
.then((res) => {
|
||||
return {
|
||||
message: `Se subio la Carta de Aceptación correctamente.`,
|
||||
|
||||
@@ -4,6 +4,7 @@ const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
const cartaTermino = async (body, file) => {
|
||||
let idServicio = validar.validarId(body.idServicio);
|
||||
let path = `./server/uploads/${validar.validar(file, 'El archivo', 1000)}`;
|
||||
|
||||
return Servicio.findOne({
|
||||
where: { idServicio },
|
||||
@@ -14,12 +15,6 @@ const cartaTermino = async (body, file) => {
|
||||
switch (res.idStatus) {
|
||||
case 4:
|
||||
case 8:
|
||||
let path = `./server/uploads/${validar.validar(
|
||||
file,
|
||||
'El archivo',
|
||||
1000
|
||||
)}`;
|
||||
|
||||
return drive.uploadFile(
|
||||
path,
|
||||
`Carta_Termino.pdf`,
|
||||
@@ -49,12 +44,10 @@ const cartaTermino = async (body, file) => {
|
||||
);
|
||||
}
|
||||
})
|
||||
.then((res) => {
|
||||
return Servicio.update({ cartaTermino: res }, { where: { idServicio } });
|
||||
})
|
||||
.then((res) => {
|
||||
return validar.validarPreTermino(idServicio);
|
||||
})
|
||||
.then((res) =>
|
||||
Servicio.update({ cartaTermino: res }, { where: { idServicio } })
|
||||
)
|
||||
.then((res) => validar.validarPreTermino(idServicio))
|
||||
.then((res) => {
|
||||
return { message: `Se subio la Carta de Termino correctamente. ${res}` };
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@ const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
const informeGlobal = async (body, file) => {
|
||||
let idServicio = validar.validarId(body.idServicio);
|
||||
let path = `./server/uploads/${validar.validar(file, 'El archivo', 1000)}`;
|
||||
|
||||
return Servicio.findOne({
|
||||
where: { idServicio },
|
||||
@@ -14,12 +15,6 @@ const informeGlobal = async (body, file) => {
|
||||
switch (res.idStatus) {
|
||||
case 4:
|
||||
case 9:
|
||||
let path = `./server/uploads/${validar.validar(
|
||||
file,
|
||||
'El archivo',
|
||||
1000
|
||||
)}`;
|
||||
|
||||
return drive.uploadFile(
|
||||
path,
|
||||
`Informe_Global.pdf`,
|
||||
@@ -49,15 +44,10 @@ const informeGlobal = async (body, file) => {
|
||||
);
|
||||
}
|
||||
})
|
||||
.then((res) => {
|
||||
return Servicio.update(
|
||||
{ informeGlobal: res },
|
||||
{ where: { idServicio } }
|
||||
);
|
||||
})
|
||||
.then(async (res) => {
|
||||
return validar.validarPreTermino(idServicio);
|
||||
})
|
||||
.then((res) =>
|
||||
Servicio.update({ informeGlobal: res }, { where: { idServicio } })
|
||||
)
|
||||
.then(async (res) => validar.validarPreTermino(idServicio))
|
||||
.then((res) => {
|
||||
return { message: `Se subio el Informe Global correctamente. ${res}` };
|
||||
});
|
||||
|
||||
@@ -14,12 +14,10 @@ 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.'
|
||||
);
|
||||
|
||||
switch (res.idStatus) {
|
||||
case 5:
|
||||
let correo = correos.terminoValidado(res.Usuario.nombre);
|
||||
|
||||
@@ -61,8 +61,8 @@ const nuevo = async (body, file) => {
|
||||
carpeta
|
||||
);
|
||||
})
|
||||
.then((res) => {
|
||||
return Servicio.create({
|
||||
.then((res) =>
|
||||
Servicio.create({
|
||||
idUsuario,
|
||||
idPrograma,
|
||||
idCarrera,
|
||||
@@ -74,8 +74,8 @@ const nuevo = async (body, file) => {
|
||||
cartaAceptacion: res,
|
||||
profesor,
|
||||
programaInterno,
|
||||
});
|
||||
})
|
||||
})
|
||||
)
|
||||
.then((res) => {
|
||||
return {
|
||||
message: `Se Pre-Registro correctamente al alumno.`,
|
||||
|
||||
@@ -7,7 +7,7 @@ const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
const newPasswordAlumno = async (body) => {
|
||||
let idServicio = await validar.validarId(body.idServicio);
|
||||
let pasword = encriptar.generarPassword();
|
||||
let password = encriptar.generarPassword();
|
||||
let idUsuario;
|
||||
|
||||
return Servicio.findOne({
|
||||
@@ -19,14 +19,14 @@ const newPasswordAlumno = async (body) => {
|
||||
if (res.Usuario.idTipoUsuario != 3)
|
||||
throw new Error('Este usuario no es de tipo alumno.');
|
||||
|
||||
let correo = correos.preRegistro(pasword, res.Usuario.nombre);
|
||||
let correo = correos.preRegistro(password, res.Usuario.nombre);
|
||||
|
||||
idUsuario = res.idUsuario;
|
||||
return gmail(correo.subject, res.correo, correo.msj);
|
||||
})
|
||||
.then((res) => {
|
||||
return Usuario.update(
|
||||
{ pasword: encriptar.encriptar(pasword) },
|
||||
{ password: encriptar.encriptar(password) },
|
||||
{ where: { idUsuario } }
|
||||
);
|
||||
})
|
||||
|
||||
@@ -6,20 +6,21 @@ const Usuario = require('../../db/tablas/Usuario');
|
||||
|
||||
const newPasswordResponsable = async (body) => {
|
||||
let idUsuario = await validar.validarId(body.idUsuario);
|
||||
let pasword = encriptar.generarPassword();
|
||||
let password = encriptar.generarPassword();
|
||||
|
||||
return Usuario.findOne({ where: { idUsuario } })
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe este Usuario.');
|
||||
if (res.Usuario.idTipoUsuario != 2)
|
||||
if (res.idTipoUsuario != 2)
|
||||
throw new Error('Este usuario no es de tipo alumno.');
|
||||
|
||||
let correo = correos.enviarSec(pasword, res.correo, res.nombre);
|
||||
return gmail(correo.subject, res.correo, correo.msj);
|
||||
let correo = correos.enviarSec(password, res.correo, res.nombre);
|
||||
|
||||
return gmail(correo.subject, res.usuario, correo.msj);
|
||||
})
|
||||
.then((res) => {
|
||||
return Usuario.update(
|
||||
{ pasword: encriptar.encriptar(pasword) },
|
||||
{ password: encriptar.encriptar(password) },
|
||||
{ where: { idUsuario } }
|
||||
);
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user