From 5e876f07fbcfbb87df5307672d5f61d9f45ffd22 Mon Sep 17 00:00:00 2001 From: jaimejimenezortega Date: Tue, 18 Jun 2024 17:47:21 +0200 Subject: [PATCH] terminado y arreglado otros bugs --- .../Presupuestos/Presupuestocliente.php | 41 ++++++++++++++----- .../PresupuestoServiciosExtraModel.php | 2 +- .../form/presupuestos/cliente/resumen.js | 12 +++++- .../cliente/viewPresupuestoList.php | 22 ++++++---- .../viewCosidotapablandaList.php | 24 +++++++---- 5 files changed, 73 insertions(+), 28 deletions(-) diff --git a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php index 2a5967fc..dd0b609c 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php @@ -693,6 +693,14 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $unidades_calculo, $direccion['tipo'] == 'cajas' ? 0 : 1 ); + + if (count($coste_envio) > 0) { + $coste = floatval($coste_envio[0]->coste); + $margen = ($coste * floatval($coste_envio[0]->margen)) / 100.0; + $coste -= $margen; + $resultado_presupuesto['info']['totales'][$i]['coste_envio'] += $coste; + $resultado_presupuesto['info']['totales'][$i]['margen_envio'] += $margen; + } } catch(Exception $e){ return $this->respond([ @@ -701,14 +709,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $csrfTokenName => $newTokenHash ]); } - - if (count($coste_envio) > 0) { - $coste = floatval($coste_envio[0]->coste); - $margen = ($coste * floatval($coste_envio[0]->margen)) / 100.0; - $coste -= $margen; - $resultado_presupuesto['info']['totales'][$i]['coste_envio'] += $coste; - $resultado_presupuesto['info']['totales'][$i]['margen_envio'] += $margen; - } } } @@ -782,10 +782,14 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController if ($servicio->tarifa_id == 3 || $servicio->tarifa_id == 5 || $servicio->tarifa_id == 16) { // Servicios acabado $this->guardarServicio($id, $servicio, 'acabado'); - } else if ($servicio->tarifa_id == 24 || $servicio->tarifa_id == 9) { + } else if ($servicio->tarifa_id == 24 ) { + // Servicios preimpresion + $this->guardarServicio($id, $servicio, 'preimpresion'); + } else if ($servicio->tarifa_id == 9) { // Servicios extra $this->guardarServicio($id, $servicio, 'extra'); - } else if ($servicio->tarifa_id == 62) { + } + else if ($servicio->tarifa_id == 62) { // Servicios manipulado $this->guardarServicio($id, $servicio, 'manipulado'); } @@ -1475,7 +1479,22 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $totalServicios += floatval($resultado[0]->total); $margenServicios += floatval($resultado[0]->total) * floatval($resultado[0]->margen) / 100.0; } - } else if (intval($servicio) == 24 || intval($servicio) == 9) { + } else if (intval($servicio) == 24) { + // Servicios preimpresion (Ferro) + $resultado = PresupuestoCLienteService::getServiciosPreimpresion([ + 'tarifa_id' => $servicio, + ]); + array_push($serviciosAutomaticos, $resultado[0]); + if ($resultado[0]->precio <= 0) + $error->servicios = lang('Presupuestos.errores.errorPresupuesto'); + + $coste_servicios += floatval($resultado[0]->precio); + if ($extra_info) { + $totalServicios += floatval($resultado[0]->precio); + $margenServicios += floatval($resultado[0]->precio) * floatval($resultado[0]->margen) / 100.0; + } + } + if(intval($servicio) == 9) { // Servicios preimpresion $resultado = PresupuestoCLienteService::getServiciosExtra([ 'tarifa_id' => $servicio, diff --git a/ci4/app/Models/Presupuestos/PresupuestoServiciosExtraModel.php b/ci4/app/Models/Presupuestos/PresupuestoServiciosExtraModel.php index e161455e..60927b0e 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoServiciosExtraModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoServiciosExtraModel.php @@ -63,7 +63,7 @@ class PresupuestoServiciosExtraModel extends \App\Models\BaseModel else{ $ret_array[] = (object)[ 'tarifa_id'=> $tarifa_extra_id, - 'tarifa_nombre'=> $modelTarifa->getNombreTarifaPreimpresion($tarifa_extra_id)[0]->nombre, + 'tarifa_nombre'=> $modelTarifa->getNombreTarifaExtra($tarifa_extra_id)[0]->nombre, 'precio' => 0, 'margen' => 0, ]; diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/resumen.js b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/resumen.js index 6e66217e..d9350ae2 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/resumen.js +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/resumen.js @@ -178,6 +178,13 @@ $('#btnBack').on('click', function() { }); function finalizarPresupuesto(confirmar){ + + let isColor = false; + if($('#colorColorDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked')) + isColor = true; + let isHq = false; + if($('#colorNegroDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked')) + isHq = true; const paths = window.location.pathname.split("/").filter(path => path !== ""); let id=0; @@ -197,8 +204,8 @@ function finalizarPresupuesto(confirmar){ paginasColor: $('#paginasColor').val(), tipo: $('.custom-option-tipo.checked').attr('id').replace('Div', ''), tapa: $('#tapaDura').is(':checked') ? 'dura' : 'blanda', - isColor: $('#colorNegroDiv').hasClass('checked') ? 0 : 1, - isHq: $('#calidadEstandarDiv').hasClass('checked') ? 0 : 1, + isColor: isColor, + isHq: isHq, papelInterior: $('#papelInterior option:selected').val(), papelInteriorNombre: $('#papelInterior option:selected').text().trim(), gramajeInterior: $('#gramajeInterior option:selected').text(), @@ -283,6 +290,7 @@ function finalizarPresupuesto(confirmar){ if(Object.keys(response).length > 0) { if(response.status > 0){ + if(confirmar || window.location.href.includes("add")) window.location.href = response.url + '/' + response.status; } diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/viewPresupuestoList.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/viewPresupuestoList.php index 860e3746..092af5f2 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/viewPresupuestoList.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/viewPresupuestoList.php @@ -50,13 +50,21 @@ const lastColNr = $('#tableOfPresupuestos').find("tr:first th").length - 1; const actionBtns = function(data) { - return ` - -
- - -
- `; + if(data.estado == 'borrador') + return ` + +
+ + +
+ `; + else + return ` + +
+ +
+ `; }; // Setup - add a text input to each footer cell diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaList.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaList.php index a7203545..ed0e0277 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaList.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaList.php @@ -51,13 +51,23 @@ const lastColNr = $('#tableOfPresupuestos').find("tr:first th").length - 1; const actionBtns = function(data) { - return ` - -
- - -
- `; + if (data.estado == 'aceptado') { + return ` + +
+ +
+ `; + } + else{ + return ` + +
+ + +
+ `; + } }; // Setup - add a text input to each footer cell