From 247f4ea48555e1292312fb3e5855dcaa9c937f51 Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Mon, 10 Jul 2023 19:00:45 +0200 Subject: [PATCH 1/7] =?UTF-8?q?a=C3=B1adidos=20los=20ficheros=20de=20Ozar?= =?UTF-8?q?=20para=20maquinas=20por=20defecto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ci4/app/Config/Routes.php | 12 ++ .../Configuracion/MaquinaDefectoEntity.php | 36 +++++ .../Configuracion/MaquinaDefectoModel.php | 118 +++++++++++++++ .../maquinas/_maquinaPorDefectoFormItems.php | 80 ++++++++++ .../maquinas/viewMaquinaPorDefectoForm.php | 64 ++++++++ .../maquinas/viewMaquinaPorDefectoList.php | 138 ++++++++++++++++++ 6 files changed, 448 insertions(+) create mode 100644 ci4/app/Entities/Configuracion/MaquinaDefectoEntity.php create mode 100644 ci4/app/Models/Configuracion/MaquinaDefectoModel.php create mode 100644 ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/_maquinaPorDefectoFormItems.php create mode 100644 ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaPorDefectoForm.php create mode 100644 ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaPorDefectoList.php diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 8af1cf19..3f27da17 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -260,6 +260,18 @@ $routes->group('maquinaspapelesimpresion', ['namespace' => 'App\Controllers\Conf $routes->resource('maquinastarifasimpresion', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Maquinastarifasimpresion', 'except' => 'show,new,create,update']); +$routes->group('maquinadefecto', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { + $routes->get('', 'Maquinadefecto::index', ['as' => 'maquinaPorDefectoList']); + $routes->get('index', 'Maquinadefecto::index', ['as' => 'maquinaPorDefectoIndex']); + $routes->get('list', 'Maquinadefecto::index', ['as' => 'maquinaPorDefectoList2']); + $routes->get('add', 'Maquinadefecto::add', ['as' => 'newMaquinaPorDefecto']); + $routes->post('add', 'Maquinadefecto::add', ['as' => 'createMaquinaPorDefecto']); + $routes->get('edit/(:num)', 'Maquinadefecto::edit/$1', ['as' => 'editMaquinaPorDefecto']); + $routes->post('edit/(:num)', 'Maquinadefecto::edit/$1', ['as' => 'updateMaquinaPorDefecto']); + $routes->get('delete/(:num)', 'Maquinadefecto::delete/$1', ['as' => 'deleteMaquinaPorDefecto']); + $routes->post('allmenuitems', 'Maquinadefecto::allItemsSelect', ['as' => 'select2ItemsOfMaquinasPorDefecto']); + $routes->post('menuitems', 'Maquinadefecto::menuItems', ['as' => 'menuItemsOfMaquinasPorDefecto']); +}); $routes->group('profile', ['namespace' => 'App\Controllers'], function ($routes) { $routes->get('', 'Profile::index', ['as' => 'profileList']); diff --git a/ci4/app/Entities/Configuracion/MaquinaDefectoEntity.php b/ci4/app/Entities/Configuracion/MaquinaDefectoEntity.php new file mode 100644 index 00000000..b98c83ba --- /dev/null +++ b/ci4/app/Entities/Configuracion/MaquinaDefectoEntity.php @@ -0,0 +1,36 @@ + null, + "tipo" => null, + "ancho_min" => 0.0, + "ancho_max" => 0.0, + "alto_min" => 0.0, + "alto_max" => 0.0, + "tirada_min" => 1, + "tirada_max" => 10000, + "maquina_id" => null, + "user_created_id" => 0, + "user_updated_id" => 0, + "is_deleted" => 0, + "created_at" => null, + "updated_at" => null, + ]; + protected $casts = [ + "ancho_min" => "float", + "ancho_max" => "float", + "alto_min" => "float", + "alto_max" => "float", + "tirada_min" => "int", + "tirada_max" => "int", + "maquina_id" => "int", + "user_created_id" => "int", + "user_updated_id" => "int", + "is_deleted" => "int", + ]; +} diff --git a/ci4/app/Models/Configuracion/MaquinaDefectoModel.php b/ci4/app/Models/Configuracion/MaquinaDefectoModel.php new file mode 100644 index 00000000..58e0fe12 --- /dev/null +++ b/ci4/app/Models/Configuracion/MaquinaDefectoModel.php @@ -0,0 +1,118 @@ + [ + "label" => "MaquinaPorDefectoes.altoMax", + "rules" => "required|decimal", + ], + "alto_min" => [ + "label" => "MaquinaPorDefectoes.altoMin", + "rules" => "required|decimal", + ], + "ancho_max" => [ + "label" => "MaquinaPorDefectoes.anchoMax", + "rules" => "required|decimal", + ], + "ancho_min" => [ + "label" => "MaquinaPorDefectoes.anchoMin", + "rules" => "required|decimal", + ], + "tipo" => [ + "label" => "MaquinaPorDefectoes.tipo", + "rules" => "required|in_list[bn,bnhq,color,portada,cubierta,rotativa]", + ], + "tirada_max" => [ + "label" => "MaquinaPorDefectoes.tiradaMax", + "rules" => "required|integer", + ], + "tirada_min" => [ + "label" => "MaquinaPorDefectoes.tiradaMin", + "rules" => "required|integer", + ], + ]; + + protected $validationMessages = [ + "alto_max" => [ + "decimal" => "MaquinaPorDefectoes.validation.alto_max.decimal", + "required" => "MaquinaPorDefectoes.validation.alto_max.required", + ], + "alto_min" => [ + "decimal" => "MaquinaPorDefectoes.validation.alto_min.decimal", + "required" => "MaquinaPorDefectoes.validation.alto_min.required", + ], + "ancho_max" => [ + "decimal" => "MaquinaPorDefectoes.validation.ancho_max.decimal", + "required" => "MaquinaPorDefectoes.validation.ancho_max.required", + ], + "ancho_min" => [ + "decimal" => "MaquinaPorDefectoes.validation.ancho_min.decimal", + "required" => "MaquinaPorDefectoes.validation.ancho_min.required", + ], + "tipo" => [ + "in_list" => "MaquinaPorDefectoes.validation.tipo.in_list", + "required" => "MaquinaPorDefectoes.validation.tipo.required", + ], + "tirada_max" => [ + "integer" => "MaquinaPorDefectoes.validation.tirada_max.integer", + "required" => "MaquinaPorDefectoes.validation.tirada_max.required", + ], + "tirada_min" => [ + "integer" => "MaquinaPorDefectoes.validation.tirada_min.integer", + "required" => "MaquinaPorDefectoes.validation.tirada_min.required", + ], + ]; + + public function findAllWithMaquinas(string $selcols = "*", int $limit = null, int $offset = 0) + { + $sql = + "SELECT t1." . + $selcols . + ", t2.nombre AS maquina FROM " . + $this->table . + " t1 LEFT JOIN lg_maquinas t2 ON t1.maquina_id = t2.id"; + if (!is_null($limit) && intval($limit) > 0) { + $sql .= " LIMIT " . $limit; + } + + if (!is_null($offset) && intval($offset) > 0) { + $sql .= " OFFSET " . $offset; + } + + $query = $this->db->query($sql); + $result = $query->getResultObject(); + return $result; + } +} diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/_maquinaPorDefectoFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/_maquinaPorDefectoFormItems.php new file mode 100644 index 00000000..aa62aae8 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/_maquinaPorDefectoFormItems.php @@ -0,0 +1,80 @@ +
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+
+ + +
+ +
+ +
\ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaPorDefectoForm.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaPorDefectoForm.php new file mode 100644 index 00000000..d31358aa --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaPorDefectoForm.php @@ -0,0 +1,64 @@ +include("Themes/_commonPartialsBs/select2bs5") ?> +extend("Themes/" . config("Basics")->theme["name"] . "/AdminLayout/defaultLayout") ?> +section("content") ?> +
+
+
+
+

