From 511c73cc0c131400e70fd59cadce062a3953122b Mon Sep 17 00:00:00 2001 From: imnavajas Date: Mon, 17 Jul 2023 22:30:27 +0200 Subject: [PATCH 1/5] Arreglando UI-delete de Tariba Acabado --- ci4/app/Controllers/Tarifas/Tarifaacabado.php | 2 +- .../themes/_commonPartialsBs/_alertBoxes.php | 100 ++++++++---------- .../_commonPartialsBs/_confirm2delete.php | 27 +---- .../tarifas/acabado/viewTarifaAcabadoList.php | 49 ++------- .../viewTarifapreimpresionList.php | 9 -- 5 files changed, 62 insertions(+), 125 deletions(-) diff --git a/ci4/app/Controllers/Tarifas/Tarifaacabado.php b/ci4/app/Controllers/Tarifas/Tarifaacabado.php index abfc4770..a1b145eb 100644 --- a/ci4/app/Controllers/Tarifas/Tarifaacabado.php +++ b/ci4/app/Controllers/Tarifas/Tarifaacabado.php @@ -114,7 +114,7 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController if ($thenRedirect) : if (!empty($this->indexRoute)) : - return redirect()->to(route_to('tarifas/tarifaacabado/edit/' . $id))->with('sweet-success', $message); + return redirect()->to(site_url('tarifas/tarifaacabado/edit/' . $id))->with('sweet-success', $message); //return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); else: return $this->redirect2listView('sweet-success', $message); diff --git a/ci4/app/Views/themes/_commonPartialsBs/_alertBoxes.php b/ci4/app/Views/themes/_commonPartialsBs/_alertBoxes.php index 0d26c166..5d5ab740 100644 --- a/ci4/app/Views/themes/_commonPartialsBs/_alertBoxes.php +++ b/ci4/app/Views/themes/_commonPartialsBs/_alertBoxes.php @@ -1,33 +1,14 @@ has('message')) { - $successMessage = session('message'); - } - if (session()->has('error')) { - $errorMessage = is_array(session('error')) ? implode(session('error')) : session('error'); - } /* // Uncomment this block if you want the errors listed line by line in the alert +if (session()->has('message')) { + $successMessage = session('message'); +} +if (session()->has('error')) { + $errorMessage = is_array(session('error')) ? implode(session('error')) : session('error'); +} /* // Uncomment this block if you want the errors listed line by line in the alert elseif (session()->has('errors')) { $errorMessage = ' - diff --git a/ci4/app/Views/themes/_commonPartialsBs/datatables.php b/ci4/app/Views/themes/_commonPartialsBs/datatables.php index c11b8dc4..6ee8d97d 100644 --- a/ci4/app/Views/themes/_commonPartialsBs/datatables.php +++ b/ci4/app/Views/themes/_commonPartialsBs/datatables.php @@ -17,167 +17,165 @@ section('additionalInlineJs') ?> - moment.locale('defaultLocale ?>'); + moment.locale('defaultLocale ?>'); - // Pipelining function for DataTables. To be used to the `ajax` option of DataTables - $.fn.dataTable.pipeline = function (opts) { - // Configuration options - let conf = $.extend({ - pages: 5, // number of pages to cache - url: '', - method: 'POST', - headers: {'X-Requested-With': 'XMLHttpRequest'} - }, opts); + // Pipelining function for DataTables. To be used to the `ajax` option of DataTables + $.fn.dataTable.pipeline = function (opts) { + // Configuration options + let conf = $.extend({ + pages: 5, // number of pages to cache + url: '', + method: 'POST', + headers: {'X-Requested-With': 'XMLHttpRequest'} + }, opts); - // Private variables for storing the cache - let cacheLower = -1; - let cacheUpper = null; - let cacheLastRequest = null; - let cacheLastJson = null; + // Private variables for storing the cache + let cacheLower = -1; + let cacheUpper = null; + let cacheLastRequest = null; + let cacheLastJson = null; - return function (request, drawCallback, settings) { - let ajax = false; - let requestStart = request.start; - let drawStart = request.start; - let requestLength = request.length; - let requestEnd = requestStart + requestLength; + return function (request, drawCallback, settings) { + let ajax = false; + let requestStart = request.start; + let drawStart = request.start; + let requestLength = request.length; + let requestEnd = requestStart + requestLength; - if (settings.clearCache) { - // API requested that the cache be cleared - ajax = true; - settings.clearCache = false; - } else if (cacheLower < 0 || requestStart < cacheLower || requestEnd > cacheUpper) { - // outside cached data - need to make a request - ajax = true; - } else if (JSON.stringify(request.order) !== JSON.stringify(cacheLastRequest.order) || - JSON.stringify(request.columns) !== JSON.stringify(cacheLastRequest.columns) || - JSON.stringify(request.search) !== JSON.stringify(cacheLastRequest.search) - ) { - // properties changed (ordering, columns, searching) - ajax = true; - } - - // Store the request for checking next time around - cacheLastRequest = $.extend(true, {}, request); - - if (ajax) { - // Need data from the server - if (requestStart < cacheLower) { - requestStart = requestStart - (requestLength * (conf.pages - 1)); - - if (requestStart < 0) { - requestStart = 0; - } - } - - cacheLower = requestStart; - cacheUpper = requestStart + (requestLength * conf.pages); - - request.start = requestStart; - request.length = requestLength * conf.pages; - - // Provide the same `data` options as DataTables. - if (typeof conf.data === 'function') { - // As a function it is executed with the data object as an arg - // for manipulation. If an object is returned, it is used as the - // data object to submit - let d = conf.data(request); - if (d) { - $.extend(request, d); - } - } else if ($.isPlainObject(conf.data)) { - // As an object, the data given extends the default - $.extend(request, conf.data); - } - - request. = v; - - return $.ajax({ - "type": conf.method, - "url": conf.url, - "data": request, - "dataType": "json", - "cache": false, - "success": function (json) { - cacheLastJson = $.extend(true, {}, json); - - if (cacheLower != drawStart) { - json.data.splice(0, drawStart - cacheLower); - } - if (requestLength >= -1) { - json.data.splice(requestLength, json.data.length); - } - - drawCallback(json); - - yeniden(json.token); - }, - error: function (jqXHR, textStatus, errorThrown) { - - $('.dataTables_processing').hide(); - const theData = jqXHR.responseJSON; - drawCallback(theData); - Toast.fire({ - icon: 'error', - title: errorThrown, - }); - } - }); - } else { - let json = $.extend(true, {}, cacheLastJson); - json.draw = request.draw; // Update the echo for each response - json.data.splice(0, requestStart - cacheLower); - json.data.splice(requestLength, json.data.length); - - drawCallback(json); - } + if (settings.clearCache) { + // API requested that the cache be cleared + ajax = true; + settings.clearCache = false; + } else if (cacheLower < 0 || requestStart < cacheLower || requestEnd > cacheUpper) { + // outside cached data - need to make a request + ajax = true; + } else if (JSON.stringify(request.order) !== JSON.stringify(cacheLastRequest.order) || + JSON.stringify(request.columns) !== JSON.stringify(cacheLastRequest.columns) || + JSON.stringify(request.search) !== JSON.stringify(cacheLastRequest.search) + ) { + // properties changed (ordering, columns, searching) + ajax = true; } - }; - // Register an API method that will empty the pipelined data, forcing an Ajax - // fetch on the next draw (i.e. `table.clearPipeline().draw()`) - $.fn.dataTable.Api.register('clearPipeline()', function () { - return this.iterator('table', function (settings) { - settings.clearCache = true; - }); + // Store the request for checking next time around + cacheLastRequest = $.extend(true, {}, request); + + if (ajax) { + // Need data from the server + if (requestStart < cacheLower) { + requestStart = requestStart - (requestLength * (conf.pages - 1)); + + if (requestStart < 0) { + requestStart = 0; + } + } + + cacheLower = requestStart; + cacheUpper = requestStart + (requestLength * conf.pages); + + request.start = requestStart; + request.length = requestLength * conf.pages; + + // Provide the same `data` options as DataTables. + if (typeof conf.data === 'function') { + // As a function it is executed with the data object as an arg + // for manipulation. If an object is returned, it is used as the + // data object to submit + let d = conf.data(request); + if (d) { + $.extend(request, d); + } + } else if ($.isPlainObject(conf.data)) { + // As an object, the data given extends the default + $.extend(request, conf.data); + } + + request. = v; + + return $.ajax({ + "type": conf.method, + "url": conf.url, + "data": request, + "dataType": "json", + "cache": false, + "success": function (json) { + cacheLastJson = $.extend(true, {}, json); + + if (cacheLower != drawStart) { + json.data.splice(0, drawStart - cacheLower); + } + if (requestLength >= -1) { + json.data.splice(requestLength, json.data.length); + } + + drawCallback(json); + + yeniden(json.token); + }, + error: function (jqXHR, textStatus, errorThrown) { + + $('.dataTables_processing').hide(); + const theData = jqXHR.responseJSON; + drawCallback(theData); + Toast.fire({ + icon: 'error', + title: errorThrown, + }); + } + }); + } else { + let json = $.extend(true, {}, cacheLastJson); + json.draw = request.draw; // Update the echo for each response + json.data.splice(0, requestStart - cacheLower); + json.data.splice(requestLength, json.data.length); + + drawCallback(json); + } + } + }; + + // Register an API method that will empty the pipelined data, forcing an Ajax + // fetch on the next draw (i.e. `table.clearPipeline().draw()`) + $.fn.dataTable.Api.register('clearPipeline()', function () { + return this.iterator('table', function (settings) { + settings.clearCache = true; }); + }); - let lastColNr = $(".using-data-table").find("tr:first th").length - 1; - theTable = $('.using-data-table').DataTable({ - "responsive": true, - "paging": true, - "lengthMenu": [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ], - "pageLength": 10, - "lengthChange": true, - "searching": true, - "ordering": true, - "info": true, - "autoWidth": true, - "scrollX": true, - "stateSave": true, - "language": { - url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/languages[$currentLocale] ?? config('Basics')->i18n ?>.json" - }, - "columnDefs": [ - { - orderable: false, - searchable: false, - targets: [0,lastColNr] - } - ] - }); - + let lastColNr = $(".using-data-table").find("tr:first th").length - 1; + theTable = $('.using-data-table').DataTable({ + "responsive": true, + "paging": true, + "lengthMenu": [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ], + "pageLength": 10, + "lengthChange": true, + "searching": true, + "ordering": true, + "info": true, + "autoWidth": true, + "scrollX": true, + "stateSave": true, + "language": { + url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/languages[$currentLocale] ?? config('Basics')->i18n ?>.json" + }, + "columnDefs": [ + { + orderable: false, + searchable: false, + targets: [0,lastColNr] + } + ] + }); - $('#confirm2delete').on('show.bs.modal', function (e) { - $(this).find('.btn-confirm').attr('href', $(e.relatedTarget).data('href')); - }); - + $('#confirm2delete').on('show.bs.modal', function (e) { + $(this).find('.btn-confirm').attr('href', $(e.relatedTarget).data('href')); + }); - function toggleAllCheckboxes($cssClass, $io=null) { - $('.'+$cssClass).prop('checked', $io); - } + function toggleAllCheckboxes($cssClass, $io=null) { + $('.'+$cssClass).prop('checked', $io); + } endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php index 5522b7dc..6922c51f 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php @@ -2,6 +2,7 @@ include("themes/_commonPartialsBs/select2bs5") ?> include("themes/_commonPartialsBs/sweetalert") ?> extend('themes/backend/vuexy/main/defaultlayout') ?> + section("content") ?>
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 3c0a69c3..32d34dec 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 @@ -43,11 +43,12 @@ const lastColNr = $('#tableOfTarifasacabado').find("tr:first th").length - 1; return `
- - + +
`; }; + theTable = $('#tableOfTarifasacabado').DataTable({ processing: true, serverSide: true, @@ -123,9 +124,7 @@ const lastColNr = $('#tableOfTarifasacabado').find("tr:first th").length - 1; } }); -$('#imn-alert').on('click', function (e) { -$(this).toggleClass('d-none'); -}); + endSection() ?> From b9f8da95583563dfd173c92c84a5004cd7290c82 Mon Sep 17 00:00:00 2001 From: imnavajas Date: Sun, 23 Jul 2023 21:39:52 +0200 Subject: [PATCH 4/5] Creado popups de alerts para exito y error --- ci4/.env | 2 +- .../Controllers/GoBaseResourceController.php | 3 +- .../themes/_commonPartialsBs/_alertBoxes.php | 50 ++++++++++++++----- .../tarifas/acabado/viewTarifaAcabadoList.php | 15 ++---- 4 files changed, 44 insertions(+), 26 deletions(-) diff --git a/ci4/.env b/ci4/.env index d1721449..e77bc5bf 100644 --- a/ci4/.env +++ b/ci4/.env @@ -22,7 +22,7 @@ CI_ENVIRONMENT = development # APP #-------------------------------------------------------------------- -app.baseURL = 'https://sk-jjo.imnavajas.es' +app.baseURL = 'https://sk-imn.imnavajas.es' #app.baseURL = 'https://sk-imn.imnavajas.es' # app.baseURL = "http://safekat.test/" # app.forceGlobalSecureRequests = false diff --git a/ci4/app/Controllers/GoBaseResourceController.php b/ci4/app/Controllers/GoBaseResourceController.php index 363b173a..7310be40 100644 --- a/ci4/app/Controllers/GoBaseResourceController.php +++ b/ci4/app/Controllers/GoBaseResourceController.php @@ -234,7 +234,8 @@ abstract class GoBaseResourceController extends \CodeIgniter\RESTful\ResourceCon } - $message = lang('Basic.global.deleteSuccess', [$objName]); + // $message = lang('Basic.global.deleteSuccess', [$objName]); IMN commented + $message = lang('Basic.global.deleteSuccess', [lang('Basic.global.record')]); $response = $this->respondDeleted(['id' => $id, 'msg' => $message]); return $response; } diff --git a/ci4/app/Views/themes/_commonPartialsBs/_alertBoxes.php b/ci4/app/Views/themes/_commonPartialsBs/_alertBoxes.php index 72f110eb..1c57a5af 100644 --- a/ci4/app/Views/themes/_commonPartialsBs/_alertBoxes.php +++ b/ci4/app/Views/themes/_commonPartialsBs/_alertBoxes.php @@ -63,24 +63,50 @@ if (session()->has('error')) {
-
section('additionalInlineJs') ?> -$('#sk-alert').on('click', function (e) { +function popSuccessAlert(successMsg){ + var htmlString = ` + `; -$(this).fadeOut("slow"); -}); + $(window).scrollTop(0); + $('#sk-alert').hide().empty().html(htmlString).fadeIn("slow", function(){ + setTimeout(function(){ + $('#sk-alert').fadeOut("slow"); + }, 5000); + }); +} + +function popErrorAlert(errorMsg){ + var htmlString = ` + `; + + $(window).scrollTop(0); + $('#sk-alert').hide().empty().html(htmlString).fadeIn("slow", function(){ + setTimeout(function(){ + $('#sk-alert').fadeOut("slow"); + }, 5000); + }); +} 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 32d34dec..2420f8e8 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 @@ -107,25 +107,16 @@ const lastColNr = $('#tableOfTarifasacabado').find("tr:first th").length - 1; url: `/tarifas/tarifaacabado/delete/${dataId}`, method: 'GET', }).done((data, textStatus, jqXHR) => { - $('#confirm2delete').modal('toggle'), - Toast.fire({ - icon: 'success', - title: data.msg ?? jqXHR.statusText, - }); - + $('#confirm2delete').modal('toggle'); theTable.clearPipeline(); theTable.row($(row)).invalidate().draw(); + popSuccessAlert(data.msg ?? jqXHR.statusText); }).fail((jqXHR, textStatus, errorThrown) => { - Toast.fire({ - icon: 'error', - title: jqXHR.responseJSON.messages.error, - }); + popErrorAlert(jqXHR.responseJSON.messages.error) }) } }); - - endSection() ?> From 281e5984c5a134dcbc5afa73e81f738d0d8f5632 Mon Sep 17 00:00:00 2001 From: imnavajas Date: Mon, 24 Jul 2023 14:50:34 +0200 Subject: [PATCH 5/5] 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() ?>