Compare commits
41 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2fc5c1f5fa | |||
| 53786516df | |||
| 6c7919af90 | |||
| afc29c4208 | |||
| 74e3c265b0 | |||
| 9cc59919f8 | |||
| 620c5da07c | |||
| 6c1d967c8c | |||
| 0aa406fb15 | |||
| 62eb0dc90c | |||
| 46fc456911 | |||
| efb4a7c374 | |||
| a750f1f71b | |||
| 3a7b2a6629 | |||
| 5623c90bda | |||
| a07a77bd8d | |||
| 6130f055b3 | |||
| 339001c6e6 | |||
| 481096e851 | |||
| 9a982a215f | |||
| 661f4985ee | |||
| 0b04777c0c | |||
| 9b153520e8 | |||
| 9fc6e4485a | |||
| 9560014865 | |||
| 7b5e36b402 | |||
| c0f37baf25 | |||
| 998be4bb38 | |||
| 11e7759ae0 | |||
| 97dab2df96 | |||
| 9ea6ad601c | |||
| 841d9b06a5 | |||
| d469b1cdc6 | |||
| fb57ee6b93 | |||
| e82093c967 | |||
| 3bad72ee52 | |||
| 4121f8d0ad | |||
| b4373c770f | |||
| 649aebcac9 | |||
| 50d0758f65 | |||
| 7de43b5daf |
Generated
+1313
-1562
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
const { validarId } = require('../../helper/validar');
|
||||
const { validarNumeroEntero } = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const CasoEspecial = require(`${dbPath}/CasoEspecial`);
|
||||
@@ -7,7 +7,10 @@ const TipoUsuario = require(`${dbPath}/TipoUsuario`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const admin = async (body) => {
|
||||
const idCasoEspecial = validarId(body.idCasoEspecial);
|
||||
const idCasoEspecial = validarNumeroEntero(
|
||||
body.idCasoEspecial,
|
||||
'id caso especial'
|
||||
);
|
||||
|
||||
return CasoEspecial.findOne({
|
||||
where: { idCasoEspecial },
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
const helperPath = '../../helper';
|
||||
const correos = require(`${helperPath}/correos`);
|
||||
const gmail = require(`${helperPath}/gmail`);
|
||||
const { validarId } = require(`${helperPath}/validar`);
|
||||
const { validarNumeroEntero } = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const CasoEspecial = require(`${dbPath}/CasoEspecial`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const liberacion = async (body) => {
|
||||
const idCasoEspecial = validarId(body.idCasoEspecial);
|
||||
const idCasoEspecial = validarNumeroEntero(
|
||||
body.idCasoEspecial,
|
||||
'id caso especial'
|
||||
);
|
||||
let update = {};
|
||||
|
||||
return CasoEspecial.findOne({
|
||||
@@ -33,7 +36,7 @@ const liberacion = async (body) => {
|
||||
.then((res) => CasoEspecial.update(update, { where: { idCasoEspecial } }))
|
||||
.then((res) => ({
|
||||
message:
|
||||
'Se cambio de estatus correctamente y se envio un correo al alumno informandole de su liberación.',
|
||||
'Se cambió de estatus correctamente y se envió un correo al alumno informandole de su liberación.',
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
@@ -7,32 +7,46 @@ const CasoEspecial = require(`${dbPath}/CasoEspecial`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const nuevo = async (body, file) => {
|
||||
const idUsuario = validar.validarId(body.idUsuario);
|
||||
const idCarrera = validar.validarId(body.idCarrera);
|
||||
const idStatus = validar.validarId(body.idStatus);
|
||||
const idUsuario = validar.validarNumeroEntero(body.idUsuario, 'id usuario');
|
||||
const idCarrera = validar.validarNumeroEntero(body.idCarrera, 'id carrera');
|
||||
const idStatus = validar.validarNumeroEntero(body.idStatus, 'id status');
|
||||
const numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta);
|
||||
const creditos = validar.validarNumero(body.creditos);
|
||||
const correo = validar.validarCorreo(body.correo);
|
||||
const telefono = validar.validarNumero(body.telefono, 15);
|
||||
const fechaInicio = validar.validarFecha(body.fechaInicio);
|
||||
const fechaFin = validar.validarFecha(body.fechaFin);
|
||||
const fechaNacimiento = validar.validarFecha(body.fechaNacimiento);
|
||||
const creditos = validar.validarNumero(body.creditos, 'créditos', true);
|
||||
const telefono = validar.validarNumero(body.telefono, 'teléfono', true, 15);
|
||||
const fechaInicio = validar.validarFecha(
|
||||
body.fechaInicio,
|
||||
'fecha de inicio',
|
||||
false
|
||||
);
|
||||
const fechaFin = validar.validarFecha(body.fechaFin, 'fecha fin', false);
|
||||
const fechaNacimiento = validar.validarFecha(
|
||||
body.fechaNacimiento,
|
||||
'fecha de nacimiento',
|
||||
false
|
||||
);
|
||||
const direccion = validar.validarAlfanumerico(
|
||||
body.direccion,
|
||||
'La dirección',
|
||||
'dirección',
|
||||
false,
|
||||
200
|
||||
);
|
||||
const institucion = body.institucion
|
||||
? validar.validarTexto(body.institucion, 'El texto institucion.', 200)
|
||||
? validar.validarTexto(body.institucion, 'institucion', false, 200)
|
||||
: '';
|
||||
const dependencia = body.dependencia
|
||||
? validar.validarTexto(body.dependencia, 'El texto dependencia.', 200)
|
||||
? validar.validarAlfanumerico(body.dependencia, 'dependencia', false, 200)
|
||||
: '';
|
||||
const motivo = body.motivo
|
||||
? validar.validarNumero(body.motivo, 'El texto motivo.', 1)
|
||||
? validar.validarNumero(body.motivo, 'motivo', true, 1)
|
||||
: '';
|
||||
const path = `./server/uploads/${validar.validacionBasicaStr(
|
||||
file,
|
||||
'archivo',
|
||||
true,
|
||||
1000
|
||||
)}`;
|
||||
let carpeta = '';
|
||||
const path = `./server/uploads/${validar.validar(file, 'El archivo', 1000)}`;
|
||||
|
||||
return Usuario.findOne({
|
||||
where: { idUsuario },
|
||||
|
||||
@@ -7,12 +7,19 @@ const Status = require(`${dbPath}/Status`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const serviciosEspeciales = async (body) => {
|
||||
const pagina = validar.validarNumero(body.pagina, true);
|
||||
const pagina = validar.validarNumero(
|
||||
body.pagina,
|
||||
'página',
|
||||
false,
|
||||
null,
|
||||
true,
|
||||
true
|
||||
);
|
||||
const where = body.idStatus
|
||||
? { idStatus: validar.validarId(body.idStatus) }
|
||||
? { idStatus: validar.validarNumeroEntero(body.idStatus, 'id status') }
|
||||
: { idStatus: { [Op.gt]: 10 } };
|
||||
const nombre = body.nombre
|
||||
? validar.validarTexto(body.nombre, 'El nombre', 60)
|
||||
? validar.validarTexto(body.nombre, 'nombre', true, 60)
|
||||
: '';
|
||||
const numeroCuenta = body.numeroCuenta
|
||||
? validar.validarNumeroCuenta(body.numeroCuenta)
|
||||
|
||||
@@ -2,7 +2,10 @@ const validar = require('../../helper/validar');
|
||||
const CasoEspecial = require('../../db/tablas/CasoEspecial');
|
||||
|
||||
const update = async (body) => {
|
||||
const idCasoEspecial = validar.validarId(body.idCasoEspecial);
|
||||
const idCasoEspecial = validar.validarNumeroEntero(
|
||||
body.idCasoEspecial,
|
||||
'id caso especial'
|
||||
);
|
||||
const dataUpdate = {};
|
||||
|
||||
return CasoEspecial.findOne({ where: { idCasoEspecial } })
|
||||
@@ -10,45 +13,64 @@ const update = async (body) => {
|
||||
if (!res) throw new Error('Este Caso Especial no existe en la db.');
|
||||
if (body.correo) dataUpdate.correo = validar.validarCorreo(body.correo);
|
||||
if (body.fechaInicio)
|
||||
dataUpdate.fechaInicio = validar.validarFecha(body.fechaInicio);
|
||||
dataUpdate.fechaInicio = validar.validarFecha(
|
||||
body.fechaInicio,
|
||||
'fecha de inicio',
|
||||
false
|
||||
);
|
||||
if (body.fechaFin)
|
||||
dataUpdate.fechaFin = validar.validarFecha(body.fechaFin);
|
||||
dataUpdate.fechaFin = validar.validarFecha(
|
||||
body.fechaFin,
|
||||
'fecha fin',
|
||||
false
|
||||
);
|
||||
if (body.fechaNacimiento)
|
||||
dataUpdate.fechaNacimiento = validar.validarFecha(body.fechaNacimiento);
|
||||
dataUpdate.fechaNacimiento = validar.validarFecha(
|
||||
body.fechaNacimiento,
|
||||
'fecha de nacimiento',
|
||||
false
|
||||
);
|
||||
if (body.direccion)
|
||||
dataUpdate.direccion = validar.validarAlfanumerico(
|
||||
body.direccion,
|
||||
'La dirección',
|
||||
'dirección',
|
||||
false,
|
||||
200
|
||||
);
|
||||
if (body.telefono)
|
||||
dataUpdate.telefono = validar.validarNumero(body.telefono, 15);
|
||||
dataUpdate.telefono = validar.validarNumero(
|
||||
body.telefono,
|
||||
'teléfono',
|
||||
true,
|
||||
15
|
||||
);
|
||||
if (body.institucion)
|
||||
dataUpdate.institucion = validar.validarTexto(
|
||||
body.institucion,
|
||||
'El texto institucion.',
|
||||
'institucion',
|
||||
false,
|
||||
200
|
||||
);
|
||||
if (body.dependencia)
|
||||
dataUpdate.dependencia = validar.validarTexto(
|
||||
body.dependencia,
|
||||
'El texto dependencia.',
|
||||
'dependencia',
|
||||
false,
|
||||
200
|
||||
);
|
||||
if (body.motivo)
|
||||
dataUpdate.motivo = validar.validarNumero(
|
||||
body.motivo,
|
||||
'El texto motivo.',
|
||||
'motivo',
|
||||
true,
|
||||
1
|
||||
);
|
||||
if (validar.validarObjetoVacio(dataUpdate))
|
||||
throw new Error(
|
||||
'No se envio nada para actualizar este Caso Especial.'
|
||||
);
|
||||
throw new Error('No se envio nada para actualizar este caso especial.');
|
||||
return CasoEspecial.update(dataUpdate, { where: { idCasoEspecial } });
|
||||
})
|
||||
.then((res) => ({
|
||||
message: 'Se guardo correctamente los cambios de este servicio.',
|
||||
message: 'Se guardo correctamente los cambios de este caso especial.',
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
@@ -4,13 +4,14 @@ const helperPath = '../../helper';
|
||||
const helper = require(`${helperPath}/helper`);
|
||||
const { validarNumero } = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const CuestionarioAlumno = require(`${dbPath}/CuestionarioAlumno`);
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
const Servicio = require(`${dbPath}/Servicio`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const get = async (body) => {
|
||||
const year = validarNumero(body.year, 4);
|
||||
const year = validarNumero(body.year, 'año', true, 4);
|
||||
const path = `server/uploads/${year}_cuestionario_alumno.csv`;
|
||||
const data = [];
|
||||
|
||||
@@ -22,6 +23,7 @@ const get = async (body) => {
|
||||
},
|
||||
{ model: Programa, where: { clavePrograma: { [Op.like]: `${year}%` } } },
|
||||
{ model: Usuario },
|
||||
{ model: Carrera },
|
||||
],
|
||||
order: [['createdAt']],
|
||||
})
|
||||
@@ -32,6 +34,7 @@ const get = async (body) => {
|
||||
clavePrograma: res[i].Programa.clavePrograma,
|
||||
usuario: res[i].Usuario.usuario,
|
||||
nombre: res[i].Usuario.nombre,
|
||||
carrera: res[i].Carrera.carrera,
|
||||
idCuestionarioAlumno: res[i].CuestionarioAlumno.idCuestionarioAlumno,
|
||||
sexo: res[i].CuestionarioAlumno.sexo,
|
||||
edad: res[i].CuestionarioAlumno.edad,
|
||||
@@ -73,9 +76,7 @@ const get = async (body) => {
|
||||
});
|
||||
return helper.crearArchivo(path, convertArrayToCSV(data));
|
||||
})
|
||||
.then((res) => {
|
||||
return path;
|
||||
});
|
||||
.then((res) => path);
|
||||
};
|
||||
|
||||
module.exports = get;
|
||||
|
||||
@@ -4,7 +4,10 @@ const CuestionarioAlumno = require(`${dbPath}/CuestionarioAlumno`);
|
||||
const Servicio = require(`${dbPath}/Servicio`);
|
||||
|
||||
const nuevo = async (body) => {
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const idServicio = validar.validarNumeroEntero(
|
||||
body.idServicio,
|
||||
'id servicio'
|
||||
);
|
||||
const sexo = body.sexo;
|
||||
const edad = body.edad;
|
||||
const servicioMedico = body.servicioMedico;
|
||||
|
||||
@@ -5,13 +5,14 @@ const helperPath = '../../helper';
|
||||
const helper = require(`${helperPath}/helper`);
|
||||
const { validarNumero } = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const CuestionarioPrograma = require(`${dbPath}/CuestionarioPrograma`);
|
||||
const Servicio = require(`${dbPath}/Servicio`);
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const get = async (body) => {
|
||||
const year = validarNumero(body.year, 4);
|
||||
const year = validarNumero(body.year, 'año', true, 4);
|
||||
const path = `server/uploads/${year}_cuestionario_programa.csv`;
|
||||
const data = [];
|
||||
|
||||
@@ -23,6 +24,7 @@ const get = async (body) => {
|
||||
},
|
||||
{ model: Programa, where: { clavePrograma: { [Op.like]: `${year}-%` } } },
|
||||
{ model: Usuario },
|
||||
{ model: Carrera },
|
||||
],
|
||||
order: [['createdAt']],
|
||||
})
|
||||
@@ -33,6 +35,7 @@ const get = async (body) => {
|
||||
clavePrograma: res[i].Programa.clavePrograma,
|
||||
usuario: res[i].Usuario.usuario,
|
||||
nombre: res[i].Usuario.nombre,
|
||||
carrera: res[i].Carrera.carrera,
|
||||
idCuestionarioPrograma:
|
||||
res[i].CuestionarioPrograma.idCuestionarioPrograma,
|
||||
actividad1: res[i].CuestionarioPrograma.actividad1,
|
||||
@@ -50,9 +53,7 @@ const get = async (body) => {
|
||||
});
|
||||
return helper.crearArchivo(path, convertArrayToCSV(data));
|
||||
})
|
||||
.then((res) => {
|
||||
return path;
|
||||
});
|
||||
.then((res) => path);
|
||||
};
|
||||
|
||||
module.exports = get;
|
||||
|
||||
@@ -4,7 +4,10 @@ const CuestionarioPrograma = require(`${dbPath}/CuestionarioPrograma`);
|
||||
const Servicio = require(`${dbPath}/Servicio`);
|
||||
|
||||
const nuevo = async (body) => {
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const idServicio = validar.validarNumeroEntero(
|
||||
body.idServicio,
|
||||
'id servicio'
|
||||
);
|
||||
const actividad1 = body.actividad1;
|
||||
const actividad2 = body.actividad2;
|
||||
const actividad3 = body.actividad3;
|
||||
|
||||
@@ -133,18 +133,10 @@ const cargaMasiva = async (file) => {
|
||||
mensaje += '\n';
|
||||
}
|
||||
await gmail('Reporte carga masiva', 'lemuel@acatlan.unam.mx', mensaje);
|
||||
// await gmail('Reporte carga masiva', 'dscad@acatlan.unam.mx', mensaje);
|
||||
// await gmail(
|
||||
// 'Reporte carga masiva',
|
||||
// 'tramites.ss@acatlan.unam.mx',
|
||||
// mensaje
|
||||
// );
|
||||
|
||||
fs.unlinkSync(path);
|
||||
});
|
||||
return {
|
||||
message:
|
||||
'Se subio correctamente el archivo csv, se enviará un correo a tramites.ss@acatlan.unam.mx con los detalles de la carga masiva.',
|
||||
message: 'Se subio correctamente el archivo csv para la carga masiva.',
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
const { validarId } = require('../../helper/validar');
|
||||
const { validarNumeroEntero } = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const programasAdmin = async (body) => {
|
||||
const idUsuario = validarId(body.idUsuario);
|
||||
const idUsuario = validarNumeroEntero(body.idUsuario, 'id usuario');
|
||||
|
||||
return Usuario.findOne({
|
||||
where: { idUsuario },
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
const { validarId } = require('../../helper/validar');
|
||||
const { validarNumeroEntero } = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const programasResponsable = async (body) => {
|
||||
const idUsuario = validarId(body.idUsuario);
|
||||
const idUsuario = validarNumeroEntero(body.idUsuario, 'id usuario');
|
||||
|
||||
return Usuario.findOne({
|
||||
where: { idUsuario },
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
const { validarId, validarCorreo } = require('../../helper/validar');
|
||||
const validar = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const reasignarProgramas = async (body) => {
|
||||
const idUsuario = validarId(body.idUsuario);
|
||||
const correoOtroResponsable = validarCorreo(body.correoOtroResponsable);
|
||||
const idUsuario = validar.validarNumeroEntero(body.idUsuario, 'id usuario');
|
||||
const correoOtroResponsable = validar.validarCorreo(
|
||||
body.correoOtroResponsable
|
||||
);
|
||||
let otorResponsable = {};
|
||||
|
||||
return Usuario.findOne({
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { validarId } = require('../../helper/validar');
|
||||
const { validarNumeroEntero } = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
@@ -8,7 +8,7 @@ const TipoUsuario = require(`${dbPath}/TipoUsuario`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const admin = async (body) => {
|
||||
const idServicio = validarId(body.idServicio);
|
||||
const idServicio = validarNumeroEntero(body.idServicio, 'id servicio');
|
||||
|
||||
return Servicio.findOne({
|
||||
where: { idServicio },
|
||||
@@ -16,12 +16,13 @@ const admin = async (body) => {
|
||||
{ model: Usuario, include: [{ model: TipoUsuario }] },
|
||||
{ model: Carrera },
|
||||
{ model: Status },
|
||||
{ model: Programa },
|
||||
{ model: Programa, include: [{ model: Usuario }] },
|
||||
],
|
||||
}).then((res) => {
|
||||
if (!res) throw new Error('No existe este servicio social.');
|
||||
delete res.dataValues.Usuario.dataValues.password;
|
||||
delete res.dataValues.Programa.dataValues.idUsuario;
|
||||
delete res.dataValues.Programa.dataValues.Usuario.dataValues.password;
|
||||
delete res.dataValues.idUsuario;
|
||||
delete res.dataValues.idCarrera;
|
||||
delete res.dataValues.idStatus;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const { Op } = require('sequelize');
|
||||
const { validarId } = require('../../helper/validar');
|
||||
const { validarNumeroEntero } = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
@@ -8,7 +8,7 @@ const Status = require(`${dbPath}/Status`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const alumno = async (body) => {
|
||||
let idUsuario = validarId(body.idUsuario);
|
||||
let idUsuario = validarNumeroEntero(body.idUsuario, 'id usuario');
|
||||
|
||||
return Usuario.findOne({ where: { idUsuario } })
|
||||
.then((res) => {
|
||||
|
||||
@@ -8,8 +8,16 @@ const Servicio = require(`${dbPath}/Servicio`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const cancelar = async (body) => {
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const mensaje = validar.validarAlfanumerico(body.mensaje, 'El mensaje', 800);
|
||||
const idServicio = validar.validarNumeroEntero(
|
||||
body.idServicio,
|
||||
'id servicio'
|
||||
);
|
||||
const mensaje = validar.validarAlfanumerico(
|
||||
body.mensaje,
|
||||
'mensaje',
|
||||
true,
|
||||
800
|
||||
);
|
||||
let correoResponsable = {};
|
||||
let correoAlumno = {};
|
||||
let emailResponsable = '';
|
||||
|
||||
@@ -4,8 +4,16 @@ const validar = require(`${helperPath}/validar`);
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
const cartaTermino = async (body, file) => {
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const path = `./server/uploads/${validar.validar(file, 'El archivo', 1000)}`;
|
||||
const idServicio = validar.validarNumeroEntero(
|
||||
body.idServicio,
|
||||
'id servicio'
|
||||
);
|
||||
const path = `./server/uploads/${validar.validacionBasicaStr(
|
||||
file,
|
||||
'archivo',
|
||||
true,
|
||||
1000
|
||||
)}`;
|
||||
|
||||
return Servicio.findOne({
|
||||
where: { idServicio },
|
||||
|
||||
@@ -4,8 +4,16 @@ const validar = require(`${helperPath}/validar`);
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
const cartaTermino = async (body, file) => {
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const path = `./server/uploads/${validar.validar(file, 'El archivo', 1000)}`;
|
||||
const idServicio = validar.validarNumeroEntero(
|
||||
body.idServicio,
|
||||
'id servicio'
|
||||
);
|
||||
const path = `./server/uploads/${validar.validacionBasicaStr(
|
||||
file,
|
||||
'archivo',
|
||||
true,
|
||||
1000
|
||||
)}`;
|
||||
|
||||
return Servicio.findOne({
|
||||
where: { idServicio },
|
||||
|
||||
@@ -10,7 +10,7 @@ const Servicio = require(`${dbPath}/Servicio`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const gustavoBazPrada = async (body) => {
|
||||
const year = validar.validarNumero(body.year, 4);
|
||||
const year = validar.validarNumero(body.year, 'año', true, 4);
|
||||
const inicio = moment(`${year}-01-31`);
|
||||
const fin = moment(`${parseInt(year) + 1}-01-31`);
|
||||
const path = `server/uploads/${year}_gustavo_baz_prada.csv`;
|
||||
|
||||
@@ -4,8 +4,16 @@ const validar = require(`${helperPath}/validar`);
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
const informeGlobal = async (body, file) => {
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const path = `./server/uploads/${validar.validar(file, 'El archivo', 1000)}`;
|
||||
const idServicio = validar.validarNumeroEntero(
|
||||
body.idServicio,
|
||||
'id servicio'
|
||||
);
|
||||
const path = `./server/uploads/${validar.validacionBasicaStr(
|
||||
file,
|
||||
'archivo',
|
||||
true,
|
||||
1000
|
||||
)}`;
|
||||
|
||||
return Servicio.findOne({
|
||||
where: { idServicio },
|
||||
|
||||
@@ -9,7 +9,10 @@ const Servicio = require(`${dbPath}/Servicio`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const liberacion = async (body) => {
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const idServicio = validar.validarNumeroEntero(
|
||||
body.idServicio,
|
||||
'id servicio'
|
||||
);
|
||||
const update = { idStatus: 6, fechaLiberacion: moment().format() };
|
||||
let correo = {};
|
||||
|
||||
|
||||
@@ -9,30 +9,40 @@ const Servicio = require(`${dbPath}/Servicio`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const nuevo = async (body, file) => {
|
||||
const idUsuario = validar.validarId(body.idUsuario);
|
||||
const idPrograma = validar.validarId(body.idPrograma);
|
||||
const idCarrera = validar.validarId(body.idCarrera);
|
||||
const idUsuario = validar.validarNumeroEntero(body.idUsuario, 'id usuario');
|
||||
const idPrograma = validar.validarNumeroEntero(
|
||||
body.idPrograma,
|
||||
'id programa'
|
||||
);
|
||||
const idCarrera = validar.validarNumeroEntero(body.idCarrera, 'id carrera');
|
||||
const numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta);
|
||||
const creditos = validar.validarNumero(body.creditos);
|
||||
const creditos = validar.validarNumero(body.creditos, 'créditos', true);
|
||||
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 fechaInicio = validar.validarFecha(
|
||||
body.fechaInicio,
|
||||
'fecha de inicio',
|
||||
false
|
||||
);
|
||||
const fechaFin = validar.validarFecha(body.fechaFin, 'fecha fin', false);
|
||||
const path = `./server/uploads/${validar.validacionBasicaStr(
|
||||
file,
|
||||
'archivo',
|
||||
true,
|
||||
1000
|
||||
)}`;
|
||||
const programaInterno = body.programaInterno
|
||||
? validar.validarAlfanumerico(
|
||||
body.programaInterno,
|
||||
'El texto programa interno',
|
||||
'programa interno',
|
||||
true,
|
||||
250
|
||||
)
|
||||
: '';
|
||||
const profesor = body.profesor
|
||||
? validar.validarTexto(body.profesor, 'El texto de profesor.', 50)
|
||||
? validar.validarTexto(body.profesor, 'profesor', true, 50)
|
||||
: '';
|
||||
let carpeta = '';
|
||||
|
||||
return Usuario.findOne({
|
||||
where: { idUsuario },
|
||||
})
|
||||
return Usuario.findOne({ where: { idUsuario } })
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('Este alumno no existe en la db.');
|
||||
if (res.idTipoUsuario !== 3)
|
||||
@@ -52,19 +62,7 @@ const nuevo = async (body, file) => {
|
||||
.then(async (res) => {
|
||||
if (res)
|
||||
throw new Error('Este alumno ya tienen un Servicio Social activo.');
|
||||
return drive.folder(numeroCuenta);
|
||||
})
|
||||
.then((res) => {
|
||||
carpeta = res;
|
||||
return drive.uploadFile(
|
||||
path,
|
||||
`Carta_Aceptacion.pdf`,
|
||||
'application/pdf',
|
||||
carpeta
|
||||
);
|
||||
})
|
||||
.then((res) =>
|
||||
Servicio.create({
|
||||
return Servicio.create({
|
||||
idUsuario,
|
||||
idPrograma,
|
||||
idCarrera,
|
||||
@@ -72,15 +70,34 @@ const nuevo = async (body, file) => {
|
||||
correo,
|
||||
fechaInicio: fechaInicio.format(),
|
||||
fechaFin: fechaFin.format(),
|
||||
carpeta,
|
||||
cartaAceptacion: res,
|
||||
carpeta: '',
|
||||
cartaAceptacion: '',
|
||||
profesor,
|
||||
programaInterno,
|
||||
})
|
||||
)
|
||||
.then((res) => ({
|
||||
message: `Se Pre-Registro correctamente al alumno.`,
|
||||
}));
|
||||
});
|
||||
})
|
||||
.then((servicio) => {
|
||||
let carpeta = '';
|
||||
|
||||
drive
|
||||
.mkDir(numeroCuenta)
|
||||
.then((res) => {
|
||||
carpeta = res;
|
||||
return drive.uploadFile(
|
||||
path,
|
||||
`Carta_Aceptacion.pdf`,
|
||||
'application/pdf',
|
||||
carpeta
|
||||
);
|
||||
})
|
||||
.then((res) =>
|
||||
Servicio.update(
|
||||
{ carpeta, cartaAceptacion: res },
|
||||
{ where: { idServicio: servicio.idServicio } }
|
||||
)
|
||||
);
|
||||
return { message: `Se Pre-Registro correctamente a este alumno.` };
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = nuevo;
|
||||
|
||||
@@ -8,8 +8,16 @@ const Servicio = require(`${dbPath}/Servicio`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const cancelar = async (body) => {
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const mensaje = validar.validarAlfanumerico(body.mensaje, 'El mensaje', 800);
|
||||
const idServicio = validar.validarNumeroEntero(
|
||||
body.idServicio,
|
||||
'id servicio'
|
||||
);
|
||||
const mensaje = validar.validarAlfanumerico(
|
||||
body.mensaje,
|
||||
'mensaje',
|
||||
true,
|
||||
800
|
||||
);
|
||||
let correoResponsable = {};
|
||||
let correoAlumno = {};
|
||||
let emailResponsable = '';
|
||||
|
||||
@@ -8,8 +8,16 @@ const Servicio = require(`${dbPath}/Servicio`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const cancelar = async (body) => {
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const mensaje = validar.validarAlfanumerico(body.mensaje, 'El mensaje', 800);
|
||||
const idServicio = validar.validarNumeroEntero(
|
||||
body.idServicio,
|
||||
'id servicio'
|
||||
);
|
||||
const mensaje = validar.validarAlfanumerico(
|
||||
body.mensaje,
|
||||
'mensaje',
|
||||
true,
|
||||
800
|
||||
);
|
||||
let correoResponsable = {};
|
||||
let correoAlumno = {};
|
||||
let emailResponsable = '';
|
||||
|
||||
@@ -8,8 +8,16 @@ const Servicio = require(`${dbPath}/Servicio`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const cancelar = async (body) => {
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const mensaje = validar.validarAlfanumerico(body.mensaje, 'El mensaje', 800);
|
||||
const idServicio = validar.validarNumeroEntero(
|
||||
body.idServicio,
|
||||
'id servicio'
|
||||
);
|
||||
const mensaje = validar.validarAlfanumerico(
|
||||
body.mensaje,
|
||||
'mensaje',
|
||||
true,
|
||||
800
|
||||
);
|
||||
let correoResponsable = {};
|
||||
let correoAlumno = {};
|
||||
let emailResponsable = '';
|
||||
|
||||
@@ -8,7 +8,10 @@ const Servicio = require(`${dbPath}/Servicio`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const registro = async (body) => {
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const idServicio = validar.validarNumeroEntero(
|
||||
body.idServicio,
|
||||
'id servicio'
|
||||
);
|
||||
const password = encriptar.generarPassword();
|
||||
let correo = {};
|
||||
let idUsuario;
|
||||
|
||||
@@ -8,12 +8,20 @@ const Servicio = require(`${dbPath}/Servicio`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const registroValidado = async (body) => {
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const fechaNacimiento = validar.validarFecha(body.fechaNacimiento);
|
||||
const telefono = validar.validarNumero(body.telefono, 15);
|
||||
const idServicio = validar.validarNumeroEntero(
|
||||
body.idServicio,
|
||||
'id servicio'
|
||||
);
|
||||
const fechaNacimiento = validar.validarFecha(
|
||||
body.fechaNacimiento,
|
||||
'fecha de nacimiento',
|
||||
false
|
||||
);
|
||||
const telefono = validar.validarNumero(body.telefono, 'teléfono', true, 15);
|
||||
const direccion = validar.validarAlfanumerico(
|
||||
body.direccion,
|
||||
'La dirección',
|
||||
'dirección',
|
||||
false,
|
||||
200
|
||||
);
|
||||
let correoResponsable = {};
|
||||
|
||||
@@ -11,8 +11,8 @@ const Status = require(`${dbPath}/Status`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const reporte = async (body) => {
|
||||
const inicio = validarFecha(body.inicio);
|
||||
const fin = validarFecha(body.fin);
|
||||
const inicio = validarFecha(body.inicio, 'fecha de inicio', false);
|
||||
const fin = validarFecha(body.fin, 'fecha fin', false);
|
||||
const path = `server/uploads/reporte.csv`;
|
||||
const data = [];
|
||||
|
||||
|
||||
@@ -8,12 +8,19 @@ const Status = require(`${dbPath}/Status`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const serviciosAdmin = async (body) => {
|
||||
const pagina = validar.validarNumero(body.pagina, true);
|
||||
const pagina = validar.validarNumero(
|
||||
body.pagina,
|
||||
'página',
|
||||
false,
|
||||
null,
|
||||
true,
|
||||
true
|
||||
);
|
||||
const where = body.idStatus
|
||||
? { idStatus: validar.validarId(body.idStatus) }
|
||||
? { idStatus: validar.validarNumeroEntero(body.idStatus, 'id status') }
|
||||
: {};
|
||||
const nombre = body.nombre
|
||||
? validar.validarTexto(body.nombre, 'El nombre', 60)
|
||||
? validar.validarTexto(body.nombre, 'nombre', true, 60)
|
||||
: '';
|
||||
const numeroCuenta = body.numeroCuenta
|
||||
? validar.validarNumeroCuenta(body.numeroCuenta)
|
||||
|
||||
@@ -9,14 +9,21 @@ const Status = require(`${dbPath}/Status`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const serviciosResponsable = async (body) => {
|
||||
const pagina = validar.validarNumero(body.pagina, true);
|
||||
const idUsuario = validar.validarId(body.idUsuario);
|
||||
const pagina = validar.validarNumero(
|
||||
body.pagina,
|
||||
'página',
|
||||
false,
|
||||
null,
|
||||
true,
|
||||
true
|
||||
);
|
||||
const idUsuario = validar.validarNumeroEntero(body.idUsuario, 'id usuario');
|
||||
const where = body.idStatus
|
||||
? { idStatus: validar.validarId(body.idStatus) }
|
||||
? { idStatus: validar.validarNumeroEntero(body.idStatus, 'id status') }
|
||||
: { idStatus: { [Op.ne]: 10 } };
|
||||
|
||||
const nombre = body.nombre
|
||||
? validar.validarTexto(body.nombre, 'El nombre', 60)
|
||||
? validar.validarTexto(body.nombre, 'nombre', true, 60)
|
||||
: '';
|
||||
const numeroCuenta = body.numeroCuenta
|
||||
? validar.validarNumeroCuenta(body.numeroCuenta)
|
||||
|
||||
@@ -4,7 +4,10 @@ const validar = require(`${helperPath}/validar`);
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
const update = async (body, files) => {
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const idServicio = validar.validarNumeroEntero(
|
||||
body.idServicio,
|
||||
'id servicio'
|
||||
);
|
||||
const dataUpdate = {};
|
||||
|
||||
return Servicio.findOne({ where: { idServicio } })
|
||||
@@ -39,19 +42,37 @@ const update = async (body, files) => {
|
||||
} catch (err) {}
|
||||
if (body.correo) dataUpdate.correo = validar.validarCorreo(body.correo);
|
||||
if (body.fechaInicio)
|
||||
dataUpdate.fechaInicio = validar.validarFecha(body.fechaInicio);
|
||||
dataUpdate.fechaInicio = validar.validarFecha(
|
||||
body.fechaInicio,
|
||||
'fecha de inicio',
|
||||
false
|
||||
);
|
||||
if (body.fechaFin)
|
||||
dataUpdate.fechaFin = validar.validarFecha(body.fechaFin);
|
||||
dataUpdate.fechaFin = validar.validarFecha(
|
||||
body.fechaFin,
|
||||
'fecha fin',
|
||||
false
|
||||
);
|
||||
if (body.fechaNacimiento)
|
||||
dataUpdate.fechaNacimiento = validar.validarFecha(body.fechaNacimiento);
|
||||
dataUpdate.fechaNacimiento = validar.validarFecha(
|
||||
body.fechaNacimiento,
|
||||
'fecha de nacimiento',
|
||||
false
|
||||
);
|
||||
if (body.direccion)
|
||||
dataUpdate.direccion = validar.validarAlfanumerico(
|
||||
body.direccion,
|
||||
'La dirección',
|
||||
'dirección',
|
||||
false,
|
||||
200
|
||||
);
|
||||
if (body.telefono)
|
||||
dataUpdate.telefono = validar.validarNumero(body.telefono, 15);
|
||||
dataUpdate.telefono = validar.validarNumero(
|
||||
body.telefono,
|
||||
'teléfono',
|
||||
true,
|
||||
15
|
||||
);
|
||||
if (validar.validarObjetoVacio(dataUpdate))
|
||||
throw new Error(
|
||||
'No se envio nada para actualizar este Servicio Social'
|
||||
|
||||
@@ -4,6 +4,33 @@ const { validarNumeroCuenta } = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const creditosCarreras = [
|
||||
{ carrera: 'LIC. EN ACTUARIA', creditos: 64 },
|
||||
{ carrera: 'LIC. EN ARQUITECTURA', creditos: 70 },
|
||||
{ carrera: 'LIC. EN CIENCIAS POLITICAS Y ADMON PUB', creditos: 67 },
|
||||
{ carrera: 'LIC. EN CIENCIAS POLITICAS Y ADMON.PUBL.', creditos: 67 },
|
||||
{ carrera: 'LIC. EN COMUNICACION', creditos: 67 },
|
||||
{ carrera: 'LIC. EN DERECHO', creditos: 68 },
|
||||
{ carrera: 'LIC. EN DERECHO (SUA)', creditos: 67 },
|
||||
{ carrera: 'LIC. EN DISEÑO GRAFICO', creditos: 70 },
|
||||
{ carrera: 'LIC. EN ECONOMIA', creditos: 66 },
|
||||
{ carrera: 'LIC. EN ENSEÑANZA DE INGLES', creditos: 69 },
|
||||
{ carrera: 'LIC. EN FILOSOFIA', creditos: 70 },
|
||||
{ carrera: 'LIC. EN HISTORIA', creditos: 70 },
|
||||
{ carrera: 'LIC. EN INGENIERIA CIVIL', creditos: 70 },
|
||||
{ carrera: 'LIC. EN LENGUA Y LITERATURA HISPANICAS', creditos: 70 },
|
||||
{ carrera: 'LIC. EN MAT. APLICADAS Y COMPUTACION', creditos: 66 },
|
||||
{ carrera: 'LIC. EN MATEMATICAS APLICADAS Y COMP.', creditos: 66 },
|
||||
{ carrera: 'LIC. EN PEDAGOGÍA', creditos: 70 },
|
||||
{ carrera: 'LIC. EN PERIODISMO Y COMUNICACION COL.', creditos: 70 },
|
||||
{ carrera: 'LIC. EN RELACIONES INTERNACIONALES', creditos: 70 },
|
||||
{ carrera: 'LIC. EN RELACIONES INTERNACIONALES (SUA)', creditos: 70 },
|
||||
{ carrera: 'LIC. EN SOCIOLOGIA', creditos: 68 },
|
||||
{ carrera: 'LIC. ENSEÑANZA DE ALEMÁN (LENG. EXTRANJS', creditos: 70 },
|
||||
{ carrera: 'LIC. ENSEÑANZA DE ESPAÑOL(LENG. EXTRANJ)', creditos: 70 },
|
||||
{ carrera: 'LIC. ENSEÑANZA DE INGLÉS(LENG. EXTRANJE)', creditos: 70 },
|
||||
{ carrera: 'LIC. ENSEÑANZA DE ITALIANO(LENG. EXTRANJ', creditos: 70 },
|
||||
];
|
||||
|
||||
const escolares = async (body) => {
|
||||
const numeroCuenta = validarNumeroCuenta(body.numeroCuenta);
|
||||
@@ -17,18 +44,26 @@ const escolares = async (body) => {
|
||||
.then((res) => {
|
||||
if (!res.data.nombre || !res.data.carrconst || !res.data.avance)
|
||||
throw new Error(
|
||||
'El alumno no cumple con los requisitos para realizar el Servicio Social. Si cree que esto es erroneo comunicate con COESI.'
|
||||
'El alumno no cumple con los requisitos para realizar el Servicio Social. Si cree que esto es erróneo comunícate al Departamento de Servicio Social y Bolsa de Trabajo.'
|
||||
);
|
||||
alumno = {
|
||||
nombre: res.data.nombre.trim(),
|
||||
creditos: res.data.avance,
|
||||
carrera: res.data.carrconst.trim(),
|
||||
};
|
||||
while (alumno.nombre.search('') != -1)
|
||||
alumno.nombre = alumno.nombre.replace('', '');
|
||||
while (alumno.nombre.search('Ã') != -1)
|
||||
for (let i = 0; i < creditosCarreras.length; i++)
|
||||
if (
|
||||
alumno.carrera === creditosCarreras[i].carrera &&
|
||||
Number(alumno.creditos) < creditosCarreras[i].creditos
|
||||
)
|
||||
throw new Error('Este alumno no cuenta con los créditos necesarios.');
|
||||
while (
|
||||
alumno.nombre.search('') != -1 &&
|
||||
alumno.nombre.search('Ã') != -1
|
||||
) {
|
||||
alumno.nombre = alumno.nombre.replace('Ã', 'Ñ');
|
||||
|
||||
alumno.nombre = alumno.nombre.replace('', '');
|
||||
}
|
||||
return Carrera.findOne({ where: { carrera: alumno.carrera } });
|
||||
})
|
||||
.then((res) => {
|
||||
|
||||
@@ -6,10 +6,16 @@ const Usuario = require(`${dbPath}/Usuario`);
|
||||
const TipoUsuario = require(`${dbPath}/TipoUsuario`);
|
||||
|
||||
const login = async (body) => {
|
||||
const usuario = validar.validar(body.usuario, 'El usuario', 60);
|
||||
const usuario = validar.validacionBasicaStr(
|
||||
body.usuario,
|
||||
'usuario',
|
||||
true,
|
||||
60
|
||||
);
|
||||
const password = validar.validarAlfanumerico(
|
||||
body.password,
|
||||
'La contraseña',
|
||||
'contraseña',
|
||||
false,
|
||||
20
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const helperPath = '../../helper';
|
||||
const { validarId } = require(`${helperPath}/validar`);
|
||||
const { validarNumeroEntero } = require(`${helperPath}/validar`);
|
||||
const gmail = require(`${helperPath}/gmail`);
|
||||
const correos = require(`${helperPath}/correos`);
|
||||
const encriptar = require(`${helperPath}/encriptar`);
|
||||
@@ -8,7 +8,7 @@ const Usuario = require(`${dbPath}/Usuario`);
|
||||
const Servicio = require(`${dbPath}/Servicio`);
|
||||
|
||||
const newPasswordAlumno = async (body) => {
|
||||
const idServicio = validarId(body.idServicio);
|
||||
const idServicio = validarNumeroEntero(body.idServicio, 'id servicio');
|
||||
const password = encriptar.generarPassword();
|
||||
let idUsuario;
|
||||
let correo = {};
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
const helperPath = '../../helper';
|
||||
const { validarId } = require(`${helperPath}/validar`);
|
||||
const { validarNumeroEntero } = require(`${helperPath}/validar`);
|
||||
const gmail = require(`${helperPath}/gmail`);
|
||||
const correos = require(`${helperPath}/correos`);
|
||||
const encriptar = require(`${helperPath}/encriptar`);
|
||||
const Usuario = require('../../db/tablas/Usuario');
|
||||
|
||||
const newPasswordResponsable = async (body) => {
|
||||
const idUsuario = await validarId(body.idUsuario);
|
||||
const idUsuario = validarNumeroEntero(body.idUsuario, 'id usuario');
|
||||
const password = encriptar.generarPassword();
|
||||
let correo = {};
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const { validarId } = require('../../helper/validar');
|
||||
const { validarNumeroEntero } = require('../../helper/validar');
|
||||
const Usuario = require('../../db/tablas/Usuario');
|
||||
|
||||
const responsable = async (body) => {
|
||||
const idUsuario = validarId(body.idUsuario);
|
||||
const idUsuario = validarNumeroEntero(body.idUsuario, 'id usuario');
|
||||
|
||||
return Usuario.findOne({
|
||||
where: { idUsuario },
|
||||
|
||||
@@ -3,7 +3,7 @@ const validar = require('../../helper/validar');
|
||||
const Usuario = require('../../db/tablas/Usuario');
|
||||
|
||||
const responsableUpdate = async (body) => {
|
||||
const idUsuario = validar.validarId(body.idUsuario);
|
||||
const idUsuario = validar.validarNumeroEntero(body.idUsuario, 'id usuario');
|
||||
const dataUpdate = {};
|
||||
|
||||
return Usuario.findOne({ where: { idUsuario } })
|
||||
@@ -24,8 +24,12 @@ const responsableUpdate = async (body) => {
|
||||
dataUpdate.usuario = validar.validarCorreo(body.correo);
|
||||
}
|
||||
if (body.nombre)
|
||||
dataUpdate.nombre = validar.validarTexto(body.nombre, 'el nombre', 70);
|
||||
|
||||
dataUpdate.nombre = validar.validarTexto(
|
||||
body.nombre,
|
||||
'nombre',
|
||||
true,
|
||||
70
|
||||
);
|
||||
if (validar.validarObjetoVacio(dataUpdate))
|
||||
throw new Error('No se a envio nada para actualizar.');
|
||||
return Usuario.update(dataUpdate, { where: { idUsuario } });
|
||||
|
||||
@@ -3,12 +3,19 @@ const validar = require('../../helper/validar');
|
||||
const Usuario = require('../../db/tablas/Usuario');
|
||||
|
||||
const responsables = async (body) => {
|
||||
const pagina = validar.validarNumero(body.pagina, true);
|
||||
const pagina = validar.validarNumero(
|
||||
body.pagina,
|
||||
'página',
|
||||
false,
|
||||
null,
|
||||
true,
|
||||
true
|
||||
);
|
||||
const nombre = body.nombre
|
||||
? validar.validarTexto(body.nombre, 'El nombre', 60)
|
||||
? validar.validarTexto(body.nombre, 'nombre', true, 60)
|
||||
: '';
|
||||
const correo = body.correo
|
||||
? validar.validar(body.correo, 'El correo', 1000)
|
||||
? validar.validacionBasicaStr(body.correo, 'correo', true, 1000)
|
||||
: '';
|
||||
|
||||
return Usuario.findAndCountAll({
|
||||
|
||||
+76
-35
@@ -1,4 +1,10 @@
|
||||
const dudas = `Cualquier duda puedes acudir al área de Registro y Control de Servicio Social en COESI de Lunes a Viernes de 10:00 a 14:00 hrs y de 16:00 a 20:00 hrs, o bien, comunicarte al 5623 1686 o al correo registross@acatlan.unam.mx`;
|
||||
const dudasAlumno = `Cualquier duda puedes acudir a las ventanillas de servicio social de la Secretaría de Asuntos Académicos Estudiantiles, en la planta baja del Edificio A-8 de lunes a viernes de 09:00 a 15:00 hrs. y de 17:00 a 19:00 hrs. o bien, comunicarte al 5623 1686 o al correo tramites.ss@acatlan.unam.mx`;
|
||||
const dudasResponsable = `Cualquier duda puede comunicarse al 5623 1686 o al correo tramites.ss@acatlan.unam.mx`;
|
||||
const atentamente = `
|
||||
Atentamente
|
||||
Departamento de Servicio Social, Desarrollo Profesional e Inserción Laboral
|
||||
FES Acatlán
|
||||
`;
|
||||
|
||||
const preRegistro = (password, nombre) => {
|
||||
return {
|
||||
@@ -6,17 +12,23 @@ const preRegistro = (password, nombre) => {
|
||||
msj: `Estimado(a) ${nombre}:
|
||||
|
||||
Te informamos que la dependencia en donde decidiste realizar tu servicio social ya te registró en nuestro sistema de servicio social, por lo que para completar el proceso debes ingresar en un periodo máximo de 10 días hábiles a partir de la recepción de este mensaje, a la página https://iris.acatlan.unam.mx/ con tu número de cuenta y contraseña: ${password}, para llenar un formulario con tus datos.
|
||||
|
||||
En caso de no realizar dicho registro, tu trámite queda inconcluso y no nos hacemos responsables por las horas de servicio social prestadas en cualquier dependencia.
|
||||
|
||||
En el sistema que se te indicó podrás dar seguimiento al resto de tu trámite de servicio social.
|
||||
Cualquier duda puedes acudir al área de Registro y Control de Servicio Social en COESI de lunes a viernes de 10:00 a 13:00 hrs. y de 16:00 a 19:00 hrs. o bien, comunicarte al 5623 1686 o al correo tramites.ss@acatlan.unam.mx
|
||||
|
||||
Instrucciones al término de tu servicio social:
|
||||
|
||||
Al día siguiente de tu fecha de término programada, quedará habilitado en el sistema la opción para subir los documentos correspondientes, por lo que la institución deberá subir escaneada tu carta de término y llenar un cuestionario sobre tu desempeño, mientras que tú debes encargarte de subir tu informe global de actividades en el formato disponible en http://bit.ly/informeglobal-FESA, así como llenar un cuestionario sobre el programa en el que participaste.
|
||||
Al día siguiente de tu fecha de término programada, quedará habilitado en el sistema la opción para subir los documentos correspondientes, por lo que la institución deberá subir escaneada tu carta de término y llenar un cuestionario sobre tu desempeño, mientras que tú debes encargarte de subir tu informe global de actividades en el formato disponible en https://bit.ly/informe-serviciosocialFESA, así como llenar un cuestionario sobre el programa en el que participaste.
|
||||
|
||||
Si se suben correctamente los documentos y cuestionarios mencionados, el Departamento de Servicio Social validará tu trámite de término en el sistema y en un periodo aproximado de 15 días hábiles te hará llegar por correo electrónico tu carta de liberación del servicio social.
|
||||
|
||||
Finalmente, te recomendamos destacar en tu bandeja de correos este mensaje para tener siempre a la mano las instrucciones recibidas, o bien, copiar en otro archivo el texto para que lo puedas ubicar fácilmente.
|
||||
|
||||
${dudas}`,
|
||||
${dudasAlumno}
|
||||
|
||||
${atentamente}
|
||||
`,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -29,7 +41,10 @@ Te informamos que hay un error con tu pre-registro de servicio social por los si
|
||||
|
||||
${motivo}
|
||||
|
||||
${dudas}`,
|
||||
${dudasAlumno}
|
||||
|
||||
${atentamente}
|
||||
`,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -37,11 +52,15 @@ const preRegistroRechazadoResponsable = (motivo, nombre) => {
|
||||
return {
|
||||
subject: `Notificación de rechazo de pre-registro.`,
|
||||
msj: `Estimado responsable de programa:
|
||||
|
||||
Te informamos que hubo un error con el pre-registro de servicio social del alumno ${nombre} por los siguientes motivos:
|
||||
|
||||
${motivo}
|
||||
|
||||
${dudas}`,
|
||||
${dudasResponsable}
|
||||
|
||||
${atentamente}
|
||||
`,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -56,7 +75,10 @@ A su vez, deberás responder un cuestionario de evaluación del programa de serv
|
||||
|
||||
Cabe mencionar que se ha enviado copia de este mensaje al responsable de programa de servicio social de tu dependencia para que esté enterado de la validación de tu registro.
|
||||
|
||||
${dudas}`,
|
||||
${dudasAlumno}
|
||||
|
||||
${atentamente}
|
||||
`,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -67,7 +89,10 @@ const registroValidadoResponsable = (nombre) => {
|
||||
|
||||
Te informamos que el Área de Registro y Control de Servicio Social ha validado la solicitud de registro del alumno ${nombre}.
|
||||
|
||||
${dudas}`,
|
||||
${dudasResponsable}
|
||||
|
||||
${atentamente}
|
||||
`,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -76,9 +101,12 @@ const terminoValidado = (nombre) => {
|
||||
subject: 'Validación de término.',
|
||||
msj: `Estimado(a) ${nombre}:
|
||||
|
||||
Te confirmamos que has concluido con los trámites necesarios para la liberación de tu servicio social por lo que ahora solo queda esperar máximo 15 días hábiles para que se te notifique por correo electrónico, a partir de cuándo puedes recoger la copia de tu carta de liberación en las ventanillas del Área de Registro y Control de Servicio Social.
|
||||
Te confirmamos que has concluido con los trámites necesarios para la liberación de tu servicio social por lo que ahora solo queda esperar máximo 15 días hábiles para que se te envíe a tu correo, la copia de tu carta de liberación.
|
||||
|
||||
${dudas}`,
|
||||
${dudasAlumno}
|
||||
|
||||
${atentamente}
|
||||
`,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -91,7 +119,10 @@ Te informamos que no fue validado tu trámite de término por el Departamento de
|
||||
|
||||
${motivo}
|
||||
|
||||
${dudas}`,
|
||||
${dudasAlumno}
|
||||
|
||||
${atentamente}
|
||||
`,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -99,11 +130,15 @@ const terminoRechazadoResponsable = (motivo, nombre) => {
|
||||
return {
|
||||
subject: 'Correo de rechazo de término',
|
||||
msj: `Estimado responsable de programa:
|
||||
|
||||
Te informamos que no fue validado el trámite de término del alumno ${nombre} por el Departamento de Servicio Social y Bolsa de Trabajo por los siguientes motivos:
|
||||
|
||||
${motivo}
|
||||
|
||||
${dudas}`,
|
||||
${dudasResponsable}
|
||||
|
||||
${atentamente}
|
||||
`,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -116,7 +151,10 @@ Te informamos que fue cancelado tu trámite de servicio social, por el Departame
|
||||
|
||||
${motivo}
|
||||
|
||||
${dudas}`,
|
||||
${dudasAlumno}
|
||||
|
||||
${atentamente}
|
||||
`,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -128,16 +166,19 @@ Te informamos que fue cancelado el trámite de servicio social del alumno ${nomb
|
||||
|
||||
${motivo}
|
||||
|
||||
${dudas}`,
|
||||
${dudasResponsable}
|
||||
|
||||
${atentamente}
|
||||
`,
|
||||
};
|
||||
};
|
||||
|
||||
const enviarSec = (secreto, usuariomail, nombre) => {
|
||||
return {
|
||||
subject: `Estimado responsable de programa de servicio social: ${nombre}`,
|
||||
msj: `Como ya se les había informado, en nuestra Facultad estamos en un proceso de actualización administrativa que implica la puesta en marcha de un nuevo sistema interno de servicio social en el cual estará el expediente electrónico del alumno y su seguimiento con respecto a estos trámites. La dirección electrónica de dicho sistema es https://iris.acatlan.unam.mx y su usuario y contraseña son:
|
||||
msj: `Le informamos que desde marzo de 2020 se implementó un nuevo sistema interno de servicio social en el cual estará el expediente electrónico del alumno y su seguimiento con respecto a estos trámites. La dirección electrónica de dicho sistema es https://iris.acatlan.unam.mx y su usuario y contraseña son:
|
||||
|
||||
Usuario: ${usuariomail}
|
||||
Nombre de usuario para ingresar: ${usuariomail}
|
||||
|
||||
Contraseña: ${secreto}
|
||||
|
||||
@@ -155,32 +196,35 @@ Para el uso de dicho sistema el proceso es el siguiente:
|
||||
|
||||
5. Por su parte el alumno ingresará al sistema para subir escaneado su informe de actividades con firma y sello de su jefe inmediato y llenará un cuestionario de evaluación del programa de servicio social en el que participó.
|
||||
|
||||
6. Si todo está correcto el Departamento de servicio social validará el trámite de término del alumno y le notificará el tiempo aproximado en que puede pasar a recoger su carta de liberación de servicio social.
|
||||
6. Si todo está correcto el Departamento de servicio social validará el trámite de término del alumno y le notificará el tiempo aproximado en que se le enviará por correo su carta de liberación.
|
||||
|
||||
Otras consideraciones:
|
||||
|
||||
- Le pedimos su apoyo cargando las cartas de los alumnos en un periodo de 10 días hábiles posteriores a la fecha de inicio y término, ya que a su vez los alumnos tendrán otros 10 días hábiles para completar lo que les corresponde en cada etapa. Para todos los casos de este año que ya hayan iniciado su servicio social con anterioridad, le pedimos que antes del 15 de Mayo, quede registrado en nuestro sistema.
|
||||
- Le pedimos su apoyo cargando las cartas de los alumnos en un periodo de 10 días hábiles posteriores a la fecha de inicio y término, ya que a su vez los alumnos tendrán otros 10 días hábiles para completar lo que les corresponde en cada etapa.
|
||||
|
||||
- Para obtener los datos que el sistema le pide del alumno puede preguntárselos directamente, ya que las cartas de presentación sólo se emiten para instituciones externas.
|
||||
- Para obtener los datos que el sistema le pide del alumno puede preguntárselos directamente, ya que las cartas de presentación sólo se emiten para instituciones externas.
|
||||
|
||||
- Los profesores de carrera con proyectos de servicio social registrados no tendrán claves de acceso a este sistema, por lo que sus áreas de adscripción deberán encargarse de hacer los trámites de servicio social de sus alumnos.
|
||||
|
||||
- Finalmente, cabe mencionar que el nuevo procedimiento sólo aplica a los alumnos que inicien su servicio social en 2020, por lo que aquellos que ya habían hecho su trámite de inicio desde 2019, lo terminarán con el proceso anterior entregando su carta de termino original en las ventanillas de servicio social.
|
||||
|
||||
- De cualquier forma para atender dudas o comentarios al respecto, podrá comunicarse con el equipo del Departamento de Servicio Social:
|
||||
|
||||
Lic. Lourdes Ibarra Celorio
|
||||
56231686
|
||||
registross@acatlan.unam.mx
|
||||
tramites.ss@acatlan.unam.mx
|
||||
|
||||
Mtra. Adriana Roque del Angel
|
||||
Lic. Marcela Martínez Rangel
|
||||
56231600
|
||||
jefaturassbt@acatlan.unam.mx
|
||||
sesocial@acatlan.unam.mx.
|
||||
|
||||
Lic. Ivette Selene Hernández Rios
|
||||
56231600
|
||||
sesoprof@acatlan.unam.mx
|
||||
|
||||
Atentamente
|
||||
|
||||
Mtra. Adriana Roque del Angel
|
||||
Jefa del Departamento de Servicio Social y Bolsa de Trabajo.`,
|
||||
Lic. Ivette Selene Hernández Rios
|
||||
Jefa del Departamento de Servicio Social, Desarrollo Profesional e Inserción Laboral
|
||||
`,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -195,15 +239,14 @@ En cuanto cumplas con las 480 horas reglamentarias, tienes 15 días hábiles par
|
||||
|
||||
Por su parte el responsable del programa de servicio social deberá ingresar al mismo sistema para subir escaneada tu carta de término y debe responder el Cuestionario de desempeño del alumno. Para lo anterior, también la institución tiene 15 días hábiles a partir de que concluiste las 480 horas de servicio.
|
||||
|
||||
En cuanto el responsable de programa de servicio social y tú suban al sistema lo que les corresponde, el Departamento de Servicio Social revisará tus documentos y en caso de estar correctos validará tu trámite para realizar la liberación de este requisito. Recibirás una notificación por correo con el periodo de tiempo aproximado que debes esperar para acudir a recoger la copia de tu carta de liberación o bien, las indicaciones de los documentos que debes corregir para poder aceptar tu trámite de término.
|
||||
En cuanto el responsable de programa de servicio social y tú suban al sistema lo que les corresponde, el Departamento de Servicio Social revisará tus documentos y en caso de estar correctos validará tu trámite para realizar la liberación de este requisito. Recibirás una notificación por correo con el periodo de tiempo aproximado que debes esperar para recibir por correo electrónico tu carta de liberación o bien, las indicaciones de los documentos que debes corregir para poder aceptar tu trámite de término.
|
||||
|
||||
Por reglamento de la Universidad, si en máximo dos años a partir de la fecha de inicio de servicio social no se realiza el trámite de término mencionado anteriormente, debes tomar en cuenta que tu registro queda cancelado y deberás tramitarlo nuevamente en otro programa.
|
||||
|
||||
${dudas}
|
||||
${dudasAlumno}
|
||||
|
||||
Atentamente
|
||||
Departamento de Servicio Social y Bolsa de Trabajo
|
||||
FES Acatlán`,
|
||||
${atentamente}
|
||||
`,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -222,11 +265,9 @@ En cuanto usted y el alumno suban al sistema lo que les corresponde, el Departam
|
||||
|
||||
También se le ha informado al alumno que por reglamento de la Universidad, si en máximo dos años a partir de la fecha de inicio de servicio social no se realiza el trámite de término mencionado anteriormente, debe tomar en cuenta que su registro queda cancelado y deberá tramitarlo nuevamente en otro programa.
|
||||
|
||||
${dudas}
|
||||
${dudasResponsable}
|
||||
|
||||
Atentamente
|
||||
Departamento de Servicio Social y Bolsa de Trabajo
|
||||
FES Acatlán
|
||||
${atentamente}
|
||||
`,
|
||||
};
|
||||
};
|
||||
|
||||
+40
-35
@@ -1,53 +1,58 @@
|
||||
const moment = require('moment');
|
||||
const gmail = require('./gmail');
|
||||
const correos = require('./correos');
|
||||
const Servicio = require('../db/tablas/Servicio');
|
||||
const Usuario = require('../db/tablas/Usuario');
|
||||
const Programa = require('../db/tablas/Programa');
|
||||
const gmail = require('./gmail');
|
||||
const correos = require('./correos');
|
||||
const now = moment();
|
||||
|
||||
const diario = async () => {
|
||||
let mensaje = '';
|
||||
const now = moment();
|
||||
const servicios = await Servicio.findAll({
|
||||
return Servicio.findAll({
|
||||
where: { idStatus: 3 },
|
||||
include: [
|
||||
{ model: Usuario },
|
||||
{ model: Programa, include: [{ model: Usuario }] },
|
||||
],
|
||||
});
|
||||
}).then(async (servicios) => {
|
||||
let mensaje = '';
|
||||
|
||||
for (let i = 0; i < servicios.length; i++) {
|
||||
let fechaFin = moment(servicios[i].fechaFin);
|
||||
let fechaFinDate = fechaFin.dayOfYear();
|
||||
for (let i = 0; i < servicios.length; i++) {
|
||||
let fechaFin = moment(servicios[i].fechaFin);
|
||||
let fechaFinDate = fechaFin.dayOfYear();
|
||||
|
||||
if (fechaFin.year() > now.year())
|
||||
fechaFinDate += 365 * (fechaFin.year() - now.year());
|
||||
if (fechaFin.year() < now.year())
|
||||
fechaFinDate -= 365 * (now.year() - fechaFin.year());
|
||||
if (fechaFinDate - now.dayOfYear() === 7) {
|
||||
let correoAlumno = correos.avisoTerminoAlumno(
|
||||
servicios[i].Usuario.nombre
|
||||
);
|
||||
let correoResponsable = correos.avisoTerminoResponsable(
|
||||
servicios[i].Usuario.nombre
|
||||
);
|
||||
if (fechaFin.year() > now.year())
|
||||
fechaFinDate += 365 * (fechaFin.year() - now.year());
|
||||
if (fechaFin.year() < now.year())
|
||||
fechaFinDate -= 365 * (now.year() - fechaFin.year());
|
||||
if (fechaFinDate - now.dayOfYear() === 7) {
|
||||
let correoAlumno = correos.avisoTerminoAlumno(
|
||||
servicios[i].Usuario.nombre
|
||||
);
|
||||
let correoResponsable = correos.avisoTerminoResponsable(
|
||||
servicios[i].Usuario.nombre
|
||||
);
|
||||
|
||||
mensaje += `Se envio correo al alumno ${servicios[i].Usuario.usuario} con id ${servicios[i].Usuario.idUsuario} al correo ${servicios[i].correo} y al responsable ${servicios[i].Programa.Usuario.nombre} con id ${servicios[i].Programa.Usuario.idUsuario} y correo ${servicios[i].Programa.Usuario.usuario}\n`;
|
||||
await gmail(correoAlumno.subject, servicios[i].correo, correoAlumno.msj);
|
||||
await gmail(
|
||||
correoResponsable.subject,
|
||||
servicios[i].Programa.Usuario.usuario,
|
||||
correoResponsable.msj
|
||||
);
|
||||
} else if (fechaFinDate - now.dayOfYear() <= -1) {
|
||||
mensaje += `El servicio con id ${servicios[i].idServicio} del alumno ${servicios[i].Usuario.usuario} con id ${servicios[i].Usuario.idUsuario} paso al status 4\n`;
|
||||
await Servicio.update(
|
||||
{ idStatus: 4 },
|
||||
{ where: { idServicio: servicios[i].idServicio } }
|
||||
);
|
||||
mensaje += `Se envio correo al alumno ${servicios[i].Usuario.usuario} con id ${servicios[i].Usuario.idUsuario} al correo ${servicios[i].correo} y al responsable ${servicios[i].Programa.Usuario.nombre} con id ${servicios[i].Programa.Usuario.idUsuario} y correo ${servicios[i].Programa.Usuario.usuario}\n\n`;
|
||||
await gmail(
|
||||
correoAlumno.subject,
|
||||
servicios[i].correo,
|
||||
correoAlumno.msj
|
||||
);
|
||||
await gmail(
|
||||
correoResponsable.subject,
|
||||
servicios[i].Programa.Usuario.usuario,
|
||||
correoResponsable.msj
|
||||
);
|
||||
} else if (fechaFinDate - now.dayOfYear() <= -1) {
|
||||
mensaje += `El servicio con id ${servicios[i].idServicio} del alumno ${servicios[i].Usuario.usuario} con id ${servicios[i].Usuario.idUsuario} paso al status 4\n\n`;
|
||||
await Servicio.update(
|
||||
{ idStatus: 4 },
|
||||
{ where: { idServicio: servicios[i].idServicio } }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
await gmail('Reporte función diario', 'lemuel@acatlan.unam.mx', mensaje);
|
||||
return gmail('Reporte función diario', 'lemuel@acatlan.unam.mx', mensaje);
|
||||
});
|
||||
};
|
||||
|
||||
diario();
|
||||
|
||||
+108
-107
@@ -10,84 +10,6 @@ const jwtClient = new google.auth.JWT(
|
||||
['https://www.googleapis.com/auth/drive']
|
||||
);
|
||||
|
||||
// Borrar archivo
|
||||
const deleteFile = (fileId) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
jwtClient.authorize(async (err, tokens) => {
|
||||
if (err) reject(err);
|
||||
|
||||
drive.files.delete(
|
||||
{
|
||||
fileId,
|
||||
auth: jwtClient,
|
||||
},
|
||||
(err, resp) => {
|
||||
if (err) reject(err);
|
||||
resolve(resp);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// SUBIR ARCHIVO
|
||||
const uploadFile = (path, name, mimeType, parent) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
jwtClient.authorize(function (err, tokens) {
|
||||
if (err) reject('Error de autorización: ' + err);
|
||||
|
||||
let requestBody = {
|
||||
name,
|
||||
parents: [parent],
|
||||
};
|
||||
let media = {
|
||||
mimeType: mimeType,
|
||||
body: fs.createReadStream(`${path}`),
|
||||
};
|
||||
|
||||
drive.files.create(
|
||||
{
|
||||
media: media,
|
||||
fields: 'id',
|
||||
requestBody,
|
||||
auth: jwtClient,
|
||||
},
|
||||
(err, file) => {
|
||||
if (err) reject(err);
|
||||
fs.unlinkSync(path);
|
||||
resolve(file.data.id);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// CREAR CARPETA
|
||||
const mkDir = (name) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
jwtClient.authorize((err, tokens) => {
|
||||
if (err) reject('Error de autorización: ' + err);
|
||||
|
||||
let requestBody = {
|
||||
name,
|
||||
mimeType: 'application/vnd.google-apps.folder',
|
||||
parents: [process.env.CARPETA],
|
||||
};
|
||||
drive.files.create(
|
||||
{
|
||||
fields: 'id',
|
||||
auth: jwtClient,
|
||||
requestBody,
|
||||
},
|
||||
(err, res) => {
|
||||
if (err) reject(err);
|
||||
resolve(res.data.id);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const list = (pageToken) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
jwtClient.authorize((err, tokens) => {
|
||||
@@ -113,6 +35,84 @@ const list = (pageToken) => {
|
||||
});
|
||||
};
|
||||
|
||||
// Borrar archivo
|
||||
const deleteFile = (fileId) => {
|
||||
if (fileId === process.env.CARPETA)
|
||||
throw new Error('No se puede eliminar este archivo/carpeta.');
|
||||
return new Promise((resolve, reject) => {
|
||||
jwtClient.authorize(async (err, tokens) => {
|
||||
if (err) reject(err);
|
||||
drive.files.delete(
|
||||
{
|
||||
fileId,
|
||||
auth: jwtClient,
|
||||
},
|
||||
(err, resp) => {
|
||||
if (err) reject(err);
|
||||
resolve(resp);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// SUBIR ARCHIVO
|
||||
const uploadFile = (path, name, mimeType, parent) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const requestBody = {
|
||||
name,
|
||||
parents: [parent],
|
||||
};
|
||||
const media = {
|
||||
mimeType,
|
||||
body: fs.createReadStream(`${path}`),
|
||||
};
|
||||
|
||||
jwtClient.authorize(function (err, tokens) {
|
||||
if (err) reject('Error de autorización: ' + err);
|
||||
drive.files.create(
|
||||
{
|
||||
media,
|
||||
requestBody,
|
||||
fields: 'id',
|
||||
auth: jwtClient,
|
||||
},
|
||||
(err, file) => {
|
||||
if (err) reject(err);
|
||||
fs.unlinkSync(path);
|
||||
resolve(file.data.id);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// CREAR CARPETA
|
||||
const mkDir = (name) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const requestBody = {
|
||||
name,
|
||||
mimeType: 'application/vnd.google-apps.folder',
|
||||
parents: [process.env.CARPETA],
|
||||
};
|
||||
|
||||
jwtClient.authorize((err, tokens) => {
|
||||
if (err) reject('Error de autorización: ' + err);
|
||||
drive.files.create(
|
||||
{
|
||||
fields: 'id',
|
||||
auth: jwtClient,
|
||||
requestBody,
|
||||
},
|
||||
(err, res) => {
|
||||
if (err) reject(err);
|
||||
resolve(res.data.id);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// Update File
|
||||
const update = (fileId, addParents, removeParents) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -133,50 +133,51 @@ const folder = async (numeroCuenta) => {
|
||||
let pageToken = '';
|
||||
|
||||
do {
|
||||
let response = await list(pageToken);
|
||||
let files = response.files;
|
||||
let res = await list(pageToken);
|
||||
|
||||
for (let i = 0; i < files.length; i++)
|
||||
for (let i = 0; i < res.files.length; i++)
|
||||
if (
|
||||
files[i].name === numeroCuenta &&
|
||||
files[i].mimeType === 'application/vnd.google-apps.folder'
|
||||
res.files[i].name === numeroCuenta &&
|
||||
res.files[i].mimeType === 'application/vnd.google-apps.folder'
|
||||
)
|
||||
return files[i].id;
|
||||
pageToken = '';
|
||||
if (response.nextPageToken) pageToken = response.nextPageToken;
|
||||
return res.files[i].id;
|
||||
pageToken = res.nextPageToken ? res.nextPageToken : '';
|
||||
} while (pageToken);
|
||||
return mkDir(numeroCuenta);
|
||||
};
|
||||
|
||||
const borrarTodo = () => {
|
||||
return list().then(async (res) => {
|
||||
console.log(res);
|
||||
// for (let i = 0; i < res.files.length; i++)
|
||||
// if (res.files[i].name !== 'Babyhelon') await deleteFile(res.files[i].id);
|
||||
});
|
||||
};
|
||||
// const borrarTodo = () => {
|
||||
// return list().then(async (res) => {
|
||||
// for (let i = 0; i < res.files.length; i++)
|
||||
// if (res.files[i].id !== process.env.CARPETA)
|
||||
// await deleteFile(res.files[i].id);
|
||||
// });
|
||||
// };
|
||||
|
||||
// borrarTodo();
|
||||
|
||||
const archivosFicheros = async () => {
|
||||
const findAll = async () => {
|
||||
const folders = [];
|
||||
const pdfs = [];
|
||||
let pageToken = '';
|
||||
const pdf = [];
|
||||
const carpetas = [];
|
||||
|
||||
do {
|
||||
let response = await list(pageToken);
|
||||
|
||||
console.log(response);
|
||||
if (response.nextPageToken) pageToken = response.nextPageToken;
|
||||
else pageToken = '';
|
||||
await list(pageToken).then((res) => {
|
||||
for (let i = 0; i < res.files.length; i++) {
|
||||
if (res.files[i].id !== process.env.CARPETA) {
|
||||
if (res.files[i].mimeType === 'application/vnd.google-apps.folder')
|
||||
folders.push(res.files[i].id);
|
||||
if (res.files[i].mimeType === 'application/pdf')
|
||||
pdfs.push(res.files[i].id);
|
||||
}
|
||||
}
|
||||
pageToken = res.nextPageToken ? res.nextPageToken : '';
|
||||
});
|
||||
} while (pageToken);
|
||||
|
||||
return { pdf, carpetas };
|
||||
return { folders, pdfs };
|
||||
};
|
||||
|
||||
// archivosFicheros();
|
||||
|
||||
module.exports = {
|
||||
folder,
|
||||
uploadFile,
|
||||
deleteFile,
|
||||
mkDir,
|
||||
};
|
||||
|
||||
@@ -1,28 +1,17 @@
|
||||
const bcrypt = require('bcrypt');
|
||||
const validar = require('./validar');
|
||||
require('../config/config');
|
||||
|
||||
const comparar = (password, dbPassword) => {
|
||||
let campo = 'password';
|
||||
|
||||
validar.noHay(password, campo);
|
||||
if (typeof password != 'string') validar.noValido(campo);
|
||||
if (!bcrypt.compareSync(password, dbPassword))
|
||||
throw new Error('Usuario o contraseña no validos.');
|
||||
if (!bcrypt.compareSync(password, dbPassword)) return false;
|
||||
return true;
|
||||
};
|
||||
|
||||
const encriptar = (password) => {
|
||||
let campo = 'password';
|
||||
|
||||
validar.noHay(password, campo);
|
||||
if (typeof password != 'string') validar.noValido(campo);
|
||||
return bcrypt.hashSync(password, Number(process.env.SALT_ROUNDS));
|
||||
};
|
||||
const encriptar = (password) =>
|
||||
bcrypt.hashSync(password, Number(process.env.SALT_ROUNDS));
|
||||
|
||||
const generarPassword = () => {
|
||||
let length = 8;
|
||||
let charset =
|
||||
const length = 8;
|
||||
const charset =
|
||||
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
||||
let password = '';
|
||||
|
||||
|
||||
+143
-106
@@ -1,60 +1,27 @@
|
||||
// const fs = require('fs');
|
||||
const moment = require('moment');
|
||||
const validator = require('validator');
|
||||
const Servicio = require('../db/tablas/Servicio');
|
||||
|
||||
const noValido = (campo) => {
|
||||
throw new Error(`${campo} no es valido.`);
|
||||
};
|
||||
|
||||
const noHay = (variable, campo) => {
|
||||
if (!variable) throw new Error(`Falta ${campo}.`);
|
||||
};
|
||||
|
||||
const yaExiste = (campo) => {
|
||||
throw new Error(`${campo} ya se encuentra en uso.`);
|
||||
};
|
||||
|
||||
const validar = (texto, campo, length) => {
|
||||
noHay(texto, campo);
|
||||
if (typeof texto !== 'string' || (length && texto.length > length))
|
||||
noValido(campo);
|
||||
return texto;
|
||||
};
|
||||
|
||||
const validarId = (id) => {
|
||||
let campo = 'El id';
|
||||
|
||||
noHay(id, campo);
|
||||
if (typeof id === 'number') id = id.toString();
|
||||
if (typeof id !== 'string' || !validator.isNumeric(id, { no_symbols: true }))
|
||||
noValido(campo);
|
||||
return Number(id);
|
||||
};
|
||||
|
||||
const validarCorreo = (correo) => {
|
||||
let campo = 'El correo';
|
||||
|
||||
noHay(correo, campo);
|
||||
if (typeof correo !== 'string' || !validator.isEmail(correo)) noValido(campo);
|
||||
return correo;
|
||||
};
|
||||
|
||||
const caracteresEspeciales = (char) => {
|
||||
// Caractéres especiales permitidos en una string
|
||||
const caracterEspecial = (char) => {
|
||||
const charset = [
|
||||
' ',
|
||||
'.',
|
||||
'-',
|
||||
',',
|
||||
'/',
|
||||
'#',
|
||||
'?',
|
||||
'¿',
|
||||
':',
|
||||
';',
|
||||
'?',
|
||||
'¿',
|
||||
'!',
|
||||
'¡',
|
||||
'(',
|
||||
')',
|
||||
'"',
|
||||
"'",
|
||||
'-',
|
||||
'_',
|
||||
'/',
|
||||
'#',
|
||||
'%',
|
||||
'\n',
|
||||
];
|
||||
@@ -63,62 +30,146 @@ const caracteresEspeciales = (char) => {
|
||||
return false;
|
||||
};
|
||||
|
||||
const validarTexto = (texto, campo, length) => {
|
||||
noHay(texto, campo);
|
||||
if (typeof texto !== 'string' || texto.length > length) noValido(campo);
|
||||
const yaExiste = (campo, m) => {
|
||||
throw new Error(`Ya se encuentra en uso ${m ? 'el' : 'la'} ${campo}.`);
|
||||
};
|
||||
|
||||
const noValido = (campo, m, razon) => {
|
||||
console.log(m);
|
||||
throw new Error(
|
||||
`${m ? 'El' : 'La'} ${campo} no es valid${m ? 'o' : 'a'}, ${razon}.`
|
||||
);
|
||||
};
|
||||
|
||||
/*
|
||||
Valida que la variable contenga un valor, de lo contrario saca un error.
|
||||
*/
|
||||
const noHay = (variable, campo, m) => {
|
||||
if (!variable) throw new Error(`No se mando ${m ? 'el' : 'la'} ${campo}.`);
|
||||
};
|
||||
|
||||
/*
|
||||
Valida que la variable sea una string y, si se necesita, que mida igual
|
||||
o menor que una longitud determinada.
|
||||
*/
|
||||
const validacionBasicaStr = (texto, campo, m, length) => {
|
||||
noHay(texto, campo, m);
|
||||
if (typeof texto !== 'string') noValido(campo, m, 'no se mando una string');
|
||||
if (length && texto.length > length)
|
||||
noValido(campo, m, 'tiene más carecteres de lo permitido');
|
||||
return texto;
|
||||
};
|
||||
|
||||
/*
|
||||
Valida que la variable sea un numero entero, ya sea que recibe una string o
|
||||
un number. Usualmente se usa para validar ids.
|
||||
*/
|
||||
const validarNumeroEntero = (numero, campo, m = true) => {
|
||||
noHay(numero, campo, m);
|
||||
if (typeof numero === 'number') numero = numero.toString();
|
||||
if (typeof numero !== 'string')
|
||||
noValido(campo, m, 'no se mando una string o un number');
|
||||
if (!validator.isNumeric(numero, { no_symbols: true }))
|
||||
noValido(campo, m, 'no es un número entero valido');
|
||||
return Number(numero);
|
||||
};
|
||||
|
||||
/*
|
||||
Valida que la stirng mandada sea un correo valido.
|
||||
*/
|
||||
const validarCorreo = (correo, campo = 'correo', m = true, length) => {
|
||||
validacionBasicaStr(correo, campo, m, length);
|
||||
if (!validator.isEmail(correo)) noValido(campo, m, 'no es un correo válido');
|
||||
return correo;
|
||||
};
|
||||
|
||||
/*
|
||||
Valida que la stirng mandada sea solo caracteres del abcdario.
|
||||
Usualmente se usa para validar nombres, apellidos, etc.
|
||||
*/
|
||||
const validarTexto = (texto, campo, m, length) => {
|
||||
validacionBasicaStr(texto, campo, m, length);
|
||||
for (let i = 0; i < texto.length; i++)
|
||||
if (
|
||||
!validator.isAlpha(texto[i], 'es-ES') &&
|
||||
texto[i] != ' ' &&
|
||||
texto[i] != '.'
|
||||
)
|
||||
noValido(campo, m, 'contiene caracteres no validos');
|
||||
return texto;
|
||||
};
|
||||
|
||||
/*
|
||||
Lo mismo que el de arriba pero este permite números y
|
||||
caracteres especiales.
|
||||
*/
|
||||
const validarAlfanumerico = (texto, campo, m, length) => {
|
||||
validacionBasicaStr(texto, campo, m, length);
|
||||
for (let i = 0; i < texto.length; i++) {
|
||||
if (caracteresEspeciales(texto[i])) continue;
|
||||
if (!validator.isAlpha(texto[i], 'es-ES')) noValido(campo);
|
||||
if (caracterEspecial(texto[i])) continue;
|
||||
if (!validator.isAlphanumeric(texto[i], 'es-ES'))
|
||||
noValido(campo, m, 'contiene caracteres no validos');
|
||||
}
|
||||
return texto;
|
||||
};
|
||||
|
||||
const validarAlfanumerico = (texto, campo, length) => {
|
||||
noHay(texto, campo);
|
||||
if (typeof texto !== 'string' || texto.length > length) noValido(campo);
|
||||
for (let i = 0; i < texto.length; i++) {
|
||||
if (caracteresEspeciales(texto[i])) continue;
|
||||
if (!validator.isAlphanumeric(texto[i], 'es-ES')) noValido(campo);
|
||||
}
|
||||
return texto;
|
||||
};
|
||||
|
||||
const validarNumeroCuenta = (numeroCuenta) => {
|
||||
let campo = 'El numero de cuenta';
|
||||
|
||||
noHay(numeroCuenta, campo);
|
||||
if (
|
||||
typeof numeroCuenta !== 'string' ||
|
||||
!validator.isNumeric(numeroCuenta, { no_symbols: true }) ||
|
||||
numeroCuenta.length > 9
|
||||
)
|
||||
noValido(campo);
|
||||
/*
|
||||
Valida que la string sea un número menor a 9 dígitos.
|
||||
*/
|
||||
const validarNumeroCuenta = (
|
||||
numeroCuenta,
|
||||
campo = 'numero de cuenta',
|
||||
m = true
|
||||
) => {
|
||||
validacionBasicaStr(numeroCuenta, campo, m, 9);
|
||||
if (!validator.isNumeric(numeroCuenta, { no_symbols: true }))
|
||||
noValido(campo, m, 'tiene caracteres que no son números');
|
||||
return numeroCuenta;
|
||||
};
|
||||
|
||||
const validarFecha = (fecha) => {
|
||||
let campo = 'La fecha';
|
||||
/*
|
||||
Valida que la variable sea una fecha moment valida.
|
||||
*/
|
||||
const validarFecha = (fecha, campo, m) => {
|
||||
let fechaMoment = moment(fecha);
|
||||
|
||||
noHay(fecha, campo);
|
||||
if (!fechaMoment.isValid()) noValido(campo);
|
||||
noHay(fecha, campo, m);
|
||||
if (!fechaMoment.isValid()) noValido(campo, m, 'no es una fecha válida');
|
||||
return fechaMoment;
|
||||
};
|
||||
|
||||
const validarNumero = (numero, makeNumber = false, length) => {
|
||||
let campo = 'El numero';
|
||||
|
||||
noHay(numero, campo);
|
||||
if (
|
||||
typeof numero !== 'string' ||
|
||||
!validator.isNumeric(numero, { no_symbols: true }) ||
|
||||
(length && numero.length > length)
|
||||
)
|
||||
noValido(campo);
|
||||
/*
|
||||
Valida que una string contenga solo números
|
||||
*/
|
||||
const validarNumero = (
|
||||
numero,
|
||||
campo,
|
||||
m,
|
||||
length,
|
||||
no_symbols = true,
|
||||
makeNumber = false
|
||||
) => {
|
||||
validacionBasicaStr(numero, campo, m, length);
|
||||
if (!validator.isNumeric(numero, { no_symbols }))
|
||||
noValido(campo, m, 'tiene caracteres que no son números');
|
||||
if (makeNumber) return Number(numero);
|
||||
return numero;
|
||||
};
|
||||
|
||||
// const validarAccesibilidad = (usuariosValidos = [], idTipoUsuario) => {
|
||||
// for (let i = 0; i < usuariosValidos.length; i++)
|
||||
// if (idTipoUsuario === usuariosValidos[i]) return;
|
||||
// throw new Error('Este usuario no tiene permitido usar esta linea de la API.');
|
||||
// };
|
||||
|
||||
/*
|
||||
Te dice si un objeto esta vacio o no.
|
||||
*/
|
||||
const validarObjetoVacio = (obj) => {
|
||||
for (let key in obj) if (obj.hasOwnProperty(key)) return false;
|
||||
return true;
|
||||
};
|
||||
|
||||
const validarPreTermino = (idServicio) => {
|
||||
return Servicio.findOne({ where: { idServicio } })
|
||||
.then((res) => {
|
||||
@@ -131,39 +182,25 @@ const validarPreTermino = (idServicio) => {
|
||||
return Servicio.update({ idStatus: 5 }, { where: { idServicio } });
|
||||
return false;
|
||||
})
|
||||
.then((res) => {
|
||||
if (res)
|
||||
return 'Este Servicio Social paso a Termino, espera a que COESI autorice tu liberación.';
|
||||
return '';
|
||||
});
|
||||
};
|
||||
|
||||
const validarAccesibilidad = (usuariosValidos = [], idTipoUsuario) => {
|
||||
for (let i = 0; i < usuariosValidos.length; i++)
|
||||
if (idTipoUsuario === usuariosValidos[i]) return;
|
||||
throw new Error('Este usuario no tiene permitido usar esta linea de la API.');
|
||||
};
|
||||
|
||||
const validarObjetoVacio = (obj) => {
|
||||
for (let key in obj) {
|
||||
if (obj.hasOwnProperty(key)) return false;
|
||||
}
|
||||
return true;
|
||||
.then((res) =>
|
||||
res
|
||||
? 'Este Servicio Social paso a Termino, espera a que COESI autorice tu liberación.'
|
||||
: ''
|
||||
);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
validar,
|
||||
noValido,
|
||||
yaExiste,
|
||||
noValido,
|
||||
noHay,
|
||||
validacionBasicaStr,
|
||||
validarNumeroEntero,
|
||||
validarCorreo,
|
||||
validarId,
|
||||
validarTexto,
|
||||
validarAlfanumerico,
|
||||
validarNumeroCuenta,
|
||||
validarFecha,
|
||||
validarNumero,
|
||||
validarPreTermino,
|
||||
validarAccesibilidad,
|
||||
validarObjetoVacio,
|
||||
validarPreTermino,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user