From b4de7978cca4fb0d7651b7eb84ebf7bf75b557b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Sat, 14 Dec 2024 10:36:51 +0100 Subject: [PATCH] realizado los cambios en los selects --- ci4/app/Config/Routes.php | 1 + .../Presupuestos/Presupuestoacabados.php | 82 ++++++++++++++----- .../Presupuestos/Presupuestocliente.php | 16 ---- ci4/app/Language/es/Presupuestos.php | 1 + .../cliente/items/_disenioCubierta.php | 56 ++----------- .../presupuestoCliente/disenioCubierta.js | 37 +++++++-- 6 files changed, 100 insertions(+), 93 deletions(-) diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index c4c439e8..c97c56e8 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -599,6 +599,7 @@ $routes->group('serviciosacabados', ['namespace' => 'App\Controllers\Presupuesto $routes->post('datatable', 'Presupuestoacabados::datatable', ['as' => 'dataTableOfPresupuestoAcabados']); $routes->post('menuitems', 'Presupuestoacabados::menuItems', ['as' => 'menuItemsOfPresupuestoAcabados']); $routes->post('edit/(:num)', 'Presupuestoacabados::edit/$1', ['as' => 'updatePresupuestoacabados']); + $routes->get('getacabados', 'Presupuestoacabados::getAcabados'); }); $routes->group('serviciosencuadernaciones', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) { diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoacabados.php b/ci4/app/Controllers/Presupuestos/Presupuestoacabados.php index 48fa392c..18dc5743 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestoacabados.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoacabados.php @@ -1,4 +1,5 @@ -request->getJSON(); - if(count($postData->datos)>0){ + if (count($postData->datos) > 0) { $this->model->deleteServiciosNotInArray($requestedId, $postData->datos); - } - else{ + } else { $this->model->deleteAllServicios($requestedId); } - if(count($postData->datos)>0){ + if (count($postData->datos) > 0) { $this->model->updateTarifas($requestedId, $postData->datos); } @@ -58,14 +58,14 @@ class Presupuestoacabados extends \App\Controllers\BaseResourceController $data = [ $csrfTokenName => $newTokenHash ]; - + return $this->respond($data); } public function update($requestedId = null) { - if ($requestedId == null) : + if ($requestedId == null): return; endif; @@ -75,20 +75,20 @@ class Presupuestoacabados extends \App\Controllers\BaseResourceController $POD = $postData->POD ?? 0; $result = []; - if(count($tarifas)>0){ - foreach ($tarifas as $tarifa){ + if (count($tarifas) > 0) { + foreach ($tarifas as $tarifa) { $values = $this->model->getPrecioTarifa($tarifa, $tirada, $POD); array_push($result, $values); } } - + $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); $data = [ 'lines' => $result, $csrfTokenName => $newTokenHash ]; - + return $this->respond($data); } @@ -101,7 +101,7 @@ class Presupuestoacabados extends \App\Controllers\BaseResourceController $tirada = $reqData['tirada'] ?? 0; $proveedor_id = $reqData['proveedor_id'] ?? -1; $POD = $reqData['POD'] ?? 0; - + $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); @@ -119,17 +119,59 @@ class Presupuestoacabados extends \App\Controllers\BaseResourceController } } + public function getAcabados() + { + if ($this->request->isAJAX()) { + + $cubierta = $this->request->getGet("cubierta") ?? 0; + $sobrecubierta = $this->request->getGet("sobrecubierta") ?? 0; + + $model = model('App\Models\Tarifas\Acabados\TarifaAcabadoModel'); + $query = $model->builder()->select( + [ + "id", + "nombre as name" + ] + ) + ->where("lg_tarifa_acabado.is_deleted", 0) + ->where("lg_tarifa_acabado.mostrar_en_presupuesto", 1); + + if($cubierta == 1){ + $query->where("lg_tarifa_acabado.acabado_cubierta", 1); + } + else if ($sobrecubierta == 1){ + $query->where("lg_tarifa_acabado.acabado_sobrecubierta", 1); + } + if ($this->request->getGet("q")) { + $query->groupStart() + ->orLike("lg_tarifa_acabado.nombre", $this->request->getGet("q")) + ->groupEnd(); + } + + $items = $query->get()->getResultObject(); + // add a custom item at the beginning + $customItem = new \stdClass; + $customItem->id = 0; + $customItem->name = "Ninguno"; + array_unshift($items, $customItem); + + return $this->response->setJSON($items); + + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } public function menuItems() { if ($this->request->isAJAX()) { $reqData = $this->request->getPost(); - try{ + try { $tarifa_id = $reqData['tarifa_id'] ?? -1; $tirada = $reqData['tirada'] ?? 0; - + $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); @@ -140,17 +182,15 @@ class Presupuestoacabados extends \App\Controllers\BaseResourceController $csrfTokenName => $newTokenHash ]; - } - catch(Exception $e){ + } catch (Exception $e) { $data = [ 'error' => $e, $csrfTokenName => $newTokenHash ]; - } - finally{ + } finally { return $this->respond($data); } - + } else { return $this->failUnauthorized('Invalid request', 403); } diff --git a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php index ca33d1d6..10a5139a 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php @@ -2278,22 +2278,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController return $data; } - protected function getAcabadosCubierta() - { - $model = model('App\Models\Tarifas\Acabados\TarifaAcabadoModel'); - $data = $model->getServiciosAcabadoCubierta(); - array_unshift($data, (object) ['id' => '', 'label' => lang('Basic.global.None')]); - return $data; - } - - protected function getAcabadosSobrecubierta() - { - $model = model('App\Models\Tarifas\Acabados\TarifaAcabadoModel'); - $data = $model->getServiciosAcabadoSobrecubierta(); - array_unshift($data, (object) ['id' => '', 'label' => lang('Basic.global.None')]); - return $data; - } - protected function getClienteListItems($selId = null) { $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Clientes.cliente'))])]; diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index 1fb887c2..fee02953 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -67,6 +67,7 @@ return [ 'papelFormatoPersonalizado' => 'TamaƱo personalizado', 'papelFormatoAncho' => 'Ancho', 'papelFormatoAlto' => 'Alto', + 'acabado' => 'Acabado', 'acabadosExteriores' => 'Acabados exteriores', 'acabadoCubierta' => 'Acabado Cubierta', 'acabadoSobrecubierta' => 'Acabado Sobrecubierta', diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta.php index 5b242bca..05beed75 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta.php @@ -171,46 +171,12 @@
-
- - -
- -
- - -
- -
-
- -
- -
+
" @@ -230,9 +196,9 @@

Extras

-
+
-
+
@@ -268,18 +234,12 @@
-
- -
diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js index d0240a60..89953851 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js @@ -62,15 +62,13 @@ class DisenioCubierta { this.divPapelCubierta = this.domItem.find("#divPapelCubierta"); this.divGramajeCubierta = this.domItem.find("#divGramajeCubierta"); - this.cubiertaPlastificado = this.domItem.find("#plastificado"); - this.cubiertaBarniz = this.domItem.find("#barniz"); - this.cubiertaEstampado = this.domItem.find("#estampado"); + this.acabadoCubierta = this.domItem.find("#acabadoCubierta"); this.cubiertaRetractilado = this.domItem.find("#retractilado"); this.configuracionSobrecubierta = this.domItem.find(".config-sobrecubierta"); this.sobrecubierta = this.domItem.find("#addSobrecubierta"); this.papelSobrecubierta = this.domItem.find("#papelSobrecubierta"); - this.plastificadoSobrecubierta = this.domItem.find("#plastificadoSobrecubierta"); + this.acabadoSobrecubierta = this.domItem.find("#acabadoSobrecubierta"); this.configuracionFaja = this.domItem.find(".config-faja"); this.faja = this.domItem.find("#addFaja"); @@ -94,6 +92,26 @@ class DisenioCubierta { this.rl_tamanio_sobrecubierta = $('#rl_tamanio_sobrecubierta'); this.rl_acabado_sobrecubierta = $("#rl_acabado_sobrecubierta"); + this.acabadoCubierta = new ClassSelect($("#acabadoCubierta"), + '/serviciosacabados/getacabados', + '', + false, + { + [this.csrf_token]: this.csrf_hash, + "cubierta": 1 + } + ); + + this.acabadoSobrecubierta = new ClassSelect($("#acabadoSobrecubierta"), + '/serviciosacabados/getacabados', + '', + false, + { + [this.csrf_token]: this.csrf_hash, + "sobrecubierta": 1 + } + ); + this.initValidation(); // Creamos un nuevo observador que detecta cambios en los atributos @@ -124,6 +142,9 @@ class DisenioCubierta { const self = this; this.papelEspecial.init(); + this.acabadoCubierta.init(); + this.acabadoSobrecubierta.init(); + $('#papelEspecialCubiertaSel').on("change", this.#handlePapelCubiertaEspecial.bind(this)); // Eventos @@ -195,9 +216,9 @@ class DisenioCubierta { $(`#divGramajeCubierta .gramaje-cubierta input[data-value="${datosCubierta.gramaje}"]`).trigger('click'); }, 0); - this.cubiertaPlastificado.val(datosCubierta.plastificado).trigger('change'); - this.cubiertaBarniz.val(datosCubierta.barniz).trigger('change'); - this.cubiertaEstampado.val(datosCubierta.estampado).trigger('change'); + // JJO this.cubiertaPlastificado.val(datosCubierta.plastificado).trigger('change'); + //this.cubiertaBarniz.val(datosCubierta.barniz).trigger('change'); + //this.cubiertaEstampado.val(datosCubierta.estampado).trigger('change'); if (datosCubierta.retractilado) { setTimeout(() => { this.cubiertaRetractilado.trigger('click'); @@ -208,7 +229,7 @@ class DisenioCubierta { this.sobrecubierta.trigger('click'); this.papelSobrecubierta.val(datosSobrecubierta.papel.code + "_" + datosSobrecubierta.gramaje).trigger('change'); this.solapasSobrecubierta.val(datosSobrecubierta.solapas_ancho); - this.plastificadoSobrecubierta.val(datosSobrecubierta.plastificado).trigger('change'); + // JJO this.plastificadoSobrecubierta.val(datosSobrecubierta.plastificado).trigger('change'); } }