From 75df199c5d5ab956022c3fdf3db2ebb69b96691e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Mon, 20 May 2024 16:18:54 +0200 Subject: [PATCH] trabajando en edit --- .../Presupuestos/Presupuestocliente.php | 66 +- .../cliente/_disenioLibroItems.php | 8 + .../form/presupuestos/cliente/disenioLibro.js | 47 +- xdebug.log | 8522 +++++++++++++++++ 4 files changed, 8623 insertions(+), 20 deletions(-) diff --git a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php index 7346983f..cd2e6e7e 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php @@ -164,6 +164,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $datosPresupuesto->clienteList = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null); + $this->obtenerTiradas($presupuestoEntity); + $this->obtenerDatosPapel($presupuestoEntity); + $this->viewData['formAction'] = route_to('updateCosidotapablanda', $id); $this->viewData['paisList'] = $this->getPaisListItems(); @@ -1369,8 +1372,10 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController if ($linea['tipo_maquina'] == 'inkjet') { $totalImpresion += $linea['precio_tinta']; - $totalImpresion += $linea['total_corte']; - $sumForFactor += $linea['total_corte']; + if(array_key_exists('total_corte', $linea)){ + $totalImpresion += $linea['total_corte']; + $sumForFactor += $linea['total_corte']; + } } $margenImpresion += $linea['margen_impresion_horas']; $margenImpresion += $linea['margen_click_pedido']; @@ -1521,13 +1526,13 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $color = 'negro'; $model = model('App\Models\Presupuestos\PresupuestoLineaModel'); - $data = $model->where('presupuestoId', $presupuestoId)->findAll();; + $data = $model->where('presupuesto_id', $presupuestoId)->findAll();; foreach($data as $linea){ if (strpos($linea->tipo, "hq") !== false) { // $linea->tipo contains the substring "hq" $calidad='premium'; } - if (strpos($linea->tipo, "hq") !== false) { // $linea->tipo contains the substring "hq" + if (strpos($linea->tipo, "color") !== false) { // $linea->tipo contains the substring "color" $color='color'; } } @@ -1544,5 +1549,58 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $tapa = 'dura'; return $tapa; + + } + + protected function obtenerTiradas($presupuestoEntity){ + + $tiradas_alternativas = json_decode($presupuestoEntity->tirada_alternativa_json_data, true); + $tiradas = array(); + array_push($tiradas, $presupuestoEntity->tirada); + if(!is_null($tiradas_alternativas)){ + if(count($tiradas_alternativas) > 0){ + foreach($tiradas_alternativas as $tirada){ + array_push($tiradas, intval($tirada['tirada'])); + } + } + } + sort($tiradas); + $presupuestoEntity->selected_tirada = $presupuestoEntity->tirada; + for($i=0; $i$key = $tiradas[$i]; + } + } + + protected function obtenerDatosPapel($presupuestoEntity){ + + $id = $presupuestoEntity->id; + + $model = model('App\Models\Presupuestos\PresupuestoLineaModel'); + $data = $model->where('presupuesto_id', $id)->findAll(); + if(count($data)>0){ + foreach($data as $linea){ + // Se coje el primer papel que se encuentre para el interior + // para presupuestos del cliente sólo se escoje un papel para el interior + if (strpos($linea->tipo, "bn") !== false || strpos($linea->tipo, "color") !== false) { + $presupuestoEntity->papel_interior = $linea->papel_id; + $presupuestoEntity->gramaje_interior = $linea->gramaje; + } + // Si es cubierta + else if (strpos($linea->tipo, "cubierta") !== false && strpos($linea->tipo, "sobrecubierta") === false) { + $presupuestoEntity->papel_cubierta = $linea->papel_id; + $presupuestoEntity->gramaje_cubierta = $linea->gramaje; + } + // Si es sobrecubierta + else if (strpos($linea->tipo, "sobrecubierta") !== false) { + $presupuestoEntity->papel_sobrecubierta = $linea->papel_id; + $presupuestoEntity->gramaje_sobrecubierta = $linea->gramaje; + } + // Si es guardas + else if (strpos($linea->tipo, "guardas") !== false) { + $presupuestoEntity->papel_guardas = $linea->papel_id;; + } + } + } } } diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/_disenioLibroItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/_disenioLibroItems.php index 3cd9e9a9..ede345b1 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/_disenioLibroItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/_disenioLibroItems.php @@ -576,6 +576,14 @@ section("additionalInlineJs") ?> +window.datosDisenioLibro = { + papel_interior: papel_interior ? $presupuestoEntity->papel_interior : 'null'; ?>, + gramaje_interior: gramaje_interior ? $presupuestoEntity->gramaje_interior : 'null'; ?>, + papel_cubierta: papel_cubierta ? $presupuestoEntity->papel_cubierta : 'null'; ?>, + gramaje_cubierta: gramaje_cubierta ? $presupuestoEntity->gramaje_cubierta : 'null'; ?>, + papel_sobrecubierta: papel_sobrecubierta ? $presupuestoEntity->papel_sobrecubierta : 'null'; ?>, + gramaje_sobrecubierta: gramaje_sobrecubierta ? $presupuestoEntity->gramaje_sobrecubierta : 'null'; ?>, +} window.routes_disenio_libro = { obtenerGramaje: "", presupuestoCliente: "", diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/disenioLibro.js b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/disenioLibro.js index 61555080..eab9b4fd 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/disenioLibro.js +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/disenioLibro.js @@ -153,7 +153,20 @@ function initDisenioLibro() { $('.change-tipo-impresion').trigger('change'); $('#papelInterior').trigger('change'); + $('#papelInterior').val(window.datosDisenioLibro.papel_interior); + $('#gramajeInterior').append($('