From 8009d34955c8701e050bc4b40aa6f230bd14d454 Mon Sep 17 00:00:00 2001 From: jaimejimenezortega Date: Tue, 7 May 2024 17:55:10 +0200 Subject: [PATCH] subir cambios antes de update --- ci4/app/Config/Routes.php | 1 + .../Presupuestos/Presupuestocliente.php | 33 +++++++++++++---- ci4/app/Filters/LoginAuthFilter.php | 1 + .../cliente/_direccionesItems.php | 9 ++++- .../form/presupuestos/cliente/direcciones.js | 34 ++++++++++++++++++ .../cliente/presupuestoCliente.js | 1 + ci4/composer.json | 5 ++- xdebug.log | 36 +++++++++++++++++++ 8 files changed, 109 insertions(+), 11 deletions(-) diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index bcebcd38..4e223770 100755 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -536,6 +536,7 @@ $routes->group('presupuestocliente', ['namespace' => 'App\Controllers\Presupuest $routes->post('datatable', 'Cosidotapablanda::datatable', ['as' => 'tablaPresupuestosCliente']); $routes->post('getgramaje', 'Presupuestocliente::getGramaje', ['as' => 'obtenerGramaje']); $routes->post('presupuesto', 'Presupuestocliente::presupuesto', ['as' => 'presupuestoCliente']); + $routes->post('getDireccionesCliente', 'Presupuestocliente::getDireccionesCliente', ['as' => 'getDirecciones']); }); $routes->resource('presupuestocliente', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Presupuestocliente', 'except' => 'show,new,create,update']); diff --git a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php index 9aed57ee..04f14496 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php @@ -608,11 +608,12 @@ class Presupuestocliente extends \App\Controllers\GoBaseResourceController public function presupuesto() { - - if ($this->request->isAJAX()) { $reqData = $this->request->getPost(); + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $error =(object)[ 'interior' => "", 'cubierta' => "", @@ -931,6 +932,7 @@ class Presupuestocliente extends \App\Controllers\GoBaseResourceController 'guardas' => $guardas, 'serviciosDefecto' => $servDefecto, 'servicios_automaticos' => $serviciosAutomaticos, + $csrfTokenName => $newTokenHash ]; @@ -940,16 +942,33 @@ class Presupuestocliente extends \App\Controllers\GoBaseResourceController } } + public function getDireccionesCliente(){ + if ($this->request->isAJAX()) { + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + + $reqData = $this->request->getPost(); + $cliente_id = $reqData['id'] ?? 0; + $model = model('App\Models\Clientes\ClienteDireccionesModel'); + $data = $model->getMenuDirecciones($cliente_id); + array_unshift($data, ['id' => 0, 'text' => 'Agregar nueva dirección']); + + return $this->respond([ + 'menu'=>$data, + $csrfTokenName => $newTokenHash + ]); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + /*********************** * * Funciones auxiliares * - **********************/ - - - - + **********************/ protected function calcular_lomo($lineas, $lomo_inicial){ $lomo = $lomo_inicial; foreach ($lineas as $linea) { diff --git a/ci4/app/Filters/LoginAuthFilter.php b/ci4/app/Filters/LoginAuthFilter.php index 358d6a72..ba60969f 100644 --- a/ci4/app/Filters/LoginAuthFilter.php +++ b/ci4/app/Filters/LoginAuthFilter.php @@ -189,6 +189,7 @@ class LoginAuthFilter implements FilterInterface 'cast', 'getGramaje', 'presupuesto', + 'getDireccionesCliente' ]; } diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cliente/_direccionesItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cliente/_direccionesItems.php index c416b8d0..e1699794 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cliente/_direccionesItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cliente/_direccionesItems.php @@ -30,4 +30,11 @@ - \ No newline at end of file + + +section("additionalInlineJs") ?> + +window.routes_direcciones = { + direcciones: "", +} +endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cliente/direcciones.js b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cliente/direcciones.js index d3490da5..b3a21b9d 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cliente/direcciones.js +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cliente/direcciones.js @@ -1,3 +1,30 @@ +function initDirecciones() { + data = { + id: $('#clienteId').val() + }, + data = Object.assign(data, window.token_ajax) + + $.ajax({ + url: window.routes_direcciones.direcciones, + type: 'POST', + data: data, + success: function(response) { + $("#direcciones").empty(); + $.each(response.menu, function(key, value) { + $('#direcciones') + .append($('