You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
143 lines
4.5 KiB
143 lines
4.5 KiB
1 year ago
|
|
||
|
$(function () {
|
||
|
|
||
|
$(document).ajaxStart(function(){
|
||
|
$.blockUI({
|
||
|
message: '<i class="fas fa-spin fa-sync text-white"></i>',
|
||
|
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 = '<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton" style="">'+
|
||
|
'<li>'+
|
||
|
'<a class="dropdown-item" onclick="eliminarUsuario('+ id +')">Eliminar</a>'+
|
||
|
'</li>'+
|
||
|
'</ul>';
|
||
|
return '<div class="dropdown dropstart">'+
|
||
|
'<a href="table-basic.html#" class="link" id="dropdownMenuButton" data-bs-toggle="dropdown" aria-expanded="false">'+
|
||
|
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-more-horizontal feather-sm">'+
|
||
|
'<circle cx="12" cy="12" r="1"></circle>'+
|
||
|
'<circle cx="19" cy="12" r="1"></circle>'+
|
||
|
'<circle cx="5" cy="12" r="1"></circle>'+
|
||
|
'</svg>'+
|
||
|
'</a>'+
|
||
|
botonAcciones+
|
||
|
'</div>';
|
||
|
},
|
||
|
title: "Acciones"},
|
||
|
{ data: "empleado.nombre_completo", defaultContent: "---", title: "Nombre" },
|
||
|
{data:function(row, type){
|
||
|
const nombre_archivo = row.nombre_archivo;
|
||
|
|
||
|
return '<a href="storage/'+ nombre_archivo +'">'+ nombre_archivo +'</a>';
|
||
|
},
|
||
|
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!",
|
||
|
});
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|