Merge branch 'main' into feat/imposiciones/sk-40

This commit is contained in:
amazuecos
2025-04-12 23:54:52 +02:00
49 changed files with 998 additions and 1288 deletions

View File

@ -17,7 +17,7 @@ $(() => {
$("#btn-new-maquina-duplicate").off();
$("#duplicated_name").addClass("is-valid").removeClass('d-none');
$("#duplicated_name").val("")
window.open('/maquinas/edit/' + response.data.id)
window.open('/configuracion/maquinas/edit/' + response.data.id)
},
(error) => {

View File

@ -35,7 +35,7 @@ class MaquinasList {
e.preventDefault(); // Previene cualquier comportamiento por defecto del enlace
const dataId = $(this).closest('tr').find('[data-id]').data('id'); // Obtén el ID dinámico
const dynamicUrl = '/maquinas/edit/' + dataId;
const dynamicUrl = '/configuracion/maquinas/edit/' + dataId;
if (!Number.isNaN(Number(dataId))) {
if (e.ctrlKey || e.metaKey) {
@ -102,7 +102,7 @@ class MaquinasList {
this.tableMaquinas = new Table(
$('#tableOfMaquinas'),
'maquinasList',
'/maquinas/datatable',
'/configuracion/maquinas/datatable',
columns,
[]
);

View File

@ -0,0 +1,97 @@
import Ajax from '../../components/ajax.js';
document.addEventListener('DOMContentLoaded', function () {
const lastColNr = $('#tableOfPaises').find("tr:first th").length - 1;
const theTable = $('#tableOfPaises').DataTable({
processing: true,
serverSide: true,
autoWidth: true,
responsive: true,
scrollX: true,
lengthMenu: [5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500],
pageLength: 10,
lengthChange: true,
dom: 'lfBrtip',
buttons: [
'copy', 'csv', 'excel', 'print', {
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'A4'
}
],
stateSave: true,
order: [[1, 'asc']],
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
ajax: {
url: '/configuracion/paises/datatable',
method: 'GET'
},
columnDefs: [
{
orderable: false,
searchable: false,
targets: [lastColNr]
}
],
columns: [
{ data: 'nombre' },
{ data: 'code' },
{ data: 'code3' },
{ data: 'moneda' },
{ data: 'url_erp' },
{ data: 'user_erp' },
{ data: 'key_erp' },
{ data: 'show_erp' },
{ data: 'actionBtns' }
]
});
$(document).on('click', '.btn-edit', function (e) {
window.location.href = '/configuracion/paises/edit/' + $(this).attr('data-id');
});
$(document).on('click', '.btn-delete', function (e) {
e.preventDefault();
const row = $(this).closest('tr')[0]._DT_RowIndex;
const dataId = $(this).attr('data-id');
Swal.fire({
title: '¿Estás seguro?',
text: 'Esta acción no se puede deshacer.',
icon: 'warning',
showCancelButton: true,
confirmButtonText: 'Sí',
cancelButtonText: 'No',
reverseButtons: false,
buttonsStyling: true,
customClass: {
confirmButton: 'btn btn-danger', // rojo para "Sí"
cancelButton: 'btn btn-secondary' // gris para "No"
}
}).then((result) => {
if (result.isConfirmed) {
new Ajax(
'/configuracion/paises/delete/' + dataId,
{},
{},
(data, textStatus, jqXHR) => {
theTable.clearPipeline();
theTable.row($(row)).invalidate().draw();
popSuccessAlert(data.msg ?? jqXHR.statusText);
},
(error) => {
console.error(error);
Swal.fire('Error', 'No se pudo eliminar el país.', 'error');
}
).get();
}
});
});
});