let Persona = {
NumeroEmpleado: "",
Password: "",
pub_key: "",
RFC: "",
Nombre: "",
aPaterno: "",
aMaterno: "",
periodos_Disponibles: [],
tiposPuesto: [],
puesto:"",
puestoSel:"",
estado_Cuenta: "",
periodo: '',
cantidad: '',
muestra: '',
descarga: '',
numerousuario:'',
responde:[],
codigo:-1,
respuesta:"",
timeprogress:0,
progreso:0,
data_Usuario: [],
intervalo:0,
CentroCosto:"",
tipodePuesto:"",
unset: function () {
this.NumeroEmpleado = "",
this.Password = "",
this.pub_key = "",
this.RFC = "",
this.Nombre = "",
this.aPaterno = "",
this.aMaterno = "",
this.periodos_Disponibles = [],
this.tiposPuesto= [],
this.puesto="",
this.puestoSel="",
this.estado_Cuenta = "",
this.periodo = "",
this.cantidad= "",
this.muestra= "",
this.descarga= "",
this.numerousuario="",
this.responde=[]
this.codigo=-1,
this.respuesta="",
this.timeprogress=0,
this.progreso=0,
this.data_Usuario=[],
this.CentroCosto="",
this.tipodePuesto=""
},
setpub_key: function () {
this.pub_key = '7rZm68EY9gZh8sElPlbAZgj1';
},
getpub_key: function () {
return pub_key;
},
setCantidad: function (Cantidad) {
this.Cantidad = Cantidad;
},
getCantidad: function () {
return this.Cantidad;
},
setaMaterno: function (aMaterno) {
this.aMaterno = aMaterno;
},
getaMaterno: function () {
return this.aMaterno;
},
setaPaterno: function (aPaterno) {
this.aPaterno = aPaterno;
},
getaPaterno: function () {
return this.aPaterno;
},
setNombre: function (Nombre) {
this.Nombre = Nombre;
},
getNombre: function () {
return this.Nombre;
},
setRFC: function (RFC) {
this.RFC = RFC;
},
getRFC: function () {
return this.RFC;
},
setNumeroEmpleado: function (NumeroEmpleado) {
this.NumeroEmpleado = NumeroEmpleado;
},
getNumeroEmpleado: function () {
return this.NumeroEmpleado;
},
setPassword: function (Password) {
this.Password = Password;
},
getPassword: function () {
return this.Password;
},
getPublic_key: function () {
return pub_key;
},
setperiodos_Disponibles: function (periodos_Disponibles) {
this.periodos_Disponibles = periodos_Disponibles;
},
getperiodos_Disponibles: function () {
return this.periodos_Disponibles;
},
setTiposPuesto: function (tiposPuesto) {
this.tiposPuesto = tiposPuesto;
},
getTiposPuesto: function () {
return this.tiposPuesto;
},
setPuesto: function (puesto) {
this.puesto = puesto;
},
getPuesto: function () {
return this.puesto;
},
setPuestoSel: function (puestoSel) {
this.puestoSel = puestoSel;
},
getPuestoSel: function () {
return this.puestoSel;
},
setEstadoCuenta: function (estado_Cuenta) {
this.estado_Cuenta = estado_Cuenta;
},
getEstadoCuenta: function () {
return this.estado_Cuenta;
},
setPeriodo: function (periodo) {
this.periodo = periodo;
},
getPeriodo: function () {
return this.periodo;
},
setMuestra: function (muestra) {
this.muestra = muestra;
},
getMuestra: function () {
return this.muestra;
},
setDescarga: function (descarga) {
this.descarga = descarga;
},
getDescarga: function () {
return this.descarga;
},
setnumerousuario: function (numerousuario) {
this.numerousuario = numerousuario;
},
getnumerousuario: function () {
return this.numerousuario;
},
setresponde: function (responde) {
this.responde = responde;
},
getresponde: function () {
return this.responde;
},
setcodigo: function (codigo) {
this.codigo = codigo;
},
getcodigo: function () {
return this.codigo;
},
setrespuesta: function (respuesta) {
this.respuesta = respuesta;
},
getrespuesta: function () {
return this.respuesta;
},
/******* */
setdata_Usuario: function (data_Usuario) {
this.data_Usuario = data_Usuario;
},
getdata_Usuario: function () {
return this.data_Usuario;
},
settimeprogress: function (value) {
this.timeprogress = value;
},
gettimeprogress: function () {
return this.timeprogress;
},
setprogreso: function (value) {
this.progreso = value;
},
getpprogreso: function () {
return this.progreso;
},
setcentroCosto: function (value) {
this.CentroCosto = value;
},
getCentroCosto: function () {
return this.CentroCosto;
},
settipodePuesto: function (value) {
this.tipodePuesto = value;
},
gettipodePuesto: function () {
return this.tipodePuesto;
},
Cipher: function (dato) {
const tiempoTranscurrido = Date.now();
const hoy = new Date(tiempoTranscurrido);
hoy.toISOString();
let cadena = dato + "~" + this.pub_key + "~" + hoy.toISOString();
//console.log("cadena " + cadena)
hash = btoa(cadena)
//console.log("hash " + hash)
return hash;
},
actualizarProgressBar:function() {
//console.log("progreso "+Persona.getpprogreso());
$("#progressLogin").width(Persona.getpprogreso() + "%");//.text(Persona.getpprogreso() + "%");
},
animarProgressBar:function(limit) {
if (Persona.getpprogreso() <= limit) {
Persona.setprogreso(Persona.getpprogreso()+3); // Incrementa el progreso (puedes ajustar esto)
this.actualizarProgressBar();
}
else{/*
Persona.setprogreso(95)
clearInterval(Persona.intervalo);
Persona.actualizarProgressBar();
//Persona.animarProgressBar(limit)
Persona.intervalo = setInterval(() => Persona.animarProgressBar(95), 500);
*/
Persona.setprogreso(Persona.getpprogreso()+1); // Incrementa el progreso (puedes ajustar esto)
this.actualizarProgressBar();
if(Persona.getpprogreso()==100){
Persona.setprogreso(95); // Incrementa el progreso (puedes ajustar esto)
this.actualizarProgressBar();
}
}
},
deten_animacion:function(){
Persona.setprogreso(0)
clearTimeout(Persona.intervalo);
}
,
Login: function () {
console.log("animo la barra")
Persona.intervalo = setInterval(() => Persona.animarProgressBar(20), 100);
//Persona.setprogreso(20); // Incrementa el progreso (puedes ajustar esto)
//this.actualizarProgressBar();
this.setNumeroEmpleado($("#txtUsuario").val())
this.setPassword(this.Cipher($("#txtContrasenya").val()))
var settings = {
"url": "/LoginSACI",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json"
},
"data": JSON.stringify({
"NumeroEmpleado": this.getNumeroEmpleado(),
"Password": this.getPassword()
}),
};
//Persona.setprogreso(60); // Incrementa el progreso (puedes ajustar esto)
//Persona.actualizarProgressBar();
$.ajax(settings).done(function (response) {
console.log(response)
//console.log("Persona.load_databaseRT()_1")
Persona.postLogin(response)
});
},
postLogin:function(response){
if(response.codigo==0){
Persona.setRFC(response.RFC)
Persona.setaPaterno(response.aPaterno);
Persona.setaMaterno(response.aMaterno);
Persona.setNombre(response.Nombre);
Persona.URL=response.url//"/EstadoCuentaLoginExitoSu"
}
else{
Persona.setcodigo(response.codigo)
Persona.setrespuesta(response.respuesta)
}
//Persona.setprogreso(90); // Incrementa el progreso (puedes ajustar esto)
//Persona.actualizarProgressBar();
//this.intervalo = setInterval(() => this.animarProgressBar(100), 100);
// Aquí puedes colocar el código que deseas ejecutar después de la espera
// Incrementa el progreso (puedes ajustar esto)
//this.actualizarProgressBar();
//console.log(response);
//deten_animacion()
//animarProgressBar(100)
/*var openWindow = window.open(response.url, 'Estado de Cuenta', 'width = 500, height = 500'); */
/*$(openWindow).html(response);*/
// console.log(response)
//setTimeout(function() {
revisarDBFB().then(function(){
//ocultarCargando();
clearInterval(Persona.intervalo)
Persona.setprogreso(100);
$("#progressLogin").width( "105%");
//timeout300 = setTimeout(Persona.llena_cuerpo(response), 5000);
timeout300 = setTimeout(function() {
Persona.llena_cuerpo(response)
}, 1000);
})
//}, 100);
},
llena_cuerpo:function(response){
$("#contenido").load(response.url, function () {
//timeout400 = setTimeout(cargaModalWebEstilos(response), 5000);
//timeout400 = setTimeout(function() {
cargaModalWebEstilos(response)
//}, 5000);
//Persona.load_databaseRT()
});
},
ConsultaEstadoCuenta: function () {
var settings = {
"url": "/ConsultaArchivo",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json"
},
"data": JSON.stringify({
"RFC": this.getRFC(),
"Periodo": this.getPeriodo(),
"NumEmp": this.getNumeroEmpleado(),
"tp":this.getPuestoSel(),
"Descarga":Persona.getDescarga(),
"Muestra":Persona.getMuestra()
}),
};
$.ajax(settings).done(function (response) {
if (response.codigo === 1) {
/*alert("Ocurió un error al mostrar el archivo, porfavor comuniquese a la ext XXXX en donde le brindarán mas detalles del error , disculpe las molestias")*/
$('#error').show()
$('#consultado').hide();
$('#periodo').hide()
$('#anterior').hide()
}
else {
$('#error').hide()
//console.log(response);
//console.log(response.archivo);
archivob64F = response.archivo
archivob64 = archivob64F.substring(2, archivob64F.length - 1);
//console.log(archivob64);
Persona.setEstadoCuenta(archivob64)
/*$("#btn-saltar").attr("href", archivob64);*/
response.cantidad > 0 ? $('#anterior').show() : $('#anterior').hide();
Persona.setCantidad(response.cantidad)
if (Persona.getMuestra() === 1) {
$("#canvas").html("");
$("#canvas").html("");
pintaPDF(archivob64)
/*response.cantidad>0 ? alert("se revisó previamente el estado de cuenta") : alert("Consulta de conformidad del Estado de Cuenta del periodo "+Persona.getPeriodo())*/
$("#PDF").css("display", "block")
//console.log("consultaEC")
}
if (Persona.getDescarga() === 1) {
var dlnk = document.getElementById('dwnldLnk');
dlnk.href = 'data:application/octet-stream;base64,' + Persona.getEstadoCuenta();
dlnk.click()
//console.log("descargaEC")
}
/*$('#DescargaEC').prop('disabled', false);*/
}
});
},
ConsultaEstadoCuentaS: function (RFC,PERIODO,NUMEROEMPLEADO,PUESTO,ConsultaDes) {
var settings = {
"url": "/ConsultaArchivoS",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json"
},
"data": JSON.stringify({
"RFC": RFC,
"Periodo": PERIODO,
"NumEmp": NUMEROEMPLEADO,
"tp":PUESTO
}),
};
$.ajax(settings).done(function (response) {
// console.log(response)
if (response.codigo === 1) {
alert("Ocurió un error al mostrar el archivo, porfavor comuniquese a la ext XXXX en donde le brindarán mas detalles del error , disculpe las molestias")
}
else {
//$('#error').hide()
//console.log(response);
//console.log(response.archivo);
archivob64F = response.archivo
archivob64 = archivob64F.substring(2, archivob64F.length - 1);
//console.log(archivob64);
//Persona.setEstadoCuenta(archivob64)
/*$("#btn-saltar").attr("href", archivob64);*/
let perr= "Periodo"
if (PERIODO == '01-01-2022 / 30-04-2022'){
perr='01-2022'
}
if (PERIODO == '01-05-2022 / 31-08-2022'){
perr='02-2022'
}
if (PERIODO == '01-09-2022 / 31-12-2022'){
perr='03-2022'
}
if (PERIODO == '01-01-2023 / 30-04-2023'){
perr='01-2023'
}
if (PERIODO == '01-05-2023 / 31-08-2023'){
perr='02-2023'
}
if (PERIODO == '01-09-2023 / 31-12-2023'){
perr='03-2023'
}
if (PERIODO == '01-01-2024 / 30-04-2024'){
perr='01-2024'
}
if (PERIODO == '01-12-2021 / 31-12-2021'){
perr='Unico-2021'
}
if(ConsultaDes==="Des"){
const linkSource = 'data:application/pdf;base64,'+archivob64;
const downloadLink = document.createElement("a");
const fileName = "EstadoCuenta-"+NUMEROEMPLEADO+"-"+perr+".pdf";
downloadLink.href = linkSource;
downloadLink.download = fileName;
downloadLink.click();
}
if(ConsultaDes==="Mue"){
console.log("pintaPDFS(archivob64,false)")
//$("#canvasS").html("");
//$("#canvasS").html("");
timeout2000 = setTimeout(function() {
pintaPDFS(archivob64,false)
}, 1000);
}
//if (Persona.getDescarga() === 1) {
/* var dlnk = document.getElementById('DescargaECS');
dlnk.href = 'data:application/pdf;base64,' +
dlnk.click()*/
//console.log("descargaEC")
//}
/*$('#DescargaEC').prop('disabled', false);*/
}
});
},
Logout: function () {
var settings = {
"url": "/LogoutSACI",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json"
},
"data": JSON.stringify({
"NumeroEmpleado": this.getNumeroEmpleado()
}),
};
$.ajax(settings).done(function (response) {
//console.log(response);
//$("#contenido").load(response.url, function () {
Persona.unset();
location.reload();
//});
});
},
ConsultaUser:function(){
var settings = {
"url": "/LoginSuperSACI",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json"
},
"data": JSON.stringify({
"NumeroEmpleado": this.getNumeroEmpleado(),
"Password": this.getPassword(),
"NumeroEmpleadoC": this.getnumerousuario()
}),
};
$.ajax(settings).done(function (response) {
//console.log(response);
/*
setresponde: function (responde) {
this.responde = responde;
},
getresponde: function () {
return this.responde;
},
*/Persona.setresponde(response)
muestraData()
});
},
/*,
ConsultaRFC:function(){
var settings = {
"url": "/ConsultaRFC",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json"
},
"data": JSON.stringify({
"NumeroEmpleado": this.getNumeroEmpleado()
}),
};
$.ajax(settings).done(function (response) {
var o = JSON.parse(response);
Persona.setRFC(o[0].RFC);
Persona.setaPaterno(o[0].aPaterno);
Persona.setaMaterno(o[0].aMaterno);
Persona.setNombre(o[0].Nombre);
});
}*/
load_databaseRT:function(){
console.log("load_databaseRT")
muestraDataExp()
}
}