$(function () { $(document).ajaxStart(function(){ $.blockUI({ message: '', overlayCSS: { backgroundColor: "#000", opacity: 0.5, cursor: "wait", }, css: { border: 0, padding: 0, color: "#333", backgroundColor: "transparent", } }); }); $(document).ajaxStop($.unblockUI); $("#formCargarArchivosNomina").on("submit", function(e){ e.preventDefault(); var formData = new FormData(this); Swal.fire({ title: "¿Esta seguro que desea cargar los archivos?", type: "warning", showCancelButton: true, confirmButtonColor: "#3085d6", cancelButtonColor: "#d33", cancelButtonText: "Cancelar", confirmButtonText: "Aceptar", }).then((result) => { if (result.value) { $('#cerrarModalCargarArchivosNominas').trigger("click"); $.ajax({ type:'POST', url:'cargar_archivos', headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')}, data: formData, processData:false, contentType: false, success:function(data){ console.log(data); cargarListaArchivos(); Swal.fire("¡Éxito!", "Se agregeraon los archivos.", "success"); }, error: function (e) { mensajeError(); } }); } }); }); }); cargarListaArchivos(); function cargarListaArchivos(){ $('#listaArchivos').empty(); $('#listaArchivos').DataTable({ searchDelay: 400, ajax: { url: 'api/obtener_lista_archivos_nominas', dataSrc: function(json){ return json; } }, // order: [[0, 'asc']], // ordering:true, columns:[ // { data: "id", defaultContent: "---", title: "#" }, {data:function(row, type){ const id = row.id; let botonAcciones = ''; return ''; }, title: "Acciones"}, { data: "empleado.nombre_completo", defaultContent: "---", title: "Nombre" }, {data:function(row, type){ const nombre_archivo = row.nombre_archivo; return ''+ nombre_archivo +''; }, title: "Archivo de nomina"}, { data: "empleado.clave_contpaq", defaultContent: "---", title: "Clave contpaq" }, ], aLengthMenu: [ [25, 50, 100, 200, -1], [25, 50, 100, 200, 'All'] ], destroy: true, paging:true, info:true, // responsive: true, // dom: "Bfrtip", // buttons: ["copy", "csv", "excel", "pdf", "print"], "language": { "url": "//cdn.datatables.net/plug-ins/1.10.19/i18n/Spanish.json" } }); } function mensajeError(){ Swal.fire({ type: "error", title: "Oops...", text: "¡Lo siento, ocurrió un error!", }); }