Primer Commit
This commit is contained in:
155
js/consultas_historial.js
Normal file
155
js/consultas_historial.js
Normal file
@@ -0,0 +1,155 @@
|
||||
|
||||
//REDIRECCION A LA PAGINA PRINCIPAL DE FACTURA
|
||||
document.getElementById('verFacturas').addEventListener('click', function () {
|
||||
var animacion = document.getElementsByClassName('xyz-in');
|
||||
|
||||
var ani = document.querySelectorAll('.xyz-in');
|
||||
|
||||
ani.forEach(function(animado, arrayIndex) {
|
||||
animado.classList.remove('xyz-in');
|
||||
animado.classList.add('xyz-out');
|
||||
});
|
||||
|
||||
setTimeout(function(){
|
||||
window.location.href = 'portal.php';
|
||||
},800);
|
||||
|
||||
});
|
||||
|
||||
|
||||
//INICIALIZACIÓN DE TABLA CON JQUERY PARA DATATABLES CON SUS ARGUMENTOS PARA DARLE CARACTERISTICAS
|
||||
$(document).ready(function () {
|
||||
var table = $('#facturasTable').DataTable({
|
||||
lengthMenu: [10, 25, 50, 100],
|
||||
pageLength: 10,
|
||||
searching: true,
|
||||
paging: true,
|
||||
ordering: true,
|
||||
info: true,
|
||||
responsive: true,
|
||||
dom: 'Blfrtip',
|
||||
buttons: [
|
||||
{
|
||||
extend: 'excel',
|
||||
className: 'btn btn-success',
|
||||
text: 'Exportar a Excel',
|
||||
filename: 'Historial_Cancelaciones',
|
||||
},
|
||||
{
|
||||
extend: 'pdf',
|
||||
className: 'btn btn-danger',
|
||||
text: 'Exportar a PDF',
|
||||
filename: 'Historial_Cancelaciones',
|
||||
|
||||
}],
|
||||
columns: [
|
||||
{"className": "xyz-in"},
|
||||
{"className": "xyz-in"},
|
||||
{"className": "xyz-in"},
|
||||
{"className": "xyz-in"},
|
||||
{"className": "xyz-in"},
|
||||
{"className": "xyz-in"},
|
||||
{"className": "xyz-in"},
|
||||
{"className": "xyz-in"},
|
||||
{"className": "xyz-in"},
|
||||
{"className": "xyz-in"},
|
||||
],
|
||||
columnDefs: [
|
||||
{ width: "5%", "targets": [0] },
|
||||
{ width: "10%", "targets": [1] },
|
||||
{ width: "5%", "targets": [2] },
|
||||
{ width: "5%", "targets": [3] },
|
||||
{ width: "20%", "targets": [4] },
|
||||
{ width: "18%", "targets": [5] },
|
||||
{ width: "5%", "targets": [6] },
|
||||
{ width: "10%", "targets": [7] },
|
||||
{ width: "10%", "targets": [8] },
|
||||
{ width: "7%", "targets": [9] },
|
||||
],
|
||||
|
||||
});
|
||||
|
||||
// Agrega control de selección de longitud
|
||||
|
||||
table.buttons().container().appendTo('#facturasTable_wrapper .col-md-6:eq(0)');
|
||||
|
||||
var responsesArray = [];
|
||||
var currentPage = 1;
|
||||
|
||||
$('#facturasTable').off('page.dt').on('page.dt', function () {
|
||||
|
||||
currentPage = table.page.info().page + 1;
|
||||
|
||||
});
|
||||
|
||||
//CUANDO EL DOCUMENTO ESTE LISTO, SE EJECUTA ESTE CODIGO MANDANDO A LLAMAR UNA API PARA CONSULTAS DE SOLICITUDES CON EL STATUS 4
|
||||
$(document).ready(function(){
|
||||
var api = document.getElementById("api").value;
|
||||
|
||||
var nombre_negocio = document.getElementById("nombre_negocio").value;
|
||||
//SE EJECUTA AJAX PARA MANDAR A LLAMAR A LA API, POR EL DATA SE MANDAN LOS PARAMETROS QUE NECESITA LA API PARA SU FUNCIONAMIENTO
|
||||
$.ajax({
|
||||
data: {nombre_negocio:nombre_negocio}, //datos que se envian a traves de ajax
|
||||
url: api+'/api/historialSolicitudesCan', //archivo que recibe la peticion
|
||||
type: 'post', //método de envio
|
||||
dataType: 'json',
|
||||
beforeSend: function () {
|
||||
//SE MUESTRA UN MENSAJE DE CARGANDO MIENTRAS SE ESPERA UNA RESPUESTA
|
||||
$("#datos_soli").html('<tr class="text-center"><td colspan="9"><div class="spinner-border" role="status"><span class="sr-only"></span></td></tr></div>');
|
||||
},
|
||||
success: function(response) {
|
||||
//CONDICIONAL PARA CORROBORAR QUE EXISTAN DATOS EN LA BD Y PINTARLOS EN LA TABLA
|
||||
if(response == "sin_datos"){
|
||||
$("#datos_soli").html('<tr class="text-center"><td colspan="8">Sin datos</td></tr></div>');
|
||||
}else{
|
||||
setTimeout(function(){
|
||||
response.forEach(function(factura, arrayIndex) {
|
||||
//CREAMOS UNA FILA POR CADA MÓDULO DE DATOS
|
||||
//factura - VARIABLE DONDE SE ENCUENTRA GUARDADA LA INFORMACIÓN DE LOS DATOS
|
||||
//arrayIndex - VARIABLE DONDE SE ENCUENTRA GUARDADA LA POSICIÓN DE LA FILA EN LA TABLA
|
||||
var fecha = factura.created_at;
|
||||
var fecha_format = fecha.slice(0, -9);
|
||||
table.row.add([
|
||||
fecha_format,
|
||||
factura.nombre_solicitante,
|
||||
factura.nombreusuarioscreador,
|
||||
factura.unidadNegocio,//se agrega el nombre de la unidad de negocio de la factura
|
||||
factura.uuid,
|
||||
factura.motivo,
|
||||
factura.nombreusuarioautoriza,
|
||||
factura.nombreusuariocancelo,
|
||||
factura.descripcion,
|
||||
factura.status
|
||||
]).draw(false);
|
||||
})
|
||||
}, 2000);
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
}).fail(function(response){ //EN CASO DE FALLO, SE PINTA UN ERROR EN CONSOLA
|
||||
console.log("FAIL", response);
|
||||
})
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
//FUNCION PARA CERRAR LA SESIÓN DEL USUARIO
|
||||
function logout() {
|
||||
|
||||
document.getElementById('logoutForm').action = 'logout.php';
|
||||
|
||||
document.getElementById('logoutForm').submit();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user