From 668d0d79e6a8154ae7e307465b317f8294bfa4b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Mon, 14 Oct 2024 18:19:41 +0200 Subject: [PATCH 1/3] problema ruta papelformato --- ci4/app/Config/Routes.php | 2 ++ ci4/app/Controllers/Clientes/Cliente.php | 26 +++++++++---------- .../Configuracion/Papelformato.php | 21 +++++++++++++++ .../assets/js/safekat/components/select2.js | 6 ++++- .../presupuestoCliente/datosGenerales.js | 2 +- 5 files changed, 41 insertions(+), 16 deletions(-) diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 1142b7f2..09c44b34 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -8,6 +8,7 @@ use CodeIgniter\Router\RouteCollection; //service('auth')->routes($routes, ['except' => ['login', 'register']]); service('auth')->routes($routes); + //WEB ROUTER ------------------------------------------------------ //------------------------------------------------------------------ $routes->get('/', 'Home::index', ['as' => 'home']); @@ -730,6 +731,7 @@ $routes->resource('buscadorpresupuestos', ['namespace' => 'App\Controllers\Presu $routes->group('papel-formato', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { $routes->post('menuitems', 'Papelformato::menuitems', ['as' => 'menuitems']); + $routes->get('getSelect2', 'Papelformato::getSelect2', ['as' => 'getSelect2']); } ); $routes->resource('papel-formato', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Papelformato', 'except' => 'show,new,create,update']); diff --git a/ci4/app/Controllers/Clientes/Cliente.php b/ci4/app/Controllers/Clientes/Cliente.php index ec271292..f388ec1f 100755 --- a/ci4/app/Controllers/Clientes/Cliente.php +++ b/ci4/app/Controllers/Clientes/Cliente.php @@ -1,4 +1,6 @@ -redirect2listView('sweet-error', $message); endif; - + if ($this->request->getPost()) : @@ -310,10 +312,9 @@ class Cliente extends \App\Controllers\BaseResourceController $onlyActiveOnes = false; $columns2select = [$reqId ?? 'id', $reqText ?? 'nombre']; $onlyActiveOnes = false; - try{ + try { $menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr); - } - catch(Exception $e){ + } catch (Exception $e) { $menu = []; } @@ -339,15 +340,13 @@ class Cliente extends \App\Controllers\BaseResourceController "nombre as name" ] )->where("deleted_at", null); - if ($this->request->getGet("q")) { $query->groupStart() ->orLike("clientes.nombre", $this->request->getGet("q")) ->groupEnd(); } - + return $this->response->setJSON($query->get()->getResultObject()); - // return $this->respond($menu); } else { return $this->failUnauthorized('Invalid request', 403); } @@ -447,24 +446,23 @@ class Cliente extends \App\Controllers\BaseResourceController } - protected function getPrecioTemplate($cliente_id){ + protected function getPrecioTemplate($cliente_id) + { $modelPreciosCliente = model('App\Models\Clientes\ClientePreciosModel'); $plantilla_id = $modelPreciosCliente->get_plantilla_precios($cliente_id); - if (is_null($plantilla_id)){ + if (is_null($plantilla_id)) { return null; } $modelPlantillaPreciosCliente = model('App\Models\Clientes\ClientePlantillaPreciosModel'); $plantilla = $modelPlantillaPreciosCliente->where("id", $plantilla_id)->where("is_deleted", 0)->first(); - if ($plantilla == false){ + if ($plantilla == false) { return null; - } - else{ + } else { return (object)array( "value" => $plantilla_id, "label" => $plantilla->nombre ); } - } } diff --git a/ci4/app/Controllers/Configuracion/Papelformato.php b/ci4/app/Controllers/Configuracion/Papelformato.php index 82d3e1e2..271bce82 100755 --- a/ci4/app/Controllers/Configuracion/Papelformato.php +++ b/ci4/app/Controllers/Configuracion/Papelformato.php @@ -260,4 +260,25 @@ class Papelformato extends \App\Controllers\BaseResourceController { } } + + public function getSelect2() + { + if ($this->request->isAJAX()) { + $query = $this->model->builder()->select( + [ + "id", + "nombre as name" + ] + )->where("deleted_at", null); + if ($this->request->getGet("q")) { + $query->groupStart() + ->orLike("clientes.nombre", $this->request->getGet("q")) + ->groupEnd(); + } + + return $this->response->setJSON($query->get()->getResultObject()); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } } diff --git a/httpdocs/assets/js/safekat/components/select2.js b/httpdocs/assets/js/safekat/components/select2.js index a2b71f22..27c188ab 100644 --- a/httpdocs/assets/js/safekat/components/select2.js +++ b/httpdocs/assets/js/safekat/components/select2.js @@ -18,7 +18,11 @@ let ClassSelect = function (domItem, url, placeholder, allowClear = false, param return this.url; }, data: (params) => { - let d = $.trim(params.term); + let q = $.trim(params.term); + let d = { + q: q, + page: params.page || 1, + }; for (let key in this.params) { d[key] = this.params[key]; diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js index e0e33c4f..9b5c3e20 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js @@ -9,7 +9,7 @@ class DatosGenerales { this.wizardStep = wizardForm.querySelector('#datos-generales'); this.validatorStepper = validatorStepper; - this.formatoLibro = new ClassSelect($("#papelFormatoId"), '/papel-formato/menuitems', window.translations["formatoLibro"]); + this.formatoLibro = new ClassSelect($("#papelFormatoId"), '/papel-formato/getSelect2', window.translations["formatoLibro"]); this.cliente = new ClassSelect($("#clienteId"), '/clientes/cliente/getSelect2', window.translations["selectCliente"]); this.titulo = this.domItem.find("#titulo"); From de9cf30aacb3548b8f6791166acb862ae1320d6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Mon, 14 Oct 2024 18:29:50 +0200 Subject: [PATCH 2/3] solucionados todos los select2 en conflicto --- .../Controllers/Configuracion/Papelformato.php | 16 +++------------- .../Models/Configuracion/PapelFormatoModel.php | 8 ++++++-- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/ci4/app/Controllers/Configuracion/Papelformato.php b/ci4/app/Controllers/Configuracion/Papelformato.php index 271bce82..b2b23276 100755 --- a/ci4/app/Controllers/Configuracion/Papelformato.php +++ b/ci4/app/Controllers/Configuracion/Papelformato.php @@ -264,19 +264,9 @@ class Papelformato extends \App\Controllers\BaseResourceController { public function getSelect2() { if ($this->request->isAJAX()) { - $query = $this->model->builder()->select( - [ - "id", - "nombre as name" - ] - )->where("deleted_at", null); - if ($this->request->getGet("q")) { - $query->groupStart() - ->orLike("clientes.nombre", $this->request->getGet("q")) - ->groupEnd(); - } - - return $this->response->setJSON($query->get()->getResultObject()); + $data = $this->model->getElementsForMenu2($this->request->getGet("q")); + + return $this->response->setJSON($data); } else { return $this->failUnauthorized('Invalid request', 403); } diff --git a/ci4/app/Models/Configuracion/PapelFormatoModel.php b/ci4/app/Models/Configuracion/PapelFormatoModel.php index d809fec6..8f54389a 100755 --- a/ci4/app/Models/Configuracion/PapelFormatoModel.php +++ b/ci4/app/Models/Configuracion/PapelFormatoModel.php @@ -98,8 +98,12 @@ class PapelFormatoModel extends \App\Models\BaseModel $builder = $this->db ->table($this->table . " t1") ->select( - "t1.id AS id, CONCAT(t1.ancho, ' x ', t1.alto) AS text" - )->where('is_deleted', 0)->orderBy('orden_select', 'asc'); + "t1.id AS id, CONCAT(t1.ancho, ' x ', t1.alto) AS name" + ) + ->where('is_deleted', 0) + ->where('id>', 0) + ->orderBy('orden_select', 'asc'); + return empty($search) ? $builder->get()->getResultObject() From a8a741f0bff9e0761966080915606c9e4909e61a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Tue, 15 Oct 2024 11:43:44 +0200 Subject: [PATCH 3/3] =?UTF-8?q?trabajando=20en=20a=C3=B1adir=20las=20tirad?= =?UTF-8?q?as=20a=20las=20direcciones?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presupuestoCliente/presupuestoCliente.js | 2 +- .../presupuestoCliente/selectorTiradaEnvio.js | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 httpdocs/assets/js/safekat/pages/presupuestoCliente/selectorTiradaEnvio.js diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js index 9b6b17bf..a5e3c5b3 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js @@ -56,7 +56,7 @@ class PresupuestoCliente { this.disenioCubierta.init(); this.direcciones.init(); - //this.RELLENAR_PRESUPUESTO(); + this.RELLENAR_PRESUPUESTO(); } diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/selectorTiradaEnvio.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/selectorTiradaEnvio.js new file mode 100644 index 00000000..455a7a95 --- /dev/null +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/selectorTiradaEnvio.js @@ -0,0 +1,46 @@ +class SelectorTiradaEnvio { + + constructor(container, id, tirada, precio_u) { + + this.container = container; + this.card = this.#generateHTML(id, tirada, precio_u); + } + + #generateHTML(id, tirada, precio_u) { + + var $div = $('
', { + id: id, + class: 'form-check custom-option custom-option-basic custom-option-tiradasDirecciones' + }).append( + $('