Merge remote-tracking branch 'origin/dev' into eithan
This commit is contained in:
@@ -6,9 +6,12 @@ const CuestionarioAlumno = require('../../db/tablas/CuestionarioAlumno');
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
const Programa = require('../../db/tablas/Programa');
|
||||
const Usuario = require('../../db/tablas/Usuario');
|
||||
const { EROFS } = require('constants');
|
||||
|
||||
const get = async (body) => {
|
||||
let year = validar.validarNumero(body.year, 4);
|
||||
const year = validar.validarNumero(body.year, 4);
|
||||
const path = `csv/${year}_cuestionario_alumno.csv`;
|
||||
const data = [];
|
||||
|
||||
return Servicio.findAll({
|
||||
include: [
|
||||
@@ -20,18 +23,13 @@ const get = async (body) => {
|
||||
{ model: Usuario },
|
||||
],
|
||||
}).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,19 +65,16 @@ 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.');
|
||||
}
|
||||
} catch (err) {
|
||||
throw new Error(err);
|
||||
}
|
||||
fs.appendFile(path, convertArrayToCSV(data), (err) => {
|
||||
if (err) throw new Error(err);
|
||||
});
|
||||
return {
|
||||
message: `Se creo/actualizo correctamente el csv del cuestionario de programa del año ${year}`,
|
||||
message: `Se creo/actualizo correctamente el csv del cuestionario de alumno del año ${year}.`,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -3,31 +3,30 @@ const CuestionarioAlumno = require('../../db/tablas/CuestionarioAlumno');
|
||||
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;
|
||||
let p1 = body.p1;
|
||||
let p2 = body.p2;
|
||||
let p4 = body.p4;
|
||||
let p6 = body.p6;
|
||||
let p7 = body.p7;
|
||||
let p9 = body.p9;
|
||||
let p10 = body.p10;
|
||||
let p11 = body.p11;
|
||||
let p12 = body.p12;
|
||||
let p13 = body.p13;
|
||||
let p16 = body.p16;
|
||||
let p18 = body.p18;
|
||||
let p19 = body.p19;
|
||||
let p20 = body.p20;
|
||||
let p25 = body.p25;
|
||||
let p26 = body.p26;
|
||||
let p27 = body.p27;
|
||||
let p28 = body.p28;
|
||||
let p29 = body.p29;
|
||||
let p30 = body.p30;
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const sexo = body.sexo;
|
||||
const edad = body.edad;
|
||||
const servicioMedico = body.servicioMedico;
|
||||
const p1 = body.p1;
|
||||
const p2 = body.p2;
|
||||
const p4 = body.p4;
|
||||
const p6 = body.p6;
|
||||
const p7 = body.p7;
|
||||
const p9 = body.p9;
|
||||
const p10 = body.p10;
|
||||
const p11 = body.p11;
|
||||
const p12 = body.p12;
|
||||
const p13 = body.p13;
|
||||
const p16 = body.p16;
|
||||
const p18 = body.p18;
|
||||
const p19 = body.p19;
|
||||
const p20 = body.p20;
|
||||
const p25 = body.p25;
|
||||
const p26 = body.p26;
|
||||
const p27 = body.p27;
|
||||
const p28 = body.p28;
|
||||
const p29 = body.p29;
|
||||
const p30 = body.p30;
|
||||
let p3 = '';
|
||||
let p5 = '';
|
||||
let p8 = '';
|
||||
@@ -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,18 +143,16 @@ 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) => {
|
||||
return { message: `Se guardaron tus respuestas correctamente. ${res}` };
|
||||
});
|
||||
)
|
||||
)
|
||||
.then((res) => validar.validarPreTermino(idServicio))
|
||||
.then((res) => ({
|
||||
message: `Se guardaron tus respuestas correctamente. ${res}`,
|
||||
}));
|
||||
};
|
||||
|
||||
module.exports = nuevo;
|
||||
|
||||
@@ -8,7 +8,9 @@ const Programa = require('../../db/tablas/Programa');
|
||||
const Usuario = require('../../db/tablas/Usuario');
|
||||
|
||||
const get = async (body) => {
|
||||
let year = validar.validarNumero(body.year, 4);
|
||||
const year = validar.validarNumero(body.year, 4);
|
||||
const path = `csv/${year}_cuestionario_programa.csv`;
|
||||
const data = [];
|
||||
|
||||
return Servicio.findAll({
|
||||
include: [
|
||||
@@ -20,10 +22,6 @@ const get = async (body) => {
|
||||
{ model: Usuario },
|
||||
],
|
||||
}).then((res) => {
|
||||
let data = [];
|
||||
let csvString = '';
|
||||
let path = `csv/${year}_cuestionarios_programa.csv`;
|
||||
|
||||
for (let i = 0; i < res.length; i++)
|
||||
data.push({
|
||||
idServicio: res[i].idServicio,
|
||||
@@ -44,16 +42,14 @@ const get = async (body) => {
|
||||
});
|
||||
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.');
|
||||
}
|
||||
} catch (err) {
|
||||
throw new Error(err);
|
||||
}
|
||||
fs.appendFile(path, convertArrayToCSV(data), (err) => {
|
||||
if (err) throw new Error(err);
|
||||
});
|
||||
return {
|
||||
message: `Se creo/actualizo correctamente el csv del cuestionario de programa del año ${year}`,
|
||||
message: `Se creo/actualizo correctamente el csv del cuestionario de programa del año ${year}.`,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -3,21 +3,20 @@ const CuestionarioPrograma = require('../../db/tablas/CuestionarioPrograma');
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
const nuevo = async (body) => {
|
||||
let idServicio = validar.validarId(body.idServicio);
|
||||
let actividad1 = body.actividad1;
|
||||
let actividad2 = body.actividad2;
|
||||
let actividad3 = body.actividad3;
|
||||
let actividad4 = body.actividad4;
|
||||
let actividad5 = body.actividad5;
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const actividad1 = body.actividad1;
|
||||
const actividad2 = body.actividad2;
|
||||
const actividad3 = body.actividad3;
|
||||
const actividad4 = body.actividad4;
|
||||
const actividad5 = body.actividad5;
|
||||
const p6 = body.p6;
|
||||
const p7 = body.p7;
|
||||
let retroalimentacion = '';
|
||||
let p6 = body.p6;
|
||||
let p7 = body.p7;
|
||||
|
||||
for (let i = 0; i < body.retroalimentacion.length; i++) {
|
||||
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,18 +58,16 @@ 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) => {
|
||||
return { message: `Se guradaron tus respuestas correctamente. ${res}` };
|
||||
});
|
||||
)
|
||||
)
|
||||
.then((res) => validar.validarPreTermino(idServicio))
|
||||
.then((res) => ({
|
||||
message: `Se guradaron tus respuestas correctamente. ${res}`,
|
||||
}));
|
||||
};
|
||||
|
||||
module.exports = nuevo;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ const Programa = require('../../db/tablas/Programa');
|
||||
const Usuario = require('../../db/tablas/Usuario');
|
||||
|
||||
const programasAdmin = async (body) => {
|
||||
let idUsuario = validar.validarId(body.idUsuario);
|
||||
const idUsuario = validar.validarId(body.idUsuario);
|
||||
|
||||
return Usuario.findOne({
|
||||
where: { idUsuario },
|
||||
|
||||
@@ -3,7 +3,7 @@ const Programa = require('../../db/tablas/Programa');
|
||||
const Usuario = require('../../db/tablas/Usuario');
|
||||
|
||||
const programasResponsable = async (body) => {
|
||||
let idUsuario = validar.validarId(body.idUsuario);
|
||||
const idUsuario = validar.validarId(body.idUsuario);
|
||||
|
||||
return Usuario.findOne({
|
||||
where: { idUsuario },
|
||||
|
||||
@@ -7,7 +7,7 @@ const Status = require('../../db/tablas/Status');
|
||||
const Programa = require('../../db/tablas/Programa');
|
||||
|
||||
const admin = async (body) => {
|
||||
let idServicio = validar.validarId(body.idServicio);
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
|
||||
return Servicio.findOne({
|
||||
where: { idServicio },
|
||||
@@ -19,51 +19,13 @@ const admin = async (body) => {
|
||||
],
|
||||
}).then((res) => {
|
||||
if (!res) throw new Error('No existe este servicio social.');
|
||||
return {
|
||||
idServicio: res.idServicio,
|
||||
creditos: res.creditos,
|
||||
correo: res.correo,
|
||||
telefono: res.telefono,
|
||||
direccion: res.direccion,
|
||||
fechaInicio: res.fechaInicio,
|
||||
fechaFin: res.fechaFin,
|
||||
fechaNacimiento: res.fechaNacimiento,
|
||||
cartaAceptacion: res.cartaAceptacion,
|
||||
cartaTermino: res.cartaTermino,
|
||||
informeGlobal: res.informeGlobal,
|
||||
programaInterno: res.programaInterno,
|
||||
profesor: res.profesor,
|
||||
vistoBuenoAcatlan: res.vistoBuenoAcatlan,
|
||||
createdAt: res.createdAt,
|
||||
updatedAt: res.updatedAt,
|
||||
idCuestionarioAlumno: res.idCuestionarioAlumno,
|
||||
idCuestionarioPrograma: res.idCuestionarioPrograma,
|
||||
Usuario: {
|
||||
idUsuario: res.Usuario.idUsuario,
|
||||
usuario: res.Usuario.usuario,
|
||||
nombre: res.Usuario.nombre,
|
||||
TipoUsuario: {
|
||||
idTipoUsuario: res.Usuario.TipoUsuario.idTipoUsuario,
|
||||
tipoUsuario: res.Usuario.TipoUsuario.tipoUsuario,
|
||||
},
|
||||
},
|
||||
Carrera: {
|
||||
idCarrera: res.Carrera.idCarrera,
|
||||
carrera: res.Carrera.carrera,
|
||||
},
|
||||
Status: {
|
||||
idStatus: res.Status.idStatus,
|
||||
status: res.Status.status,
|
||||
},
|
||||
Programa: {
|
||||
idPrograma: res.Programa.idPrograma,
|
||||
institucion: res.Programa.institucion,
|
||||
dependencia: res.Programa.dependencia,
|
||||
programa: res.Programa.programa,
|
||||
clavePrograma: res.Programa.clavePrograma,
|
||||
acatlan: res.Programa.acatlan,
|
||||
},
|
||||
};
|
||||
delete res.dataValues.Usuario.dataValues.password;
|
||||
delete res.dataValues.Programa.dataValues.idUsuario;
|
||||
delete res.dataValues.idUsuario;
|
||||
delete res.dataValues.idCarrera;
|
||||
delete res.dataValues.idStatus;
|
||||
delete res.dataValues.idPrograma;
|
||||
return res;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -13,52 +13,26 @@ const alumno = async (body) => {
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe este usuario.');
|
||||
if (res.idTipoUsuario !== 3)
|
||||
throw new Error('No es un usuaior de tipo alumno.');
|
||||
throw new Error('No es un usuario de tipo alumno.');
|
||||
return Servicio.findOne({
|
||||
where: { idUsuario, idStatus: { [Op.not]: 10 } },
|
||||
include: [
|
||||
{ model: Usuario },
|
||||
{ model: Carrera },
|
||||
{ model: Status },
|
||||
{ model: Programa },
|
||||
],
|
||||
include: [{ model: Carrera }, { model: Status }, { model: Programa }],
|
||||
});
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe este servicio social.');
|
||||
return {
|
||||
idServicio: res.idServicio,
|
||||
creditos: res.creditos,
|
||||
correo: res.correo,
|
||||
telefono: res.telefono,
|
||||
direccion: res.direccion,
|
||||
fechaInicio: res.fechaInicio,
|
||||
fechaFin: res.fechaFin,
|
||||
fechaNacimiento: res.fechaNacimiento,
|
||||
informeGlobal: res.informeGlobal,
|
||||
programaInterno: res.programaInterno,
|
||||
profesor: res.profesor,
|
||||
createdAt: res.createdAt,
|
||||
updatedAt: res.updatedAt,
|
||||
idCuestionarioAlumno: res.idCuestionarioAlumno,
|
||||
Carrera: {
|
||||
idCarrera: res.Carrera.idCarrera,
|
||||
carrera: res.Carrera.carrera,
|
||||
},
|
||||
Status: {
|
||||
idStatus: res.Status.idStatus,
|
||||
status: res.Status.status,
|
||||
},
|
||||
Programa: {
|
||||
idPrograma: res.Programa.idPrograma,
|
||||
institucion: res.Programa.institucion,
|
||||
dependencia: res.Programa.dependencia,
|
||||
programa: res.Programa.programa,
|
||||
clavePrograma: res.Programa.clavePrograma,
|
||||
acatlan: res.Programa.acatlan,
|
||||
activo: res.Programa.activo,
|
||||
},
|
||||
};
|
||||
delete res.dataValues.idUsuario;
|
||||
delete res.dataValues.idCarrera;
|
||||
delete res.dataValues.idStatus;
|
||||
delete res.dataValues.idPrograma;
|
||||
delete res.dataValues.updatedAt;
|
||||
delete res.dataValues.carpeta;
|
||||
delete res.dataValues.cartaAceptacion;
|
||||
delete res.dataValues.cartaTermino;
|
||||
delete res.dataValues.vistoBuenoAcatlan;
|
||||
delete res.dataValues.idCuestionarioPrograma;
|
||||
delete res.dataValues.Programa.idUsuario;
|
||||
return res;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -6,9 +6,10 @@ const Usuario = require('../../db/tablas/Usuario');
|
||||
const Programa = require('../../db/tablas/Programa');
|
||||
|
||||
const cancelar = async (body) => {
|
||||
let idServicio = validar.validarId(body.idServicio);
|
||||
let mensaje = validar.validarAlfanumerico(body.mensaje, 'El mensaje', 800);
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const 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,25 +37,19 @@ 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) => {
|
||||
return { message: 'Se cancelo correctamente este Servicio Social.' };
|
||||
});
|
||||
)
|
||||
)
|
||||
.then((res) => Servicio.update({ idStatus: 10 }, { where: { idServicio } }))
|
||||
.then((res) => ({
|
||||
message: 'Se cancelo correctamente este Servicio Social.',
|
||||
}));
|
||||
};
|
||||
|
||||
module.exports = cancelar;
|
||||
|
||||
@@ -3,7 +3,8 @@ const drive = require('../../helper/drive');
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
const cartaTermino = async (body, file) => {
|
||||
let idServicio = validar.validarId(body.idServicio);
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const 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,17 +45,15 @@ 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.`,
|
||||
};
|
||||
});
|
||||
)
|
||||
)
|
||||
.then((res) => ({
|
||||
message: `Se subio la Carta de Aceptación correctamente.`,
|
||||
}));
|
||||
};
|
||||
|
||||
module.exports = cartaTermino;
|
||||
|
||||
@@ -3,7 +3,8 @@ const drive = require('../../helper/drive');
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
const cartaTermino = async (body, file) => {
|
||||
let idServicio = validar.validarId(body.idServicio);
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const 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,15 +44,13 @@ const cartaTermino = async (body, file) => {
|
||||
);
|
||||
}
|
||||
})
|
||||
.then((res) => {
|
||||
return Servicio.update({ cartaTermino: res }, { where: { idServicio } });
|
||||
})
|
||||
.then((res) => {
|
||||
return validar.validarPreTermino(idServicio);
|
||||
})
|
||||
.then((res) => {
|
||||
return { message: `Se subio la Carta de Termino correctamente. ${res}` };
|
||||
});
|
||||
.then((res) =>
|
||||
Servicio.update({ cartaTermino: res }, { where: { idServicio } })
|
||||
)
|
||||
.then((res) => validar.validarPreTermino(idServicio))
|
||||
.then((res) => ({
|
||||
message: `Se subio la Carta de Termino correctamente. ${res}`,
|
||||
}));
|
||||
};
|
||||
|
||||
module.exports = cartaTermino;
|
||||
|
||||
@@ -3,7 +3,8 @@ const drive = require('../../helper/drive');
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
const informeGlobal = async (body, file) => {
|
||||
let idServicio = validar.validarId(body.idServicio);
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const 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,18 +44,13 @@ const informeGlobal = async (body, file) => {
|
||||
);
|
||||
}
|
||||
})
|
||||
.then((res) => {
|
||||
return Servicio.update(
|
||||
{ informeGlobal: res },
|
||||
{ where: { idServicio } }
|
||||
);
|
||||
})
|
||||
.then(async (res) => {
|
||||
return validar.validarPreTermino(idServicio);
|
||||
})
|
||||
.then((res) => {
|
||||
return { message: `Se subio el Informe Global correctamente. ${res}` };
|
||||
});
|
||||
.then((res) =>
|
||||
Servicio.update({ informeGlobal: res }, { where: { idServicio } })
|
||||
)
|
||||
.then(async (res) => validar.validarPreTermino(idServicio))
|
||||
.then((res) => ({
|
||||
message: `Se subio el Informe Global correctamente. ${res}`,
|
||||
}));
|
||||
};
|
||||
|
||||
module.exports = informeGlobal;
|
||||
|
||||
@@ -6,7 +6,9 @@ const Usuario = require('../../db/tablas/Usuario');
|
||||
const Programa = require('../../db/tablas/Programa');
|
||||
|
||||
const liberacion = async (body) => {
|
||||
let idServicio = validar.validarId(body.idServicio);
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const update = { idStatus: 6 };
|
||||
let correo = {};
|
||||
|
||||
return Servicio.findOne({
|
||||
where: { idServicio },
|
||||
@@ -14,16 +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.'
|
||||
'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:
|
||||
@@ -46,18 +46,11 @@ 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) => {
|
||||
return {
|
||||
message:
|
||||
'Se cambio de estatus correctamente y se envio un correo al alumno informandole de su liberación.',
|
||||
};
|
||||
});
|
||||
.then((res) => Servicio.update(update, { where: { idServicio } }))
|
||||
.then((res) => ({
|
||||
message:
|
||||
'Se cambio de estatus correctamente y se envio un correo al alumno informandole de su liberación.',
|
||||
}));
|
||||
};
|
||||
|
||||
module.exports = liberacion;
|
||||
|
||||
@@ -7,26 +7,26 @@ const Carrera = require('../../db/tablas/Carrera');
|
||||
const validar = require('../../helper/validar');
|
||||
|
||||
const nuevo = async (body, file) => {
|
||||
let idUsuario = validar.validarId(body.idUsuario);
|
||||
let idPrograma = validar.validarId(body.idPrograma);
|
||||
let idCarrera = validar.validarId(body.idCarrera);
|
||||
let numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta);
|
||||
let creditos = validar.validarNumero(body.creditos);
|
||||
let correo = validar.validarCorreo(body.correo);
|
||||
let fechaInicio = validar.validarFecha(body.fechaInicio);
|
||||
let fechaFin = validar.validarFecha(body.fechaFin);
|
||||
let path = `./server/uploads/${validar.validar(file, 'El archivo', 1000)}`;
|
||||
let carpeta = '';
|
||||
let programaInterno = body.programaInterno
|
||||
const idUsuario = validar.validarId(body.idUsuario);
|
||||
const idPrograma = validar.validarId(body.idPrograma);
|
||||
const idCarrera = validar.validarId(body.idCarrera);
|
||||
const numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta);
|
||||
const creditos = validar.validarNumero(body.creditos);
|
||||
const correo = validar.validarCorreo(body.correo);
|
||||
const fechaInicio = validar.validarFecha(body.fechaInicio);
|
||||
const fechaFin = validar.validarFecha(body.fechaFin);
|
||||
const path = `./server/uploads/${validar.validar(file, 'El archivo', 1000)}`;
|
||||
const programaInterno = body.programaInterno
|
||||
? validar.validarTexto(
|
||||
body.programaInterno,
|
||||
'El texto programa interno.',
|
||||
80
|
||||
)
|
||||
: '';
|
||||
let profesor = body.profesor
|
||||
const profesor = body.profesor
|
||||
? validar.validarTexto(body.profesor, 'El texto de profesor.', 50)
|
||||
: '';
|
||||
let carpeta = '';
|
||||
|
||||
return Usuario.findOne({
|
||||
where: { idUsuario },
|
||||
@@ -61,8 +61,8 @@ const nuevo = async (body, file) => {
|
||||
carpeta
|
||||
);
|
||||
})
|
||||
.then((res) => {
|
||||
return Servicio.create({
|
||||
.then((res) =>
|
||||
Servicio.create({
|
||||
idUsuario,
|
||||
idPrograma,
|
||||
idCarrera,
|
||||
@@ -74,13 +74,11 @@ const nuevo = async (body, file) => {
|
||||
cartaAceptacion: res,
|
||||
profesor,
|
||||
programaInterno,
|
||||
});
|
||||
})
|
||||
.then((res) => {
|
||||
return {
|
||||
message: `Se Pre-Registro correctamente al alumno.`,
|
||||
};
|
||||
});
|
||||
})
|
||||
)
|
||||
.then((res) => ({
|
||||
message: `Se Pre-Registro correctamente al alumno.`,
|
||||
}));
|
||||
};
|
||||
|
||||
module.exports = nuevo;
|
||||
|
||||
@@ -6,9 +6,10 @@ const Usuario = require('../../db/tablas/Usuario');
|
||||
const Programa = require('../../db/tablas/Programa');
|
||||
|
||||
const cancelar = async (body) => {
|
||||
let idServicio = validar.validarId(body.idServicio);
|
||||
let mensaje = validar.validarAlfanumerico(body.mensaje, 'El mensaje', 800);
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const 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,22 +52,18 @@ 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: 7, cartaAceptacion: '' },
|
||||
.then((res) =>
|
||||
gmail(correoResponsable.subject, emailResponsable, correoResponsable.msj)
|
||||
)
|
||||
.then((res) =>
|
||||
Servicio.update(
|
||||
{ idStatus: 7, cartaAceptacion: null },
|
||||
{ where: { idServicio } }
|
||||
);
|
||||
})
|
||||
.then((res) => {
|
||||
return { message: 'Se rechazo correctamente la Carta de Aceptación.' };
|
||||
});
|
||||
)
|
||||
)
|
||||
.then((res) => ({
|
||||
message: 'Se rechazo correctamente la Carta de Aceptación.',
|
||||
}));
|
||||
};
|
||||
|
||||
module.exports = cancelar;
|
||||
|
||||
@@ -6,9 +6,10 @@ const Usuario = require('../../db/tablas/Usuario');
|
||||
const Programa = require('../../db/tablas/Programa');
|
||||
|
||||
const cancelar = async (body) => {
|
||||
let idServicio = validar.validarId(body.idServicio);
|
||||
let mensaje = validar.validarAlfanumerico(body.mensaje, 'El mensaje', 800);
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const 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,22 +53,18 @@ 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: null },
|
||||
{ where: { idServicio } }
|
||||
);
|
||||
})
|
||||
.then((res) => {
|
||||
return { message: 'Se rechazo correctamente el Informe Global.' };
|
||||
});
|
||||
)
|
||||
)
|
||||
.then((res) => ({
|
||||
message: 'Se rechazo correctamente el Informe Global.',
|
||||
}));
|
||||
};
|
||||
|
||||
module.exports = cancelar;
|
||||
|
||||
@@ -6,9 +6,10 @@ const Usuario = require('../../db/tablas/Usuario');
|
||||
const Programa = require('../../db/tablas/Programa');
|
||||
|
||||
const cancelar = async (body) => {
|
||||
let idServicio = validar.validarId(body.idServicio);
|
||||
let mensaje = validar.validarAlfanumerico(body.mensaje, 'El mensaje', 800);
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const 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,22 +53,18 @@ 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: null },
|
||||
{ where: { idServicio } }
|
||||
);
|
||||
})
|
||||
.then((res) => {
|
||||
return { message: 'Se rechazo correctamente la Carta de Termino.' };
|
||||
});
|
||||
)
|
||||
)
|
||||
.then((res) => ({
|
||||
message: 'Se rechazo correctamente la Carta de Termino.',
|
||||
}));
|
||||
};
|
||||
|
||||
module.exports = cancelar;
|
||||
|
||||
@@ -6,8 +6,8 @@ const Servicio = require('../../db/tablas/Servicio');
|
||||
const Usuario = require('../../db/tablas/Usuario');
|
||||
|
||||
const registro = async (body) => {
|
||||
let idServicio = validar.validarId(body.idServicio);
|
||||
let password = '';
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const password = encriptar.generarPassword();
|
||||
let correo = {};
|
||||
let idUsuario;
|
||||
|
||||
@@ -20,7 +20,6 @@ const registro = async (body) => {
|
||||
|
||||
switch (res.idStatus) {
|
||||
case 1:
|
||||
password = encriptar.generarPassword();
|
||||
correo = correos.preRegistro(password, res.Usuario.nombre);
|
||||
idUsuario = res.idUsuario;
|
||||
return gmail(correo.subject, res.correo, correo.msj);
|
||||
@@ -48,15 +47,11 @@ const registro = async (body) => {
|
||||
{ where: { idUsuario } }
|
||||
);
|
||||
})
|
||||
.then((res) => {
|
||||
return Servicio.update({ idStatus: 2 }, { where: { idServicio } });
|
||||
})
|
||||
.then((res) => {
|
||||
return {
|
||||
message:
|
||||
'Se cambio de estatus correctamente y se envio un correo al alumno con sus credenciales.',
|
||||
};
|
||||
});
|
||||
.then((res) => Servicio.update({ idStatus: 2 }, { where: { idServicio } }))
|
||||
.then((res) => ({
|
||||
message:
|
||||
'Se cambio de estatus correctamente y se envio un correo al alumno con sus credenciales.',
|
||||
}));
|
||||
};
|
||||
|
||||
module.exports = registro;
|
||||
|
||||
@@ -6,15 +6,16 @@ const Usuario = require('../../db/tablas/Usuario');
|
||||
const Programa = require('../../db/tablas/Programa');
|
||||
|
||||
const registroValidado = async (body) => {
|
||||
let idServicio = validar.validarId(body.idServicio);
|
||||
let fechaNacimiento = validar.validarFecha(body.fechaNacimiento);
|
||||
let telefono = validar.validarNumero(body.telefono, 15);
|
||||
let direccion = validar.validarAlfanumerico(
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const fechaNacimiento = validar.validarFecha(body.fechaNacimiento);
|
||||
const telefono = validar.validarNumero(body.telefono, 15);
|
||||
const direccion = validar.validarAlfanumerico(
|
||||
body.direccion,
|
||||
'La dirección',
|
||||
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,26 +62,21 @@ 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(
|
||||
// Producción
|
||||
// { idStatus: 3, direccion, telefono, fechaNacimiento },
|
||||
// Pruebas
|
||||
{ idStatus: 4, direccion, telefono, fechaNacimiento },
|
||||
{ where: { idServicio } }
|
||||
);
|
||||
})
|
||||
.then((res) => {
|
||||
return {
|
||||
message:
|
||||
'Haz terminado el registro de tu Servicio Social correctamente.',
|
||||
};
|
||||
});
|
||||
)
|
||||
)
|
||||
.then((res) => ({
|
||||
message: 'Haz terminado el registro de tu Servicio Social correctamente.',
|
||||
}));
|
||||
};
|
||||
|
||||
module.exports = registroValidado;
|
||||
|
||||
@@ -7,17 +7,18 @@ const Status = require('../../db/tablas/Status');
|
||||
const TipoUsuario = require('../../db/tablas/TipoUsuario');
|
||||
|
||||
const serviciosAdmin = async (body) => {
|
||||
let pagina = validar.validarId(body.pagina);
|
||||
let idStatus = body.idStatus ? validar.validarId(body.idStatus) : null;
|
||||
let nombre = body.nombre
|
||||
const pagina = validar.validarId(body.pagina);
|
||||
const where = body.idStatus
|
||||
? { idStatus: validar.validarId(body.idStatus) }
|
||||
: {};
|
||||
const nombre = body.nombre
|
||||
? validar.validarTexto(body.nombre, 'El nombre', 60)
|
||||
: '';
|
||||
let numeroCuenta = body.numeroCuenta
|
||||
const numeroCuenta = body.numeroCuenta
|
||||
? validar.validarNumeroCuenta(body.numeroCuenta)
|
||||
: '';
|
||||
let where = {};
|
||||
const data = [];
|
||||
|
||||
if (idStatus) where.idStatus = idStatus;
|
||||
return Servicio.findAll({
|
||||
where,
|
||||
include: [
|
||||
@@ -32,31 +33,22 @@ 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,
|
||||
nombre: res[i].Usuario.nombre,
|
||||
TipoUsuario: {
|
||||
idTipoUsuario: res[i].Usuario.TipoUsuario.idTipoUsuario,
|
||||
tipoUsuario: res[i].Usuario.TipoUsuario.tipoUsuario,
|
||||
},
|
||||
},
|
||||
Carrera: {
|
||||
idCarrera: res[i].Carrera.idCarrera,
|
||||
carrera: res[i].Carrera.carrera,
|
||||
},
|
||||
Status: {
|
||||
idStatus: res[i].Status.idStatus,
|
||||
status: res[i].Status.status,
|
||||
TipoUsuario: res[i].Usuario.TipoUsuario,
|
||||
},
|
||||
Carrera: res[i].Carrera,
|
||||
Status: res[i].Status,
|
||||
});
|
||||
return {
|
||||
registros: res.length,
|
||||
|
||||
@@ -8,18 +8,20 @@ const TipoUsuario = require('../../db/tablas/TipoUsuario');
|
||||
const Programa = require('../../db/tablas/Programa');
|
||||
|
||||
const serviciosResponsable = async (body) => {
|
||||
let pagina = validar.validarId(body.pagina);
|
||||
let idUsuario = validar.validarId(body.idUsuario);
|
||||
let idStatus = body.idStatus ? validar.validarId(body.idStatus) : null;
|
||||
let nombre = body.nombre
|
||||
const pagina = validar.validarId(body.pagina);
|
||||
const idUsuario = validar.validarId(body.idUsuario);
|
||||
const where = body.idStatus
|
||||
? { idStatus: validar.validarId(body.idStatus) }
|
||||
: {};
|
||||
|
||||
const nombre = body.nombre
|
||||
? validar.validarTexto(body.nombre, 'El nombre', 60)
|
||||
: '';
|
||||
let numeroCuenta = body.numeroCuenta
|
||||
const numeroCuenta = body.numeroCuenta
|
||||
? validar.validarNumeroCuenta(body.numeroCuenta)
|
||||
: '';
|
||||
let where = { [Op.and]: [{ idStatus: { [Op.ne]: 10 } }] };
|
||||
const data = [];
|
||||
|
||||
if (idStatus) where[Op.and].push({ idStatus });
|
||||
return Usuario.findOne({ where: { idUsuario } })
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe este usuario.');
|
||||
@@ -40,11 +42,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,
|
||||
@@ -56,19 +57,10 @@ const serviciosResponsable = async (body) => {
|
||||
idUsuario: res[i].Usuario.idUsuario,
|
||||
usuario: res[i].Usuario.usuario,
|
||||
nombre: res[i].Usuario.nombre,
|
||||
TipoUsuario: {
|
||||
idTipoUsuario: res[i].Usuario.TipoUsuario.idTipoUsuario,
|
||||
tipoUsuario: res[i].Usuario.TipoUsuario.tipoUsuario,
|
||||
},
|
||||
},
|
||||
Carrera: {
|
||||
idCarrera: res[i].Carrera.idCarrera,
|
||||
carrera: res[i].Carrera.carrera,
|
||||
},
|
||||
Status: {
|
||||
idStatus: res[i].Status.idStatus,
|
||||
status: res[i].Status.status,
|
||||
TipoUsuario: res[i].Usuario.TipoUsuario,
|
||||
},
|
||||
Carrera: res[i].Carrera,
|
||||
Status: res[i].Status,
|
||||
});
|
||||
return {
|
||||
registros: res.length,
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
const drive = require('../../helper/drive');
|
||||
const validar = require('../../helper/validar');
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
const Usuario = require('../../db/tablas/Usuario');
|
||||
|
||||
const update = async (body, files) => {
|
||||
let idServicio = validar.validarId(body.idServicio);
|
||||
let dataUpdate = {};
|
||||
console.log('hola2');
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const dataUpdate = {};
|
||||
|
||||
return Servicio.findOne({ where: { idServicio } })
|
||||
.then(async (res) => {
|
||||
if (!res) throw new Error('Este Servicio Social no existe en la db.');
|
||||
|
||||
try {
|
||||
if (files['cartaAceptacion'][0].filename)
|
||||
dataUpdate.cartaAceptacion = await drive.uploadFile(
|
||||
@@ -54,18 +51,15 @@ const update = async (body, files) => {
|
||||
);
|
||||
if (body.telefono)
|
||||
dataUpdate.telefono = validar.validarNumero(body.telefono, 15);
|
||||
|
||||
if (validar.isObjectEmpty(dataUpdate))
|
||||
throw new Error(
|
||||
'No se envio nada para actualizar este Servicio Social'
|
||||
);
|
||||
return Servicio.update(dataUpdate, { where: { idServicio } });
|
||||
})
|
||||
.then((res) => {
|
||||
return {
|
||||
message: 'Se guadro correctamente los cambios de este servicio.',
|
||||
};
|
||||
});
|
||||
.then((res) => ({
|
||||
message: 'Se guadro correctamente los cambios de este servicio.',
|
||||
}));
|
||||
};
|
||||
|
||||
module.exports = update;
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
const Status = require('../../db/tablas/Status');
|
||||
|
||||
const get = () => {
|
||||
return Status.findAll().then((res) => {
|
||||
return res;
|
||||
});
|
||||
};
|
||||
const get = () => Status.findAll();
|
||||
|
||||
module.exports = get;
|
||||
|
||||
@@ -5,7 +5,7 @@ const Usuario = require('../../db/tablas/Usuario');
|
||||
const Carrera = require('../../db/tablas/Carrera');
|
||||
|
||||
const escolares = async (body) => {
|
||||
let numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta);
|
||||
const numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta);
|
||||
let alumno;
|
||||
|
||||
return axios({
|
||||
@@ -14,16 +14,14 @@ const escolares = async (body) => {
|
||||
data: `${process.env.ESCOLARES_PASS}`,
|
||||
})
|
||||
.then((res) => {
|
||||
let data = res.data;
|
||||
|
||||
if (!data.nombre || !data.carrconst || !data.avance)
|
||||
if (!res.data.nombre || !res.data.carrconst || !res.data.avance)
|
||||
throw new Error(
|
||||
'El alumno no cumple con los requicitos para realizar el Servicio Social. Si cree que esto es erroneo comunicate con COESI.'
|
||||
);
|
||||
alumno = {
|
||||
nombre: data.nombre.trim(),
|
||||
creditos: data.avance,
|
||||
carrera: data.carrconst.trim(),
|
||||
nombre: res.data.nombre.trim(),
|
||||
creditos: res.data.avance,
|
||||
carrera: res.data.carrconst.trim(),
|
||||
};
|
||||
return Carrera.findOne({ where: { carrera: alumno.carrera } });
|
||||
})
|
||||
@@ -45,9 +43,7 @@ const escolares = async (body) => {
|
||||
});
|
||||
return res;
|
||||
})
|
||||
.then((res) => {
|
||||
return { ...alumno, idUsuario: res.idUsuario };
|
||||
});
|
||||
.then((res) => ({ ...alumno, idUsuario: res.idUsuario }));
|
||||
};
|
||||
|
||||
module.exports = escolares;
|
||||
|
||||
@@ -5,28 +5,28 @@ const Usuario = require('../../db/tablas/Usuario');
|
||||
const TipoUsuario = require('../../db/tablas/TipoUsuario');
|
||||
|
||||
const login = async (body) => {
|
||||
let usuario = validar.validar(body.usuario, 'El usuario', 60);
|
||||
let password = validar.validarAlfanumerico(body.password, 'El password', 20);
|
||||
const usuario = validar.validar(body.usuario, 'El usuario', 60);
|
||||
const password = validar.validarAlfanumerico(
|
||||
body.password,
|
||||
'El password',
|
||||
20
|
||||
);
|
||||
|
||||
return Usuario.findOne({
|
||||
where: { usuario, activo: true },
|
||||
where: { usuario },
|
||||
include: [{ model: TipoUsuario }],
|
||||
}).then((res) => {
|
||||
if (!res) throw new Error('No existe este usuario.');
|
||||
if (!res.activo) throw new Error('Este usuario no esta activo.');
|
||||
if (encriptar.comparar(password, res.password)) {
|
||||
delete res.dataValues.password;
|
||||
delete res.dataValues.activo;
|
||||
return {
|
||||
Usuario: {
|
||||
idUsuario: res.idUsuario,
|
||||
usuario: res.usuario,
|
||||
nombre: res.nombre,
|
||||
TipoUsuario: {
|
||||
idTipoUsuario: res.TipoUsuario.idTipoUsuario,
|
||||
tipoUsuario: res.TipoUsuario.tipoUsuario,
|
||||
},
|
||||
},
|
||||
Usuario: res,
|
||||
token: crearToken(res.idUsuario),
|
||||
};
|
||||
}
|
||||
throw new Error('La contraseña es incorrecta');
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -6,9 +6,10 @@ const Usuario = require('../../db/tablas/Usuario');
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
const newPasswordAlumno = async (body) => {
|
||||
let idServicio = await validar.validarId(body.idServicio);
|
||||
let pasword = encriptar.generarPassword();
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const password = encriptar.generarPassword();
|
||||
let idUsuario;
|
||||
let correo = {};
|
||||
|
||||
return Servicio.findOne({
|
||||
where: { idServicio },
|
||||
@@ -18,23 +19,19 @@ const newPasswordAlumno = async (body) => {
|
||||
if (!res) throw new Error('No existe este Servicio Social.');
|
||||
if (res.Usuario.idTipoUsuario != 3)
|
||||
throw new Error('Este usuario no es de tipo alumno.');
|
||||
|
||||
let correo = correos.preRegistro(pasword, res.Usuario.nombre);
|
||||
|
||||
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) },
|
||||
.then((res) =>
|
||||
Usuario.update(
|
||||
{ password: encriptar.encriptar(password) },
|
||||
{ where: { idUsuario } }
|
||||
);
|
||||
})
|
||||
.then((res) => {
|
||||
return {
|
||||
message: 'Se envio un correo con una contraseña nueva al alumno.',
|
||||
};
|
||||
});
|
||||
)
|
||||
)
|
||||
.then((res) => ({
|
||||
message: 'Se envio un correo con una contraseña nueva al alumno.',
|
||||
}));
|
||||
};
|
||||
|
||||
module.exports = newPasswordAlumno;
|
||||
|
||||
@@ -5,29 +5,27 @@ const validar = require('../../helper/validar');
|
||||
const Usuario = require('../../db/tablas/Usuario');
|
||||
|
||||
const newPasswordResponsable = async (body) => {
|
||||
let idUsuario = await validar.validarId(body.idUsuario);
|
||||
let pasword = encriptar.generarPassword();
|
||||
const idUsuario = await validar.validarId(body.idUsuario);
|
||||
const password = encriptar.generarPassword();
|
||||
let correo = {};
|
||||
|
||||
return Usuario.findOne({ where: { idUsuario } })
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe este Usuario.');
|
||||
if (res.Usuario.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);
|
||||
if (res.idTipoUsuario != 2)
|
||||
throw new Error('Este usuario no es de tipo responsable.');
|
||||
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) },
|
||||
.then((res) =>
|
||||
Usuario.update(
|
||||
{ password: encriptar.encriptar(password) },
|
||||
{ where: { idUsuario } }
|
||||
);
|
||||
})
|
||||
.then((res) => {
|
||||
return {
|
||||
message: 'Se envio un correo con una contraseña nueva al responsable.',
|
||||
};
|
||||
});
|
||||
)
|
||||
)
|
||||
.then((res) => ({
|
||||
message: 'Se envio un correo con una contraseña nueva al responsable.',
|
||||
}));
|
||||
};
|
||||
|
||||
module.exports = newPasswordResponsable;
|
||||
|
||||
@@ -4,13 +4,14 @@ const Usuario = require('../../db/tablas/Usuario');
|
||||
const TipoUsuario = require('../../db/tablas/TipoUsuario');
|
||||
|
||||
const responsable = async (body) => {
|
||||
let pagina = validar.validarId(body.pagina);
|
||||
let nombre = body.nombre
|
||||
const pagina = validar.validarId(body.pagina);
|
||||
const nombre = body.nombre
|
||||
? validar.validarTexto(body.nombre, 'El nombre', 60)
|
||||
: '';
|
||||
let correo = body.correo
|
||||
const correo = body.correo
|
||||
? validar.validar(body.correo, 'El correo', 1000)
|
||||
: '';
|
||||
const data = [];
|
||||
|
||||
return Usuario.findAll({
|
||||
where: {
|
||||
@@ -20,19 +21,11 @@ const responsable = async (body) => {
|
||||
},
|
||||
include: [{ model: TipoUsuario }],
|
||||
}).then((res) => {
|
||||
let data = [];
|
||||
|
||||
for (let i = pagina * 25 - 25; i < res.length && i < pagina * 25; i++)
|
||||
data.push({
|
||||
idUsuario: res[i].idUsuario,
|
||||
usuario: res[i].usuario,
|
||||
nombre: res[i].nombre,
|
||||
activo: res[i].activo,
|
||||
TipoUsuario: {
|
||||
idTipoUsuario: res[i].TipoUsuario.idTipoUsuario,
|
||||
tipoUsuario: res[i].TipoUsuario.tipoUsuario,
|
||||
},
|
||||
});
|
||||
for (let i = pagina * 25 - 25; i < res.length && i < pagina * 25; i++) {
|
||||
delete res[i].dataValues.password;
|
||||
delete res[i].dataValues.idTipoUsuario;
|
||||
data.push(res[i]);
|
||||
}
|
||||
return {
|
||||
registros: res.length,
|
||||
faltantes: res.length - data.length - (pagina - 1) * 25,
|
||||
|
||||
@@ -3,8 +3,8 @@ const validar = require('../../helper/validar');
|
||||
const Usuario = require('../../db/tablas/Usuario');
|
||||
|
||||
const responsableUpdate = async (body) => {
|
||||
let idUsuario = validar.validarId(body.idUsuario);
|
||||
let dataUpdate = {};
|
||||
const idUsuario = validar.validarId(body.idUsuario);
|
||||
const dataUpdate = {};
|
||||
|
||||
return Usuario.findOne({ where: { idUsuario } })
|
||||
.then(async (res) => {
|
||||
@@ -30,12 +30,10 @@ const responsableUpdate = async (body) => {
|
||||
throw new Error('No se a envio nada para actualizar.');
|
||||
return Usuario.update(dataUpdate, { where: { idUsuario } });
|
||||
})
|
||||
.then((res) => {
|
||||
return {
|
||||
message:
|
||||
'Se actualizó la información de este responsable de programas correctamente.',
|
||||
};
|
||||
});
|
||||
.then((res) => ({
|
||||
message:
|
||||
'Se actualizó la información de este responsable de programas correctamente.',
|
||||
}));
|
||||
};
|
||||
|
||||
module.exports = responsableUpdate;
|
||||
|
||||
+10
-21
@@ -7,27 +7,15 @@ const Servicio = require('./tablas/Servicio');
|
||||
const Usuario = require('./tablas/Usuario');
|
||||
|
||||
const guardar = async () => {
|
||||
let idsProgramas = [];
|
||||
let idsAlumnos = [];
|
||||
let idsRegistros = [];
|
||||
let responsables = await csv()
|
||||
.fromFile('db/responsable.csv')
|
||||
.then((res) => res);
|
||||
let programas = await csv()
|
||||
.fromFile('db/programa.csv')
|
||||
.then((res) => res);
|
||||
let alumnos = await csv()
|
||||
.fromFile('db/alumno.csv')
|
||||
.then((res) => res);
|
||||
let registros = await csv()
|
||||
.fromFile('db/registro.csv')
|
||||
.then((res) => res);
|
||||
let cuestionariosAlumno = await csv()
|
||||
.fromFile('db/cuestionarioA.csv')
|
||||
.then((res) => res);
|
||||
let cuestionariosPrograma = await csv()
|
||||
.fromFile('db/cuestionarioP.csv')
|
||||
.then((res) => res);
|
||||
const idsProgramas = [];
|
||||
const idsAlumnos = [];
|
||||
const idsRegistros = [];
|
||||
const responsables = await csv().fromFile('db/responsable.csv');
|
||||
let programas = await csv().fromFile('db/programa.csv');
|
||||
let alumnos = await csv().fromFile('db/alumno.csv');
|
||||
let registros = await csv().fromFile('db/registro.csv');
|
||||
let cuestionariosAlumno = await csv().fromFile('db/cuestionarioA.csv');
|
||||
let cuestionariosPrograma = await csv().fromFile('db/cuestionarioP.csv');
|
||||
|
||||
for (let i = 0; i < responsables.length; i++) {
|
||||
await Usuario.create({
|
||||
@@ -50,6 +38,7 @@ const guardar = async () => {
|
||||
clavePrograma: programas[j].clavePrograma,
|
||||
acatlan: responsables[i].acatlanContigo === 'true' ? true : false,
|
||||
activo: true,
|
||||
// activo: false,
|
||||
idUsuario: res.dataValues.idUsuario,
|
||||
})
|
||||
.then((res) => {
|
||||
|
||||
@@ -213,7 +213,6 @@ app.put(
|
||||
{ name: 'informeGlobal', maxCount: 1 },
|
||||
]),
|
||||
(req, res) => {
|
||||
console.log('hola');
|
||||
return update(JSON.parse(req.body.data), req.files)
|
||||
.then((data) => {
|
||||
res.status(200).json(data);
|
||||
|
||||
Reference in New Issue
Block a user