From 2a73d29546024dbfbb7980e645bc9120a37111a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Sun, 17 Nov 2024 20:54:11 +0100 Subject: [PATCH] =?UTF-8?q?modificado=20formulario=20cliente.=20A=C3=B1adi?= =?UTF-8?q?da=20migracion=20para=20la=20bbdd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ci4/app/Config/Routes.php | 39 ++-- .../Configuracion/Comunidadesautonomas.php | 21 ++ .../Controllers/Configuracion/FormasPago.php | 30 ++- ci4/app/Controllers/Configuracion/Paises.php | 21 ++ .../Controllers/Configuracion/Provincias.php | 21 ++ ci4/app/Controllers/Configuracion/Users.php | 8 +- ci4/app/Models/UserModel.php | 2 +- .../clientes/cliente/_clienteFormItems.php | 5 - .../form/clientes/cliente/viewClienteForm.php | 199 +----------------- .../presupuestoCliente/datosGenerales.js | 2 - .../presupuestoCliente/presupuestoCliente.js | 33 +-- 11 files changed, 100 insertions(+), 281 deletions(-) diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 06df20fe..4ff6d0ef 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -77,14 +77,7 @@ $routes->group('configuracion', ['namespace' => 'App\Controllers\Configuracion'] $routes->post('menuitemsFacturas', 'SeriesFacturas::menuItemsFacturas', ['as' => 'menuItemsOfSeriesFacturas']); }); - /* Formas de Pago */ - $routes->group('formas-pago', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { - $routes->get('', 'FormasPago::index', ['as' => 'formasPagoList']); - $routes->match(['get', 'post'], 'add', 'FormasPago::add', ['as' => 'formasPagoAdd']); - $routes->match(['get', 'post'], 'edit/(:num)', 'FormasPago::edit/$1', ['as' => 'formasPagoEdit']); - $routes->get('delete/(:num)', 'FormasPago::delete/$1', ['as' => 'formasPagoDelete']); - $routes->post('datatable', 'FormasPago::datatable', ['as' => 'formasPagoDT']); - }); + $routes->group("variables", ["namespace" => 'App\Controllers\Configuracion'], function ($routes) { $routes->get('', 'ConfigVariables::index', ['as' => 'variablesIndex']); $routes->get('find/(:num)', 'ConfigVariables::get/$1', ['as' => 'variablesFind']); @@ -113,8 +106,10 @@ $routes->group('users', ['namespace' => 'App\Controllers\Configuracion'], functi $routes->get('delete/(:num)', 'Users::delete/$1', ['as' => 'deleteUser']); $routes->post('allmenuitems', 'Users::allItemsSelect', ['as' => 'select2ItemsOfUsers']); $routes->post('menuitems', 'Users::menuItems', ['as' => 'menuItemsOfUsers']); - $routes->post('getMenuComerciales', 'Users::getMenuComerciales', ['as' => 'menuItemsComerciales']); + $routes->get('getMenuComerciales', 'Users::getMenuComerciales', ['as' => 'menuItemsComerciales']); }); +$routes->resource('users', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Users', 'except' => 'show,new,create,update']); + $routes->group('group', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { $routes->get('', 'Group::index', ['as' => 'userGroupList']); @@ -332,10 +327,22 @@ $routes->group('comunidades-autonomas', ['namespace' => 'App\Controllers\Configu $routes->post('datatable', 'Comunidadesautonomas::datatable', ['as' => 'dataTableOfComunidadesAutonomas']); $routes->post('allmenuitems', 'Comunidadesautonomas::allItemsSelect', ['as' => 'select2ItemsOfComunidadesAutonomas']); $routes->post('menuitems', 'Comunidadesautonomas::menuItems', ['as' => 'menuItemsOfComunidadesAutonomas']); + $routes->get('menuitems2', 'Comunidadesautonomas::menuItems2', ['as' => 'menuItemsOfComunidadesAutonomas2']); }); $routes->resource('comunidades-autonomas', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Comunidadesautonomas', 'except' => 'show,new,create,update']); +$routes->group('formas-pago', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { + $routes->get('', 'FormasPago::index', ['as' => 'formasPagoList']); + $routes->match(['get', 'post'], 'add', 'FormasPago::add', ['as' => 'formasPagoAdd']); + $routes->match(['get', 'post'], 'edit/(:num)', 'FormasPago::edit/$1', ['as' => 'formasPagoEdit']); + $routes->get('delete/(:num)', 'FormasPago::delete/$1', ['as' => 'formasPagoDelete']); + $routes->post('datatable', 'FormasPago::datatable', ['as' => 'formasPagoDT']); + $routes->get('menuitems', 'FormasPago::menuItems', ['as' => 'menuItemsOfFormasDePagos']); +}); +$routes->resource('formas-pago', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'FormasPago', 'except' => 'show,new,create,update']); + + $routes->group('paises', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { $routes->get('', 'Paises::index', ['as' => 'paisList']); $routes->get('add', 'Paises::add', ['as' => 'newPais']); @@ -346,6 +353,7 @@ $routes->group('paises', ['namespace' => 'App\Controllers\Configuracion'], funct $routes->post('datatable', 'Paises::datatable', ['as' => 'dataTableOfPaises']); $routes->post('allmenuitems', 'Paises::allItemsSelect', ['as' => 'select2ItemsOfPaises']); $routes->post('menuitems', 'Paises::menuItems', ['as' => 'menuItemsOfPaises']); + $routes->get('menuitems2', 'Paises::menuItems2', ['as' => 'menuItemsOfPaises2']); }); $routes->resource('paises', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Paises', 'except' => 'show,new,create,update']); @@ -360,6 +368,7 @@ $routes->group('provincias', ['namespace' => 'App\Controllers\Configuracion'], f $routes->post('datatable', 'Provincias::datatable', ['as' => 'dataTableOfProvincias']); $routes->post('allmenuitems', 'Provincias::allItemsSelect', ['as' => 'select2ItemsOfProvincias']); $routes->post('menuitems', 'Provincias::menuItems', ['as' => 'menuItemsOfProvincias']); + $routes->get('menuitems2', 'Provincias::menuItems2', ['as' => 'menuItemsOfProvincias2']); }); $routes->resource('provincias', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Provincias', 'except' => 'show,new,create,update']); @@ -420,18 +429,6 @@ $routes->group('misdirecciones', ['namespace' => 'App\Controllers\Clientes'], fu }); -$routes->group('formas-pagos', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { - $routes->get('', 'Formaspagos::index', ['as' => 'formaDePagoList']); - $routes->get('add', 'Formaspagos::add', ['as' => 'newFormaDePago']); - $routes->post('add', 'Formaspagos::add', ['as' => 'createFormaDePago']); - $routes->post('create', 'Formaspagos::create', ['as' => 'ajaxCreateFormaDePago']); - $routes->put('(:num)/update', 'Formaspagos::update/$1', ['as' => 'ajaxUpdateFormaDePago']); - $routes->post('(:num)/edit', 'Formaspagos::edit/$1', ['as' => 'updateFormaDePago']); - $routes->post('datatable', 'Formaspagos::datatable', ['as' => 'dataTableOfFormasDePagos']); - $routes->post('allmenuitems', 'Formaspagos::allItemsSelect', ['as' => 'select2ItemsOfFormasDePagos']); - $routes->post('menuitems', 'Formaspagos::menuItems', ['as' => 'menuItemsOfFormasDePagos']); -}); -$routes->resource('formas-pagos', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Formaspagos', 'except' => 'show,new,create,update']); $routes->group('tarifasencuadernacion', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) { $routes->get('', 'Tarifasencuadernacion::index', ['as' => 'tarifaEncuadernacionList']); diff --git a/ci4/app/Controllers/Configuracion/Comunidadesautonomas.php b/ci4/app/Controllers/Configuracion/Comunidadesautonomas.php index 86f8ae6b..141c29c1 100755 --- a/ci4/app/Controllers/Configuracion/Comunidadesautonomas.php +++ b/ci4/app/Controllers/Configuracion/Comunidadesautonomas.php @@ -271,6 +271,27 @@ class Comunidadesautonomas extends \App\Controllers\BaseResourceController } } + public function menuItems2() + { + if ($this->request->isAJAX()) { + $query = $this->model->builder()->select( + [ + "id", + "nombre as name" + ] + )->orderBy("nombre", "asc"); + if ($this->request->getGet("q")) { + $query->groupStart() + ->orLike("lg_comunidades_autonomas.nombre", $this->request->getGet("q")) + ->groupEnd(); + } + + return $this->response->setJSON($query->get()->getResultObject()); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + protected function getPaisListItems($selId = null) { diff --git a/ci4/app/Controllers/Configuracion/FormasPago.php b/ci4/app/Controllers/Configuracion/FormasPago.php index a2867c59..9186a2af 100644 --- a/ci4/app/Controllers/Configuracion/FormasPago.php +++ b/ci4/app/Controllers/Configuracion/FormasPago.php @@ -230,25 +230,19 @@ class FormasPago extends \App\Controllers\BaseResourceController public function menuItems() { if ($this->request->isAJAX()) { - $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; - $reqId = goSanitize($this->request->getPost('id'))[0]; - $reqText = goSanitize($this->request->getPost('text'))[0]; - $onlyActiveOnes = false; - $columns2select = [$reqId ?? 'id', $reqText ?? 'nombre']; - $onlyActiveOnes = false; - $menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr); - $nonItem = new \stdClass; - $nonItem->id = ''; - $nonItem->text = '- ' . lang('Basic.global.None') . ' -'; - array_unshift($menu, $nonItem); + $query = $this->model->builder()->select( + [ + "id", + "nombre as name" + ] + )->orderBy("nombre", "asc"); + if ($this->request->getGet("q")) { + $query->groupStart() + ->orLike("formas_pago.nombre", $this->request->getGet("q")) + ->groupEnd(); + } - $newTokenHash = csrf_hash(); - $csrfTokenName = csrf_token(); - $data = [ - 'menu' => $menu, - $csrfTokenName => $newTokenHash - ]; - return $this->respond($data); + return $this->response->setJSON($query->get()->getResultObject()); } else { return $this->failUnauthorized('Invalid request', 403); } diff --git a/ci4/app/Controllers/Configuracion/Paises.php b/ci4/app/Controllers/Configuracion/Paises.php index 05383412..a9d8b5d1 100755 --- a/ci4/app/Controllers/Configuracion/Paises.php +++ b/ci4/app/Controllers/Configuracion/Paises.php @@ -269,4 +269,25 @@ class Paises extends \App\Controllers\BaseResourceController } } + public function menuItems2() + { + if ($this->request->isAJAX()) { + $query = $this->model->builder()->select( + [ + "id", + "nombre as name" + ] + )->orderBy("nombre", "asc"); + if ($this->request->getGet("q")) { + $query->groupStart() + ->orLike("lg_paises.nombre", $this->request->getGet("q")) + ->groupEnd(); + } + + return $this->response->setJSON($query->get()->getResultObject()); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + } diff --git a/ci4/app/Controllers/Configuracion/Provincias.php b/ci4/app/Controllers/Configuracion/Provincias.php index 573a4a39..ffbfa084 100755 --- a/ci4/app/Controllers/Configuracion/Provincias.php +++ b/ci4/app/Controllers/Configuracion/Provincias.php @@ -271,6 +271,27 @@ class Provincias extends \App\Controllers\BaseResourceController } } + public function menuItems2() + { + if ($this->request->isAJAX()) { + $query = $this->model->builder()->select( + [ + "id", + "nombre as name" + ] + )->orderBy("nombre", "asc"); + if ($this->request->getGet("q")) { + $query->groupStart() + ->orLike("lg_provincias.nombre", $this->request->getGet("q")) + ->groupEnd(); + } + + return $this->response->setJSON($query->get()->getResultObject()); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + protected function getPaisListItems($selId = null) { diff --git a/ci4/app/Controllers/Configuracion/Users.php b/ci4/app/Controllers/Configuracion/Users.php index dcb8a140..7e7ab4dc 100755 --- a/ci4/app/Controllers/Configuracion/Users.php +++ b/ci4/app/Controllers/Configuracion/Users.php @@ -372,13 +372,7 @@ class Users extends \App\Controllers\GoBaseController if ($this->request->isAJAX()) { $comerciales = $this->model->getComerciales(); - $newTokenHash = csrf_hash(); - $csrfTokenName = csrf_token(); - $data = [ - 'menu' => $comerciales, - $csrfTokenName => $newTokenHash - ]; - return $this->respond($data); + return $this->respond($comerciales); } else { return $this->failUnauthorized('Invalid request', 403); } diff --git a/ci4/app/Models/UserModel.php b/ci4/app/Models/UserModel.php index ccc79a9c..d397eaf2 100644 --- a/ci4/app/Models/UserModel.php +++ b/ci4/app/Models/UserModel.php @@ -66,7 +66,7 @@ class UserModel extends ShieldUserModel $builder = $this->db ->table("users" . " t1") ->select( - "t1.id AS id, CONCAT(t1.first_name, ' ', t1.last_name) AS text" + "t1.id AS id, CONCAT(t1.first_name, ' ', t1.last_name) AS name" ); $builder->where('t1.deleted_at', null); diff --git a/ci4/app/Views/themes/vuexy/form/clientes/cliente/_clienteFormItems.php b/ci4/app/Views/themes/vuexy/form/clientes/cliente/_clienteFormItems.php index cc7dddde..3a741867 100644 --- a/ci4/app/Views/themes/vuexy/form/clientes/cliente/_clienteFormItems.php +++ b/ci4/app/Views/themes/vuexy/form/clientes/cliente/_clienteFormItems.php @@ -158,11 +158,6 @@ diff --git a/ci4/app/Views/themes/vuexy/form/clientes/cliente/viewClienteForm.php b/ci4/app/Views/themes/vuexy/form/clientes/cliente/viewClienteForm.php index ca21d53f..9c3eb039 100644 --- a/ci4/app/Views/themes/vuexy/form/clientes/cliente/viewClienteForm.php +++ b/ci4/app/Views/themes/vuexy/form/clientes/cliente/viewClienteForm.php @@ -34,201 +34,6 @@ endSection() ?> -section("additionalInlineJs") ?> - $(document).keypress(function (e) { - var key = e.which; - if(key == 13) // the enter key code - { e.preventDefault() - if($('#addressForm').hasClass('show')){ - $("#saveAdd").click(); - } - else if ($('#convert2Template').hasClass('show')){ - $("#saveTemplate").click(); - } - else{ - $('#saveForm').click(); - } - } - }); - - - $('#soporteId').select2({ - allowClear: false, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - id: 'id_user', - text: 'first_name', - searchTerm: params.term, - : v - }; - }, - delay: 60, - processResults: function (response) { - - yeniden(response.); - - return { - results: response.menu - }; - }, - - cache: true - } - }); - - $('#formaPagoId').select2({ - 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 - } - }); - - $('#paisId').select2({ - 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 - } - }); - - $('#provinciaId').select2({ - 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 - } - }); - - $('#comunidadAutonomaId').select2({ - 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 - } - }); - - $('#comercialId').select2({ - allowClear: false, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - id: 'id', - text: 'text', - searchTerm: params.term, - : v - }; - }, - delay: 60, - processResults: function (response) { - - yeniden(response.); - - return { - results: response.menu - }; - }, - - cache: true - } - }); - -endSection() ?> - - section('css') ?> "> @@ -236,3 +41,7 @@ endSection() ?> + +section("additionalExternalJs") ?> + +endSection() ?> \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js index 727a2a4e..ab98c386 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js @@ -1,6 +1,4 @@ import ClassSelect from '../../components/select2.js'; -import tarjetaTiradasPrecio from './tarjetaTiradasPrecio.js'; - class DatosGenerales { diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js index 10d03e88..89edef0c 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js @@ -11,38 +11,7 @@ import tarjetaTiradasPrecio from './tarjetaTiradasPrecio.js'; class PresupuestoCliente { constructor() { - /* - // Seleccionar el header y el contenedor del offcanvas - var stepperHeader = document.querySelector('#sharedStepper'); - var offcanvasBody = document.querySelector('#menu-offcanvas .offcanvas-body'); - - // Función para verificar el tamaño de la pantalla y mover el contenido - function adjustStepperLocation() { - if (window.innerWidth < 768) { - // Si es un dispositivo móvil o tablet, mover el stepper al offcanvas - if (offcanvasBody && stepperHeader) { - // Verificar si el stepper ya está en el offcanvas - if (!offcanvasBody.contains(stepperHeader)) { - offcanvasBody.appendChild(stepperHeader); // Mover al offcanvas - } - } - } else { - // Si es un dispositivo grande, dejar el stepper en su lugar original - var originalContainer = document.querySelector('.bs-stepper-header').parentNode; - if (originalContainer && !originalContainer.contains(stepperHeader)) { - originalContainer.appendChild(stepperHeader); // Mover de vuelta al contenedor original - } - } - } - - // Llamar a la función para ajustar la ubicación al cargar - adjustStepperLocation(); - - // También ejecutar la función cuando cambie el tamaño de la ventana - window.addEventListener('resize', function () { - adjustStepperLocation(); - }); - */ + this.clientePresupuestoWizard = document.querySelector('#wizard-presupuesto-cliente'); this.validationStepper = new Stepper(this.clientePresupuestoWizard, {