diff --git a/ci4/app/Controllers/Configuracion/Papelesgenericos.php b/ci4/app/Controllers/Configuracion/Papelesgenericos.php index 7196d9ba..43ef6206 100755 --- a/ci4/app/Controllers/Configuracion/Papelesgenericos.php +++ b/ci4/app/Controllers/Configuracion/Papelesgenericos.php @@ -72,9 +72,9 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController - - if ($this->request->getPost()) : + + if ($this->request->getPost()): $nullIfEmpty = true; // !(phpversion() >= '8.1'); @@ -84,36 +84,36 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController $noException = true; - if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) : - if ($this->canValidate()) : + if ($this->canValidate()): try { $successfulResult = $this->model->skipValidation(true)->save($sanitizedData); } catch (\Exception $e) { $noException = false; $this->dealWithException($e); } - else : + else: $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]); $this->session->setFlashdata('formErrors', $this->model->errors()); endif; $thenRedirect = true; // Change this to false if you want your user to stay on the form after submission endif; - if ($noException && $successfulResult) : + if ($noException && $successfulResult): $id = $this->model->db->insertID(); $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; - if ($thenRedirect) : - if (!empty($this->indexRoute)) : + if ($thenRedirect): + if (!empty($this->indexRoute)): return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); - else : + else: return $this->redirect2listView('sweet-success', $message); endif; - else : + else: $this->session->setFlashData('sweet-success', $message); endif; @@ -133,20 +133,20 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController public function edit($requestedId = null) { - if ($requestedId == null) : + if ($requestedId == null): return $this->redirect2listView(); endif; $id = filter_var($requestedId, FILTER_SANITIZE_URL); $papelGenerico = $this->model->find($id); - if ($papelGenerico == false) : + if ($papelGenerico == false): $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('PapelGenerico.papelGenerico')), $id]); return $this->redirect2listView('sweet-error', $message); endif; - - if ($this->request->getPost()) : + + if ($this->request->getPost()): $nullIfEmpty = true; // !(phpversion() >= '8.1'); @@ -159,24 +159,24 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController if ($this->request->getPost('show_in_client_special') == null) { $sanitizedData['show_in_client_special'] = false; } - - if($sanitizedData['show_in_client_special']){ + + if ($sanitizedData['show_in_client_special']) { $sanitizedData['show_in_client'] = true; } $noException = true; - if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) : - if ($this->canValidate()) : + if ($this->canValidate()): try { $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); } catch (\Exception $e) { $noException = false; $this->dealWithException($e); } - else : + else: $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('PapelGenerico.papelGenerico'))]); $this->session->setFlashdata('formErrors', $this->model->errors()); @@ -186,17 +186,17 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController $thenRedirect = false; endif; - if ($noException && $successfulResult) : + if ($noException && $successfulResult): $id = $papelGenerico->id ?? $id; - $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]).'.'; + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; - if ($thenRedirect) : - if (!empty($this->indexRoute)) : + if ($thenRedirect): + if (!empty($this->indexRoute)): return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); - else : + else: return $this->redirect2listView('sweet-success', $message); endif; - else : + else: $this->session->setFlashData('sweet-success', $message); endif; @@ -210,7 +210,7 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('PapelGenerico.moduleTitle') . ' ' . lang('Basic.global.edit3'); $this->viewData['usingServerSideDataTable'] = true; - + return $this->displayForm(__METHOD__, $id); } // end function edit(...) @@ -297,15 +297,14 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController public function getPapelCliente() { if ($this->request->isAJAX()) { - + $tirada = goSanitize($this->request->getGet('tirada'))[0] ?? null; $POD = null; - if($tirada != null){ + if ($tirada != null) { $POD_value = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value; - if(intval($tirada) <= intval($POD_value)){ + if (intval($tirada) <= intval($POD_value)) { $POD = true; - } - else{ + } else { $POD = false; } } @@ -313,17 +312,38 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController $selected_papel = goSanitize($this->request->getGet('papel'))[0] ?? null; $cubierta = goSanitize($this->request->getGet('cubierta'))[0] ?? 0; $tapa_dura = goSanitize($this->request->getGet('tapa_dura'))[0] ?? null; - + $sobrecubierta = goSanitize($this->request->getGet('sobrecubierta'))[0] ?? 0; + $ancho = floatval($this->request->getGet('ancho') ?? 0); $alto = floatval($this->request->getGet('alto') ?? 0); $solapas = floatval($this->request->getGet('solapas') ?? 0); $lomo = floatval($this->request->getGet('lomo') ?? 0); - $anchoLibro = 2* $ancho + 2 * $solapas + $lomo; - - $menu = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, $tapa_dura, false, $POD, $anchoLibro, $alto, $tirada); - $menu2 = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, $tapa_dura, true, $POD, $anchoLibro, $alto, $tirada); - + $forSelect2 = intval($this->request->getGet('forSelect2') ?? 0); + + $anchoLibro = 2 * $ancho + 2 * $solapas + $lomo; + + $menu = $this->model->getPapelCliente($tipo, $cubierta, $sobrecubierta, $selected_papel, $tapa_dura, false, $POD, $anchoLibro, $alto, $tirada); + $menu2 = $this->model->getPapelCliente($tipo, $cubierta, $sobrecubierta, $selected_papel, $tapa_dura, true, $POD, $anchoLibro, $alto, $tirada); + + if ($forSelect2) { + $menu = array_map(function ($item) { + if (isset($item->id)) { + return [ + 'id' => $item->id, + 'name' => $item->nombre + ]; + } else { + return [ + 'id' => $item->gramaje, + 'name' => $item->gramaje + ]; + } + }, $menu); + + return $this->respond($menu); + } + $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); $data = [ @@ -340,23 +360,23 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController public function selectPapelEspecial() { - + if ($this->request->isAJAX()) { - + $tirada = goSanitize($this->request->getGet('tirada'))[0] ?? null; $POD = null; - if($tirada != null){ + if ($tirada != null) { $POD_value = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value; - if(intval($tirada) <= intval($POD_value)){ + if (intval($tirada) <= intval($POD_value)) { $POD = true; - } - else{ + } else { $POD = false; } } $tipo = goSanitize($this->request->getGet('tipo'))[0]; $cubierta = goSanitize($this->request->getGet('cubierta'))[0] ?? 0; - + $sobrecubierta = goSanitize($this->request->getGet('sobrecubierta'))[0] ?? 0; + $ancho = floatval($this->request->getGet('ancho') ?? 0); $alto = floatval($this->request->getGet('alto') ?? 0); $solapas = floatval($this->request->getGet('solapas') ?? 0); @@ -364,9 +384,9 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController $tapa_dura = $this->request->getGet('tapa_dura') ?? 0; - $anchoLibro = 2* $ancho + 2 * $solapas + $lomo; + $anchoLibro = 2 * $ancho + 2 * $solapas + $lomo; - $items = $this->model->getPapelCliente($tipo, $cubierta, null, $tapa_dura, true, $POD, $anchoLibro, $alto, $tirada); + $items = $this->model->getPapelCliente($tipo, $cubierta, $sobrecubierta, null, $tapa_dura, true, $POD, $anchoLibro, $alto, $tirada); $items = array_map(function ($item) { return [ 'id' => $item->id, diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index cc5f99b8..72bbadad 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -125,6 +125,7 @@ return [ 'faja' => 'Faja', 'altoFaja' => 'Alto faja', 'papelFaja' => 'Papel faja', + 'gramajeFaja' => 'Gramaje faja', 'tamanioSolapasFaja' => 'Tamaño solapas faja', 'plastificadoFaja' => 'Plastificado faja', 'estucadoMate170gr' => 'Estucado mate 170 gr', @@ -263,7 +264,7 @@ return [ 'formatoLibro' => "Formato libro", 'selectCliente' => "Seleccione cliente", 'selectPapel' => "Seleccione papel", - + 'selectGramaje' => "Seleccione gramaje", // Preview 'preview' => 'Previsualización de configuraciones', @@ -370,6 +371,7 @@ return [ 'opcion_solapas' => 'Seleccione la opción para las solapas', 'paginas_multiplo_4' => 'El número de páginas para cosido o grapado debe ser múltiplo de 4', 'paginas_pares' => 'El número de páginas debe ser par', + 'extras_cubierta' => 'Rellene todos los campos', ], 'errores' => [ diff --git a/ci4/app/Models/Configuracion/PapelGenericoModel.php b/ci4/app/Models/Configuracion/PapelGenericoModel.php index 41aa10d7..619ae1ac 100755 --- a/ci4/app/Models/Configuracion/PapelGenericoModel.php +++ b/ci4/app/Models/Configuracion/PapelGenericoModel.php @@ -129,16 +129,16 @@ class PapelGenericoModel extends \App\Models\BaseModel return empty($search) ? $builder : $builder - ->groupStart() - ->like("t1.id", $search) - ->orLike("t1.nombre", $search) - ->orLike("t1.code", $search) - ->orLike("t1.code_ot", $search) - ->orLike("t1.id", $search) - ->orLike("t1.nombre", $search) - ->orLike("t1.code", $search) - ->orLike("t1.code_ot", $search) - ->groupEnd(); + ->groupStart() + ->like("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.code", $search) + ->orLike("t1.code_ot", $search) + ->orLike("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.code", $search) + ->orLike("t1.code_ot", $search) + ->groupEnd(); } @@ -413,6 +413,7 @@ class PapelGenericoModel extends \App\Models\BaseModel public function getPapelCliente( $tipo, $is_cubierta = false, + $is_sobrecubierta = false, $selected_papel_id = null, $tapa_dura = null, $papel_especial = false, @@ -517,6 +518,9 @@ class PapelGenericoModel extends \App\Models\BaseModel if ($tapa_dura == true) { $builder->where("t2.use_for_tapa_dura", 1); } + } else if ($is_sobrecubierta == true) { + $builder->where("t2.sobrecubierta", 1); + $builder->where("t5.uso", 'sobrecubierta'); } else { $builder->where("t2.interior", 1); $builder->where("t5.uso", 'interior'); diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta.php index 34e3a455..6f035b2f 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta.php @@ -172,8 +172,9 @@
- +
@@ -187,58 +188,54 @@

