From 281e5984c5a134dcbc5afa73e81f738d0d8f5632 Mon Sep 17 00:00:00 2001 From: imnavajas Date: Mon, 24 Jul 2023 14:50:34 +0200 Subject: [PATCH] Terminada funcionalidad eliminar basada en Modal y SweetAlert. Aplicada a tarifas, papeles y maquinas existentes --- ci4/app/Config/Routes.php | 1 + ci4/app/Controllers/Clientes/Cliente.php | 9 +- .../_commonPartialsBs/_confirm2delete.php | 2 +- .../form/clientes/cliente/viewClienteList.php | 74 +++---- .../maquinas/viewMaquinaList.php | 198 ++++++++---------- .../maquinas/viewMaquinaPorDefectoList.php | 80 +++---- .../papel/viewPapelGenericoList.php | 89 ++++---- .../papel/viewPapelImpresionList.php | 101 ++++----- .../tarifas/acabado/viewTarifaAcabadoList.php | 3 +- .../manipulado/viewTarifaManipuladoList.php | 64 ++---- 10 files changed, 260 insertions(+), 361 deletions(-) diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 04dd195a..e00b2501 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -328,6 +328,7 @@ $routes->group('cliente', ['namespace' => 'App\Controllers\Clientes'], function $routes->post('create', 'Cliente::create', ['as' => 'ajaxCreateCliente']); $routes->put('(:num)/update', 'Cliente::update/$1', ['as' => 'ajaxUpdateCliente']); $routes->post('(:num)/edit', 'Cliente::edit/$1', ['as' => 'updateCliente']); + $routes->get('delete/(:num)', 'Cliente::delete/$1', ['as' => 'deleteCliente']); $routes->post('datatable', 'Cliente::datatable', ['as' => 'dataTableOfClientes']); $routes->post('allmenuitems', 'Cliente::allItemsSelect', ['as' => 'select2ItemsOfClientes']); $routes->post('menuitems', 'Cliente::menuItems', ['as' => 'menuItemsOfClientes']); diff --git a/ci4/app/Controllers/Clientes/Cliente.php b/ci4/app/Controllers/Clientes/Cliente.php index 2ae6d61a..cb56cc1c 100644 --- a/ci4/app/Controllers/Clientes/Cliente.php +++ b/ci4/app/Controllers/Clientes/Cliente.php @@ -41,6 +41,12 @@ class Cliente extends \App\Controllers\GoBaseResourceController { $this->viewData['pageTitle'] = lang('Clientes.moduleTitle'); $this->viewData['usingSweetAlert'] = true; + // Se indica que este controlador trabaja con soft_delete + $this->soft_delete = true; + // Se indica el flag para los ficheros borrados + $this->delete_flag = 1; + + // Breadcrumbs (IMN) $this->viewData['breadcrumb'] = [ ['title' => lang("App.menu_clientes"), 'route' => "", 'active' => false], @@ -68,8 +74,7 @@ class Cliente extends \App\Controllers\GoBaseResourceController { public function add() { - - + $requestMethod = $this->request->getMethod(); diff --git a/ci4/app/Views/themes/_commonPartialsBs/_confirm2delete.php b/ci4/app/Views/themes/_commonPartialsBs/_confirm2delete.php index 177526e4..50e7ee0b 100644 --- a/ci4/app/Views/themes/_commonPartialsBs/_confirm2delete.php +++ b/ci4/app/Views/themes/_commonPartialsBs/_confirm2delete.php @@ -13,7 +13,7 @@ diff --git a/ci4/app/Views/themes/backend/vuexy/form/clientes/cliente/viewClienteList.php b/ci4/app/Views/themes/backend/vuexy/form/clientes/cliente/viewClienteList.php index 06bd7895..4e73a652 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/clientes/cliente/viewClienteList.php +++ b/ci4/app/Views/themes/backend/vuexy/form/clientes/cliente/viewClienteList.php @@ -1,8 +1,9 @@ -include('themes/_commonPartialsBs/select2bs5') ?> -include('themes/_commonPartialsBs/datatables') ?> -include('themes/_commonPartialsBs/sweetalert') ?> -extend('themes/backend/vuexy/main/defaultlayout') ?> -section('content'); ?> +include('themes/_commonPartialsBs/select2bs5') ?> +include('themes/_commonPartialsBs/datatables') ?> +include('themes/_commonPartialsBs/_confirm2delete') ?> +extend('themes/backend/vuexy/main/defaultlayout') ?> + +section('content'); ?>
@@ -46,8 +47,8 @@ return `
- - + +
`; }; @@ -101,47 +102,30 @@ $(document).on('click', '.btn-edit', function(e) { - //window.location.href = `/${$(this).attr('data-id')}/edit`; window.location.href = `/clientes/cliente/edit/${$(this).attr('data-id')}`; }); - - $(document).on('click', '.btn-delete', function(e) { - Swal.fire({ - title: '', - text: '', - icon: 'warning', - showCancelButton: true, - confirmButtonColor: '#3085d6', - confirmButtonText: '', - cancelButtonText: '', - cancelButtonColor: '#d33' - }) - .then((result) => { - const dataId = $(this).data('id'); - const row = $(this).closest('tr'); - if (result.value) { - $.ajax({ - url: `/${dataId}`, - method: 'DELETE', - }).done((data, textStatus, jqXHR) => { - Toast.fire({ - icon: 'success', - title: data.msg ?? jqXHR.statusText, - }); - - theTable.clearPipeline(); - theTable.row($(row)).invalidate().draw(); - }).fail((jqXHR, textStatus, errorThrown) => { - Toast.fire({ - icon: 'error', - title: jqXHR.responseJSON.messages.error, - }); - }) - } - }); - }); - + $(document).on('click', '.btn-delete', function(e) { + $(".btn-remove").attr('data-id', $(this).attr('data-id')); + }); + + $(document).on('click', '.btn-remove', function(e) { + const dataId = $(this).attr('data-id'); + const row = $(this).closest('tr'); + if ($.isNumeric(dataId)) { + $.ajax({ + url: `/clientes/cliente/delete/${dataId}`, + method: 'GET', + }).done((data, textStatus, jqXHR) => { + $('#confirm2delete').modal('toggle'); + theTable.clearPipeline(); + theTable.row($(row)).invalidate().draw(); + popSuccessAlert(data.msg ?? jqXHR.statusText); + }).fail((jqXHR, textStatus, errorThrown) => { + popErrorAlert(jqXHR.responseJSON.messages.error) + }) + } + }); endSection() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaList.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaList.php index 46c63c0f..e56b3f73 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaList.php +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaList.php @@ -1,8 +1,9 @@ -include('themes/_commonPartialsBs/select2bs5') ?> -include('themes/_commonPartialsBs/datatables') ?> -include('themes/_commonPartialsBs/sweetalert') ?> +include('themes/_commonPartialsBs/select2bs5') ?> +include('themes/_commonPartialsBs/datatables') ?> +include('themes/_commonPartialsBs/_confirm2delete') ?> extend('themes/backend/vuexy/main/defaultlayout') ?> -section('content'); ?> + +section('content'); ?>
@@ -49,25 +50,26 @@ section('additionalInlineJs') ?> - const lastColNr = $('#tableOfMaquinas').find("tr:first th").length - 1; - const actionBtns = function(data) { - return ` -
- - -
- `; - }; - theTable = $('#tableOfMaquinas').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', + const lastColNr = $('#tableOfMaquinas').find("tr:first th").length - 1; + const actionBtns = function(data) { + return ` + +
+ + +
+ `; + }; + theTable = $('#tableOfMaquinas').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', @@ -75,98 +77,76 @@ pageSize: 'A4' } ], - stateSave: true, - order: [[0, 'asc']], - language: { - url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" - }, - ajax : $.fn.dataTable.pipeline( { - url: '', - method: 'POST', - headers: {'X-Requested-With': 'XMLHttpRequest'}, - async: true, - }), - columnDefs: [ - { - orderable: false, - searchable: false, - targets: [lastColNr] - } - ], - columns : [ - { 'data': 'nombre' }, - { 'data': 'padre' }, - { 'data': 'tipo' }, - { 'data': 'velocidad' }, - { 'data': 'duracion_jornada' }, - { 'data': 'ancho' }, - { 'data': 'alto' }, - { 'data': 'ancho_impresion' }, - { 'data': 'alto_impresion' }, - { 'data': 'orden_planning' }, - { 'data': 'min' }, - { 'data': 'max' }, - { 'data': actionBtns } - ] - }); - - - theTable.on( 'draw.dt', function () { - const boolCols = []; - for (let coln of boolCols) { - theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) { - cell.innerHTML = cell.innerHTML == '1' ? '' : ''; - }); + stateSave: true, + order: [[0, 'asc']], + language: { + url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" + }, + ajax : $.fn.dataTable.pipeline( { + url: '', + method: 'POST', + headers: {'X-Requested-With': 'XMLHttpRequest'}, + async: true, + }), + columnDefs: [ + { + orderable: false, + searchable: false, + targets: [lastColNr] } - + ], + columns : [ + { 'data': 'nombre' }, + { 'data': 'padre' }, + { 'data': 'tipo' }, + { 'data': 'velocidad' }, + { 'data': 'duracion_jornada' }, + { 'data': 'ancho' }, + { 'data': 'alto' }, + { 'data': 'ancho_impresion' }, + { 'data': 'alto_impresion' }, + { 'data': 'orden_planning' }, + { 'data': 'min' }, + { 'data': 'max' }, + { 'data': actionBtns } + ] }); -$(document).on('click', '.btn-edit', function(e) { - //window.location.href = `/${$(this).attr('data-id')}/edit`; + + theTable.on( 'draw.dt', function () { + const boolCols = []; + for (let coln of boolCols) { + theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) { + cell.innerHTML = cell.innerHTML == '1' ? '' : ''; + }); + } + }); + + $(document).on('click', '.btn-edit', function(e) { window.location.href = `/configuracion/maquinas/edit/${$(this).attr('data-id')}`; }); - -$(document).on('click', '.btn-delete', function(e) { - Swal.fire({ - title: '', - text: '', - icon: 'warning', - showCancelButton: true, - confirmButtonColor: '#3085d6', - confirmButtonText: '', - cancelButtonText: '', - cancelButtonColor: '#d33' - }) - .then((result) => { - const dataId = $(this).data('id'); - const row = $(this).closest('tr'); - if (result.value) { - $.ajax({ - //url: `/${dataId}`, - //method: 'DELETE', - url: `/configuracion/maquinas/delete/${dataId}`, - method: 'GET', - }).done((data, textStatus, jqXHR) => { - Toast.fire({ - icon: 'success', - title: data.msg ?? jqXHR.statusText, - }); - - theTable.clearPipeline(); - theTable.row($(row)).invalidate().draw(); - }).fail((jqXHR, textStatus, errorThrown) => { - Toast.fire({ - icon: 'error', - title: jqXHR.responseJSON.messages.error, - }); - }) - } - }); - }); - - - + $(document).on('click', '.btn-delete', function(e) { + $(".btn-remove").attr('data-id', $(this).attr('data-id')); + }); + + $(document).on('click', '.btn-remove', function(e) { + const dataId = $(this).attr('data-id'); + const row = $(this).closest('tr'); + if ($.isNumeric(dataId)) { + $.ajax({ + url: `/configuracion/maquinas/delete/${dataId}`, + method: 'GET', + }).done((data, textStatus, jqXHR) => { + $('#confirm2delete').modal('toggle'); + theTable.clearPipeline(); + theTable.row($(row)).invalidate().draw(); + popSuccessAlert(data.msg ?? jqXHR.statusText); + }).fail((jqXHR, textStatus, errorThrown) => { + popErrorAlert(jqXHR.responseJSON.messages.error) + }) + } + }); endSection() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaPorDefectoList.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaPorDefectoList.php index 9d808c59..f4ed92c2 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaPorDefectoList.php +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaPorDefectoList.php @@ -1,9 +1,9 @@ -include('themes/_commonPartialsBs/select2bs5') ?> -include('themes/_commonPartialsBs/datatables') ?> -include('themes/_commonPartialsBs/sweetalert') ?> -extend('themes/backend/vuexy/main/defaultlayout') ?> +include('themes/_commonPartialsBs/select2bs5') ?> +include('themes/_commonPartialsBs/datatables') ?> +include('themes/_commonPartialsBs/_confirm2delete') ?> +extend('themes/backend/vuexy/main/defaultlayout') ?> -section('content'); ?> +section('content'); ?>
@@ -50,8 +50,8 @@ const actionBtns = function(data) { return `
- - + +
`; }; @@ -120,51 +120,35 @@ $(document).on('click', '.btn-edit', function(e) { window.location.href = `configuracion/maquinasdefecto/edit/${$(this).attr('data-id')}`; }); - + $(document).on('click', '.btn-delete', function(e) { - Swal.fire({ - title: '', - text: '', - icon: 'warning', - showCancelButton: true, - confirmButtonColor: '#3085d6', - confirmButtonText: '', - cancelButtonText: '', - cancelButtonColor: '#d33' - }) - .then((result) => { - const dataId = $(this).data('id'); - const row = $(this).closest('tr'); - if (result.value) { - $.ajax({ - //url: `/${dataId}`, - //method: 'DELETE', - url: `/configuracion/maquinasdefecto/delete/${dataId}`, - method: 'GET', - }).done((data, textStatus, jqXHR) => { - Toast.fire({ - icon: 'success', - title: data.msg ?? jqXHR.statusText, - }); - - theTable.clearPipeline(); - theTable.row($(row)).invalidate().draw(); - }).fail((jqXHR, textStatus, errorThrown) => { - Toast.fire({ - icon: 'error', - title: jqXHR.responseJSON.messages.error, - }); - }) - } - }); + $(".btn-remove").attr('data-id', $(this).attr('data-id')); }); - -endSection() ?> + + $(document).on('click', '.btn-remove', function(e) { + const dataId = $(this).attr('data-id'); + const row = $(this).closest('tr'); + if ($.isNumeric(dataId)) { + $.ajax({ + url: `/configuracion/maquinasdefecto/delete/${dataId}`, + method: 'GET', + }).done((data, textStatus, jqXHR) => { + $('#confirm2delete').modal('toggle'); + theTable.clearPipeline(); + theTable.row($(row)).invalidate().draw(); + popSuccessAlert(data.msg ?? jqXHR.statusText); + }).fail((jqXHR, textStatus, errorThrown) => { + popErrorAlert(jqXHR.responseJSON.messages.error) + }) + } + }); + +endSection() ?> -section('css') ?> +section('css') ?> -endSection() ?> +endSection() ?> section('additionalExternalJs') ?> @@ -174,5 +158,5 @@ -endSection() ?> +endSection() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelGenericoList.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelGenericoList.php index 2a32f237..13dc668d 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelGenericoList.php +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelGenericoList.php @@ -1,10 +1,10 @@ -include('themes/_commonPartialsBs/datatables') ?> -include('themes/_commonPartialsBs/sweetalert') ?> -extend('themes/backend/vuexy/main/defaultlayout') ?> -section('content'); ?> +include('themes/_commonPartialsBs/datatables') ?> +include('themes/_commonPartialsBs/_confirm2delete') ?> +extend('themes/backend/vuexy/main/defaultlayout') ?> + +section('content'); ?>
-

@@ -29,7 +29,6 @@
@@ -41,13 +40,15 @@ section('additionalInlineJs') ?> const lastColNr = $('#tableOfPapelesgenericos').find("tr:first th").length - 1; const actionBtns = function(data) { - return ` -
- - -
- `; + return ` + +
+ + +
+ `; }; + theTable = $('#tableOfPapelesgenericos').DataTable({ processing: true, serverSide: true, @@ -105,53 +106,37 @@ }); $(document).on('click', '.btn-edit', function(e) { - //window.location.href = `/edit/${$(this).attr('data-id')}`; window.location.href = `/configuracion/papelesgenericos/edit/${$(this).attr('data-id')}`; }); $(document).on('click', '.btn-delete', function(e) { - Swal.fire({ - title: '', - text: '', - icon: 'warning', - showCancelButton: true, - confirmButtonColor: '#3085d6', - confirmButtonText: '', - cancelButtonText: '', - cancelButtonColor: '#d33' - }) - .then((result) => { - const dataId = $(this).data('id'); - const row = $(this).closest('tr'); - if (result.value) { - $.ajax({ - //url: `/${dataId}`, - //method: 'DELETE', - url: `/configuracion/papelesgenericos/delete/${dataId}`, - method: 'GET', - }).done((data, textStatus, jqXHR) => { - Toast.fire({ - icon: 'success', - title: data.msg ?? jqXHR.statusText, - }); - - theTable.clearPipeline(); - theTable.row($(row)).invalidate().draw(); - }).fail((jqXHR, textStatus, errorThrown) => { - Toast.fire({ - icon: 'error', - title: jqXHR.responseJSON.messages.error, - }); - }) - } - }); + $(".btn-remove").attr('data-id', $(this).attr('data-id')); }); -endSection() ?> + + $(document).on('click', '.btn-remove', function(e) { + const dataId = $(this).attr('data-id'); + const row = $(this).closest('tr'); + if ($.isNumeric(dataId)) { + $.ajax({ + url: `/configuracion/papelesgenericos/delete/${dataId}`, + method: 'GET', + }).done((data, textStatus, jqXHR) => { + $('#confirm2delete').modal('toggle'); + theTable.clearPipeline(); + theTable.row($(row)).invalidate().draw(); + popSuccessAlert(data.msg ?? jqXHR.statusText); + }).fail((jqXHR, textStatus, errorThrown) => { + popErrorAlert(jqXHR.responseJSON.messages.error) + }) + } + }); + +endSection() ?> -section('css') ?> +section('css') ?> -endSection() ?> +endSection() ?> section('additionalExternalJs') ?> @@ -162,5 +147,5 @@ -endSection() ?> +endSection() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionList.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionList.php index c49ff858..4ae5971d 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionList.php +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionList.php @@ -1,6 +1,6 @@ include('themes/_commonPartialsBs/select2bs5') ?> include('themes/_commonPartialsBs/datatables') ?> -include('themes/_commonPartialsBs/sweetalert') ?> +include('themes/_commonPartialsBs/_confirm2delete') ?> extend('themes/backend/vuexy/main/defaultlayout') ?> section('content'); ?> @@ -49,12 +49,13 @@ const lastColNr = $('#tableOfPapelesimpresion').find("tr:first th").length - 1; const actionBtns = function(data) { - return ` + return ` +
- - + +
- `; + `; }; theTable = $('#tableOfPapelesimpresion').DataTable({ processing: true, @@ -107,78 +108,56 @@ }); -theTable.on( 'draw.dt', function () { + theTable.on( 'draw.dt', function () { const boolCols = [3, 4, 5, 6, 7, 8]; - for (let coln of boolCols) { - theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) { - cell.innerHTML = cell.innerHTML == '1' ? '' : ''; - }); - } -}); + for (let coln of boolCols) { + theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) { + cell.innerHTML = cell.innerHTML == '1' ? '' : ''; + }); + } + }); -$(document).on('click', '.btn-edit', function(e) { - //window.location.href = `/${$(this).attr('data-id')}/edit`; + $(document).on('click', '.btn-edit', function(e) { window.location.href = `/configuracion/papelesimpresion/edit/${$(this).attr('data-id')}`; }); - -$(document).on('click', '.btn-delete', function(e) { - Swal.fire({ - title: '', - text: '', - icon: 'warning', - showCancelButton: true, - confirmButtonColor: '#3085d6', - confirmButtonText: '', - cancelButtonText: '', - cancelButtonColor: '#d33' - }) - .then((result) => { - const dataId = $(this).data('id'); - const row = $(this).closest('tr'); - if (result.value) { - $.ajax({ - //url: `/${dataId}`, - //method: 'DELETE', - url: `/configuracion/papelesimpresion/delete/${dataId}`, - method: 'GET', - }).done((data, textStatus, jqXHR) => { - Toast.fire({ - icon: 'success', - title: data.msg ?? jqXHR.statusText, - }); - - theTable.clearPipeline(); - theTable.row($(row)).invalidate().draw(); - }).fail((jqXHR, textStatus, errorThrown) => { - Toast.fire({ - icon: 'error', - title: jqXHR.responseJSON.messages.error, - }); - }) - } - }); + + $(document).on('click', '.btn-delete', function(e) { + $(".btn-remove").attr('data-id', $(this).attr('data-id')); }); - - - -endSection() ?> + $(document).on('click', '.btn-remove', function(e) { + const dataId = $(this).attr('data-id'); + const row = $(this).closest('tr'); + if ($.isNumeric(dataId)) { + $.ajax({ + url: `/configuracion/papelesimpresion/delete/${dataId}`, + method: 'GET', + }).done((data, textStatus, jqXHR) => { + $('#confirm2delete').modal('toggle'); + theTable.clearPipeline(); + theTable.row($(row)).invalidate().draw(); + popSuccessAlert(data.msg ?? jqXHR.statusText); + }).fail((jqXHR, textStatus, errorThrown) => { + popErrorAlert(jqXHR.responseJSON.messages.error) + }) + } + }); + +endSection() ?> -section('css') ?> +section('css') ?> -endSection() ?> +endSection() ?> section('additionalExternalJs') ?> - + - - -endSection() ?> +endSection() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoList.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoList.php index 2420f8e8..d9f349e0 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoList.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoList.php @@ -1,6 +1,5 @@ include('themes/_commonPartialsBs/datatables') ?> -include('themes/_commonPartialsBs/_confirm2delete') ?> -include('themes/_commonPartialsBs/sweetalert') ?> +include('themes/_commonPartialsBs/_confirm2delete') ?> extend('themes/backend/vuexy/main/defaultlayout') ?> section('content'); ?>
diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifaManipuladoList.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifaManipuladoList.php index 9f51f7e6..49f3693b 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifaManipuladoList.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifaManipuladoList.php @@ -1,5 +1,5 @@ include('themes/_commonPartialsBs/datatables') ?> -include('themes/_commonPartialsBs/sweetalert') ?> +include('themes/_commonPartialsBs/_confirm2delete') ?> extend('themes/backend/vuexy/main/defaultlayout') ?> section('content'); ?>
@@ -41,8 +41,8 @@ const actionBtns = function(data) { return `
- - + +
`; }; @@ -90,49 +90,31 @@ $(document).on('click', '.btn-edit', function(e) { - //window.location.href = `/${$(this).attr('data-id')}/edit`; window.location.href = `/tarifas/tarifasmanipulado/edit/${$(this).attr('data-id')}`; }); - + $(document).on('click', '.btn-delete', function(e) { - Swal.fire({ - title: '', - text: '', - icon: 'warning', - showCancelButton: true, - confirmButtonColor: '#3085d6', - confirmButtonText: '', - cancelButtonText: '', - cancelButtonColor: '#d33' - }) - .then((result) => { - const dataId = $(this).data('id'); - const row = $(this).closest('tr'); - if (result.value) { - $.ajax({ - //url: `/${dataId}`, - //method: 'DELETE', - url: `/tarifas/tarifasmanipulado/delete/${dataId}`, - method: 'GET', - }).done((data, textStatus, jqXHR) => { - Toast.fire({ - icon: 'success', - title: data.msg ?? jqXHR.statusText, - }); - - theTable.clearPipeline(); - theTable.row($(row)).invalidate().draw(); - }).fail((jqXHR, textStatus, errorThrown) => { - Toast.fire({ - icon: 'error', - title: jqXHR.responseJSON.messages.error, - }); - }) - } - }); + $(".btn-remove").attr('data-id', $(this).attr('data-id')); + }); + + $(document).on('click', '.btn-remove', function(e) { + const dataId = $(this).attr('data-id'); + const row = $(this).closest('tr'); + if ($.isNumeric(dataId)) { + $.ajax({ + url: `/tarifas/tarifasmanipulado/delete/${dataId}`, + method: 'GET', + }).done((data, textStatus, jqXHR) => { + $('#confirm2delete').modal('toggle'); + theTable.clearPipeline(); + theTable.row($(row)).invalidate().draw(); + popSuccessAlert(data.msg ?? jqXHR.statusText); + }).fail((jqXHR, textStatus, errorThrown) => { + popErrorAlert(jqXHR.responseJSON.messages.error) + }) + } }); - endSection() ?>