diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php index 7265f9a0..0bed7c99 100644 --- a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php @@ -328,12 +328,17 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $this->viewData['POD'] = $this->getPOD(); $this->viewData['serviciosAutomaticos'] = [ + 'solapas_cubierta' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('servicio_solapas_cubierta')->value, + 'solapas_sobrecubierta' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('servicio_solapas_sobrecubierta')->value, + 'solapas_faja' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('servicio_solapas_faja')->value, 'retractilado' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_retractilado')->value, 'retractilado5' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_retractilado5')->value, 'ferro' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_ferro')->value, 'prototipo' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_prototipo')->value, 'plegado_guardas' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_guardas')->value, - 'solapas_grandes' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas')->value, + 'solapas_grandes_cubierta' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_cubierta')->value, + 'solapas_grandes_sobrecubierta' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_sobrecubierta')->value, + 'solapas_grandes_faja' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_faja')->value, ]; $this->viewData['tipo_impresion_id'] = $presupuestoEntity->tipo_impresion_id; // Cosido tapa blanda JJO @@ -1574,6 +1579,11 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController { $lineas = (new PresupuestoLineaModel())->getLineasPresupuesto($presupuestoEntity->id); + $modelPapel = new PapelGenericoModel(); + foreach ($lineas as $linea) { + $linea->papel_generico = (new PapelGenericoModel())->find($linea->papel_id)->nombre; + } + $input_data = []; $input_data['presupuesto'] = $presupuestoEntity; diff --git a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php index 66be309a..9e7ffe24 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php @@ -758,7 +758,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $anchoTotal += $interior[1]['mano']; } else { if (count($interior) > 0) - $anchoTotal += $interior['mano']; + $anchoTotal += $interior[0]['mano']; } @@ -1300,20 +1300,69 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController foreach ($resultado_presupuesto['values']['serviciosDefecto']['manipulado'] as $servicio) { $this->guardarServicio($id, $servicio, 'manipulado'); } + $servicio_ferro = (object) [ + 'nombre' => 'ferro', + 'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_ferro')->value + ]; + $servicio_prototipo = (object) [ + 'nombre' => 'prototipo', + 'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_prototipo')->value + ]; + $servicio_retractilado = (object) [ + 'nombre' => 'retractilado', + 'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_retractilado')->value + ]; + $servicio_retractilado5 = (object) [ + 'nombre' => 'retractilado5', + 'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_retractilado5')->value + ]; + $servicio_plegado_guardas = (object) [ + 'nombre' => 'plegado_guardas', + 'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_guardas')->value + ]; + $servicio_solapas_cubierta = (object) [ + 'nombre' => 'solapas_cubierta', + 'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('servicio_solapas_cubierta')->value + ]; + $servicio_solapas_sobrecubierta = (object) [ + 'nombre' => 'solapas_sobrecubierta', + 'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('servicio_solapas_sobrecubierta')->value + ]; + $servicio_solapas_faja = (object) [ + 'nombre' => 'solapas_faja', + 'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('servicio_solapas_faja')->value + ]; + $servicio_solapas_grandes_cubierta = (object) [ + 'nombre' => 'solapas_grandes_cubierta', + 'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_cubierta')->value + ]; + $servicio_solapas_grandes_sobrecubierta = (object) [ + 'nombre' => 'solapas_grandes_sobrecubierta', + 'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_sobrecubierta')->value + ]; + $servicio_solapas_grandes_faja = (object) [ + 'nombre' => 'solapas_grandes_faja', + 'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_faja')->value + ]; + foreach ($resultado_presupuesto['values']['servicios_automaticos'] as $servicio) { - if ($servicio->tarifa_id == 3 || $servicio->tarifa_id == 5 || $servicio->tarifa_id == 16) { + if ($servicio->tarifa_id == $servicio_retractilado->id || $servicio->tarifa_id == $servicio_retractilado5->id) { // Servicios acabado $this->guardarServicio($id, $servicio, 'acabado'); - } else if ($servicio->tarifa_id == 24) { - // Servicios preimpresion - $this->guardarServicio($id, $servicio, 'preimpresion'); - } else if ($servicio->tarifa_id == 9) { + } else if ($servicio->tarifa_id == $servicio_ferro->id || $servicio->tarifa_id == $servicio_prototipo->id) { // Servicios extra $this->guardarServicio($id, $servicio, 'extra'); - } else if ($servicio->tarifa_id == 62) { + } else if ($servicio->tarifa_id == $servicio_plegado_guardas->id) { // Servicios manipulado $this->guardarServicio($id, $servicio, 'manipulado'); - } else if ($servicio->tarifa_id == 73) { + } else if ( + $servicio->tarifa_id == $servicio_solapas_cubierta->id || + $servicio->tarifa_id == $servicio_solapas_sobrecubierta->id || + $servicio->tarifa_id == $servicio_solapas_faja->id || + $servicio->tarifa_id == $servicio_solapas_grandes_cubierta->id || + $servicio->tarifa_id == $servicio_solapas_grandes_sobrecubierta->id || + $servicio->tarifa_id == $servicio_solapas_grandes_faja->id + ) { // Servicios manipulado $this->guardarServicio($id, $servicio, 'manipulado'); } @@ -2287,12 +2336,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController } // Servicios - - - $serviciosAutomaticos = []; $servicios = []; - + $servicio_ferro = (object) [ 'nombre' => 'ferro', 'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_ferro')->value @@ -2313,9 +2359,29 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController 'nombre' => 'plegado_guardas', 'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_guardas')->value ]; - $servicio_solapas_grandes = (object) [ - 'nombre' => 'solapas_grandes', - 'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas')->value + $servicio_solapas_cubierta = (object) [ + 'nombre' => 'solapas_cubierta', + 'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('servicio_solapas_cubierta')->value + ]; + $servicio_solapas_sobrecubierta = (object) [ + 'nombre' => 'solapas_sobrecubierta', + 'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('servicio_solapas_sobrecubierta')->value + ]; + $servicio_solapas_faja = (object) [ + 'nombre' => 'solapas_faja', + 'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('servicio_solapas_faja')->value + ]; + $servicio_solapas_grandes_cubierta = (object) [ + 'nombre' => 'solapas_grandes_cubierta', + 'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_cubierta')->value + ]; + $servicio_solapas_grandes_sobrecubierta = (object) [ + 'nombre' => 'solapas_grandes_sobrecubierta', + 'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_sobrecubierta')->value + ]; + $servicio_solapas_grandes_faja = (object) [ + 'nombre' => 'solapas_grandes_faja', + 'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_faja')->value ]; // se comprueba si $datos guardas es un array @@ -2337,8 +2403,15 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController array_push($servicios, $servicio_prototipo); if ($datos_entrada['servicios']['ferro']) // extra array_push($servicios, $servicio_ferro); - /*if ($datos_entrada['servicios']['ferroDigital']) - array_push($servicios, 29);*/ // Es gratis + if ($input_data['datosPedido']->solapas_ancho > 0) + array_push($servicios, $servicio_solapas_cubierta); + if (!is_null($sobreCubierta) && $sobreCubierta) // Si hay sobrecubierta, siempre con solapas + array_push($servicios, $servicio_solapas_sobrecubierta); + /* TO-DO + if (!is_null($faja) && $faja) // Si hay faja, siempre con solapas + array_push($servicios, $servicio_solapas_faja); + */ + foreach ($servicios as $servicio) { if ($servicio->nombre == "retractilado" || $servicio->nombre == "retractilado5") { @@ -2377,7 +2450,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $resultado = PresupuestoCLienteService::getServiciosExtra([ 'tarifa_id' => intval($servicio->id), ]); - array_push($serviciosAutomaticos, $resultado[0]); + if ($resultado[0]->precio <= 0) { $errorModel = new ErrorPresupuesto(); @@ -2395,6 +2468,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController return $return_data; } + array_push($serviciosAutomaticos, $resultado[0]); $coste_servicios += floatval($resultado[0]->precio); if ($extra_info) { @@ -2402,21 +2476,49 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $margenServicios += floatval($resultado[0]->precio) * floatval($resultado[0]->margen) / 100.0; } } + else if ($servicio->nombre == 'solapas_cubierta' || $servicio->nombre == 'solapas_sobrecubierta' || $servicio->nombre == 'solapas_faja'){ + // Servicios manipulado + $resultado = PresupuestoCLienteService::getServiciosManipulado([ + 'tarifa_id' => intval($servicio->id), + 'tirada' => $datosPedido->tirada, + 'POD' => $POD, + ]); + + if ($resultado[0]->total <= 0) { + + $errorModel = new ErrorPresupuesto(); + $errorModel->insertError( + $datos_entrada['id'], + auth()->user()->id, + 'No se puede obtener servicio de manupulado con ' . ((string) $servicio->nombre), + $input_data + ); + $return_data = [ + 'errors' => (object) ([ + 'status' => 1 + ]), + ]; + return $return_data; + } else { + array_push($serviciosAutomaticos, $resultado[0]); + } + + $coste_servicios += floatval($resultado[0]->total); + if ($extra_info) { + $totalServicios += floatval($resultado[0]->total); + $margenServicios += floatval($resultado[0]->total) * floatval($resultado[0]->margen) / 100.0; + } + } } // Plegado de solapas grandes - if ( - (intval($solapasCubierta) > 0 && intval($cubierta['dimension_desarrollo']['ancho']) > 630) || - (is_array($sobreCubierta) && ($sobreCubierta['solapas'] > 0 && intval($linea_sobrecubierta['dimension_desarrollo']['ancho']) > 630)) - ) { - - // Servicios acabado + if (intval($solapasCubierta) > 0 && intval($cubierta['dimension_desarrollo']['ancho']) > 630) { + // Servicios manipulado $resultado = PresupuestoCLienteService::getServiciosManipulado([ - 'tarifa_id' => intval($servicio_solapas_grandes->id), + 'tarifa_id' => intval($servicio_solapas_grandes_cubierta->id), 'tirada' => $datosPedido->tirada, 'POD' => $POD, ]); - array_push($serviciosAutomaticos, $resultado[0]); if ($resultado[0]->total <= 0) { @@ -2424,7 +2526,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $errorModel->insertError( $datos_entrada['id'], auth()->user()->id, - 'No se puede obtener servicio de manupulado con id ' . ((string) $servicio), + 'No se puede obtener servicio de manupulado con ' . ((string) $servicio->nombre), $input_data ); $return_data = [ @@ -2433,6 +2535,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController ]), ]; return $return_data; + } else { + array_push($serviciosAutomaticos, $resultado[0]); } $coste_servicios += floatval($resultado[0]->total); @@ -2440,9 +2544,45 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $totalServicios += floatval($resultado[0]->total); $margenServicios += floatval($resultado[0]->total) * floatval($resultado[0]->margen) / 100.0; } - } + if (is_array($sobreCubierta) && ($sobreCubierta['solapas'] > 0 && intval($linea_sobrecubierta['dimension_desarrollo']['ancho']) > 630)) { + + // Servicios manipulado + $resultado = PresupuestoCLienteService::getServiciosManipulado([ + 'tarifa_id' => intval($servicio_solapas_grandes_sobrecubierta->id), + 'tirada' => $datosPedido->tirada, + 'POD' => $POD, + ]); + + if ($resultado[0]->total <= 0) { + + $errorModel = new ErrorPresupuesto(); + $errorModel->insertError( + $datos_entrada['id'], + auth()->user()->id, + 'No se puede obtener servicio de manupulado ' . ((string) $servicio->nombre), + $input_data + ); + $return_data = [ + 'errors' => (object) ([ + 'status' => 1 + ]), + ]; + return $return_data; + } else { + array_push($serviciosAutomaticos, $resultado[0]); + } + + $coste_servicios += floatval($resultado[0]->total); + if ($extra_info) { + $totalServicios += floatval($resultado[0]->total); + $margenServicios += floatval($resultado[0]->total) * floatval($resultado[0]->margen) / 100.0; + } + } + + // TO-DO Faja + array_push($precio_u, round(($costeInterior + $coste_cubierta + $coste_sobrecubierta + $costeServiciosDefecto + $coste_servicios) / $tirada[$t], 4)); array_push($peso, round($peso_interior + $peso_cubierta + $peso_sobrecubierta + $peso_guardas, 2)); diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index 3404b63a..2a55273b 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -385,6 +385,7 @@ return [ 'noInterior' => 'No se hay resultados para el interior', 'noCubiertaSobrecubierta' => 'No se hay resultados para cubierta/sobrecubierta', 'errorPresupuesto' => 'Se ha producido un error al calcular el presupuesto. Póngase en contacto con el administrador', + 'error_sobrecubierta_sin_solapas' => 'Debe seleccionar "sobrecubierta" en los datos del libro para introducir el ancho de solapa' ], ]; diff --git a/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php b/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php index 47e6ec82..6a34a602 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php @@ -330,9 +330,8 @@ class PresupuestoLineaModel extends \App\Models\BaseModel $builder = $this->db ->table($this->table . " t1") ->select( - "*, t2.nombre AS papel_generico" + "*" ) - ->join("lg_papel_generico t2", "t1.papel_id = t2.id", "left") ->where("t1.presupuesto_id", $presupuesto_id); return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php index 79f31bcf..c442c76c 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php @@ -116,10 +116,9 @@
+ id="solapas_sobrecubierta" name="solapas_sobrecubierta" tabindex="6" value="1"> + for="solapas_sobrecubierta">
@@ -301,12 +300,27 @@ + > + > + > > - > + service-id=> + > + > diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js index ebbc52ac..c2414539 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js @@ -85,8 +85,8 @@ class PresupuestoAdminEdit { alto: () => this.getDimensionLibro().alto, lomo: () => $('#lomo_cubierta').val() === '' ? parseFloat('0.0') : parseFloat($('#lomo_cubierta').val()), lomoSobrecubierta: () => $('#lomo_sobrecubierta').val() === '' ? parseFloat('0.0') : parseFloat($('#lomo_sobrecubierta').val()), - solapa: () => $('#solapas').prop('checked') ? parseFloat($('#solapas_ancho').val()) : 0, - solapa_sobrecubierta: () => $('#solapas_sobrecubierta').prop('checked') ? parseFloat($('#solapas_ancho_sobrecubierta').val()) : 0, + solapas: () => $('#solapas').prop('checked') ? parseFloat($('#solapas_ancho').val()) : 0, + solapas_sobrecubierta: () => $('#solapas_sobrecubierta').prop('checked') ? parseFloat($('#solapas_ancho_sobrecubierta').val()) : 0, lomoRedondo: () => (this.tipo_impresion == 1 || this.tipo_impresion == 3) ? parseFloat($('#compLomoRedondo').val()) : 0, } ); @@ -113,6 +113,9 @@ class PresupuestoAdminEdit { $(document).on('update-presupuesto', this.updatePresupuesto.bind(this)); this.guardar.on('click', this.guardarPresupuesto.bind(this)); + + $('#lomo_cubierta').on('change', this.datosLibro.changeAnchoSolapasCubierta); + $('#lomo_sobrecubierta').on('change', this.datosLibro.changeAnchoSolapasSobrecubierta); } diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js index c132f929..57db6fdc 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js @@ -244,7 +244,11 @@ class Comparador { this.gramajeSobrecubierta.init(); this.papelSobrecubierta.onChange(() => self.gramajeSobrecubierta.empty()); this.sobrecubierta.on('change', () => { - if (this.sobrecubierta.val() == 1) { + if (this.sobrecubierta.select2('data')[0].id == 1) { + if($('#solapas_sobrecubierta').prop('checked') == false){ + this.sobrecubierta.val(0); + popErrorAlert(window.language.Presupuestos.errores.error_sobrecubierta_sin_solapas, 'divAlarmasComparador') + } $('#solapas_sobrecubierta').prop('checked', true); $('#div_solapas_ancho_sobrecubierta').removeClass('d-none'); $('#solapas_ancho_sobrecubierta').val(60); @@ -316,7 +320,6 @@ class Comparador { if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3 || this.tipo_impresion_id == 5 || this.tipo_impresion_id == 7) { $('.comp_guardas_items').on('change', this.obtenerComparadorGuardas.bind(this)); } - } #changePaginasComparador(element) { diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js index 2eec89a4..a9f56ea5 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js @@ -89,6 +89,9 @@ class DatosLibro { this.solapasSobrecubierta.on('change', this.changeSolapasSobrecubierta.bind(this)); this.tamanioPersonalizado.on('change', this.changeTipoTamanio.bind(this)); + this.anchoSolapasCubierta.on('change', this.changeAnchoSolapasCubierta.bind(this)); + this.anchoSolapasSobrecubierta.on('change', this.changeAnchoSolapasSobrecubierta.bind(this)); + this.paginas.on('change', this.changePaginas.bind(this)); this.tirada.on('change', this.changeTirada.bind(this)); } @@ -211,21 +214,30 @@ class DatosLibro { setTimeout(() => { if (this.solapasCubierta.prop('checked')) { $('#div_solapas_ancho').removeClass('d-none'); - $(document).trigger('add-servicio-lineas', 'solapas'); + $(document).trigger('add-servicio-lineas', 'solapas_cubierta'); } else { $('#div_solapas_ancho').addClass('d-none'); - this.anchoSolapasCubierta.val(60); - $(document).trigger('remove-servicio-lineas', 'solapas'); + $(document).trigger('remove-servicio-lineas', 'solapas_cubierta'); + $(document).trigger('remove-servicio-lineas', 'solapas_grandes_cubierta'); } }, 100); - $(document).trigger('update-presupuesto', { - update_lineas : false, - update_servicios : true, - update_envios: false, - update_resumen: false, - update_tiradas_alternativas: false - }); + + // para que se actualice el comparador + $('paginas').trigger('change'); + } + + changeAnchoSolapasCubierta(){ + + if(this.checkSolapasGrandes('cubierta')){ + $(document).trigger('add-servicio-lineas', 'solapas_grandes_cubierta'); + } + else{ + $(document).trigger('remove-servicio-lineas', 'solapas_grandes_cubierta'); + } + + // para que se actualice el comparador + $('paginas').trigger('change'); } @@ -233,21 +245,53 @@ class DatosLibro { if (this.solapasSobrecubierta.prop('checked')) { this.divSolapasSobrecubierta.removeClass('d-none'); - $(document).trigger('remove-servicio-lineas', 'solapas'); + $(document).trigger('add-servicio-lineas', 'solapas_sobrecubierta'); } else { this.divSolapasSobrecubierta.addClass('d-none'); - this.anchoSolapasSobrecubierta.val(60); - $(document).trigger('add-servicio-lineas', 'solapas'); + $(document).trigger('remove-servicio-lineas', 'solapas_sobrecubierta'); + $(document).trigger('remove-servicio-lineas', 'solapas_grandes_sobrecubierta'); + if ($('#compSobrecubierta').length) { + $('#compSobrecubierta').val(0).trigger('change'); + } } - $(document).trigger('update-presupuesto', { - update_lineas : false, - update_servicios : true, - update_envios: false, - update_resumen: false, - update_tiradas_alternativas: false - }); + } + + changeAnchoSolapasSobrecubierta(){ + + if(this.checkSolapasGrandes('cubierta')){ + $(document).trigger('add-servicio-lineas', 'solapas_grandes_sobrecubierta'); + } + else{ + $(document).trigger('remove-servicio-lineas', 'solapas_grandes_sobrecubierta'); + } + + // para que se actualice el comparador + $('paginas').trigger('change'); + + } + + checkSolapasGrandes(elemento) { + + const ancho_libro = 2 * this.getDimensionLibro().ancho; + let ancho_solapas = 0.0; + let lomo = 0.0; + if(elemento == 'cubierta'){ + ancho_solapas = 2 * parseFloat($('solapas_ancho').val()); + lomo = parseFloat($('lomo_cubierta').val()); + } + else if (elemento == 'sobrecubierta'){ + ancho_solapas = 2 * parseFloat($('solapas_ancho_sobrecubierta').val()); + lomo = parseFloat($('lomo_sobrecubierta').val()); + } + else + return false; + + if (ancho_libro + ancho_solapas + lomo > 630) + return true; + else + return false } changePaginas() { @@ -389,7 +433,7 @@ class DatosLibro { if (datos.solapasCubierta) { this.solapasCubierta.prop('checked', true); this.anchoSolapasCubierta.val(datos.solapasCubiertaAncho); - this.divSolapasSobrecubierta.removeClass('d-none'); + this.divSolapasCubierta.removeClass('d-none'); } else { this.solapasCubierta.prop('checked', false); diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/servicios.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/servicios.js index e4b84818..bdb46ae2 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/servicios.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/servicios.js @@ -110,9 +110,6 @@ class Servicios { else if (servicio == 'acabadoSobrecubierta') { this.serviciosAcabado.updateAcabadosExteriores(0, 1); } - else if (servicio == 'solapas') { - this.ServiciosManipulado.addSolapas(); - } else if (servicio == 'ferro'){ const id = $('#ferro').attr('service-id'); this.serviciosExtra.getPresupuestoExtra(id); @@ -139,56 +136,115 @@ class Servicios { }; this.ServiciosManipulado.getPresupuestoManipulado(id); } + else if (servicio == 'solapas_cubierta'){ + const id = $('#serv_solapas_cubierta').attr('service-id'); + this.ServiciosManipulado.getPresupuestoManipulado(id); + } + else if (servicio == 'solapas_sobrecubierta'){ + const id = $('#serv_solapas_sobrecubierta').attr('service-id'); + this.ServiciosManipulado.getPresupuestoManipulado(id); + } + else if (servicio == 'solapas_grandes_cubierta'){ + const id = $('#solapas_grandes_cubierta').attr('service-id'); + this.ServiciosManipulado.getPresupuestoManipulado(id); + } + else if (servicio == 'solapas_grandes_sobrecubierta'){ + const id = $('#solapas_grandes_sobrecubierta').attr('service-id'); + this.ServiciosManipulado.getPresupuestoManipulado(id); + } } removeServicio(event, servicio) { - if (servicio == 'solapas') { - this.ServiciosManipulado.removeSolapas(); - } - else if (servicio == 'ferro'){ + + if (servicio == 'ferro'){ const id = $('#ferro').attr('service-id'); this.serviciosExtra.table.rows().every(function () { - var data = this.data(); + let data = this.data(); if (data.tarifa_id == id) { - this.remove().draw(); + this.remove(); } }); + this.serviciosExtra.table.draw(); } else if (servicio == 'prototipo'){ const id = $('#prototipo').attr('service-id'); this.serviciosExtra.table.rows().every(function () { var data = this.data(); if (data.tarifa_id == id) { - this.remove().draw(); + this.remove(); } }); + this.serviciosExtra.table.draw(); } else if (servicio == 'retractilado'){ const id = $('#retractilado').attr('service-id'); this.serviciosAcabado.table.rows().every(function () { - var data = this.data(); + let data = this.data(); if (data.tarifa_id == id) { - this.remove().draw(); + this.remove(); } }); + this.serviciosAcabado.table.draw(); } else if (servicio == 'retractilado5'){ const id = $('#retractilado5').attr('service-id'); this.serviciosAcabado.table.rows().every(function () { - var data = this.data(); + let data = this.data(); if (data.tarifa_id == id) { this.remove().draw(); } }); + this.serviciosAcabado.table.draw(); } else if(servicio == 'plegado_guardas'){ const id = $('#plegado_guardas').attr('service-id'); this.ServiciosManipulado.table.rows().every(function () { var data = this.data(); - if (data.tarifa_id == id) { - this.remove().draw(); + if (data && data.tarifa_id == id) { + this.remove(); } }); + this.ServiciosManipulado.table.draw(); + } + else if (servicio == 'solapas_cubierta'){ + const id = $('#serv_solapas_cubierta').attr('service-id'); + this.ServiciosManipulado.table.rows().every(function () { + let data = this.data(); + if (data && parseInt(data.tarifa_id) == id) { + this.remove(); + } + }); + this.ServiciosManipulado.table.draw(); + } + else if (servicio == 'solapas_sobrecubierta'){ + const id = $('#serv_solapas_sobrecubierta').attr('service-id'); + this.ServiciosManipulado.table.rows().every(function () { + let data = this.data(); + if (data && data.tarifa_id == id) { + this.remove(); + } + }); + this.ServiciosManipulado.table.draw(); + } + else if (servicio == 'solapas_grandes_cubierta'){ + const id = $('#solapas_grandes_cubierta').attr('service-id'); + this.ServiciosManipulado.table.rows().every(function () { + let data = this.data(); + if (data && data.tarifa_id == id) { + this.remove(); + } + }); + this.ServiciosManipulado.table.draw(); + } + else if (servicio == 'solapas_grandes_sobrecubierta'){ + const id = $('#solapas_grandes_sobrecubierta').attr('service-id'); + this.ServiciosManipulado.table.rows().every(function () { + var data = this.data(); + if (data && data.tarifa_id == id) { + this.remove(); + } + }); + this.ServiciosManipulado.table.draw(); } } @@ -1318,53 +1374,7 @@ class ServiciosManipulado { showBreadCrumbSaveButton(true); } - addSolapas() { - - const self = this; - new Ajax('/serviciosmanipulados/serviciosolapas', {}, {}, - function (response) { - if (response.service) { - - const tarifa_id = response.service; - var rows = self.table.rows().data().toArray(); - var found = rows.some(row => row.tarifa_id === tarifa_id); - - if (!found) - self.getPresupuestoManipulado(tarifa_id); - - } - }, - function (error) { - console.error(error); - } - ).get(); - } - - removeSolapas() { - - const self = this; - - new Ajax('/serviciosmanipulados/serviciosolapas', {}, {}, - function (response) { - if (response.service) { - - const tarifa_id = response.service; - var rows = self.table.rows().data().toArray(); - for (let i = 0; i < rows.length; i++) { - if (rows[i]['tarifa_id'] == tarifa_id) { - self.table.row(i).remove().draw(); - break; - } - } - - } - }, - function (error) { - console.error(error); - } - ).get(); - } - + updateServicios() { const self = this; @@ -1380,7 +1390,6 @@ class ServiciosManipulado { if (tarifa_ids.length > 0) { const data = { datos: tarifa_ids, - solapas: $('#solapas').is(':checked') ? 1 : 0, tirada: tirada }; new Ajax('/serviciosmanipulados/update/' + id, data, {},