+
+
+ +
+ + getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> + +
+ +
+
+
+
+endSection() ?> + + +section("additionalInlineJs") ?> + + + $('#maquinaId').select2({ + theme: 'bootstrap-5', + allowClear: false, + ajax: { + url: '', + type: 'post', + dataType: 'json', + + data: function (params) { + return { + id: 'id', + text: 'nombre', + searchTerm: params.term, + : v + }; + }, + delay: 60, + processResults: function (response) { + + yeniden(response.); + + return { + results: response.menu + }; + }, + + cache: true + } + }); + + +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 new file mode 100644 index 00000000..0c2c4482 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaPorDefectoList.php @@ -0,0 +1,138 @@ +include('Themes/_commonPartialsBs/select2bs5') ?> +include('Themes/_commonPartialsBs/datatables') ?> +extend('Themes/'.config('Basics')->theme['name'].'/AdminLayout/defaultLayout') ?> +section('content'); ?> +
+
+ +
+
+

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ id), lang('Basic.global.edit'), ['class'=>'btn btn-sm btn-warning btn-edit me-1', 'data-id'=>$item->id,]); ?> + 'btn btn-sm btn-danger btn-delete ms-1', 'data-href'=>route_to('deleteMaquinaPorDefecto', $item->id), 'data-bs-toggle'=>'modal', 'data-bs-target'=>'#confirm2delete']); ?> + + id ?> + + tipo) ?> + + ancho_min) ?> + + ancho_max) ?> + + alto_min) ?> + + alto_max) ?> + + tirada_min) ?> + + tirada_max) ?> + + maquina) ?> + + id), lang('Basic.global.edit'), ['class'=>'btn btn-sm btn-warning btn-edit me-1', 'data-id'=>$item->id,]); ?> + 'btn btn-sm btn-danger btn-delete ms-1', 'data-href'=>route_to('deleteMaquinaPorDefecto', $item->id), 'data-bs-toggle'=>'modal', 'data-bs-target'=>'#confirm2delete']); ?> +
+
+ +
+
+
+ +endSection() ?> + + +section('css') ?> + +endSection() ?> + + +section('additionalExternalJs') ?> + + + + + + + + + + +endSection() ?> + +section('additionalInlineJs') ?> + + const lastColNr2 = $(".using-exportable-data-table").find("tr:first th").length - 1; + theTable = $('.using-exportable-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, + "dom": 'lfrtipB', // 'lfBrtip', // you can try different layout combinations by uncommenting one or the other + // "dom": '<"top"lf><"clear">rt<"bottom"ipB><"clear">', // remember to comment this line if you uncomment the above + "buttons": [ + 'copy', 'csv', 'excel', 'print', { + extend: 'pdfHtml5', + orientation: 'landscape', + pageSize: 'A4' + } + ], + "autoWidth": true, + "scrollX": true, + "stateSave": true, + "language": { + url: "/assets/dt/languages[$currentLocale] ?? config('Basics')->i18n ?>.json" + }, + "columnDefs": [ + { + orderable: false, + searchable: false, + targets: [0,lastColNr2] + } + ] + }); +endSection() ?> \ No newline at end of file From 810e1c8b375d701167204de522aa3fc9841a4337 Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Wed, 12 Jul 2023 12:24:55 +0200 Subject: [PATCH 2/7] Terminando formulario --- ci4/app/Config/Routes.php | 23 +- .../Configuracion/MaquinaDefectoEntity.php | 36 --- .../Configuracion/MaquinaDefectoModel.php | 118 --------- .../maquinas/_maquinaPorDefectoFormItems.php | 44 ++-- .../maquinas/viewMaquinaPorDefectoForm.php | 9 +- .../maquinas/viewMaquinaPorDefectoList.php | 229 +++++++++++------- 6 files changed, 177 insertions(+), 282 deletions(-) delete mode 100644 ci4/app/Entities/Configuracion/MaquinaDefectoEntity.php delete mode 100644 ci4/app/Models/Configuracion/MaquinaDefectoModel.php diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 3f27da17..0f4b2cef 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -260,18 +260,19 @@ $routes->group('maquinaspapelesimpresion', ['namespace' => 'App\Controllers\Conf $routes->resource('maquinastarifasimpresion', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Maquinastarifasimpresion', 'except' => 'show,new,create,update']); -$routes->group('maquinadefecto', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { - $routes->get('', 'Maquinadefecto::index', ['as' => 'maquinaPorDefectoList']); - $routes->get('index', 'Maquinadefecto::index', ['as' => 'maquinaPorDefectoIndex']); - $routes->get('list', 'Maquinadefecto::index', ['as' => 'maquinaPorDefectoList2']); - $routes->get('add', 'Maquinadefecto::add', ['as' => 'newMaquinaPorDefecto']); - $routes->post('add', 'Maquinadefecto::add', ['as' => 'createMaquinaPorDefecto']); - $routes->get('edit/(:num)', 'Maquinadefecto::edit/$1', ['as' => 'editMaquinaPorDefecto']); - $routes->post('edit/(:num)', 'Maquinadefecto::edit/$1', ['as' => 'updateMaquinaPorDefecto']); - $routes->get('delete/(:num)', 'Maquinadefecto::delete/$1', ['as' => 'deleteMaquinaPorDefecto']); - $routes->post('allmenuitems', 'Maquinadefecto::allItemsSelect', ['as' => 'select2ItemsOfMaquinasPorDefecto']); - $routes->post('menuitems', 'Maquinadefecto::menuItems', ['as' => 'menuItemsOfMaquinasPorDefecto']); +$routes->group('maquinasdefecto', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { + $routes->get('', 'Maquinasdefecto::index', ['as' => 'maquinaPorDefectoList']); + $routes->get('add', 'Maquinasdefecto::add', ['as' => 'newMaquinaPorDefecto']); + $routes->post('add', 'Maquinasdefecto::add', ['as' => 'createMaquinaPorDefecto']); + $routes->post('create', 'Maquinasdefecto::create', ['as' => 'ajaxCreateMaquinaPorDefecto']); + $routes->put('(:num)/update', 'Maquinasdefecto::update/$1', ['as' => 'ajaxUpdateMaquinaPorDefecto']); + $routes->post('(:num)/edit', 'Maquinasdefecto::edit/$1', ['as' => 'updateMaquinaPorDefecto']); + $routes->post('datatable', 'Maquinasdefecto::datatable', ['as' => 'dataTableOfMaquinasPorDefecto']); + $routes->post('allmenuitems', 'Maquinasdefecto::allItemsSelect', ['as' => 'select2ItemsOfMaquinasPorDefecto']); + $routes->post('menuitems', 'Maquinasdefecto::menuItems', ['as' => 'menuItemsOfMaquinasPorDefecto']); }); +$routes->resource('maquinasdefecto', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Maquinasdefecto', 'except' => 'show,new,create,update']); + $routes->group('profile', ['namespace' => 'App\Controllers'], function ($routes) { $routes->get('', 'Profile::index', ['as' => 'profileList']); diff --git a/ci4/app/Entities/Configuracion/MaquinaDefectoEntity.php b/ci4/app/Entities/Configuracion/MaquinaDefectoEntity.php deleted file mode 100644 index b98c83ba..00000000 --- a/ci4/app/Entities/Configuracion/MaquinaDefectoEntity.php +++ /dev/null @@ -1,36 +0,0 @@ - null, - "tipo" => null, - "ancho_min" => 0.0, - "ancho_max" => 0.0, - "alto_min" => 0.0, - "alto_max" => 0.0, - "tirada_min" => 1, - "tirada_max" => 10000, - "maquina_id" => null, - "user_created_id" => 0, - "user_updated_id" => 0, - "is_deleted" => 0, - "created_at" => null, - "updated_at" => null, - ]; - protected $casts = [ - "ancho_min" => "float", - "ancho_max" => "float", - "alto_min" => "float", - "alto_max" => "float", - "tirada_min" => "int", - "tirada_max" => "int", - "maquina_id" => "int", - "user_created_id" => "int", - "user_updated_id" => "int", - "is_deleted" => "int", - ]; -} diff --git a/ci4/app/Models/Configuracion/MaquinaDefectoModel.php b/ci4/app/Models/Configuracion/MaquinaDefectoModel.php deleted file mode 100644 index 58e0fe12..00000000 --- a/ci4/app/Models/Configuracion/MaquinaDefectoModel.php +++ /dev/null @@ -1,118 +0,0 @@ - [ - "label" => "MaquinaPorDefectoes.altoMax", - "rules" => "required|decimal", - ], - "alto_min" => [ - "label" => "MaquinaPorDefectoes.altoMin", - "rules" => "required|decimal", - ], - "ancho_max" => [ - "label" => "MaquinaPorDefectoes.anchoMax", - "rules" => "required|decimal", - ], - "ancho_min" => [ - "label" => "MaquinaPorDefectoes.anchoMin", - "rules" => "required|decimal", - ], - "tipo" => [ - "label" => "MaquinaPorDefectoes.tipo", - "rules" => "required|in_list[bn,bnhq,color,portada,cubierta,rotativa]", - ], - "tirada_max" => [ - "label" => "MaquinaPorDefectoes.tiradaMax", - "rules" => "required|integer", - ], - "tirada_min" => [ - "label" => "MaquinaPorDefectoes.tiradaMin", - "rules" => "required|integer", - ], - ]; - - protected $validationMessages = [ - "alto_max" => [ - "decimal" => "MaquinaPorDefectoes.validation.alto_max.decimal", - "required" => "MaquinaPorDefectoes.validation.alto_max.required", - ], - "alto_min" => [ - "decimal" => "MaquinaPorDefectoes.validation.alto_min.decimal", - "required" => "MaquinaPorDefectoes.validation.alto_min.required", - ], - "ancho_max" => [ - "decimal" => "MaquinaPorDefectoes.validation.ancho_max.decimal", - "required" => "MaquinaPorDefectoes.validation.ancho_max.required", - ], - "ancho_min" => [ - "decimal" => "MaquinaPorDefectoes.validation.ancho_min.decimal", - "required" => "MaquinaPorDefectoes.validation.ancho_min.required", - ], - "tipo" => [ - "in_list" => "MaquinaPorDefectoes.validation.tipo.in_list", - "required" => "MaquinaPorDefectoes.validation.tipo.required", - ], - "tirada_max" => [ - "integer" => "MaquinaPorDefectoes.validation.tirada_max.integer", - "required" => "MaquinaPorDefectoes.validation.tirada_max.required", - ], - "tirada_min" => [ - "integer" => "MaquinaPorDefectoes.validation.tirada_min.integer", - "required" => "MaquinaPorDefectoes.validation.tirada_min.required", - ], - ]; - - public function findAllWithMaquinas(string $selcols = "*", int $limit = null, int $offset = 0) - { - $sql = - "SELECT t1." . - $selcols . - ", t2.nombre AS maquina FROM " . - $this->table . - " t1 LEFT JOIN lg_maquinas t2 ON t1.maquina_id = t2.id"; - if (!is_null($limit) && intval($limit) > 0) { - $sql .= " LIMIT " . $limit; - } - - if (!is_null($offset) && intval($offset) > 0) { - $sql .= " OFFSET " . $offset; - } - - $query = $this->db->query($sql); - $result = $query->getResultObject(); - return $result; - } -} diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/_maquinaPorDefectoFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/_maquinaPorDefectoFormItems.php index aa62aae8..5693150f 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/_maquinaPorDefectoFormItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/_maquinaPorDefectoFormItems.php @@ -2,72 +2,72 @@
- +
- +
- +
- +
- +
- +
- $v) : ?> - include("Themes/_commonPartialsBs/select2bs5") ?> -extend("Themes/" . config("Basics")->theme["name"] . "/AdminLayout/defaultLayout") ?> +include("themes/_commonPartialsBs/select2bs5") ?> +include("themes/_commonPartialsBs/sweetalert") ?> +extend('themes/backend/vuexy/main/defaultlayout') ?> section("content") ?>
@@ -10,12 +11,12 @@
- + getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
- -
- - +
- -
- -
- - +
- +
-
- - -
+
@@ -63,7 +44,7 @@ - $v) : ?> @@ -75,6 +56,29 @@
+ +
+ + +
+ + +
+ + +
+ +
+ + +
+
\ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaForm.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaForm.php index 224ae1a2..e16f1726 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaForm.php @@ -287,9 +287,6 @@ yeniden(json.); - setTimeout(() => { - console.log("1 Segundo esperado") - }, 1000); $.ajax({ url: '', data: { diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaPorDefectoForm.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaPorDefectoForm.php index b1bc22f8..e2e70ec6 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaPorDefectoForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaPorDefectoForm.php @@ -15,12 +15,15 @@ getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
- +
+ " + /> + "btn btn-secondary"]) ?> +
@@ -32,7 +35,6 @@ $('#maquinaId').select2({ - theme: 'bootstrap-5', allowClear: false, ajax: { url: '', 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 7d24705e..7a39f6fa 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 @@ -125,7 +125,7 @@ $(document).on('click', '.btn-edit', function(e) { $(document).on('click', '.btn-delete', function(e) { Swal.fire({ - title: '', + title: '', text: '', icon: 'warning', showCancelButton: true, @@ -139,8 +139,10 @@ $(document).on('click', '.btn-delete', function(e) { const row = $(this).closest('tr'); if (result.value) { $.ajax({ - url: `/${dataId}`, - method: 'DELETE', + //url: `/${dataId}`, + //method: 'DELETE', + url: `/configuracion/maquinasdefecto/delete/${dataId}`, + method: 'GET', }).done((data, textStatus, jqXHR) => { Toast.fire({ icon: 'success', @@ -166,20 +168,18 @@ $(document).on('click', '.btn-delete', function(e) { section('css') ?> - + endSection() ?> section('additionalExternalJs') ?> - - + + + - - - endSection() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/preimpresion/_tarifapreimpresionFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/preimpresion/_tarifapreimpresionFormItems.php index 1b02eb61..a21e3271 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/preimpresion/_tarifapreimpresionFormItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/preimpresion/_tarifapreimpresionFormItems.php @@ -25,7 +25,7 @@ - + */ ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/preimpresion/viewTarifapreimpresionList.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/preimpresion/viewTarifapreimpresionList.php index 1e5360d1..5d78905a 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/preimpresion/viewTarifapreimpresionList.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/preimpresion/viewTarifapreimpresionList.php @@ -48,7 +48,7 @@ user_created_id) ?> - user_update_id) ?> + user_updated_id) ?> created_at) ? '' : date('d/m/Y H:m:s', strtotime($item->created_at)) ?> diff --git a/from mac to app.txt b/from mac to app.txt index 453b3f74..935ea43b 100644 --- a/from mac to app.txt +++ b/from mac to app.txt @@ -51,8 +51,8 @@ Pasos para añadir el soft delete a una tabla debajo de $sanitizedData = $this->sanitized($postData, $nullIfEmpty); // JJO - if(isset($this->model->user_update_id)){ - $sanitizedData['user_update_id'] = $session->id_user; + if(isset($this->model->user_updated_id)){ + $sanitizedData['user_updated_id'] = $session->id_user; } 5b.- Con lazy-tables: From ade327004fd28e2e6803f5fb1368e0417f6bda78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Thu, 13 Jul 2023 08:22:09 +0200 Subject: [PATCH 5/7] a falta de validar --- .../Configuracion/Maquinasdefecto.php | 32 ++++++++++---- ci4/app/Language/en/MaquinasPorDefecto.php | 2 + ci4/app/Language/es/MaquinasPorDefecto.php | 2 + .../Configuracion/MaquinasDefectoModel.php | 43 +++++++++++++++++++ 4 files changed, 71 insertions(+), 8 deletions(-) diff --git a/ci4/app/Controllers/Configuracion/Maquinasdefecto.php b/ci4/app/Controllers/Configuracion/Maquinasdefecto.php index 4ec1393e..225c32a2 100644 --- a/ci4/app/Controllers/Configuracion/Maquinasdefecto.php +++ b/ci4/app/Controllers/Configuracion/Maquinasdefecto.php @@ -75,15 +75,23 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController { // JJO $sanitizedData['user_created_id'] = $session->id_user; - - + $noException = true; if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : - if ($this->canValidate()) : + // JJO: se añade que se checkeen los intervalos de ancho y tirada. + // En caso de error se devuelve un mensaje. try { - $successfulResult = $this->model->skipValidation(true)->save($sanitizedData); + $error = $this->model->checkIntervals($sanitizedData); + if(empty($error)){ + $successfulResult = $this->model->skipValidation(true)->save($sanitizedData); + } + else{ + $successfulResult = false; + $this->viewData['errorMessage'] = $error; + $this->session->setFlashdata('formErrors', $this->model->errors()); + } } catch (\Exception $e) { $noException = false; $this->dealWithException($e); @@ -160,12 +168,20 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController { $noException = true; if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : - - if ($this->canValidate()) : - try { - $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); + // JJO: se añade que se checkeen los intervalos de ancho y tirada. + // En caso de error se devuelve un mensaje. + try { + $error = $this->model->checkIntervals($sanitizedData); + if(empty($error)){ + $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); + } + else{ + $successfulResult = false; + $this->viewData['errorMessage'] = $error; + $this->session->setFlashdata('formErrors', $this->model->errors()); + } } catch (\Exception $e) { $noException = false; $this->dealWithException($e); diff --git a/ci4/app/Language/en/MaquinasPorDefecto.php b/ci4/app/Language/en/MaquinasPorDefecto.php index 06823f2c..6efc57fe 100644 --- a/ci4/app/Language/en/MaquinasPorDefecto.php +++ b/ci4/app/Language/en/MaquinasPorDefecto.php @@ -31,6 +31,8 @@ return [ 'userCreatedId' => 'User Created ID', 'userUpdatedId' => 'User Updated ID', 'validation' => [ + 'error_ancho_overlap' => 'The range [Min Width, Max Width] is overlapped with another one for the selected type.', + 'error_tirada_overlap' => 'The range [Min Printing, Max Printing] is overlapped with another one for the selected type.', 'alto_max' => [ 'decimal' => 'The {field} field must contain a decimal number.', 'required' => 'The {field} field is required.', diff --git a/ci4/app/Language/es/MaquinasPorDefecto.php b/ci4/app/Language/es/MaquinasPorDefecto.php index 9ba009b9..a16729ab 100644 --- a/ci4/app/Language/es/MaquinasPorDefecto.php +++ b/ci4/app/Language/es/MaquinasPorDefecto.php @@ -31,6 +31,8 @@ return [ 'userCreatedId' => 'User Created ID', 'userUpdatedId' => 'User Updated ID', 'validation' => [ + 'error_ancho_overlap' => 'El rango [Ancho Min, Ancho Max] se solapa con otro existente para el tipo seleccionado.', + 'error_tirada_overlap' => 'El rango [Tirada Min, Tirada Max] se solapa con otro existente para el tipo seleccionado.', 'alto_max' => [ 'decimal' => 'El campo {field} debe contener un número decimal.', 'required' => 'El campo {field} es obligatorio.', diff --git a/ci4/app/Models/Configuracion/MaquinasDefectoModel.php b/ci4/app/Models/Configuracion/MaquinasDefectoModel.php index 5fe5012d..e2963e7e 100644 --- a/ci4/app/Models/Configuracion/MaquinasDefectoModel.php +++ b/ci4/app/Models/Configuracion/MaquinasDefectoModel.php @@ -145,6 +145,7 @@ class MaquinasDefectoModel extends \App\Models\GoBaseModel ->select( "t1.id AS id, t1.tipo AS tipo, t1.ancho_min AS ancho_min, t1.ancho_max AS ancho_max, t1.alto_min AS alto_min, t1.alto_max AS alto_max, t1.tirada_min AS tirada_min, t1.tirada_max AS tirada_max, t2.nombre AS maquina" ); + $builder->where('t1.is_deleted', 0); $builder->join("lg_maquinas t2", "t1.maquina_id = t2.id", "left"); return empty($search) @@ -172,4 +173,46 @@ class MaquinasDefectoModel extends \App\Models\GoBaseModel ->orLike("t2.nombre", $search) ->groupEnd(); } + + public function checkIntervals($data = []){ + $ancho_min = $this->db + ->table($this->table) + ->selectMin("ancho_min") + ->where("is_deleted", 0) + ->where("tipo", $data["tipo"])->get()->getRow()->ancho_min; + + $ancho_max = $this->db + ->table($this->table) + ->selectMin("ancho_max") + ->where("is_deleted", 0) + ->where("tipo", $data["tipo"])->get()->getRow()->ancho_max; + + $tirada_min = $this->db + ->table($this->table) + ->selectMin("tirada_min") + ->where("is_deleted", 0) + ->where("tipo", $data["tipo"])->get()->getRow()->tirada_min; + + $tirada_max = $this->db + ->table($this->table) + ->selectMin("tirada_max") + ->where("is_deleted", 0) + ->where("tipo", $data["tipo"])->get()->getRow()->tirada_max; + + if(!is_null($ancho_max) && !is_null($ancho_min)){ + if($data["ancho_min"]>=intval($ancho_min) || + $data["ancho_max"]<=intval($ancho_max) ) + return lang('MaquinasPorDefecto.validation.error_ancho_overlap'); + } + + if(!is_null($tirada_max) && !is_null($tirada_min)){ + if($data["tirada_min"]>=intval($tirada_min) || + $data["tirada_max"]<=intval($tirada_max) ) + return lang('MaquinasPorDefecto.validation.error_tirada_overlap'); + } + + return ""; + } } + + From e918c8558339be1305cab064d107933111804a03 Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Thu, 13 Jul 2023 12:08:29 +0200 Subject: [PATCH 6/7] Fin --- .../Configuracion/Maquinasdefecto.php | 2 +- ci4/app/Language/en/MaquinasPorDefecto.php | 2 + ci4/app/Language/es/MaquinasPorDefecto.php | 2 + .../Configuracion/MaquinasDefectoModel.php | 97 ++++++++++++------- .../maquinas/_maquinaPorDefectoFormItems.php | 16 +-- 5 files changed, 76 insertions(+), 43 deletions(-) diff --git a/ci4/app/Controllers/Configuracion/Maquinasdefecto.php b/ci4/app/Controllers/Configuracion/Maquinasdefecto.php index 225c32a2..427dbfbc 100644 --- a/ci4/app/Controllers/Configuracion/Maquinasdefecto.php +++ b/ci4/app/Controllers/Configuracion/Maquinasdefecto.php @@ -173,7 +173,7 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController { // JJO: se añade que se checkeen los intervalos de ancho y tirada. // En caso de error se devuelve un mensaje. try { - $error = $this->model->checkIntervals($sanitizedData); + $error = $this->model->checkIntervals($sanitizedData, $id); if(empty($error)){ $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); } diff --git a/ci4/app/Language/en/MaquinasPorDefecto.php b/ci4/app/Language/en/MaquinasPorDefecto.php index 6efc57fe..524b38d2 100644 --- a/ci4/app/Language/en/MaquinasPorDefecto.php +++ b/ci4/app/Language/en/MaquinasPorDefecto.php @@ -33,6 +33,8 @@ return [ 'validation' => [ 'error_ancho_overlap' => 'The range [Min Width, Max Width] is overlapped with another one for the selected type.', 'error_tirada_overlap' => 'The range [Min Printing, Max Printing] is overlapped with another one for the selected type.', + 'error_ancho_range' => 'The field Min Width must be lower than the field Max Width', + 'error_tirada_range' => 'The field Min Printing must be lower than the field Max Printing', 'alto_max' => [ 'decimal' => 'The {field} field must contain a decimal number.', 'required' => 'The {field} field is required.', diff --git a/ci4/app/Language/es/MaquinasPorDefecto.php b/ci4/app/Language/es/MaquinasPorDefecto.php index a16729ab..fc9a9bf8 100644 --- a/ci4/app/Language/es/MaquinasPorDefecto.php +++ b/ci4/app/Language/es/MaquinasPorDefecto.php @@ -33,6 +33,8 @@ return [ 'validation' => [ 'error_ancho_overlap' => 'El rango [Ancho Min, Ancho Max] se solapa con otro existente para el tipo seleccionado.', 'error_tirada_overlap' => 'El rango [Tirada Min, Tirada Max] se solapa con otro existente para el tipo seleccionado.', + 'error_ancho_range' => 'El campo Ancho Min debe ser menor que el campo Ancho Max', + 'error_tirada_range' => 'El campo Tirada Min debe ser menor que el campo Tirada Max', 'alto_max' => [ 'decimal' => 'El campo {field} debe contener un número decimal.', 'required' => 'El campo {field} es obligatorio.', diff --git a/ci4/app/Models/Configuracion/MaquinasDefectoModel.php b/ci4/app/Models/Configuracion/MaquinasDefectoModel.php index e2963e7e..64d39383 100644 --- a/ci4/app/Models/Configuracion/MaquinasDefectoModel.php +++ b/ci4/app/Models/Configuracion/MaquinasDefectoModel.php @@ -77,6 +77,10 @@ class MaquinasDefectoModel extends \App\Models\GoBaseModel "label" => "MaquinasPorDefecto.tiradaMin", "rules" => "required|integer", ], + "maquina_id" => [ + "label" => "MaquinasPorDefecto.maquinaId", + "rules" => "required", + ], ]; protected $validationMessages = [ @@ -108,6 +112,9 @@ class MaquinasDefectoModel extends \App\Models\GoBaseModel "integer" => "MaquinasPorDefecto.validation.tirada_min.integer", "required" => "MaquinasPorDefecto.validation.tirada_min.required", ], + "maquina_id" => [ + "required" => "MaquinasPorDefecto.validation.tirada_min.required", + ], ]; public function findAllWithMaquinas(string $selcols = "*", int $limit = null, int $offset = 0) @@ -118,11 +125,11 @@ class MaquinasDefectoModel extends \App\Models\GoBaseModel ", t2.nombre AS maquina FROM " . $this->table . " t1 LEFT JOIN lg_maquinas t2 ON t1.maquina_id = t2.id"; - if (!is_null($limit) && intval($limit) > 0) { + if (!is_null($limit) && floatval($limit) > 0) { $sql .= " LIMIT " . $limit; } - if (!is_null($offset) && intval($offset) > 0) { + if (!is_null($offset) && floatval($offset) > 0) { $sql .= " OFFSET " . $offset; } @@ -174,45 +181,67 @@ class MaquinasDefectoModel extends \App\Models\GoBaseModel ->groupEnd(); } - public function checkIntervals($data = []){ - $ancho_min = $this->db - ->table($this->table) - ->selectMin("ancho_min") - ->where("is_deleted", 0) - ->where("tipo", $data["tipo"])->get()->getRow()->ancho_min; + public function checkIntervals($data = [], $id = null){ - $ancho_max = $this->db - ->table($this->table) - ->selectMin("ancho_max") - ->where("is_deleted", 0) - ->where("tipo", $data["tipo"])->get()->getRow()->ancho_max; - - $tirada_min = $this->db - ->table($this->table) - ->selectMin("tirada_min") - ->where("is_deleted", 0) - ->where("tipo", $data["tipo"])->get()->getRow()->tirada_min; - - $tirada_max = $this->db - ->table($this->table) - ->selectMin("tirada_max") - ->where("is_deleted", 0) - ->where("tipo", $data["tipo"])->get()->getRow()->tirada_max; - - if(!is_null($ancho_max) && !is_null($ancho_min)){ - if($data["ancho_min"]>=intval($ancho_min) || - $data["ancho_max"]<=intval($ancho_max) ) - return lang('MaquinasPorDefecto.validation.error_ancho_overlap'); + if(floatval($data["ancho_min"])>= floatval($data["ancho_max"])){ + return lang('MaquinasPorDefecto.validation.error_ancho_range'); } - if(!is_null($tirada_max) && !is_null($tirada_min)){ - if($data["tirada_min"]>=intval($tirada_min) || - $data["tirada_max"]<=intval($tirada_max) ) - return lang('MaquinasPorDefecto.validation.error_tirada_overlap'); + if(floatval($data["tirada_min"])>= floatval($data["tirada_max"])){ + return lang('MaquinasPorDefecto.validation.error_tirada_range'); + } + + $anchos = $this->db + ->table($this->table) + ->select("id, ancho_min, ancho_max") + ->where("is_deleted", 0) + ->where("tipo", $data["tipo"]) + ->get()->getResultObject(); + + + foreach ($anchos as $row) { + if (!is_null($id)){ + if($row->id == $id){ + continue; + } + } + if($this->check_overlap(floatval($data["ancho_min"]), floatval($data["ancho_max"]), + $row->ancho_min, $row->ancho_max)){ + return lang('MaquinasPorDefecto.validation.error_ancho_overlap'); + } + } + + $tiradas = $this->db + ->table($this->table) + ->select("id, tirada_min, tirada_max") + ->where("is_deleted", 0) + ->where("tipo", $data["tipo"]) + ->get()->getResultObject(); + + foreach ($tiradas as $row) { + if (!is_null($id)){ + if($row->id == $id){ + continue; + } + } + if($this->check_overlap(floatval($data["tirada_min"]), floatval($data["tirada_max"]), + $row->tirada_min, $row->tirada_max)){ + return lang('MaquinasPorDefecto.validation.error_ancho_overlap'); + } } return ""; } + + + // Devuelve true si los intervalos (a1,a2) (b1,b2) se solapan + // https://stackoverflow.com/questions/3269434/whats-the-most-efficient-way-to-test-if-two-ranges-overlap + private function check_overlap($a1, $a2, $b1, $b2){ + + if (max($a2, $b2) - min($a1, $b1) < ($a2 - $a1) + ($b2 - $b1)) + return true; + return false; + } } diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/_maquinaPorDefectoFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/_maquinaPorDefectoFormItems.php index 76ded6c8..88acab17 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/_maquinaPorDefectoFormItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/_maquinaPorDefectoFormItems.php @@ -4,7 +4,7 @@ - @@ -19,21 +19,21 @@ - +
- +
- +
@@ -44,7 +44,7 @@ - $v) : ?> @@ -61,7 +61,7 @@ - + @@ -69,14 +69,14 @@ - +
- +
From 7b42d497e0facf366b2b066b12b174b3ffd33143 Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Thu, 13 Jul 2023 13:41:12 +0200 Subject: [PATCH 7/7] =?UTF-8?q?a=C3=B1adido=20la=20comprobaci=C3=B3n=20de?= =?UTF-8?q?=20que=20no=20se=20solape=20el=20alto=20en=20maquinas=20defecto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ci4/app/Language/en/MaquinasPorDefecto.php | 2 ++ ci4/app/Language/es/MaquinasPorDefecto.php | 2 ++ .../Configuracion/MaquinasDefectoModel.php | 28 ++++++++----------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/ci4/app/Language/en/MaquinasPorDefecto.php b/ci4/app/Language/en/MaquinasPorDefecto.php index 524b38d2..61b3ddae 100644 --- a/ci4/app/Language/en/MaquinasPorDefecto.php +++ b/ci4/app/Language/en/MaquinasPorDefecto.php @@ -32,8 +32,10 @@ return [ 'userUpdatedId' => 'User Updated ID', 'validation' => [ 'error_ancho_overlap' => 'The range [Min Width, Max Width] is overlapped with another one for the selected type.', + 'error_alto_overlap' => 'The range [Min Height, Max Height] is overlapped with another one for the selected type.', 'error_tirada_overlap' => 'The range [Min Printing, Max Printing] is overlapped with another one for the selected type.', 'error_ancho_range' => 'The field Min Width must be lower than the field Max Width', + 'error_alto_range' => 'The field Min Height must be lower than the field Max Height', 'error_tirada_range' => 'The field Min Printing must be lower than the field Max Printing', 'alto_max' => [ 'decimal' => 'The {field} field must contain a decimal number.', diff --git a/ci4/app/Language/es/MaquinasPorDefecto.php b/ci4/app/Language/es/MaquinasPorDefecto.php index fc9a9bf8..08d02125 100644 --- a/ci4/app/Language/es/MaquinasPorDefecto.php +++ b/ci4/app/Language/es/MaquinasPorDefecto.php @@ -32,8 +32,10 @@ return [ 'userUpdatedId' => 'User Updated ID', 'validation' => [ 'error_ancho_overlap' => 'El rango [Ancho Min, Ancho Max] se solapa con otro existente para el tipo seleccionado.', + 'error_alto_overlap' => 'El rango [Alto Min, Alto Max] se solapa con otro existente para el tipo seleccionado.', 'error_tirada_overlap' => 'El rango [Tirada Min, Tirada Max] se solapa con otro existente para el tipo seleccionado.', 'error_ancho_range' => 'El campo Ancho Min debe ser menor que el campo Ancho Max', + 'error_alto_range' => 'El campo Alto Min debe ser menor que el campo Alto Max', 'error_tirada_range' => 'El campo Tirada Min debe ser menor que el campo Tirada Max', 'alto_max' => [ 'decimal' => 'El campo {field} debe contener un número decimal.', diff --git a/ci4/app/Models/Configuracion/MaquinasDefectoModel.php b/ci4/app/Models/Configuracion/MaquinasDefectoModel.php index 64d39383..f17287dd 100644 --- a/ci4/app/Models/Configuracion/MaquinasDefectoModel.php +++ b/ci4/app/Models/Configuracion/MaquinasDefectoModel.php @@ -191,15 +191,19 @@ class MaquinasDefectoModel extends \App\Models\GoBaseModel return lang('MaquinasPorDefecto.validation.error_tirada_range'); } - $anchos = $this->db + if(floatval($data["alto_min"])>= floatval($data["alto_max"])){ + return lang('MaquinasPorDefecto.validation.error_alto_range'); + } + + $rows = $this->db ->table($this->table) - ->select("id, ancho_min, ancho_max") + ->select("id, ancho_min, ancho_max, alto_min, alto_max, tirada_min, tirada_max") ->where("is_deleted", 0) ->where("tipo", $data["tipo"]) ->get()->getResultObject(); - foreach ($anchos as $row) { + foreach ($rows as $row) { if (!is_null($id)){ if($row->id == $id){ continue; @@ -209,20 +213,9 @@ class MaquinasDefectoModel extends \App\Models\GoBaseModel $row->ancho_min, $row->ancho_max)){ return lang('MaquinasPorDefecto.validation.error_ancho_overlap'); } - } - - $tiradas = $this->db - ->table($this->table) - ->select("id, tirada_min, tirada_max") - ->where("is_deleted", 0) - ->where("tipo", $data["tipo"]) - ->get()->getResultObject(); - - foreach ($tiradas as $row) { - if (!is_null($id)){ - if($row->id == $id){ - continue; - } + if($this->check_overlap(floatval($data["alto_min"]), floatval($data["alto_max"]), + $row->alto_min, $row->alto_max)){ + return lang('MaquinasPorDefecto.validation.error_alto_overlap'); } if($this->check_overlap(floatval($data["tirada_min"]), floatval($data["tirada_max"]), $row->tirada_min, $row->tirada_max)){ @@ -230,6 +223,7 @@ class MaquinasDefectoModel extends \App\Models\GoBaseModel } } + return ""; }