Extras

-
- - - -
-
- - -
+
+ +
+
+ +
+
-
- - -
+
+ + +
-
- - -
- Entre 60 y 120 mm -
+
+ + +
+ Entre 60 y 120 mm
+
-
- - -
+
+ + +
-
+
-
+
@@ -246,26 +243,35 @@
+
+
+ + +
+
+ + +
+
+ +
+ class="calcular-presupuesto form-control text-center num-input" min="50" step="1" value="60">
- Mayor 60 mm + Entre 50 mm y 120 mm
-
- - -
`; diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js index b541b546..18fa2655 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js @@ -1509,6 +1509,9 @@ class Comparador { let datosComp = {}; datosComp.sobrecubierta = this.getDataForComp('faja'); + if(datosComp.sobrecubierta.error){ + return; + } datosComp.sobrecubierta.data['faja'] = 1; // se indica que es faja para el calculo de formas datosComp.sobrecubierta.data[this.csrf_token] = this.csrf_hash; diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js index dab67dc1..c2a3da63 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js @@ -98,6 +98,7 @@ class DatosLibro { this.anchoSolapasCubierta.on('change', this.changeAnchoSolapasCubierta.bind(this)); this.anchoSolapasSobrecubierta.on('change', this.changeAnchoSolapasSobrecubierta.bind(this)); + this.fajaSolapasAncho.on('change', this.changeAnchoSolapasFaja.bind(this)); this.paginas.on('change', this.changePaginas.bind(this)); this.tirada.on('change', this.changeTirada.bind(this)); @@ -116,10 +117,13 @@ class DatosLibro { if (this.faja.prop('checked')) { this.div_faja.removeClass('d-none'); $('#compFaja').val(1).trigger('change'); + $(document).trigger('add-servicio-lineas', 'solapas_faja'); } else { this.div_faja.addClass('d-none'); $('#compFaja').val(0).trigger('change'); + $(document).trigger('remove-servicio-lineas', 'solapas_faja'); + $(document).trigger('remove-servicio-lineas', 'solapas_grandes_faja'); } } @@ -300,7 +304,7 @@ class DatosLibro { changeAnchoSolapasSobrecubierta() { - if (this.checkSolapasGrandes('cubierta')) { + if (this.checkSolapasGrandes('sobrecubierta')) { $(document).trigger('add-servicio-lineas', 'solapas_grandes_sobrecubierta'); } else { @@ -311,18 +315,38 @@ class DatosLibro { $('#compSobrecubierta').trigger('change'); } + + changeAnchoSolapasFaja() { + + if (this.checkSolapasGrandes('faja')) { + $(document).trigger('add-servicio-lineas', 'solapas_grandes_faja'); + } + else { + $(document).trigger('remove-servicio-lineas', 'solapas_grandes_faja'); + } + + // para que se actualice el comparador + if($('#compGramajeFaja').select2('data').length > 0){ + $('#compGramajeFaja').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()); + 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()); + ancho_solapas = 2 * parseFloat($('#solapas_ancho_sobrecubierta').val()); + lomo = parseFloat($('#lomo_sobrecubierta').val()); + } + else if (elemento == 'faja') { + ancho_solapas = 2 * parseFloat($('#faja_solapas_ancho').val()); + lomo = parseFloat($('#lomo_sobrecubierta').val()); } else return false; diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/servicios.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/servicios.js index c7e25b1b..9eace60b 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/servicios.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/servicios.js @@ -144,6 +144,10 @@ class Servicios { const id = $('#serv_solapas_sobrecubierta').attr('service-id'); this.ServiciosManipulado.getPresupuestoManipulado(id); } + else if (servicio == 'solapas_faja'){ + const id = $('#solapas_faja').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); @@ -152,6 +156,10 @@ class Servicios { const id = $('#solapas_grandes_sobrecubierta').attr('service-id'); this.ServiciosManipulado.getPresupuestoManipulado(id); } + else if (servicio == 'solapas_grandes_faja'){ + const id = $('#solapas_grandes_faja').attr('service-id'); + this.ServiciosManipulado.getPresupuestoManipulado(id); + } } removeServicio(event, servicio) { diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js index 7f4e6f5e..7ca45554 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js @@ -92,6 +92,7 @@ class DatosGenerales { // Eventos this.checkFormatoPersonalizado.bind('change', this.#handleFormatoLibro.bind(this)); + this.formatoLibro.item.on('change', this.#handleFormatoLibro.bind(this)); this.tiposLibro.on('click', this.#handleTipolibro.bind(this)); this.domItem.find('.input-paginas').on('change', this.#handlePaginas.bind(this)); this.anchoPersonalizado.on('blur', this.#handleCheckFormatoPersonalizado.bind(this)); @@ -674,6 +675,8 @@ class DatosGenerales { this.formValidation.revalidateField('papel_formato_ancho'); this.formValidation.revalidateField('papel_formato_alto'); } + const alto = this.getDimensionLibro().alto; + $('#altoFaja').closest('.config-faja').find('.form-text').text('Entre 50 y ' + alto + ' mm'); } #checkValue(event){ diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js index 95b391de..9762ba31 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js @@ -33,12 +33,12 @@ class DisenioCubierta { [this.csrf_token]: this.csrf_hash, tipo: 'colorhq', cubierta: 1, - ancho: () => {return this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho}, - alto: () => {return this.presupuestoCliente.datosGenerales.getDimensionLibro().alto}, - solapas: () => {return $('#solapas_cubierta').hasClass("d-none") ? 0 : $('#solapas_cubierta').val()}, - lomo: () => {return $('#lc').val()}, - tapa_dura: () => {return this.tapaBlanda.hasClass("selected") ? 0 : 1}, - tirada: () => {return this.presupuestoCliente.datosGenerales.getTiradas()[0]}, + ancho: () => { return this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho }, + alto: () => { return this.presupuestoCliente.datosGenerales.getDimensionLibro().alto }, + solapas: () => { return $('#solapas_cubierta').hasClass("d-none") ? 0 : $('#solapas_cubierta').val() }, + lomo: () => { return $('#lc').val() }, + tapa_dura: () => { return this.tapaBlanda.hasClass("selected") ? 0 : 1 }, + tirada: () => { return this.presupuestoCliente.datosGenerales.getTiradas()[0] }, } ); @@ -77,11 +77,46 @@ class DisenioCubierta { this.configuracionFaja = this.domItem.find(".config-faja"); this.faja = this.domItem.find("#addFaja"); + this.papelFaja = new ClassSelect($("#papelFaja"), + '/papelesgenericos/getpapelcliente', + window.translations["selectPapel"], + false, + { + [this.csrf_token]: this.csrf_hash, + tipo: 'colorhq', + sobrecubierta: 1, + ancho: () => { return this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho }, + alto: () => { return $('#altoFaja').val() }, + solapas: () => { return $('#solapasFaja').val() }, + lomo: () => { return parseFloat($('#lsc').val()) + parseFloat($('#lc').val()) }, + tirada: () => { return this.presupuestoCliente.datosGenerales.getTiradas()[0] }, + forSelect2: 1, + } + ); + this.gramajeFaja = new ClassSelect($("#gramajeFaja"), + '/papelesgenericos/getpapelcliente', + window.translations["selectGramaje"], + false, + { + [this.csrf_token]: this.csrf_hash, + tipo: 'colorhq', + papel: () => { return this.papelFaja.getVal() }, + sobrecubierta: 1, + ancho: () => { return this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho }, + alto: () => { return $('#altoFaja').val() }, + solapas: () => { return $('#solapasFaja').val() }, + lomo: () => { return parseFloat($('#lsc').val()) + parseFloat($('#lc').val()) }, + tirada: () => { return this.presupuestoCliente.datosGenerales.getTiradas()[0] }, + forSelect2: 1, + } + ); this.solapasSobrecubierta = this.domItem.find("#solapasSobrecubierta"); this.textoSolapasSobrecubierta = this.domItem.find("#textoLimitesSolapasSobrecubierta"); + this.solapasFaja = this.domItem.find("#solapasFaja"); this.altoFaja = this.domItem.find("#altoFaja"); + this.textoSolapasFaja = this.domItem.find("#textoLimitesSolapasFaja"); this.fresado = $(this.domItem.find("#fresado")[0]); this.cosido = $(this.domItem.find("#cosido")[0]); @@ -154,6 +189,9 @@ class DisenioCubierta { this.acabadoCubierta.init(); this.acabadoSobrecubierta.init(); + this.papelFaja.init(); + this.gramajeFaja.init(); + $('#papelEspecialCubiertaSel').on("change", this.#handlePapelCubiertaEspecial.bind(this)); // Eventos @@ -171,10 +209,12 @@ class DisenioCubierta { } ); this.faja.on('change', () => { - this.faja.is(":checked") ? this.configuracionFaja.removeClass("d-none") : this.configuracionFaja.addClass("d-none") - } - ); + this.faja.is(":checked") ? this.configuracionFaja.removeClass("d-none") : this.configuracionFaja.addClass("d-none"); + const div = $('#divExtras'); // Selecciona el div + div.find('.fv-plugins-message-container').remove(); + }); + this.papelFaja.item.on('change', () => { this.gramajeFaja.empty(); }); // Observadores this.observer.observe(this.tapaBlanda[0], { attributes: true }); @@ -371,6 +411,34 @@ class DisenioCubierta { } } }, + div_extras: { + validators: { + callback: { + callback: function (input) { + + const div = $('#divExtras'); // Selecciona el div + div.find('.fv-plugins-message-container').remove(); + + const papelFaja = $('#papelFaja').select2('data').length > 0; + const gramajeFaja = $('#gramajeFaja').select2('data').length > 0; + if (papelFaja && gramajeFaja) { + return true; + + } + else { + div.append(` +
+
+ ${window.translations["validation"].extras_cubierta} +
+
+ `); + return false; + } + }, + } + } + }, }, plugins: { trigger: new FormValidation.plugins.Trigger(), @@ -388,6 +456,8 @@ class DisenioCubierta { case 'div_gramaje_cubierta': case 'div_papel_especial_cubierta': return '.col-sm-10'; + case 'div_extras': + return '.col-sm-12'; default: return '.col-sm-3'; } @@ -643,9 +713,8 @@ class DisenioCubierta { else { let faja = {}; faja.alto = this.domItem.find("#altoFaja").val(); - let papel = this.domItem.find("#papelFaja").children("option:selected").val(); - faja.papel = papel.split('_')[0]; - faja.gramaje = papel.split('_')[1]; + faja.papel = this.papelFaja.getVal(); + faja.gramaje = this.gramajeFaja.getVal(); faja.solapas = this.domItem.find("#solapasFaja").val(); faja.plastificado = this.domItem.find("#plastificadoFaja").children("option:selected").val(); return faja; diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js index 2623ce40..9eee7877 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js @@ -178,6 +178,7 @@ class PresupuestoCliente { this.disenioCubierta.solapasSobrecubierta.attr('max', response); this.disenioCubierta.textoSolapasCubierta.text("Entre 60 y " + response + " mm"); this.disenioCubierta.textoSolapasSobrecubierta.text("Entre 60 y " + response + " mm"); + this.disenioCubierta.textoSolapasFaja.text("Entre 60 y " + response + " mm"); }, () => { } ).post();