From 41fde19f435e30aec1f6f633ea918c966116883d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Tue, 24 Jun 2025 17:56:22 +0200 Subject: [PATCH 01/12] modificado disenio interior para que borre los errores --- .../presupuestoCliente/disenioCubierta.js | 9 + .../presupuestoCliente/disenioInterior.js | 159 ++++++++++++------ 2 files changed, 120 insertions(+), 48 deletions(-) diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js index 63da86b8..7dd144f9 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js @@ -286,6 +286,15 @@ class DisenioCubierta { this.papelFaja.init(); this.gramajeFaja.init(); + this.acabadoCubierta.onChange(() => { + if (this.acabadoCubierta.getVal() > 0) { + $('#alert-cubierta-sin-acabado').addClass('d-none'); + } + else { + $('#alert-cubierta-sin-acabado').removeClass('d-none'); + } + }); + $('#papelEspecialCubiertaSel').on("change", this.#handlePapelCubiertaEspecial.bind(this)); // Eventos diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioInterior.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioInterior.js index 5e69213c..1cb00768 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioInterior.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioInterior.js @@ -93,6 +93,8 @@ class DisenioInterior { this.gramajeNegroForResumen = ""; this.papelColorForResumen = ""; this.gramajeColorForResumen = ""; + + this.errores = []; } @@ -377,72 +379,36 @@ class DisenioInterior { validate(goToNext = true) { - let errores = []; - - let continueCheck = true; + this.errores = []; // impresion interior - if ($('.disenio-interior.selected').length > 0) { - $('#divImpresionInterior').removeClass('is-invalid'); - } - else { - errores.push(window.translations["validation"].disenio_interior); - $('#divImpresionInterior').addClass('is-invalid'); - continueCheck = false; - } + let continueCheck = this.validateDisenioInterior(); // papel interior if (continueCheck) { - const papelSeleccionado = $('.custom-selector-papel input[type="radio"]:checked'); - if (papelSeleccionado.length > 0) { - if (!$('#divPapelEspecialInterior').hasClass("d-none")) { - if ($('#papelEspecialInterior').select2('data').length == 0) { - $('#divPapelInterior').addClass('is-invalid'); - errores.push(window.translations["validation"].papel_interior_especial); - continueCheck = false; - } - else { - $('#divPapelInterior').removeClass('is-invalid'); - } - } - else { - $('#divPapelInterior').removeClass('is-invalid'); - } - } else { - $('#divPapelInterior').addClass('is-invalid'); - errores.push(window.translations["validation"].papel_interior); - continueCheck = false; - } + continueCheck = this.validatePapelInterior(); } // gramaje interior if (continueCheck) { - const gramajeSeleccionado = $('.custom-selector-gramaje input[type="radio"]:checked'); - if (gramajeSeleccionado.length > 0) { - $('#divGramajeInterior').removeClass('is-invalid'); - } - else { - $('#divGramajeInterior').addClass('is-invalid'); - errores.push(window.translations["validation"].gramaje_interior); - } + this.validateGramajeInterior(); } const skAlert = document.getElementById('sk-alert'); skAlert.innerHTML = ''; - const uniqueErrors = [...new Set(errores)]; + this.errores = [...new Set(this.errores)]; - if (uniqueErrors.length > 0) { + if (this.errores.length > 0) { const message = window.translations["validation"].fix_errors + ``; popErrorAlert(message, 'sk-alert', false); - errores = []; return false; } else { document.getElementById('sk-alert').innerHTML = ''; - errores = []; + this.errores = []; if (goToNext) this.validatorStepper.next(); else @@ -450,6 +416,58 @@ class DisenioInterior { } } + validateDisenioInterior() { + + if ($('.disenio-interior.selected').length > 0) { + $('#divImpresionInterior').removeClass('is-invalid'); + return true; + } + else { + this.errores.push(window.translations["validation"].disenio_interior); + $('#divImpresionInterior').addClass('is-invalid'); + return false; + } + } + + validatePapelInterior() { + + const papelSeleccionado = $('.custom-selector-papel input[type="radio"]:checked'); + if (papelSeleccionado.length > 0) { + if (!$('#divPapelEspecialInterior').hasClass("d-none")) { + if ($('#papelEspecialInterior').select2('data').length == 0) { + $('#divPapelInterior').addClass('is-invalid'); + this.errores.push(window.translations["validation"].papel_interior_especial); + return false; + } + else { + $('#divPapelInterior').removeClass('is-invalid'); + return true; + } + } + else { + $('#divPapelInterior').removeClass('is-invalid'); + return true; + } + } else { + $('#divPapelInterior').addClass('is-invalid'); + this.errores.push(window.translations["validation"].papel_interior); + return false; + } + } + + validateGramajeInterior() { + const gramajeSeleccionado = $('.custom-selector-gramaje input[type="radio"]:checked'); + if (gramajeSeleccionado.length > 0) { + $('#divGramajeInterior').removeClass('is-invalid'); + return true; + } + else { + $('#divGramajeInterior').addClass('is-invalid'); + this.errores.push(window.translations["validation"].gramaje_interior); + return false; + } + } + getTipoImpresion() { @@ -730,6 +748,21 @@ class DisenioInterior { else this.updatePapeles(); } + + if (this.validateDisenioInterior()) { + const hasError = this.errores.filter(err => err === window.translations["validation"].disenio_interior).length > 0; + if (hasError) { + // remove the item from this.errores + this.errores = this.errores.filter(err => err !== window.translations["validation"].disenio_interior); + } + if (this.errores.length == 0) { + document.getElementById('sk-alert').innerHTML = ''; + } + else { + document.getElementById('sk-alert').innerHTML = document.getElementById('sk-alert').innerHTML. + replace(window.translations["validation"].disenio_interior, ''); + } + } } @@ -780,8 +813,23 @@ class DisenioInterior { (response) => { console.log(response); } ).get(); } - if (!this.cargando) + if (!this.cargando) { this.gramaje = null; + if (this.validatePapelInterior()) { + const hasError = this.errores.filter(err => err === window.translations["validation"].papel_interior).length > 0; + if (hasError) { + // remove the item from this.errores + this.errores = this.errores.filter(err => err !== window.translations["validation"].papel_interior); + } + if (this.errores.length == 0) { + document.getElementById('sk-alert').innerHTML = ''; + } + else { + document.getElementById('sk-alert').innerHTML = document.getElementById('sk-alert').innerHTML. + replace(window.translations["validation"].papel_interior, ''); + } + } + } else { this.cargando = false; } @@ -938,9 +986,24 @@ class DisenioInterior { const element = $(event.target); const gramaje = element[0].id; - this.presupuestoCliente.calcularSolapas(event); - this.presupuestoCliente.checkLomoInterior(event); - this.presupuestoCliente.checkForm(event); + if (this.validateGramajeInterior()) { + const hasError = this.errores.filter(err => err === window.translations["validation"].gramaje_interior).length > 0; + if (hasError) { + // remove the item from this.errores + this.errores = this.errores.filter(err => err !== window.translations["validation"].gramaje_interior); + } + if (this.errores.length == 0) { + document.getElementById('sk-alert').innerHTML = ''; + } + else { + document.getElementById('sk-alert').innerHTML = document.getElementById('sk-alert').innerHTML. + replace(window.translations["validation"].gramaje_interior, ''); + } + + this.presupuestoCliente.calcularSolapas(event); + this.presupuestoCliente.checkLomoInterior(event); + this.presupuestoCliente.checkForm(event); + }; }); From ff9ce9eda28acd40613ee77f721c2e2c13f642f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Wed, 25 Jun 2025 07:50:01 +0200 Subject: [PATCH 02/12] trabajando en la cubierta --- ci4/app/Language/es/Presupuestos.php | 1 - .../presupuestoCliente/disenioCubierta.js | 263 +++++++++++++----- 2 files changed, 188 insertions(+), 76 deletions(-) diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index c5d50698..9c89acbe 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -396,7 +396,6 @@ return [ 'paginasColor' => 'El número de páginas a color debe ser un número entero mayor o igual que 0.', 'paginasNegro' => 'El número de páginas en negro debe ser un número entero mayor o igual que 0.', 'paginas' => 'El total de páginas tiene que ser mayor que 0.', - 'paginas_pares' => 'El número de páginas debe ser par.', 'tipo_libro' => 'Seleccione el tipo de libro que desea para el presupuesto.', 'decimal' => 'El campo {field} debe contener un número decimal.', 'integer' => 'El campo {field} debe contener un número entero.', diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js index 7dd144f9..3ed65420 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js @@ -1,5 +1,4 @@ -import { getToken } from '../../common/common.js'; -import { capitalizeFirstLetter } from '../../common/common.js'; +import { capitalizeFirstLetter, getToken } from '../../common/common.js'; import Ajax from '../../components/ajax.js'; import ClassSelect from '../../components/select2.js'; @@ -265,6 +264,8 @@ class DisenioCubierta { this.presupuestoConfirmado = false; this.papelForResumen = ""; this.gramajeForResumen = ""; + + this.errores = []; } @@ -327,6 +328,18 @@ class DisenioCubierta { this.observer.observe(this.tapaDuraLomoRedondo[0], { attributes: true }); this.observer.observe(this.conSolapas[0], { attributes: true }); this.observer.observe(this.sinSolapas[0], { attributes: true }); + + this.papelGuardas.onChange(() => { + if (self.validateTapaDuraOptions()) { + self.removeError(window.translations["validation"].papel_guardas) + } + }); + + this.gramajeGuardas.onChange(() => { + if (self.validateTapaDuraOptions()) { + self.removeError(window.translations["validation"].gramaje_guardas) + } + }); } @@ -403,106 +416,47 @@ class DisenioCubierta { validate(goToNext = true) { - let errores = []; + this.errores = []; let continueCheck = true; // diseño cubierta - $('#divTipoCubierta').removeClass('is-invalid'); - if ($('.tipo-cubierta.selected').length == 0) { - $('#divTipoCubierta').addClass('is-invalid'); - errores.push(window.translations["validation"].tipo_cubierta); - continueCheck = false; - } + continueCheck = this.validateDisenioCubierta(); // solapas cubierta - $('#divSolapasCubierta').removeClass('is-invalid'); - if (!$('#divSolapasCubierta').hasClass("d-none") && $('.solapas-cubierta.selected').length == 0 && continueCheck) { - $('#divSolapasCubierta').addClass('is-invalid'); - errores.push(window.translations["validation"].opcion_solapas); - } + this.validateSolapasCubierta(continueCheck); // opciones tapa dura y lomo redondo - $('#papelGuardas').removeClass('is-invalid'); - $('#gramajeGuardas').removeClass('is-invalid'); - if (!$('#divConfigTapaDura').hasClass('d-none') && continueCheck) { - if ($('#papelGuardas').select2('data').length == 0) { - $('#papelGuardas').addClass('is-invalid'); - errores.push(window.translations["validation"].papel_guardas); - } - if ($('#gramajeGuardas').select2('data').length == 0) { - $('#gramajeGuardas').addClass('is-invalid'); - errores.push(window.translations["validation"].gramaje_guardas); - } - } + this.validateTapaDuraOptions(continueCheck); // papel - $('#divPapelCubierta').removeClass('is-invalid'); - if ($('.custom-selector-papel-cubierta input[type="radio"]:checked').length == 0 && continueCheck) { - - $('#divPapelCubierta').addClass('is-invalid'); - errores.push(window.translations["validation"].papel_cubierta); - continueCheck = false; - } - else if (!$('#divPapelEspecialCubierta').hasClass("d-none")) { - if ($('#papelEspecialCubiertaSel').select2('data').length == 0 && continueCheck) { - $('#divPapelEspecialCubierta').addClass('is-invalid'); - errores.push(window.translations["validation"].papel_cubierta_especial); - continueCheck = false; - } - } + continueCheck = this.validatePapelCubierta(continueCheck); // gramaje - $('#divGramajeCubierta').removeClass('is-invalid'); - if ($('.custom-selector-gramaje-cubierta input[type="radio"]:checked').length == 0 && continueCheck) { - $('#divGramajeCubierta').addClass('is-invalid'); - errores.push(window.translations["validation"].gramaje_cubierta); - } + this.validateGramajeCubierta(continueCheck); // sobrecubierta - $('#papelSobrecubierta').removeClass('is-invalid'); - $('#gramajeSobrecubierta').removeClass('is-invalid'); - if ($("#addSobrecubierta").prop("checked") == true) { - if ($('#papelSobrecubierta').select2('data').length == 0) { - $('#papelSobrecubierta').addClass('is-invalid'); - errores.push(window.translations["validation"].papel_sobrecubierta); - } - if ($('#gramajeSobrecubierta').select2('data').length == 0) { - $('#gramajeSobrecubierta').addClass('is-invalid'); - errores.push(window.translations["validation"].gramaje_sobrecubierta); - } - } + this.validateSobrecubierta(); // faja - $('#papelFaja').removeClass('is-invalid'); - $('#gramajeFaja').removeClass('is-invalid'); - if ($("#addFaja").prop("checked") == true) { - if ($('#papelFaja').select2('data').length == 0) { - $('#papelFaja').addClass('is-invalid'); - errores.push(window.translations["validation"].papel_faja); - } - if ($('#gramajeFaja').select2('data').length == 0) { - $('#gramajeFaja').addClass('is-invalid'); - errores.push(window.translations["validation"].gramaje_faja); - } - } + this.validateFaja(); const skAlert = document.getElementById('sk-alert'); skAlert.innerHTML = ''; - const uniqueErrors = [...new Set(errores)]; + this.errores = [...new Set(this.errores)]; - if (uniqueErrors.length > 0) { + if (this.errores.length > 0) { const message = window.translations["validation"].fix_errors + ``; popErrorAlert(message, 'sk-alert', false); - errores = []; + this.errores = []; return false; } else { document.getElementById('sk-alert').innerHTML = ''; - errores = []; + this.errores = []; if (goToNext) this.validatorStepper.next(); else @@ -511,6 +465,123 @@ class DisenioCubierta { } + validateDisenioCubierta() { + + $('#divTipoCubierta').removeClass('is-invalid'); + if ($('.tipo-cubierta.selected').length == 0) { + $('#divTipoCubierta').addClass('is-invalid'); + this.errores.push(window.translations["validation"].tipo_cubierta); + return false; + } + return true; + } + + validateSolapasCubierta(continueCheck = true) { + + $('#divSolapasCubierta').removeClass('is-invalid'); + if (!$('#divSolapasCubierta').hasClass("d-none") && $('.solapas-cubierta.selected').length == 0) { + $('#divSolapasCubierta').addClass('is-invalid'); + this.errores.push(window.translations["validation"].opcion_solapas); + return false; + } + return true; + } + + + validateTapaDuraOptions(continueCheck = true) { + + $('#papelGuardas').removeClass('is-invalid'); + $('#gramajeGuardas').removeClass('is-invalid'); + if (!continueCheck) + return false; + if (!$('#divConfigTapaDura').hasClass('d-none') && continueCheck) { + if ($('#papelGuardas').select2('data').length == 0) { + $('#papelGuardas').addClass('is-invalid'); + this.errores.push(window.translations["validation"].papel_guardas); + return false; + } + if ($('#gramajeGuardas').select2('data').length == 0) { + $('#gramajeGuardas').addClass('is-invalid'); + this.errores.push(window.translations["validation"].gramaje_guardas); + return false; + } + } + return true; + } + + validatePapelCubierta(continueCheck = true) { + + $('#divPapelCubierta').removeClass('is-invalid'); + $('#divPapelEspecialCubierta').removeClass('is-invalid'); + if (!continueCheck) + return false; + if ($('.custom-selector-papel-cubierta input[type="radio"]:checked').length == 0 && continueCheck) { + + $('#divPapelCubierta').addClass('is-invalid'); + this.errores.push(window.translations["validation"].papel_cubierta); + return false; + } + else if (!$('#divPapelEspecialCubierta').hasClass("d-none")) { + if ($('#papelEspecialCubiertaSel').select2('data').length == 0 && continueCheck) { + $('#divPapelEspecialCubierta').addClass('is-invalid'); + this.errores.push(window.translations["validation"].papel_cubierta_especial); + return false; + } + } + return true; + } + + validateGramajeCubierta(continueCheck = true) { + + $('#divGramajeCubierta').removeClass('is-invalid'); + if ($('.custom-selector-gramaje-cubierta input[type="radio"]:checked').length == 0 && continueCheck) { + $('#divGramajeCubierta').addClass('is-invalid'); + this.errores.push(window.translations["validation"].gramaje_cubierta); + return false; + } + return true; + } + + validateSobrecubierta() { + + let noError = true; + $('#papelSobrecubierta').removeClass('is-invalid'); + $('#gramajeSobrecubierta').removeClass('is-invalid'); + if ($("#addSobrecubierta").prop("checked") == true) { + if ($('#papelSobrecubierta').select2('data').length == 0) { + $('#papelSobrecubierta').addClass('is-invalid'); + this.errores.push(window.translations["validation"].papel_sobrecubierta); + noError = false; + } + if ($('#gramajeSobrecubierta').select2('data').length == 0) { + $('#gramajeSobrecubierta').addClass('is-invalid'); + this.errores.push(window.translations["validation"].gramaje_sobrecubierta); + noError = false; + } + } + return noError; + } + + validateFaja() { + + let noError = true; + $('#papelFaja').removeClass('is-invalid'); + $('#gramajeFaja').removeClass('is-invalid'); + if ($("#addFaja").prop("checked") == true) { + if ($('#papelFaja').select2('data').length == 0) { + $('#papelFaja').addClass('is-invalid'); + this.errores.push(window.translations["validation"].papel_faja); + noError = false; + } + if ($('#gramajeFaja').select2('data').length == 0) { + $('#gramajeFaja').addClass('is-invalid'); + this.errores.push(window.translations["validation"].gramaje_faja); + noError = false; + } + } + return noError; + } + getLomoCubierta() { const lomoRedondo = this.tapaDuraLomoRedondo.hasClass("selected"); @@ -818,6 +889,10 @@ class DisenioCubierta { } element.trigger('change'); + + if (this.validateDisenioCubierta()) { + this.removeError(window.translations["validation"].tipo_cubierta); + } } @@ -839,6 +914,10 @@ class DisenioCubierta { element.closest('.image-presupuesto').toggleClass('selected'); element.trigger('change'); + + if (this.validateSobrecubierta()) { + this.removeError(window.translations["validation"].opcion_solapas); + } } @@ -911,6 +990,11 @@ class DisenioCubierta { this.papelCubierta = this.papelEspecial.getVal(); const tapa_dura = this.tapaBlanda.hasClass("selected") ? 0 : 1; + if (this.validatePapelCubierta()) { + this.removeError(window.translations["validation"].papel_cubierta); + this.removeError(window.translations["validation"].papel_cubierta_especial); + } + new Ajax('/configuracion/papelesgenericos/getpapelcliente', { [this.csrf_token]: this.csrf_hash, @@ -925,6 +1009,7 @@ class DisenioCubierta { tirada: this.presupuestoCliente.datosGenerales.getTiradas()[0], }, {}, + this.fillGramajes.bind(context), (response) => { console.log(response); } ).get(); @@ -934,8 +1019,13 @@ class DisenioCubierta { fillPapeles(response) { + const self = this; + this.divPapelCubierta.empty(); this.divGramajeCubierta.empty(); + this.divPapelCubierta.removeClass('is-invalid'); + this.divGramajeCubierta.removeClass('is-invalid'); + this.divPapelEspecial.removeClass('is-invalid'); if (response.papeles.length > 0) { this.textoPapelCubierta.removeClass('d-none'); @@ -962,7 +1052,11 @@ class DisenioCubierta { text: papel.nombre }); - radioButton.on('click', this.#handleGramajeCubierta.bind(this)); + radioButton.on('click', () => { + self.removeError(window.translations["validation"].papel_cubierta); + self.removeError(window.translations["validation"].papel_cubierta_especial); + this.#handleGramajeCubierta(); + }); container.append(radioButton).append(label); $('#divPapelCubierta').append(container); @@ -1101,6 +1195,10 @@ class DisenioCubierta { const element = $(event.target); const gramaje = element[0].id; + /*if(this.validateGramajeCubierta()) { + this.removeError(window.translations["validation"].gramaje_cubierta); + }*/ + this.presupuestoCliente.checkForm(event); }); @@ -1171,6 +1269,21 @@ class DisenioCubierta { else if ($('#' + id).val() > max) $('#' + id).val(max); } + + removeError(error) { + const hasError = this.errores.filter(err => err === error).length > 0; + if (hasError) { + // remove the item from this.errores + this.errores = this.errores.filter(err => err !== error); + } + if (this.errores.length == 0) { + document.getElementById('sk-alert').innerHTML = ''; + } + else { + document.getElementById('sk-alert').innerHTML = document.getElementById('sk-alert').innerHTML. + replace(window.translations["validation"].error, ''); + } + } } From 83753d1784ae3deaca69665ebc6039f8836c825e Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Wed, 25 Jun 2025 10:06:21 +0200 Subject: [PATCH 03/12] trabajando en cubierta --- .../cliente/items/_disenioCubierta.php | 8 +++--- .../presupuestoCliente/datosGenerales.js | 7 +++-- .../presupuestoCliente/disenioCubierta.js | 27 ++++++++++++++++--- 3 files changed, 33 insertions(+), 9 deletions(-) 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 30729a8a..4f62b196 100755 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta.php @@ -200,7 +200,7 @@
-
@@ -211,7 +211,7 @@ -
@@ -251,7 +251,7 @@
-
@@ -262,7 +262,7 @@ -
diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js index fee7ab5d..2076bab5 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js @@ -570,8 +570,11 @@ class DatosGenerales { this.formatoEstandar.removeClass('d-none'); this.formatoPersonalizado.addClass('d-none'); } - const alto = this.getDimensionLibro().alto; - $('#altoFaja').closest('.config-faja').find('.form-text').text('Entre 50 y ' + alto + ' mm'); + const dimensionLibro = this.getDimensionLibro(); + if (dimensionLibro && dimensionLibro.alto) { + + $('#altoFaja').closest('.config-faja').find('.form-text').text('Entre 50 y ' + dimensionLibro.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 3ed65420..2d7c7dd5 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js @@ -309,11 +309,32 @@ class DisenioCubierta { this.carasCubierta.on('change', this.#handleCarasCubierta.bind(this)); this.sobrecubierta.on('change', () => { - this.sobrecubierta.is(":checked") ? this.configuracionSobrecubierta.removeClass("d-none") : this.configuracionSobrecubierta.addClass("d-none") + + if (this.sobrecubierta.is(":checked")) { + + this.configuracionSobrecubierta.removeClass("d-none"); + if (this.papelSobrecubierta.getVal() && this.gramajeSobrecubierta.getVal()) { + $('#tirada').trigger('change'); // recalcular presupuesto + } + } + else { + this.configuracionSobrecubierta.addClass("d-none"); + $('#tirada').trigger('change'); // recalcular presupuesto + } } ); this.faja.on('change', () => { - this.faja.is(":checked") ? this.configuracionFaja.removeClass("d-none") : this.configuracionFaja.addClass("d-none"); + + if(this.faja.is(":checked")) { + this.configuracionFaja.removeClass("d-none"); + if (this.papelFaja.getVal() && this.gramajeFaja.getVal()) { + $('#tirada').trigger('change'); // recalcular presupuesto + } + } + else{ + this.configuracionFaja.addClass("d-none"); + $('#tirada').trigger('change'); // recalcular presupuesto + } const div = $('#divExtras'); // Selecciona el div div.find('.fv-plugins-message-container').remove(); }); @@ -1025,7 +1046,7 @@ class DisenioCubierta { this.divGramajeCubierta.empty(); this.divPapelCubierta.removeClass('is-invalid'); this.divGramajeCubierta.removeClass('is-invalid'); - this.divPapelEspecial.removeClass('is-invalid'); + this.divPapelEspecial.removeClass('is-invalid'); if (response.papeles.length > 0) { this.textoPapelCubierta.removeClass('d-none'); From c3bce03921f650a978e612957ef9e6f649f77f2d Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Wed, 25 Jun 2025 11:14:09 +0200 Subject: [PATCH 04/12] =?UTF-8?q?terminada=20validaci=C3=B3n=20nueva=20en?= =?UTF-8?q?=20diseniocubierta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presupuestoAdmin/sections/comparador.js | 6 ++++++ .../presupuestoCliente/disenioCubierta.js | 19 +++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js index 6bed090c..7aac7b45 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js @@ -365,6 +365,7 @@ class Comparador { popErrorAlert(window.language.Presupuestos.errores.error_sobrecubierta_sin_solapas, 'divAlarmasComparador') }*/ $('#solapas_sobrecubierta').prop('checked', true); + $('#solapas_sobrecubierta').trigger('change'); $('#div_solapas_ancho_sobrecubierta').removeClass('d-none'); $('#solapas_ancho_sobrecubierta').val(60); $('#compPapelSobrecubierta').prop('disabled', false); @@ -373,6 +374,8 @@ class Comparador { else { this.papelSobrecubierta.setVal(0); this.gramajeSobrecubierta.setVal(0); + $('#solapas_sobrecubierta').prop('checked', false); + $('#solapas_sobrecubierta').trigger('change') $('#compPapelSobrecubierta').prop('disabled', true); $('#compGramajeSobrecubierta').prop('disabled', true); @@ -387,6 +390,7 @@ class Comparador { popErrorAlert(window.language.Presupuestos.errores.error_faja_sin_solapas, 'divAlarmasComparador'); } $('#faja').prop('checked', true); + $('#faja').trigger('change'); $('.faja-div').removeClass('d-none'); $('#compPapelFaja').prop('disabled', false); $('#compGramajeFaja').prop('disabled', false); @@ -394,6 +398,8 @@ class Comparador { else { this.papelFaja.setVal(0); this.gramajeFaja.setVal(0); + $('#faja').prop('checked', false); + $('#faja').trigger('change'); $('#compPapelFaja').prop('disabled', true); $('#compGramajeFaja').prop('disabled', true); } diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js index 2d7c7dd5..0cb63017 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js @@ -339,9 +339,24 @@ class DisenioCubierta { div.find('.fv-plugins-message-container').remove(); }); - this.papelFaja.item.on('change', () => { this.gramajeFaja.empty(); }); + this.papelSobrecubierta.item.on('change', () => { + this.papelSobrecubierta.item.find('option').remove(); + this.papelSobrecubierta.item.val(null); + this.papelSobrecubierta.item.trigger('select2:clear'); + }); - this.papelGuardas.item.on('change', () => { this.gramajeGuardas.empty(); }); + this.papelFaja.item.on('change', () => { + this.gramajeFaja.item.find('option').remove(); + this.gramajeFaja.item.val(null); + this.gramajeFaja.item.trigger('select2:clear'); + }); + + this.papelGuardas.item.on('change', () => { + this.gramajeGuardas.item.find('option').remove(); + this.gramajeGuardas.item.val(null); + this.gramajeGuardas.item.trigger('select2:clear'); + + }); // Observadores this.observer.observe(this.tapaBlanda[0], { attributes: true }); From 647c0bd72d9fd48979152ea7aaa473ea48679807 Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Wed, 25 Jun 2025 13:55:31 +0200 Subject: [PATCH 05/12] =?UTF-8?q?trabajando=20en=20la=20validaci=C3=B3n=20?= =?UTF-8?q?de=20los=20datosgenerales?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presupuestoCliente/datosGenerales.js | 247 ++++++++++++------ .../presupuestoCliente/disenioCubierta.js | 11 +- 2 files changed, 172 insertions(+), 86 deletions(-) diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js index 2076bab5..17b2e151 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js @@ -103,9 +103,13 @@ class DatosGenerales { this.pagColorConsecutivas.on('change', this.#handPaginasConsecutivas.bind(this)); this.papelDiferente.on('change', this.#handlePapelDiferente.bind(this)); + $('.tirada-presupuesto').on('change', () => { - - self.validate(false); + + if (this.validateTiradas()) { + this.removeError(window.translations["validation"].tirada_integer_greatherThan_0); + this.removeError(window.translations["validation"].tirada_pod_nopod); + } let tiradas = self.getTiradas(); if (!Array.isArray(tiradas)) { tiradas = [tiradas]; @@ -120,7 +124,21 @@ class DatosGenerales { this.anchoPersonalizado.on("change", this.#checkValue.bind(this)); this.altoPersonalizado.on("change", this.#checkValue.bind(this)); - this.titulo.on('change', () => { $(".titulo").html(this.titulo.val()); }); + this.titulo.on('change', () => { + $(".titulo").html(this.titulo.val()); + if (this.validateTitulo()) { + this.removeError(window.translations["validation"].titulo_requerido); + } + else { + this.addError(window.translations["validation"].titulo_requerido); + } + }); + + this.cliente.item.on('change', () => { + if (this.validateCliente()) { + this.removeError(window.translations["validation"].cliente); + } + }); this.retractilado.on('change', this.#eventRetractilado.bind(this)); this.retractilado5.on('change', this.#eventRetractilado.bind(this)); @@ -132,86 +150,22 @@ class DatosGenerales { this.errores = []; // Titulo - if (this.titulo.val().trim() === '') { - this.errores.push(window.translations["validation"].titulo_requerido); - this.titulo.addClass('is-invalid'); - } else { - this.titulo.removeClass('is-invalid'); - } + this.validateTitulo(); // Cliente - if ($(this.excluirRotativa).prop('hidden')) { - if ($('#clienteId').val() === null || $('#clienteId').val().length === 0) { - this.errores.push(window.translations["validation"].cliente); - $('#clienteId').addClass('is-invalid'); - } else { - $('#clienteId').removeClass('is-invalid'); - } - } else { - if (this.cliente.getVal() <= 0) { - this.errores.push(window.translations["validation"].cliente); - this.cliente.item.addClass('is-invalid'); - } else { - this.cliente.item.removeClass('is-invalid'); - } - } + this.validateCliente(); // Tirada - let tiradas = this.getTiradas(); - if (tiradas.length === 0 || tiradas.some(tirada => - !Number.isInteger(tirada) || - parseInt(tirada) <= 0 || - tirada == "")) { - - this.errores.push(window.translations["validation"].tirada_integer_greatherThan_0); - this.tirada1.addClass('is-invalid'); - - } else { - this.tirada1.removeClass('is-invalid'); - // Comprobar tiradas POD - const noPOD = tiradas.some(tirada => parseInt(tirada) > 30); - const siPOD = tiradas.some(tirada => parseInt(tirada) <= 30); - if (noPOD && siPOD) { - this.errores.push(window.translations["validation"].tirada_pod_nopod); - this.tirada1.addClass('is-invalid'); - } - else { - this.tirada1.removeClass('is-invalid'); - } - } + this.validateTiradas(); // formato libro - if (this.checkFormatoPersonalizado.is(':checked')) { - if (this.anchoPersonalizado.val().length === 0 || isNaN(this.anchoPersonalizado.val()) || - parseFloat(this.anchoPersonalizado.val()) <= 0) { - this.errores.push(window.translations["validation"].papelFormatoAncho); - this.anchoPersonalizado.addClass('is-invalid'); - } else { - this.anchoPersonalizado.removeClass('is-invalid'); - } - if (this.altoPersonalizado.val().length === 0 || isNaN(this.altoPersonalizado.val()) || - parseFloat(this.altoPersonalizado.val()) <= 0) { - this.errores.push(window.translations["validation"].papelFormatoAlto); - this.altoPersonalizado.addClass('is-invalid'); - } else { - this.altoPersonalizado.removeClass('is-invalid'); - } - } else { - const options = $("#papelFormatoId").select2('data'); - const hasValidOption = options.some(option => parseInt(option.id) > 0); - if (options !== null && options.length > 0 && hasValidOption) { - this.papelFormatoId.removeClass('is-invalid'); - } else { - this.errores.push(window.translations["validation"].papelFormato); - this.papelFormatoId.addClass('is-invalid'); - } - } + this.validateFormatoLibro(); // Paginas if (this.paginasColor.val() == '' || isNaN(this.paginasColor.val()) || parseInt(this.paginasColor.val()) < 0) { this.errores.push(window.translations["validation"].paginasColor); this.paginasColor.addClass('is-invalid'); - } + } else if (parseInt(this.paginasColor.val()) % 2 != 0) { this.errores.push(window.translations["validation"].paginas_pares); this.paginasColor.addClass('is-invalid'); @@ -222,7 +176,7 @@ class DatosGenerales { if (this.paginasNegro.val() == '' || isNaN(this.paginasNegro.val()) || parseInt(this.paginasNegro.val()) < 0) { this.errores.push(window.translations["validation"].paginasNegro); this.paginasNegro.addClass('is-invalid'); - } + } else if (parseInt(this.paginasNegro.val()) % 2 != 0) { this.errores.push(window.translations["validation"].paginas_pares); this.paginasNegro.addClass('is-invalid'); @@ -258,15 +212,14 @@ class DatosGenerales { const skAlert = document.getElementById('sk-alert'); skAlert.innerHTML = ''; - const uniqueErrors = [...new Set(this.errores)]; + this.errores = [...new Set(this.errores)]; - if (uniqueErrors.length > 0) { + if (this.errores.length > 0) { const message = window.translations["validation"].fix_errors + `
    - ${uniqueErrors.map(err => `
  • ${err}
  • `).join('')} + ${this.errores.map(err => `
  • ${err}
  • `).join('')}
`; popErrorAlert(message, 'sk-alert', false); - this.errores = []; return false; } else { @@ -279,6 +232,104 @@ class DatosGenerales { } } + validateFormatoLibro() { + + let noError = true; + if (this.checkFormatoPersonalizado.is(':checked')) { + if (this.anchoPersonalizado.val().length === 0 || isNaN(this.anchoPersonalizado.val()) || + parseFloat(this.anchoPersonalizado.val()) <= 0) { + this.errores.push(window.translations["validation"].papelFormatoAncho); + this.anchoPersonalizado.addClass('is-invalid'); + noError = false; + } else { + this.anchoPersonalizado.removeClass('is-invalid'); + } + if (this.altoPersonalizado.val().length === 0 || isNaN(this.altoPersonalizado.val()) || + parseFloat(this.altoPersonalizado.val()) <= 0) { + this.errores.push(window.translations["validation"].papelFormatoAlto); + this.altoPersonalizado.addClass('is-invalid'); + noError = false; + } else { + this.altoPersonalizado.removeClass('is-invalid'); + } + } else { + const options = $("#papelFormatoId").select2('data'); + const hasValidOption = options.some(option => parseInt(option.id) > 0); + if (options !== null && options.length > 0 && hasValidOption) { + this.papelFormatoId.removeClass('is-invalid'); + } else { + this.errores.push(window.translations["validation"].papelFormato); + this.papelFormatoId.addClass('is-invalid'); + noError = false; + } + } + return noError; + } + + validateTiradas() { + + let tiradas = this.getTiradas(); + if (tiradas.length === 0 || tiradas.some(tirada => + !Number.isInteger(tirada) || + parseInt(tirada) <= 0 || + tirada == "")) { + + this.errores.push(window.translations["validation"].tirada_integer_greatherThan_0); + this.tirada1.addClass('is-invalid'); + return false; + + } else { + this.tirada1.removeClass('is-invalid'); + // Comprobar tiradas POD + const noPOD = tiradas.some(tirada => parseInt(tirada) > 30); + const siPOD = tiradas.some(tirada => parseInt(tirada) <= 30); + if (noPOD && siPOD) { + this.errores.push(window.translations["validation"].tirada_pod_nopod); + this.tirada1.addClass('is-invalid'); + return false; + } + else { + this.tirada1.removeClass('is-invalid'); + return true; + } + } + } + + validateCliente() { + + if ($(this.excluirRotativa).prop('hidden')) { + if ($('#clienteId').val() === null || $('#clienteId').val().length === 0) { + this.errores.push(window.translations["validation"].cliente); + $('#clienteId').addClass('is-invalid'); + return false; + } else { + $('#clienteId').removeClass('is-invalid'); + return true; + } + } else { + if (this.cliente.getVal() <= 0) { + this.errores.push(window.translations["validation"].cliente); + this.cliente.item.addClass('is-invalid'); + return false; + } else { + this.cliente.item.removeClass('is-invalid'); + return true; + } + } + } + + validateTitulo() { + + if (this.titulo.val().trim() === '') { + this.errores.push(window.translations["validation"].titulo_requerido); + this.titulo.addClass('is-invalid'); + return false; + } else { + this.titulo.removeClass('is-invalid'); + return true; + } + } + processMenuLateral() { @@ -572,7 +623,7 @@ class DatosGenerales { } const dimensionLibro = this.getDimensionLibro(); if (dimensionLibro && dimensionLibro.alto) { - + $('#altoFaja').closest('.config-faja').find('.form-text').text('Entre 50 y ' + dimensionLibro.alto + ' mm'); } } @@ -582,6 +633,10 @@ class DatosGenerales { if (target.value < target.min) { target.value = target.min; } + if (this.validateFormatoLibro()) { + this.removeError(window.translations["validation"].papelFormatoAncho); + this.removeError(window.translations["validation"].papelFormatoAlto); + } } #eventRetractilado(event) { @@ -634,7 +689,7 @@ class DatosGenerales { $('#addSobrecubierta').prop('checked', false).trigger('change'); $(".sobrecubierta-items").addClass('d-none'); - if (this.grapado.hasClass('selected')){ + if (this.grapado.hasClass('selected')) { $("#tapaBlanda").addClass('selected'); $("#tapaBlanda").removeClass('d-none'); @@ -695,7 +750,7 @@ class DatosGenerales { this.domItem.find('#grapado').show(); } - if( totalPaginas < 20){ + if (totalPaginas < 20) { this.domItem.find('#espiral').removeClass('selected'); this.domItem.find('#espiral').find('.image-presupuesto').removeClass('selected'); this.domItem.find('#espiral').hide(); @@ -832,6 +887,38 @@ class DatosGenerales { return servicios; } + removeError(error) { + const hasError = this.errores.filter(err => err === error).length > 0; + if (hasError) { + // remove the item from this.errores + this.errores = this.errores.filter(err => err !== error); + } + if (this.errores.length == 0) { + document.getElementById('sk-alert').innerHTML = ''; + } + else { + document.getElementById('sk-alert').innerHTML = document.getElementById('sk-alert').innerHTML + .replace(`
  • ${error}
  • `, '').replace(error, ''); + } + } + + addError(error) { + + if ($('#sk-alert').html() == '') { + const message = window.translations["validation"].fix_errors + + `
      ` + + `
    • ${error}
    • ` + + `
    `; + popErrorAlert(message, 'sk-alert', false); + return false; + } + else { + $('#sk-alert').html() += + `
      ` + + `
    • ${error}
    • ` + + `
    `; + } + } } diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js index 0cb63017..da6df22b 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js @@ -340,9 +340,9 @@ class DisenioCubierta { }); this.papelSobrecubierta.item.on('change', () => { - this.papelSobrecubierta.item.find('option').remove(); - this.papelSobrecubierta.item.val(null); - this.papelSobrecubierta.item.trigger('select2:clear'); + this.gramajeSobrecubierta.item.find('option').remove(); + this.gramajeSobrecubierta.item.val(null); + this.gramajeSobrecubierta.item.trigger('select2:clear'); }); this.papelFaja.item.on('change', () => { @@ -487,7 +487,6 @@ class DisenioCubierta { ${this.errores.map(err => `
  • ${err}
  • `).join('')} `; popErrorAlert(message, 'sk-alert', false); - this.errores = []; return false; } else { @@ -951,7 +950,7 @@ class DisenioCubierta { element.trigger('change'); - if (this.validateSobrecubierta()) { + if (this.validateSolapasCubierta()) { this.removeError(window.translations["validation"].opcion_solapas); } } @@ -1317,7 +1316,7 @@ class DisenioCubierta { } else { document.getElementById('sk-alert').innerHTML = document.getElementById('sk-alert').innerHTML. - replace(window.translations["validation"].error, ''); + replace(error, ''); } } } From 7e82142b3894b62eaa718c365360ae492eca1db5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Wed, 25 Jun 2025 18:26:27 +0200 Subject: [PATCH 06/12] nuevo docker --- ci4/app/Config/Kint.php | 2 +- ci4/composer.lock | 197 +++++++++++++++++++++------------------- 2 files changed, 103 insertions(+), 96 deletions(-) diff --git a/ci4/app/Config/Kint.php b/ci4/app/Config/Kint.php index 117e66d8..1917f9c5 100755 --- a/ci4/app/Config/Kint.php +++ b/ci4/app/Config/Kint.php @@ -42,7 +42,7 @@ class Kint extends BaseConfig */ public string $richTheme = 'aante-light.css'; public bool $richFolder = false; - public int $richSort = AbstractRenderer::SORT_FULL; + //public int $richSort = AbstractRenderer::SORT_FULL; /** * @var array>|null diff --git a/ci4/composer.lock b/ci4/composer.lock index 7913e452..aea7a0ef 100644 --- a/ci4/composer.lock +++ b/ci4/composer.lock @@ -8,34 +8,34 @@ "packages": [ { "name": "codeigniter4/framework", - "version": "v4.5.5", + "version": "v4.6.1", "source": { "type": "git", "url": "https://github.com/codeigniter4/framework.git", - "reference": "2849e7ff36b4c4aa1376d990a9a1e3f0c393b8d0" + "reference": "d021b04fdf23afc85d8a8b9b541be9a0a9ccdb5f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/codeigniter4/framework/zipball/2849e7ff36b4c4aa1376d990a9a1e3f0c393b8d0", - "reference": "2849e7ff36b4c4aa1376d990a9a1e3f0c393b8d0", + "url": "https://api.github.com/repos/codeigniter4/framework/zipball/d021b04fdf23afc85d8a8b9b541be9a0a9ccdb5f", + "reference": "d021b04fdf23afc85d8a8b9b541be9a0a9ccdb5f", "shasum": "" }, "require": { "ext-intl": "*", "ext-mbstring": "*", - "laminas/laminas-escaper": "^2.13", + "laminas/laminas-escaper": "^2.14", "php": "^8.1", "psr/log": "^3.0" }, "require-dev": { "codeigniter/coding-standard": "^1.7", - "fakerphp/faker": "^1.9", + "fakerphp/faker": "^1.24", "friendsofphp/php-cs-fixer": "^3.47.1", - "kint-php/kint": "^5.0.4", - "mikey179/vfsstream": "^1.6", + "kint-php/kint": "^6.0", + "mikey179/vfsstream": "^1.6.12", "nexusphp/cs-config": "^3.6", "phpunit/phpunit": "^10.5.16 || ^11.2", - "predis/predis": "^1.1 || ^2.0" + "predis/predis": "^1.1 || ^2.3" }, "suggest": { "ext-curl": "If you use CURLRequest class", @@ -78,7 +78,7 @@ "slack": "https://codeigniterchat.slack.com", "source": "https://github.com/codeigniter4/CodeIgniter4" }, - "time": "2024-09-07T08:49:38+00:00" + "time": "2025-05-02T16:00:55+00:00" }, { "name": "codeigniter4/settings", @@ -211,16 +211,16 @@ }, { "name": "dompdf/dompdf", - "version": "v3.0.1", + "version": "v3.1.0", "source": { "type": "git", "url": "https://github.com/dompdf/dompdf.git", - "reference": "2d622faf9aa1f8f7f24dd094e49b5cf6c0c5d4e6" + "reference": "a51bd7a063a65499446919286fb18b518177155a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dompdf/dompdf/zipball/2d622faf9aa1f8f7f24dd094e49b5cf6c0c5d4e6", - "reference": "2d622faf9aa1f8f7f24dd094e49b5cf6c0c5d4e6", + "url": "https://api.github.com/repos/dompdf/dompdf/zipball/a51bd7a063a65499446919286fb18b518177155a", + "reference": "a51bd7a063a65499446919286fb18b518177155a", "shasum": "" }, "require": { @@ -236,7 +236,7 @@ "ext-json": "*", "ext-zip": "*", "mockery/mockery": "^1.3", - "phpunit/phpunit": "^7.5 || ^8 || ^9 || ^10", + "phpunit/phpunit": "^7.5 || ^8 || ^9 || ^10 || ^11", "squizlabs/php_codesniffer": "^3.5", "symfony/process": "^4.4 || ^5.4 || ^6.2 || ^7.0" }, @@ -269,9 +269,9 @@ "homepage": "https://github.com/dompdf/dompdf", "support": { "issues": "https://github.com/dompdf/dompdf/issues", - "source": "https://github.com/dompdf/dompdf/tree/v3.0.1" + "source": "https://github.com/dompdf/dompdf/tree/v3.1.0" }, - "time": "2024-12-05T14:59:38+00:00" + "time": "2025-01-15T14:09:04+00:00" }, { "name": "dompdf/php-font-lib", @@ -366,16 +366,16 @@ }, { "name": "firebase/php-jwt", - "version": "v6.10.1", + "version": "v6.11.1", "source": { "type": "git", "url": "https://github.com/firebase/php-jwt.git", - "reference": "500501c2ce893c824c801da135d02661199f60c5" + "reference": "d1e91ecf8c598d073d0995afa8cd5c75c6e19e66" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/firebase/php-jwt/zipball/500501c2ce893c824c801da135d02661199f60c5", - "reference": "500501c2ce893c824c801da135d02661199f60c5", + "url": "https://api.github.com/repos/firebase/php-jwt/zipball/d1e91ecf8c598d073d0995afa8cd5c75c6e19e66", + "reference": "d1e91ecf8c598d073d0995afa8cd5c75c6e19e66", "shasum": "" }, "require": { @@ -423,22 +423,22 @@ ], "support": { "issues": "https://github.com/firebase/php-jwt/issues", - "source": "https://github.com/firebase/php-jwt/tree/v6.10.1" + "source": "https://github.com/firebase/php-jwt/tree/v6.11.1" }, - "time": "2024-05-18T18:05:11+00:00" + "time": "2025-04-09T20:32:01+00:00" }, { "name": "greenlion/php-sql-parser", - "version": "v4.6.0", + "version": "v4.7.0", "source": { "type": "git", "url": "https://github.com/greenlion/PHP-SQL-Parser.git", - "reference": "f0e4645eb1612f0a295e3d35bda4c7740ae8c366" + "reference": "0cd49149efc5868db9c32d1a09558ea516892586" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/greenlion/PHP-SQL-Parser/zipball/f0e4645eb1612f0a295e3d35bda4c7740ae8c366", - "reference": "f0e4645eb1612f0a295e3d35bda4c7740ae8c366", + "url": "https://api.github.com/repos/greenlion/PHP-SQL-Parser/zipball/0cd49149efc5868db9c32d1a09558ea516892586", + "reference": "0cd49149efc5868db9c32d1a09558ea516892586", "shasum": "" }, "require": { @@ -447,7 +447,7 @@ "require-dev": { "analog/analog": "^1.0.6", "phpunit/phpunit": "^9.5.13", - "squizlabs/php_codesniffer": "^1.5.1" + "squizlabs/php_codesniffer": "^2.8.1" }, "type": "library", "autoload": { @@ -485,7 +485,7 @@ "issues": "https://github.com/greenlion/PHP-SQL-Parser/issues", "source": "https://github.com/greenlion/PHP-SQL-Parser" }, - "time": "2023-03-09T20:54:23+00:00" + "time": "2024-12-02T12:14:07+00:00" }, { "name": "hermawan/codeigniter4-datatables", @@ -531,16 +531,16 @@ }, { "name": "laminas/laminas-escaper", - "version": "2.14.0", + "version": "2.17.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-escaper.git", - "reference": "0f7cb975f4443cf22f33408925c231225cfba8cb" + "reference": "df1ef9503299a8e3920079a16263b578eaf7c3ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-escaper/zipball/0f7cb975f4443cf22f33408925c231225cfba8cb", - "reference": "0f7cb975f4443cf22f33408925c231225cfba8cb", + "url": "https://api.github.com/repos/laminas/laminas-escaper/zipball/df1ef9503299a8e3920079a16263b578eaf7c3ba", + "reference": "df1ef9503299a8e3920079a16263b578eaf7c3ba", "shasum": "" }, "require": { @@ -552,12 +552,11 @@ "zendframework/zend-escaper": "*" }, "require-dev": { - "infection/infection": "^0.27.9", - "laminas/laminas-coding-standard": "~3.0.0", - "maglnet/composer-require-checker": "^3.8.0", - "phpunit/phpunit": "^9.6.16", - "psalm/plugin-phpunit": "^0.19.0", - "vimeo/psalm": "^5.21.1" + "infection/infection": "^0.29.8", + "laminas/laminas-coding-standard": "~3.0.1", + "phpunit/phpunit": "^10.5.45", + "psalm/plugin-phpunit": "^0.19.2", + "vimeo/psalm": "^6.6.2" }, "type": "library", "autoload": { @@ -589,7 +588,7 @@ "type": "community_bridge" } ], - "time": "2024-10-24T10:12:53+00:00" + "time": "2025-05-06T19:29:36+00:00" }, { "name": "masterminds/html5", @@ -829,16 +828,16 @@ }, { "name": "phpseclib/phpseclib", - "version": "3.0.42", + "version": "3.0.45", "source": { "type": "git", "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "db92f1b1987b12b13f248fe76c3a52cadb67bb98" + "reference": "bd81b90d5963c6b9d87de50357585375223f4dd8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/db92f1b1987b12b13f248fe76c3a52cadb67bb98", - "reference": "db92f1b1987b12b13f248fe76c3a52cadb67bb98", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/bd81b90d5963c6b9d87de50357585375223f4dd8", + "reference": "bd81b90d5963c6b9d87de50357585375223f4dd8", "shasum": "" }, "require": { @@ -919,7 +918,7 @@ ], "support": { "issues": "https://github.com/phpseclib/phpseclib/issues", - "source": "https://github.com/phpseclib/phpseclib/tree/3.0.42" + "source": "https://github.com/phpseclib/phpseclib/tree/3.0.45" }, "funding": [ { @@ -935,20 +934,20 @@ "type": "tidelift" } ], - "time": "2024-09-16T03:06:04+00:00" + "time": "2025-06-22T22:54:43+00:00" }, { "name": "picqer/php-barcode-generator", - "version": "v3.2.0", + "version": "v3.2.2", "source": { "type": "git", "url": "https://github.com/picqer/php-barcode-generator.git", - "reference": "3ef0b26ebd3996e8bb9e90fa2059a67d2e482b3e" + "reference": "a1d1e687c4a758be759383a709b6205e445091ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/picqer/php-barcode-generator/zipball/3ef0b26ebd3996e8bb9e90fa2059a67d2e482b3e", - "reference": "3ef0b26ebd3996e8bb9e90fa2059a67d2e482b3e", + "url": "https://api.github.com/repos/picqer/php-barcode-generator/zipball/a1d1e687c4a758be759383a709b6205e445091ec", + "reference": "a1d1e687c4a758be759383a709b6205e445091ec", "shasum": "" }, "require": { @@ -1014,9 +1013,9 @@ ], "support": { "issues": "https://github.com/picqer/php-barcode-generator/issues", - "source": "https://github.com/picqer/php-barcode-generator/tree/v3.2.0" + "source": "https://github.com/picqer/php-barcode-generator/tree/v3.2.2" }, - "time": "2024-10-01T19:35:25+00:00" + "time": "2025-06-03T09:09:33+00:00" }, { "name": "psr/log", @@ -1070,16 +1069,16 @@ }, { "name": "sabberworm/php-css-parser", - "version": "v8.7.0", + "version": "v8.8.0", "source": { "type": "git", "url": "https://github.com/MyIntervals/PHP-CSS-Parser.git", - "reference": "f414ff953002a9b18e3a116f5e462c56f21237cf" + "reference": "3de493bdddfd1f051249af725c7e0d2c38fed740" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/MyIntervals/PHP-CSS-Parser/zipball/f414ff953002a9b18e3a116f5e462c56f21237cf", - "reference": "f414ff953002a9b18e3a116f5e462c56f21237cf", + "url": "https://api.github.com/repos/MyIntervals/PHP-CSS-Parser/zipball/3de493bdddfd1f051249af725c7e0d2c38fed740", + "reference": "3de493bdddfd1f051249af725c7e0d2c38fed740", "shasum": "" }, "require": { @@ -1087,7 +1086,7 @@ "php": "^5.6.20 || ^7.0.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0" }, "require-dev": { - "phpunit/phpunit": "5.7.27 || 6.5.14 || 7.5.20 || 8.5.40" + "phpunit/phpunit": "5.7.27 || 6.5.14 || 7.5.20 || 8.5.41" }, "suggest": { "ext-mbstring": "for parsing UTF-8 CSS" @@ -1129,9 +1128,9 @@ ], "support": { "issues": "https://github.com/MyIntervals/PHP-CSS-Parser/issues", - "source": "https://github.com/MyIntervals/PHP-CSS-Parser/tree/v8.7.0" + "source": "https://github.com/MyIntervals/PHP-CSS-Parser/tree/v8.8.0" }, - "time": "2024-10-27T17:38:32+00:00" + "time": "2025-03-23T17:59:05+00:00" } ], "packages-dev": [ @@ -1207,16 +1206,16 @@ }, { "name": "fakerphp/faker", - "version": "v1.24.0", + "version": "v1.24.1", "source": { "type": "git", "url": "https://github.com/FakerPHP/Faker.git", - "reference": "a136842a532bac9ecd8a1c723852b09915d7db50" + "reference": "e0ee18eb1e6dc3cda3ce9fd97e5a0689a88a64b5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/a136842a532bac9ecd8a1c723852b09915d7db50", - "reference": "a136842a532bac9ecd8a1c723852b09915d7db50", + "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/e0ee18eb1e6dc3cda3ce9fd97e5a0689a88a64b5", + "reference": "e0ee18eb1e6dc3cda3ce9fd97e5a0689a88a64b5", "shasum": "" }, "require": { @@ -1264,9 +1263,9 @@ ], "support": { "issues": "https://github.com/FakerPHP/Faker/issues", - "source": "https://github.com/FakerPHP/Faker/tree/v1.24.0" + "source": "https://github.com/FakerPHP/Faker/tree/v1.24.1" }, - "time": "2024-11-07T15:11:20+00:00" + "time": "2024-11-21T13:46:39+00:00" }, { "name": "mikey179/vfsstream", @@ -1322,16 +1321,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.12.1", + "version": "1.13.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845" + "reference": "1720ddd719e16cf0db4eb1c6eca108031636d46c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/123267b2c49fbf30d78a7b2d333f6be754b94845", - "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/1720ddd719e16cf0db4eb1c6eca108031636d46c", + "reference": "1720ddd719e16cf0db4eb1c6eca108031636d46c", "shasum": "" }, "require": { @@ -1370,7 +1369,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.12.1" + "source": "https://github.com/myclabs/DeepCopy/tree/1.13.1" }, "funding": [ { @@ -1378,20 +1377,20 @@ "type": "tidelift" } ], - "time": "2024-11-08T17:47:46+00:00" + "time": "2025-04-29T12:36:36+00:00" }, { "name": "nikic/php-parser", - "version": "v5.3.1", + "version": "v5.5.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b" + "reference": "ae59794362fe85e051a58ad36b289443f57be7a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/8eea230464783aa9671db8eea6f8c6ac5285794b", - "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/ae59794362fe85e051a58ad36b289443f57be7a9", + "reference": "ae59794362fe85e051a58ad36b289443f57be7a9", "shasum": "" }, "require": { @@ -1434,9 +1433,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.3.1" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.5.0" }, - "time": "2024-10-08T18:51:32+00:00" + "time": "2025-05-31T08:24:38+00:00" }, { "name": "phar-io/manifest", @@ -1877,16 +1876,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.21", + "version": "9.6.23", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa" + "reference": "43d2cb18d0675c38bd44982a5d1d88f6d53d8d95" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa", - "reference": "de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/43d2cb18d0675c38bd44982a5d1d88f6d53d8d95", + "reference": "43d2cb18d0675c38bd44982a5d1d88f6d53d8d95", "shasum": "" }, "require": { @@ -1897,7 +1896,7 @@ "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.12.0", + "myclabs/deep-copy": "^1.13.1", "phar-io/manifest": "^2.0.4", "phar-io/version": "^3.2.1", "php": ">=7.3", @@ -1960,7 +1959,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.21" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.23" }, "funding": [ { @@ -1971,12 +1970,20 @@ "url": "https://github.com/sebastianbergmann", "type": "github" }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, { "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", "type": "tidelift" } ], - "time": "2024-09-19T10:50:18+00:00" + "time": "2025-05-02T06:40:34+00:00" }, { "name": "psr/container", @@ -2996,16 +3003,16 @@ }, { "name": "symfony/deprecation-contracts", - "version": "v3.5.0", + "version": "v3.6.0", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1" + "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", - "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62", + "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62", "shasum": "" }, "require": { @@ -3013,12 +3020,12 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "3.5-dev" - }, "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, + "branch-alias": { + "dev-main": "3.6-dev" } }, "autoload": { @@ -3043,7 +3050,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.6.0" }, "funding": [ { @@ -3059,7 +3066,7 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:32:20+00:00" + "time": "2024-09-25T14:21:43+00:00" }, { "name": "theseer/tokenizer", From 2d267386a65345ab866f87d92d7fdcb88a94bd5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Wed, 25 Jun 2025 18:27:17 +0200 Subject: [PATCH 07/12] nuevo docker --- ci4/app/Config/Kint.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci4/app/Config/Kint.php b/ci4/app/Config/Kint.php index 117e66d8..1917f9c5 100755 --- a/ci4/app/Config/Kint.php +++ b/ci4/app/Config/Kint.php @@ -42,7 +42,7 @@ class Kint extends BaseConfig */ public string $richTheme = 'aante-light.css'; public bool $richFolder = false; - public int $richSort = AbstractRenderer::SORT_FULL; + //public int $richSort = AbstractRenderer::SORT_FULL; /** * @var array>|null From 03b43de1853b882ea58e06b67c255923d21cb5a1 Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Thu, 26 Jun 2025 08:58:13 +0200 Subject: [PATCH 08/12] terminado datosGenerales para la validacion --- .../presupuestoCliente/datosGenerales.js | 154 +++++++++++------- 1 file changed, 97 insertions(+), 57 deletions(-) diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js index 17b2e151..d41c9d91 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js @@ -110,6 +110,9 @@ class DatosGenerales { this.removeError(window.translations["validation"].tirada_integer_greatherThan_0); this.removeError(window.translations["validation"].tirada_pod_nopod); } + else{ + this.addErrors(); + } let tiradas = self.getTiradas(); if (!Array.isArray(tiradas)) { tiradas = [tiradas]; @@ -130,7 +133,7 @@ class DatosGenerales { this.removeError(window.translations["validation"].titulo_requerido); } else { - this.addError(window.translations["validation"].titulo_requerido); + this.addErrors(); } }); @@ -138,6 +141,9 @@ class DatosGenerales { if (this.validateCliente()) { this.removeError(window.translations["validation"].cliente); } + else{ + this.addErrors(); + } }); this.retractilado.on('change', this.#eventRetractilado.bind(this)); @@ -162,36 +168,29 @@ class DatosGenerales { this.validateFormatoLibro(); // Paginas - if (this.paginasColor.val() == '' || isNaN(this.paginasColor.val()) || parseInt(this.paginasColor.val()) < 0) { - this.errores.push(window.translations["validation"].paginasColor); - this.paginasColor.addClass('is-invalid'); - } - else if (parseInt(this.paginasColor.val()) % 2 != 0) { - this.errores.push(window.translations["validation"].paginas_pares); - this.paginasColor.addClass('is-invalid'); - } - else { - this.paginasColor.removeClass('is-invalid'); - } - if (this.paginasNegro.val() == '' || isNaN(this.paginasNegro.val()) || parseInt(this.paginasNegro.val()) < 0) { - this.errores.push(window.translations["validation"].paginasNegro); - this.paginasNegro.addClass('is-invalid'); - } - else if (parseInt(this.paginasNegro.val()) % 2 != 0) { - this.errores.push(window.translations["validation"].paginas_pares); - this.paginasNegro.addClass('is-invalid'); - } - else { - this.paginasNegro.removeClass('is-invalid'); - } - if (this.paginas.val() == '' || isNaN(this.paginas.val()) || parseInt(this.paginas.val()) <= 0) { - this.errores.push(window.translations["validation"].paginas); - this.paginas.addClass('is-invalid'); - } else { - this.paginas.removeClass('is-invalid'); - } + this.validatePaginas(); // Tipo de libro + this.validateTipoLibro(); + + this.addErrors(); + + if (this.errores.length > 0) { + + return false; + } + else { + if (goToNext) + this.validatorStepper.next(); + else + return true; + } + } + + validateTipoLibro() { + + let noError = true; + if ($('.tipo-libro.selected').length > 0) { if ($('#cosido').hasClass('selected') || $('#grapado').hasClass('selected')) { const value = parseInt($("#paginas").val()); @@ -199,6 +198,7 @@ class DatosGenerales { if (parseInt(this.paginas.val()) % 4 != 0) { this.errores.push(window.translations["validation"].paginas_multiplo_4); this.paginas.addClass('is-invalid'); + noError = false; } else { this.paginas.removeClass('is-invalid'); } @@ -208,28 +208,49 @@ class DatosGenerales { } else { this.errores.push(window.translations["validation"].tipo_libro); this.domItem.find('#divTipoLibro').addClass('is-invalid'); + noError = false; } + } - const skAlert = document.getElementById('sk-alert'); - skAlert.innerHTML = ''; - this.errores = [...new Set(this.errores)]; + validatePaginas() { - if (this.errores.length > 0) { - const message = window.translations["validation"].fix_errors + - `
      - ${this.errores.map(err => `
    • ${err}
    • `).join('')} -
    `; - popErrorAlert(message, 'sk-alert', false); - return false; + let noError = true; + + if (this.paginasColor.val() == '' || isNaN(this.paginasColor.val()) || parseInt(this.paginasColor.val()) < 0) { + this.errores.push(window.translations["validation"].paginasColor); + this.paginasColor.addClass('is-invalid'); + noError = false; + } + else if (parseInt(this.paginasColor.val()) % 2 != 0) { + this.errores.push(window.translations["validation"].paginas_pares); + this.paginasColor.addClass('is-invalid'); + noError = false; } else { - document.getElementById('sk-alert').innerHTML = ''; - this.errores = []; - if (goToNext) - this.validatorStepper.next(); - else - return true; + this.paginasColor.removeClass('is-invalid'); } + if (this.paginasNegro.val() == '' || isNaN(this.paginasNegro.val()) || parseInt(this.paginasNegro.val()) < 0) { + this.errores.push(window.translations["validation"].paginasNegro); + this.paginasNegro.addClass('is-invalid'); + noError = false; + } + else if (parseInt(this.paginasNegro.val()) % 2 != 0) { + this.errores.push(window.translations["validation"].paginas_pares); + this.paginasNegro.addClass('is-invalid'); + noError = false; + } + else { + this.paginasNegro.removeClass('is-invalid'); + } + if (this.paginas.val() == '' || isNaN(this.paginas.val()) || parseInt(this.paginas.val()) <= 0) { + this.errores.push(window.translations["validation"].paginas); + this.paginas.addClass('is-invalid'); + noError = false; + } else { + this.paginas.removeClass('is-invalid'); + } + + return noError; } validateFormatoLibro() { @@ -637,6 +658,9 @@ class DatosGenerales { this.removeError(window.translations["validation"].papelFormatoAncho); this.removeError(window.translations["validation"].papelFormatoAlto); } + else{ + this.addErrors(); + } } #eventRetractilado(event) { @@ -655,6 +679,7 @@ class DatosGenerales { #handleTipolibro(event) { + // Accede al ID del elemento que disparó el evento const element = $(event.target); @@ -705,7 +730,13 @@ class DatosGenerales { } } - this.validate(false); + if(this.validateTipoLibro()) { + this.removeError(window.translations["validation"].tipo_libro); + this.removeError(window.translations["validation"].paginas_multiplo_4); + } + else{ + this.addErrors(); + } // Para recalcular el presupuesto $('#paginas').trigger('change'); @@ -798,6 +829,15 @@ class DatosGenerales { } $('.calcular-lomo').trigger('change'); + if(this.validatePaginas()) { + this.removeError(window.translations["validation"].paginas); + this.removeError(window.translations["validation"].paginasColor); + this.removeError(window.translations["validation"].paginasNegro); + this.removeError(window.translations["validation"].paginas_pares); + } + else{ + this.addErrors(); + } } @@ -902,21 +942,21 @@ class DatosGenerales { } } - addError(error) { + addErrors() { - if ($('#sk-alert').html() == '') { + const skAlert = document.getElementById('sk-alert'); + skAlert.innerHTML = ''; + this.errores = [...new Set(this.errores)]; + + if (this.errores.length > 0) { const message = window.translations["validation"].fix_errors + - `
      ` + - `
    • ${error}
    • ` + - `
    `; + `
      + ${this.errores.map(err => `
    • ${err}
    • `).join('')} +
    `; popErrorAlert(message, 'sk-alert', false); - return false; } - else { - $('#sk-alert').html() += - `
      ` + - `
    • ${error}
    • ` + - `
    `; + else{ + skAlert.innerHTML = ''; } } } From 33a196667e9a209507bef2773aed7380474c5869 Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Thu, 26 Jun 2025 09:34:41 +0200 Subject: [PATCH 09/12] modificado archivo de config para evitar error --- ci4/app/Config/Kint.php | 1 + 1 file changed, 1 insertion(+) diff --git a/ci4/app/Config/Kint.php b/ci4/app/Config/Kint.php index 1917f9c5..0fa50c8e 100755 --- a/ci4/app/Config/Kint.php +++ b/ci4/app/Config/Kint.php @@ -43,6 +43,7 @@ class Kint extends BaseConfig public string $richTheme = 'aante-light.css'; public bool $richFolder = false; //public int $richSort = AbstractRenderer::SORT_FULL; + public int $richSort = 0; /** * @var array>|null From 4a60bcdd615635501016e7dcc24b479ff82da3be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Fri, 27 Jun 2025 08:38:23 +0200 Subject: [PATCH 10/12] corregido el texto del error del tipo de libro y que se borre el error --- .../Presupuestos/Presupuestocliente.php | 52 +++++-------- ci4/app/Language/en/Presupuestos.php | 4 +- ci4/app/Language/es/Presupuestos.php | 2 +- .../Language/es/PresupuestosDirecciones.php | 2 + .../cliente/items/_datosGenerales.php | 6 +- .../cliente/items/_direcciones.php | 77 ++++++++++++++++++- .../components/configVariableDatatable.js | 5 +- .../presupuestoCliente/datosGenerales.js | 48 +++++++++--- 8 files changed, 147 insertions(+), 49 deletions(-) diff --git a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php index a06f93a9..fb069b7d 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php @@ -1585,7 +1585,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $modelPapelFormato = new PapelFormatoModel(); $modelCliente = new ClienteModel(); - $presupuesto = $this->model->find($id); $data = []; if ($presupuesto) { @@ -1695,7 +1694,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController if (intval($presupuesto->recoger_en_taller) == 1) { $data['direcciones']['entrega_taller'] = 1; } else { - $data['direcciones'] = $this->obtenerDireccionesEnvio($id, $presupuesto->cliente_id); + $data['direcciones'] = $this->obtenerDireccionesEnvio($id); } if (intval($presupuesto->estado_id) == 2) { @@ -3398,39 +3397,22 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController } } - protected function obtenerDireccionesEnvio($id, $cliente_id) + protected function obtenerDireccionesEnvio($id) { $model = model('App\Models\Presupuestos\PresupuestoDireccionesModel'); - $model_direcciones = model('App\Models\Clientes\ClienteDireccionesModel'); - $direcciones = $model->where('presupuesto_id', $id)->asArray()->findAll(); + $direcciones = $model->where('presupuesto_id', $id) + ->where('is_ferro_prototipo', 0)->asArray()->findAll(); return $direcciones; + } - $result = []; - $temp = []; - for ($i = 0; $i < count($direcciones); $i++) { - $direccion_id = $model_direcciones->getIdForPresupuestoCliente( - $cliente_id, - $direcciones[$i]->att, - $direcciones[$i]->email, - $direcciones[$i]->direccion, - $direcciones[$i]->cp, - $direcciones[$i]->pais_id, - $direcciones[$i]->telefono - ); - if (count($direccion_id) > 0) { - $temp = $direcciones[$i]->toArray(); - array_push($result, [ - 'id' => $temp['id'], - 'unidades' => $temp['cantidad'], - 'palets' => $temp['entregaPieCalle'], - ]); - } - } - if (count($result) > 0) - return $result; - else - return []; + protected function obtenerDireccionesEnvioFerro($id) + { + $model = model('App\Models\Presupuestos\PresupuestoDireccionesModel'); + $direcciones = $model->where('presupuesto_id', $id) + ->where('is_ferro_prototipo', 0)->asArray()->findAll(); + + return $direcciones; } protected function obtenerDatosPapel($presupuesto_id) @@ -3643,10 +3625,18 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController foreach ($data as $servicio) { $id = "service_extra_" . $servicio->id; + + $tarifa_excluyente = false; + if(str_contains(strtolower($servicio->nombre), 'ferro') || str_contains(strtolower($servicio->nombre), 'prototipo')) { + $tarifa_excluyente = true; + } + $atributo_excluyente = $tarifa_excluyente ? 'data-tarifa-extra-excluyente="1"' : ''; + array_push( $servicios, "id}\" data-tarifa-tipo=\"extra\" data-tarifa-nombre=\"{$servicio->nombre}\"> + name=\"{$id}\" value=\"1\" data-tarifa-id=\"{$servicio->id}\" data-tarifa-tipo=\"extra\" data-tarifa-nombre=\"{$servicio->nombre}\" + {$atributo_excluyente}> " ); } diff --git a/ci4/app/Language/en/Presupuestos.php b/ci4/app/Language/en/Presupuestos.php index 4823c372..f465f2ef 100755 --- a/ci4/app/Language/en/Presupuestos.php +++ b/ci4/app/Language/en/Presupuestos.php @@ -42,8 +42,8 @@ return [ 'papelFormatoAncho' => 'Width', 'papelFormatoAlto' => 'Height', 'cosido' => 'Sewn', - 'ferro' => 'Ferro', - 'ferroDigital' => 'Digital Ferro', + 'ferro' => 'Blueline proof', + 'ferroDigital' => 'Digital Blueline proof', 'prototipo' => 'Prototype', 'imagenesBnInterior' => 'B/W pictures inside', 'recogerEnTaller' => 'Pick up in workshop', diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index 9c89acbe..dae270ef 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -396,7 +396,7 @@ return [ 'paginasColor' => 'El número de páginas a color debe ser un número entero mayor o igual que 0.', 'paginasNegro' => 'El número de páginas en negro debe ser un número entero mayor o igual que 0.', 'paginas' => 'El total de páginas tiene que ser mayor que 0.', - 'tipo_libro' => 'Seleccione el tipo de libro que desea para el presupuesto.', + 'tipo_libro' => 'Seleccione el tipo de encuadernación que desea para el presupuesto.', 'decimal' => 'El campo {field} debe contener un número decimal.', 'integer' => 'El campo {field} debe contener un número entero.', 'requerido' => 'El campo {field} es obligatorio.', diff --git a/ci4/app/Language/es/PresupuestosDirecciones.php b/ci4/app/Language/es/PresupuestosDirecciones.php index fbb1be1b..16205e78 100755 --- a/ci4/app/Language/es/PresupuestosDirecciones.php +++ b/ci4/app/Language/es/PresupuestosDirecciones.php @@ -21,6 +21,8 @@ return [ 'costePrecio' => 'Coste/Precio', 'saveDirection' => 'Guardar en direcciones de cliente', 'entregaPieCalle' => 'Entrega a pie de calle (enviado en palets)', + 'sameAddPrincipal' => 'Usar la dirección principal del presupuesto', + 'sameAddFP1' => 'Usar la dirección del ferro/prototipo 1', 'validation' => [ 'ejemplares_envio' => 'El número de ejemplares enviados no coincide con la tirada', 'max_length' => 'Max. valor caracteres alcanzado', diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php index 01febb89..53de120a 100755 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php @@ -283,12 +283,12 @@
    - +
    - +
    @@ -300,7 +300,7 @@
    - +
    diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_direcciones.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_direcciones.php index 3dc42fdc..8380b378 100755 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_direcciones.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_direcciones.php @@ -62,7 +62,82 @@
    -
    +
    + +
    +
    + +
    +
    +

    Dirección de envío ferro/prototipo

    +
    + +
    +
    + + +
    + +
    + +
    +
    + +
    +
    + + +
    +
    + +
    + +
    +
    + +
    +
    +

    Dirección de envío ferro/prototipo 2

    +
    + +
    +
    + + +
    + +
    + +
    +
    + +
    +
    + + +
    +
    + +
    +
    + + +
    +
    + +
    diff --git a/httpdocs/assets/js/safekat/components/configVariableDatatable.js b/httpdocs/assets/js/safekat/components/configVariableDatatable.js index ade81e35..c1534967 100644 --- a/httpdocs/assets/js/safekat/components/configVariableDatatable.js +++ b/httpdocs/assets/js/safekat/components/configVariableDatatable.js @@ -17,9 +17,10 @@ class ConfigVariableDatatable init(){ this.datatable = this.datatableItem.DataTable({ processing: true, - dom: 'Brtip', + dom: 'Blrtip', serverSide: true, - + lengthMenu: [ 25, 50, 100, 200 ], + pageLength: 50, language: { url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" }, diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js index d41c9d91..07254345 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js @@ -103,6 +103,34 @@ class DatosGenerales { this.pagColorConsecutivas.on('change', this.#handPaginasConsecutivas.bind(this)); this.papelDiferente.on('change', this.#handlePapelDiferente.bind(this)); + // check ferro y prototipo + this.domItem.on('change', 'input[type="checkbox"][data-tarifa-extra-excluyente="1"]', (e) => { + if (!this.cargando) { + const current = $(e.target); + + if (current.is(':checked')) { + this.domItem.find('input[type="checkbox"][data-tarifa-extra-excluyente="1"]') + .not(current) + .prop('checked', false); + + if ((current.data('tarifa-nombre')?.toString().toLowerCase() || '').includes('2')) { + $('#direccionesFerroPrototipo2').removeClass('d-none'); + } + $('#direccionesFerroPrototipo').removeClass('d-none'); + } + else { + if (this.domItem.find('input[type="checkbox"][data-tarifa-extra-excluyente="1"]').prop('checked').length === 0) { + + $('#direccionesFerroPrototipo').addClass('d-none'); + $('#divDireccionesFerroPrototipo').empty(); + $('#direccionesFerroPrototipo2').addClass('d-none'); + $('#divDireccionesFerroPrototipo2').empty(); + } + } + } + }); + + $('.tirada-presupuesto').on('change', () => { @@ -110,7 +138,7 @@ class DatosGenerales { this.removeError(window.translations["validation"].tirada_integer_greatherThan_0); this.removeError(window.translations["validation"].tirada_pod_nopod); } - else{ + else { this.addErrors(); } let tiradas = self.getTiradas(); @@ -141,7 +169,7 @@ class DatosGenerales { if (this.validateCliente()) { this.removeError(window.translations["validation"].cliente); } - else{ + else { this.addErrors(); } }); @@ -176,7 +204,7 @@ class DatosGenerales { this.addErrors(); if (this.errores.length > 0) { - + return false; } else { @@ -210,6 +238,8 @@ class DatosGenerales { this.domItem.find('#divTipoLibro').addClass('is-invalid'); noError = false; } + + return noError; } validatePaginas() { @@ -658,7 +688,7 @@ class DatosGenerales { this.removeError(window.translations["validation"].papelFormatoAncho); this.removeError(window.translations["validation"].papelFormatoAlto); } - else{ + else { this.addErrors(); } } @@ -730,11 +760,11 @@ class DatosGenerales { } } - if(this.validateTipoLibro()) { + if (this.validateTipoLibro()) { this.removeError(window.translations["validation"].tipo_libro); this.removeError(window.translations["validation"].paginas_multiplo_4); } - else{ + else { this.addErrors(); } @@ -829,13 +859,13 @@ class DatosGenerales { } $('.calcular-lomo').trigger('change'); - if(this.validatePaginas()) { + if (this.validatePaginas()) { this.removeError(window.translations["validation"].paginas); this.removeError(window.translations["validation"].paginasColor); this.removeError(window.translations["validation"].paginasNegro); this.removeError(window.translations["validation"].paginas_pares); } - else{ + else { this.addErrors(); } } @@ -955,7 +985,7 @@ class DatosGenerales { `; popErrorAlert(message, 'sk-alert', false); } - else{ + else { skAlert.innerHTML = ''; } } From 410d21dc5f3fcfd18f92908ffe7fd0778c332834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Fri, 27 Jun 2025 12:44:55 +0200 Subject: [PATCH 11/12] trabajando en las direcciones ferro / prototipo --- .../PresupuestoDireccionesEntity.php | 2 + .../PresupuestoDireccionesModel.php | 3 +- .../cliente/items/_direcciones.php | 57 +++--- .../components/tarjetaDireccionPresupuesto.js | 11 +- .../pages/presupuestoCliente/direcciones.js | 176 +++++++++++------- .../presupuestoCliente/presupuestoCliente.js | 2 + 6 files changed, 159 insertions(+), 92 deletions(-) diff --git a/ci4/app/Entities/Presupuestos/PresupuestoDireccionesEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoDireccionesEntity.php index 11538041..5bde9014 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoDireccionesEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoDireccionesEntity.php @@ -26,6 +26,7 @@ class PresupuestoDireccionesEntity extends \CodeIgniter\Entity\Entity "margen" => null, "entregaPieCalle" => null, "is_ferro_prototipo" => null, + "num_ferro_prototipo" => null, ]; protected $casts = [ "presupuesto_id" => "int", @@ -40,6 +41,7 @@ class PresupuestoDireccionesEntity extends \CodeIgniter\Entity\Entity "proveedor_id" => "int", "entregaPieCalle" => "int", "is_ferro_prototipo" => "int", + "num_ferro_prototipo" => "int", ]; } diff --git a/ci4/app/Models/Presupuestos/PresupuestoDireccionesModel.php b/ci4/app/Models/Presupuestos/PresupuestoDireccionesModel.php index 15f63294..7a269872 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoDireccionesModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoDireccionesModel.php @@ -45,7 +45,8 @@ class PresupuestoDireccionesModel extends \App\Models\BaseModel "proveedor_id", "proveedor", "entregaPieCalle", - "is_ferro_prototipo" + "is_ferro_prototipo", + "num_ferro_prototipo" ]; protected $returnType = "App\Entities\Presupuestos\PresupuestoDireccionesEntity"; diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_direcciones.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_direcciones.php index 8380b378..516f6767 100755 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_direcciones.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_direcciones.php @@ -68,30 +68,35 @@ -
    +

    Dirección de envío ferro/prototipo

    +
    -
    - + +
    +
    -
    +
    +
    -
    - - +
    +
    + + +
    @@ -101,38 +106,42 @@
    -
    +

    Dirección de envío ferro/prototipo 2

    -
    -
    +
    +
    -
    -
    -
    -
    - - +
    +
    + + +
    -
    - - +
    +
    + + +
    diff --git a/httpdocs/assets/js/safekat/components/tarjetaDireccionPresupuesto.js b/httpdocs/assets/js/safekat/components/tarjetaDireccionPresupuesto.js index 7c555773..efa22e3f 100644 --- a/httpdocs/assets/js/safekat/components/tarjetaDireccionPresupuesto.js +++ b/httpdocs/assets/js/safekat/components/tarjetaDireccionPresupuesto.js @@ -1,6 +1,6 @@ class tarjetaDireccion { - constructor(container, id, direccion) { + constructor(container, id, direccion, isFerroPrototipo = false, numFerro = 0) { this.container = container; this.id = id; @@ -9,6 +9,8 @@ class tarjetaDireccion { this.deleteBtn = this.card.find('.direccion-eliminar'); this.editBtn = this.card.find('.direccion-editar'); this.direccion = direccion; + this.isFerroPrototipo = direccion.isFerroPrototipo; + this.numFerro = this.numFerro || 0; } @@ -109,6 +111,13 @@ class tarjetaDireccion { entregaPalets: this.getEntregaPalets() }; } + + getIsFerroPrototipo() { + return this.isFerroPrototipo; + } + getNumFerro() { + return this.numFerro; + } } export default tarjetaDireccion; \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js index 9720cd8c..14e43201 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js @@ -22,13 +22,21 @@ class Direcciones { this.entregaPieCallero = this.domItem.find('#entregaPieCalle'); this.direccionesCliente = new ClassSelect($("#direcciones"), '/misdirecciones/getSelect2'); + this.direccionesClienteFP1 = new ClassSelect($("#direccionesFP1"), '/misdirecciones/getSelect2'); + this.direccionesClienteFP2 = new ClassSelect($("#direccionesFP2"), '/misdirecciones/getSelect2'); this.divDirecciones = $(this.domItem.find('#divDirecciones')); this.divTiradas = this.domItem.find('#containerTiradasEnvios'); + this.sameAddPrincipalFP1 = this.domItem.find('#sameAddPrincipalFP1'); + this.sameAddPrincipalFP2 = this.domItem.find('#sameAddPrincipalFP2'); + this.sameAddFP1 = this.domItem.find('#sameAddFP1'); + this.checksTiradasEnvio = $('.check-tirada-envio'); this.direcciones = []; + this.direccionesFP1 = []; + this.direccionesFP2 = []; this.tiradaSeleccionada = null; @@ -57,6 +65,8 @@ class Direcciones { this.direccionesCliente.init(); + this.direccionesClienteFP1.init(); + this.direccionesClienteFP2.init(); this.btnAdd.on('click', this.#insertDireccion.bind(this)); this.btnNew.on('click', this.#nuevaDireccion.bind(this)); @@ -80,9 +90,14 @@ class Direcciones { self.divTiradas.trigger('change'); } }); + + this.sameAddPrincipalFP1.on('change', this.#handleSameAddPrincipalFP1.bind(this)); + this.sameAddPrincipalFP2.on('change', this.#handleSameAddPrincipalFP2.bind(this)); + this.sameAddFP1.on('change', this.#handleSameAddFP1.bind(this)); } + cargarDatos(datos, datosGenerales) { self = this; @@ -223,72 +238,6 @@ class Direcciones { } } - initValidation() { - - const stepper = this.validatorStepper; - - this.formValidation = FormValidation.formValidation(this.wizardStep, { - fields: { - div_error_envios: { - validators: { - callback: { - callback: () => { - - - div.find('.fv-plugins-message-container').remove(); - - if ($('.check-tirada-envio:checked').length > 0) { - let unidades = parseInt($($('.check-tirada-envio:checked')[0]).attr('tirada')); - let total_envio = 0; - // se recorre el array this.direcciones - this.direcciones.forEach(direccion => { - total_envio += parseInt(direccion.getUnidades()); - }); - if (total_envio <= unidades) { - return true; - } - } - - div.append(` -
    -
    - El total de unidades enviadas no puede ser mayor que la tirada seleccionada -
    -
    - `); - return false; - }, - } - - } - } - }, - plugins: { - trigger: new FormValidation.plugins.Trigger(), - bootstrap5: new FormValidation.plugins.Bootstrap5({ - // Use this for enabling/changing valid/invalid class - // eleInvalidClass: '', - eleValidClass: '', - rowSelector: function (field, ele) { - // field is the field name - // ele is the field element - switch (field) { - case 'div_error_envios': - return '.col-sm-10'; - default: - return '.col-sm-3'; - } - } - }), - autoFocus: new FormValidation.plugins.AutoFocus(), - submitButton: new FormValidation.plugins.SubmitButton() - } - }).on('core.form.valid', () => { - if (this.allowNext) - stepper.next(); - }); - } - insertTirada(tirada) { @@ -449,6 +398,10 @@ class Direcciones { this.direccionesCliente.setParams({ 'cliente_id': $("#clienteId").select2('data')[0].id }) this.direccionesCliente.empty(); + this.direccionesClienteFP1.setParams({ 'cliente_id': $("#clienteId").select2('data')[0].id }) + this.direccionesClienteFP1.empty(); + this.direccionesClienteFP2.setParams({ 'cliente_id': $("#clienteId").select2('data')[0].id }) + this.direccionesClienteFP2.empty(); this.domItem.find('.direccion-cliente').remove(); this.direcciones = []; @@ -500,6 +453,97 @@ class Direcciones { this.divDirecciones.trigger('change'); } + #handleSameAddPrincipalFP1() { + + if (this.sameAddPrincipalFP2.is(':checked')) { + $('.div-direcciones-fp1').addClass('d-none'); + $('#divDireccionesFerroPrototipo').empty(); + if (this.direcciones.length > 0) { + // get first element + let firstDireccion = this.direcciones[0]; + let tarjeta = new tarjetaDireccion( + $("#divDireccionesFerroPrototipo"), + 'dirEnvio-FP-1', + firstDireccion.getData(), true, 1); + tarjeta.setUnidades(1); + $('#divDireccionesFerroPrototipo').append(tarjeta.card); + this.direccionesFP1 = []; + this.direccionesFP1.push(tarjeta); + $('#divDireccionesFerroPrototipo').removeClass('d-none'); + } + else { + // mostrar alerta de que no hay direcciones + } + + } + else { + $('.div-direcciones-fp1').removeClass('d-none'); + $('#divDireccionesFerroPrototipo').removeClass('d-none'); + $('#divDireccionesFerroPrototipo').empty(); + } + } + + #handleSameAddPrincipalFP2() { + + if (this.sameAddPrincipalFP2.is(':checked')) { + $('.div-direcciones-fp2').addClass('d-none'); + $('#divDireccionesFerroPrototipo2').empty(); + if (this.direcciones.length > 0) { + // get first element + let firstDireccion = this.direcciones[0]; + let tarjeta = new tarjetaDireccion( + $("#divDireccionesFerroPrototipo2"), + 'dirEnvio-FP-2', + firstDireccion.getData(), true, 1); + tarjeta.setUnidades(1); + $('#divDireccionesFerroPrototipo2').append(tarjeta.card); + this.direccionesFP2 = []; + this.direccionesFP2.push(tarjeta); + $('#divDireccionesFerroPrototipo2').removeClass('d-none'); + } + else { + // mostrar alerta de que no hay direcciones + } + + } + else { + $('.div-direcciones-fp2').removeClass('d-none'); + $('#divDireccionesFerroPrototipo2').removeClass('d-none'); + $('#divDireccionesFerroPrototipo2').empty(); + } + } + + #handleSameAddFP1() { + + if (this.sameAddFP1.is(':checked')) { + $('.div-direcciones-fp2').addClass('d-none'); + $('#divDireccionesFerroPrototipo2').empty(); + if (this.direccionesFP1.length > 0) { + // get first element + let firstDireccion = this.direccionesFP1[0]; + let tarjeta = new tarjetaDireccion( + $("#divDireccionesFerroPrototipo2"), + 'dirEnvio-FP-2', + firstDireccion.getData(), true, 1); + tarjeta.setUnidades(1); + $('#divDireccionesFerroPrototipo2').append(tarjeta.card); + this.direccionesFP2 = []; + this.direccionesFP2.push(tarjeta); + $('#divDireccionesFerroPrototipo2').removeClass('d-none'); + } + else { + // mostrar alerta de que no hay direcciones + } + + } + else { + $('.div-direcciones-fp2').removeClass('d-none'); + $('#divDireccionesFerroPrototipo2').removeClass('d-none'); + $('#divDireccionesFerroPrototipo2').empty(); + } + } + + getSelectedTirada() { if ($('.check-tirada-envio:checked').length > 0) return parseInt($($('.check-tirada-envio:checked')[0]).attr('tirada')); diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js index 21daec53..67f654cd 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js @@ -86,6 +86,8 @@ class PresupuestoCliente { if (this.datosGenerales.excluirRotativa.length == 0) { this.direcciones.direccionesCliente.setParams({ 'cliente_id': $("#clienteId").val() }) + this.direcciones.direccionesClienteFP1.setParams({ 'cliente_id': $("#clienteId").val() }) + this.direcciones.direccionesClienteFP2.setParams({ 'cliente_id': $("#clienteId").val() }) } From 9fcda514f0d78872646e54ddfa48bb6651de0103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Sat, 28 Jun 2025 11:27:39 +0200 Subject: [PATCH 12/12] guardando direcciones ferro en presupuesto cliente --- ci4/app/Config/Routes.php | 1 + .../Clientes/Clientedirecciones.php | 59 ++++- .../Presupuestos/Presupuestocliente.php | 24 +- ...06-27-113000_DireccionesFerroPrototipo.php | 30 +++ httpdocs/assets/js/safekat/components/ajax.js | 70 ++++-- .../components/tarjetaDireccionPresupuesto.js | 15 +- .../pages/presupuestoCliente/direcciones.js | 232 ++++++++++++------ .../presupuestoCliente/presupuestoCliente.js | 13 + 8 files changed, 324 insertions(+), 120 deletions(-) create mode 100644 ci4/app/Database/Migrations/2025-06-27-113000_DireccionesFerroPrototipo.php diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 471136c8..bd702019 100755 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -319,6 +319,7 @@ $routes->group('clienteusuarios', ['namespace' => 'App\Controllers\Clientes'], f $routes->group('misdirecciones', ['namespace' => 'App\Controllers\Clientes'], function ($routes) { $routes->get('', 'Clientedirecciones::index', ['as' => 'clientedireccionesIndex']); $routes->get('get/(:num)', 'Clientedirecciones::get/$1', ['as' => 'get']); + $routes->get('getId', 'Clientedirecciones::getDireccionIdFromData'); $routes->get('getDireccionPresupuesto/(:num)', 'Clientedirecciones::getDireccionPresupuesto/$1', ['as' => 'getDireccionPresupuesto']); $routes->post('add', 'Clientedirecciones::add', ['as' => 'newClientedirecciones']); $routes->get('getSelect2', 'Clientedirecciones::getSelect2', ['as' => 'listaClientedirecciones']); diff --git a/ci4/app/Controllers/Clientes/Clientedirecciones.php b/ci4/app/Controllers/Clientes/Clientedirecciones.php index 2979bd10..5efbee06 100755 --- a/ci4/app/Controllers/Clientes/Clientedirecciones.php +++ b/ci4/app/Controllers/Clientes/Clientedirecciones.php @@ -215,13 +215,13 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController { try { $resourceData = $this->model->getDireccion($id); - $response = (object)[ + $response = (object) [ 'error' => false, 'data' => $resourceData ]; return $this->respond($response); } catch (\Exception $e) { - $response = (object)[ + $response = (object) [ 'error' => true, 'message' => $e->getMessage() ]; @@ -229,22 +229,61 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController } } + public function getDireccionIdFromData() + { + $data = $this->request->getGet('data') ?? []; + $cliente_id = $this->request->getGet('cliente_id') ?? -1; + $att = $data['att'] ?? ""; + $direccion = $data['direccion'] ?? ""; + $cp = $data['cp'] ?? ""; + $municipio = $data['municipio'] ?? ""; + $provincia = $data['provincia'] ?? ""; + $pais_id = $data['pais_id'] ?? -1; + $email = $data['email'] ?? ""; + $telefono = $data['telefono'] ?? ""; + try { + $model = model('App\Models\Clientes\ClienteDireccionesModel'); + $id = $model->select('id') + ->where('att', $att) + ->where('direccion', $direccion) + ->where('cp', $cp) + ->where('municipio', $municipio) + ->where('provincia', $provincia) + ->where('pais_id', $pais_id) + ->where('email', $email) + ->where('telefono', $telefono) + ->where('cliente_id', $cliente_id) + ->get() + ->getResultObject(); + + if (count($id) > 0) { + $id = $id[0]->id; + } else { + $id = null; + } + return $id; + + } catch (\Exception $e) { + throw new \RuntimeException($e->getMessage()); + } + } + public function getDireccionPresupuesto($id) { try { $model = model('App\Models\Presupuestos\PresupuestoDireccionesModel'); $resourceData = $model->getDireccion($id); - if(count($resourceData) > 0){ + if (count($resourceData) > 0) { $resourceData[0]->direccionId = $id; } - - $response = (object)[ + + $response = (object) [ 'error' => false, 'data' => $resourceData ]; return $this->respond($response); } catch (\Exception $e) { - $response = (object)[ + $response = (object) [ 'error' => true, 'message' => $e->getMessage() ]; @@ -400,11 +439,11 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController protected function getComunidadAutonomaListItems($selId = null) { $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('ComunidadesAutonomas.comunidadAutonoma'))])]; - if (!is_null($selId)) : + if (!is_null($selId)): $comunidadAutonomaModel = model('App\Models\Configuracion\ComunidadAutonomaModel'); $selOption = $comunidadAutonomaModel->where('id', $selId)->findColumn('nombre'); - if (!empty($selOption)) : + if (!empty($selOption)): $data[$selId] = $selOption[0]; endif; endif; @@ -414,11 +453,11 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController protected function getProvinciaListItems($selId = null) { $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Provincias.provincia'))])]; - if (!empty($selId)) : + if (!empty($selId)): $provinciaModel = model('App\Models\Configuracion\ProvinciaModel'); $selOption = $provinciaModel->where('id', $selId)->findColumn('nombre'); - if (!empty($selOption)) : + if (!empty($selOption)): $data[$selId] = $selOption[0]; endif; endif; diff --git a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php index fb069b7d..60c3c251 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php @@ -1065,6 +1065,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $direcciones = $reqData['direcciones'] ?? []; + $direccionesFP1 = $reqData['direccionesFP1'] ?? []; + $direccionesFP2 = $reqData['direccionesFP2'] ?? []; + if ($tipo != "") $tipo_impresion_id = $this->getTipoImpresion($tipo, $cubierta['tipoCubierta']); else @@ -1557,6 +1560,14 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController } } + if (count($direccionesFP1) > 0) { + $this->guardarLineaEnvio($id, $direccionesFP1, $peso_libro, true); + + } + if (count($direccionesFP2) > 0) { + $this->guardarLineaEnvio($id, $direccionesFP2, $peso_libro, true); + } + if ($confirmar) { $model_presupuesto->confirmarPresupuesto($id); PresupuestoService::crearPedido($id); @@ -1860,12 +1871,13 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController } - protected function guardarLineaEnvio($presupuestoId, $direccion, $peso_libro) + protected function guardarLineaEnvio($presupuestoId, $direccion, $peso_libro, $coste_cero = false) { $unidades = intval($direccion['unidades']); $peso_envio = $peso_libro * $unidades / 1000.0; + $data = $this->getCosteEnvio( $direccion['direccion'], $peso_libro, @@ -1879,7 +1891,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $data->presupuesto_id = $presupuestoId; $data->tarifa_id = $data->id; unset($data->id); - $data->precio = $data->coste; + if($coste_cero) { + $data->coste = 0; + } else { + $data->precio = $data->coste; + } unset($data->coste); $data->entregaPieCalle = ($direccion['entregaPalets'] == 'false' || $direccion['entregaPalets'] == 0) ? 0 : 1; unset($data->tipo); @@ -3625,9 +3641,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController foreach ($data as $servicio) { $id = "service_extra_" . $servicio->id; - + $tarifa_excluyente = false; - if(str_contains(strtolower($servicio->nombre), 'ferro') || str_contains(strtolower($servicio->nombre), 'prototipo')) { + if (str_contains(strtolower($servicio->nombre), 'ferro') || str_contains(strtolower($servicio->nombre), 'prototipo')) { $tarifa_excluyente = true; } $atributo_excluyente = $tarifa_excluyente ? 'data-tarifa-extra-excluyente="1"' : ''; diff --git a/ci4/app/Database/Migrations/2025-06-27-113000_DireccionesFerroPrototipo.php b/ci4/app/Database/Migrations/2025-06-27-113000_DireccionesFerroPrototipo.php new file mode 100644 index 00000000..de982a31 --- /dev/null +++ b/ci4/app/Database/Migrations/2025-06-27-113000_DireccionesFerroPrototipo.php @@ -0,0 +1,30 @@ +forge->addColumn('presupuesto_direcciones', [ + 'num_ferro_prototipo' => [ + 'type' => 'INT', + 'constraint' => 3, + 'null' => false, + 'default' => '0', + 'description' => 'numero de ferro/prototipo', + ], + ]); + + } + + public function down() + { + $this->db->table('presupuesto_direcciones')->whereIn('name', [ + 'num_ferro_prototipo', + 'lomo_maximo_wireo' + ])->delete(); + } +} diff --git a/httpdocs/assets/js/safekat/components/ajax.js b/httpdocs/assets/js/safekat/components/ajax.js index 9e8be0bc..8a92c701 100644 --- a/httpdocs/assets/js/safekat/components/ajax.js +++ b/httpdocs/assets/js/safekat/components/ajax.js @@ -1,24 +1,24 @@ -class Ajax{ - constructor(url, data, headers, success, error, type='default'){ - this.url = url; - this.data = data; - this.headers = headers; - this.success = success; - this.error = error; - this.type = type; - this.jqXHR = null; - } - post(){ - (this.type == 'default') ? this.ajax('POST'): this.ajaxForm('POST'); +class Ajax { + constructor(url, data, headers, success, error, type = 'default') { + this.url = url; + this.data = data; + this.headers = headers; + this.success = success; + this.error = error; + this.type = type; + this.jqXHR = null; } - get(){ + post() { + (this.type == 'default') ? this.ajax('POST') : this.ajaxForm('POST'); + } + get() { this.ajax('GET'); } - put(){ - (this.type == 'default') ? this.ajax('PUT'): this.ajaxForm('PUT'); + put() { + (this.type == 'default') ? this.ajax('PUT') : this.ajaxForm('PUT'); } - delete(){ - (this.type == 'default') ? this.ajax('DELETE'): this.ajaxForm('DELETE'); + delete() { + (this.type == 'default') ? this.ajax('DELETE') : this.ajaxForm('DELETE'); } abort() { if (this.jqXHR) { @@ -26,31 +26,31 @@ class Ajax{ this.jqXHR = null; // Limpiamos la referencia a la petición } } - setData(data){ + setData(data) { this.data = data; } - ajax(method){ + ajax(method) { if (this.jqXHR) { this.jqXHR.abort(); } this.jqXHR = $.ajax({ - url : this.url, - type : method, + url: this.url, + type: method, data: this.data, headers: this.headers, success: this.success, error: this.error }) } - ajaxForm(method){ + ajaxForm(method) { if (this.jqXHR) { this.jqXHR.abort(); } this.jqXHR = $.ajax({ - url : this.url, - type : method, + url: this.url, + type: method, data: this.data, processData: false, contentType: false, @@ -59,6 +59,28 @@ class Ajax{ error: this.error }) } + getPromise() { + if (this.jqXHR) { + this.jqXHR.abort(); + } + + return new Promise((resolve, reject) => { + this.jqXHR = $.ajax({ + url: this.url, + type: 'GET', + data: this.data, + headers: this.headers, + success: (response) => { + if (this.success) this.success(response); + resolve(response); + }, + error: (xhr) => { + if (this.error) this.error(xhr); + reject(xhr); + } + }); + }); + } } export default Ajax \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/components/tarjetaDireccionPresupuesto.js b/httpdocs/assets/js/safekat/components/tarjetaDireccionPresupuesto.js index efa22e3f..96763d04 100644 --- a/httpdocs/assets/js/safekat/components/tarjetaDireccionPresupuesto.js +++ b/httpdocs/assets/js/safekat/components/tarjetaDireccionPresupuesto.js @@ -5,12 +5,13 @@ class tarjetaDireccion { this.container = container; this.id = id; this.direccionId = direccion.id; + this.direccion = direccion; + this.isFerroPrototipo = isFerroPrototipo; + this.numFerro = numFerro || 0; this.card = this.#generateHTML(id, direccion); this.deleteBtn = this.card.find('.direccion-eliminar'); this.editBtn = this.card.find('.direccion-editar'); - this.direccion = direccion; - this.isFerroPrototipo = direccion.isFerroPrototipo; - this.numFerro = this.numFerro || 0; + } @@ -40,7 +41,13 @@ class tarjetaDireccion { var $hr = $('
    ', { class: 'my-2' }); var $eliminar = $('', { class: 'ms-auto direccion-eliminar', href: 'javascript:void(0)', text: 'Eliminar' }); var $editar = $('', { class: 'me-auto direccion-editar', href: 'javascript:void(0)', text: 'Editar' }); - var $eliminarContainer = $('', { class: 'd-flex w-100 position-relative' }).append($editar, $eliminar); + var $eliminarContainer = ''; + if(!this.isFerroPrototipo) { + $eliminarContainer = $('', { class: 'd-flex w-100 position-relative' }).append($editar, $eliminar); + } + else{ + $eliminarContainer = $('', { class: 'd-flex w-100 position-relative' }).append($eliminar); + } // Construir la estructura del HTML $header.append($name, $unidades); diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js index 14e43201..ca4a2d74 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js @@ -70,6 +70,13 @@ class Direcciones { this.btnAdd.on('click', this.#insertDireccion.bind(this)); this.btnNew.on('click', this.#nuevaDireccion.bind(this)); + $('#insertarDireccionFP1').on('click', () => { + this.#insertDireccionFP(1); + }); + $('#insertarDireccionFP2').on('click', () => { + this.#insertDireccionFP(2); + }); + // evento para actualizar el selector de tiradas $(document).on('update-tiradas-envios', (event, data) => { self.divTiradas.empty(); @@ -165,29 +172,6 @@ class Direcciones { tarjeta.card.find('.direccion-eliminar').on('click', this.#deleteDireccion.bind(self)); this.divDirecciones.append(tarjeta.card); this.direcciones.push(tarjeta); - - /*let peticion = new Ajax('/misdirecciones/getDireccionPresupuesto/' + id, {}, {}, - (response) => { - let divId = "dirEnvio-1"; - let direccionesActuales = this.divDirecciones.find('.direccion-cliente'); - if (direccionesActuales.length > 0) { - // the the lass item - let last = direccionesActuales[direccionesActuales.length - 1]; - divId = "dirEnvio-" + (parseInt(last.id.split('-')[1]) + 1); - } - let tarjeta = new tarjetaDireccion(this.divDirecciones, divId, response.data[0]); - tarjeta.setUnidades(unidades); - tarjeta.setEntregaPalets(entregaPalets); - tarjeta.card.find('.direccion-editar').on('click', this.#editUnits.bind(self)); - tarjeta.card.find('.direccion-eliminar').on('click', this.#deleteDireccion.bind(self)); - this.divDirecciones.append(tarjeta.card); - this.direcciones.push(tarjeta); - }, - () => { - console.error('Error getting address'); - }); - - peticion.get();*/ } } } catch (e) { @@ -357,42 +341,107 @@ class Direcciones { return; } } + this.#addTarjetaDireccion(this.divDirecciones, this.direcciones, divId, id, unidades, entregaPalets); - $('#loader').modal('show'); - let peticion = new Ajax('/misdirecciones/get/' + id, {}, {}, - (response) => { - - if (this.direcciones.length == 0) { - $('#loader').modal('hide'); - if (entregaPalets) { - this.calcularPresupuesto = true; - } - } - else { - this.calcularPresupuesto = true; - } - let tarjeta = new tarjetaDireccion(this.divDirecciones, divId, response.data[0]); - tarjeta.setUnidades(unidades); - tarjeta.setEntregaPalets(entregaPalets); - tarjeta.card.find('.direccion-editar').on('click', this.#editUnits.bind(self)); - tarjeta.card.find('.direccion-eliminar').on('click', this.#deleteDireccion.bind(self)); - this.divDirecciones.append(tarjeta.card); - this.direcciones.push(tarjeta); - self.divDirecciones.trigger('change'); - - }, - () => { - console.error('Error getting address'); - $('#loader').modal('hide'); - }); - - peticion.get(); } catch (e) { console.error(e); $('#loader').modal('hide'); } } + #insertDireccionFP(num_ferroPrototipo) { + + self = this; + + try { + + let id = 0; + if( num_ferroPrototipo === 1) { + id = this.direccionesClienteFP1.getVal(); + } + if( num_ferroPrototipo === 2) { + id = this.direccionesClienteFP2.getVal(); + } + let unidades = 1; + + if (id == null || id <= 0 || id == undefined) + return; + + let divId = "dirEnvio-FP-" + num_ferroPrototipo; + let containerId = num_ferroPrototipo === 1 ? "#divDireccionesFerroPrototipo" : "#divDireccionesFerroPrototipo2"; + let arrayName = num_ferroPrototipo === 1 ? this.direccionesFP1 : this.direccionesFP2; + + this.#addTarjetaDireccion( + $(containerId), + arrayName, + divId, + id, + 1, false, true, num_ferroPrototipo); + + $('.div-direcciones-fp' + num_ferroPrototipo).addClass('d-none'); + + } catch (e) { + console.error(e); + $('#loader').modal('hide'); + } + } + + async #addTarjetaDireccion(container, addArray, divId, data, unidades, entregaPalets = false, isFerroPrototipo = false, numFerroPrototipo = 0) { + const self = this; + + let id = data; + + try { + if (typeof data === 'object') { + const ajaxGetId = new Ajax('/misdirecciones/getId', { + data: data, + cliente_id: $("#clienteId").select2('data')[0].id + }, {}, null, null); + const response = await ajaxGetId.getPromise(); + id = response; + } + + $('#loader').modal('show'); + + const ajaxGetDireccion = new Ajax('/misdirecciones/get/' + id, {}, {}, null, null); + const response = await ajaxGetDireccion.getPromise(); + + if (this.direcciones.length === 0) { + $('#loader').modal('hide'); + if (entregaPalets) { + this.calcularPresupuesto = true; + } + } else { + this.calcularPresupuesto = true; + } + + const tarjeta = new tarjetaDireccion(container, divId, response.data[0], isFerroPrototipo, numFerroPrototipo); + tarjeta.setUnidades(unidades); + tarjeta.setEntregaPalets(entregaPalets); + + if (!isFerroPrototipo) { + tarjeta.card.find('.direccion-eliminar').on('click', this.#deleteDireccion.bind(self)); + tarjeta.card.find('.direccion-editar').on('click', this.#editUnits.bind(self)); + } + else { + tarjeta.card.find('.direccion-eliminar').on('click', (event) => { + this.#deleteDireccionFP(event, numFerroPrototipo); + $('.div-direcciones-fp' + numFerroPrototipo).removeClass('d-none'); + }); + } + container.append(tarjeta.card); + addArray.push(tarjeta); + container.trigger('change'); + + } catch (err) { + console.error('Error en petición Ajax:', err); + $('#loader').modal('hide'); + } + } + + + + handleChangeCliente() { @@ -453,22 +502,43 @@ class Direcciones { this.divDirecciones.trigger('change'); } + #deleteDireccionFP(event, num_ferroPrototipo = 1) { + + let tarjeta = event.currentTarget.closest('.direccion-cliente'); + + this.calcularPresupuesto = true; + + if (num_ferroPrototipo === 1) { + this.direccionesFP1 = []; + this.sameAddPrincipalFP1.prop('checked', false); + $('#divDireccionesFerroPrototipo1').trigger('change'); + } + if (num_ferroPrototipo === 2) { + this.direccionesFP2 = []; + this.sameAddPrincipalFP2.prop('checked', false); + this.sameAddFP1.prop('checked', false); + $('#divDireccionesFerroPrototipo2').trigger('change'); + } + + tarjeta.remove(); + } + #handleSameAddPrincipalFP1() { - if (this.sameAddPrincipalFP2.is(':checked')) { + if (this.sameAddPrincipalFP1.is(':checked')) { $('.div-direcciones-fp1').addClass('d-none'); $('#divDireccionesFerroPrototipo').empty(); if (this.direcciones.length > 0) { // get first element - let firstDireccion = this.direcciones[0]; - let tarjeta = new tarjetaDireccion( - $("#divDireccionesFerroPrototipo"), - 'dirEnvio-FP-1', - firstDireccion.getData(), true, 1); - tarjeta.setUnidades(1); - $('#divDireccionesFerroPrototipo').append(tarjeta.card); + let data = this.direcciones[0].getDireccion(); + this.direccionesFP1 = []; - this.direccionesFP1.push(tarjeta); + this.#addTarjetaDireccion( + $("#divDireccionesFerroPrototipo"), + this.direccionesFP1, + 'dirEnvio-FP-1', + data, + 1, false, true, 1); $('#divDireccionesFerroPrototipo').removeClass('d-none'); } else { @@ -486,19 +556,21 @@ class Direcciones { #handleSameAddPrincipalFP2() { if (this.sameAddPrincipalFP2.is(':checked')) { + if(this.sameAddFP1.is(':checked')) { + this.sameAddFP1.prop('checked', false); + } $('.div-direcciones-fp2').addClass('d-none'); $('#divDireccionesFerroPrototipo2').empty(); if (this.direcciones.length > 0) { - // get first element - let firstDireccion = this.direcciones[0]; - let tarjeta = new tarjetaDireccion( - $("#divDireccionesFerroPrototipo2"), - 'dirEnvio-FP-2', - firstDireccion.getData(), true, 1); - tarjeta.setUnidades(1); - $('#divDireccionesFerroPrototipo2').append(tarjeta.card); + + let data = this.direcciones[0].getDireccion(); this.direccionesFP2 = []; - this.direccionesFP2.push(tarjeta); + this.#addTarjetaDireccion( + $("#divDireccionesFerroPrototipo2"), + this.direccionesFP2, + 'dirEnvio-FP-2', + data, + 1, false, true, 2); $('#divDireccionesFerroPrototipo2').removeClass('d-none'); } else { @@ -516,19 +588,23 @@ class Direcciones { #handleSameAddFP1() { if (this.sameAddFP1.is(':checked')) { + if(this.sameAddPrincipalFP2.is(':checked')) { + this.sameAddPrincipalFP2.prop('checked', false); + } $('.div-direcciones-fp2').addClass('d-none'); $('#divDireccionesFerroPrototipo2').empty(); if (this.direccionesFP1.length > 0) { - // get first element - let firstDireccion = this.direccionesFP1[0]; - let tarjeta = new tarjetaDireccion( + + let data = this.direccionesFP1[0].getDireccion(); + + this.direccionesFP1 = []; + this.#addTarjetaDireccion( $("#divDireccionesFerroPrototipo2"), + this.direccionesFP2, 'dirEnvio-FP-2', - firstDireccion.getData(), true, 1); - tarjeta.setUnidades(1); - $('#divDireccionesFerroPrototipo2').append(tarjeta.card); - this.direccionesFP2 = []; - this.direccionesFP2.push(tarjeta); + data, + 1, false, true, 2); + $('#divDireccionesFerroPrototipo2').removeClass('d-none'); } else { diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js index 67f654cd..46768cdc 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js @@ -793,6 +793,19 @@ class PresupuestoCliente { }; } } + + if( this.direcciones.direccionesFP1.length > 0) { + this.datos.direccionesFP1 = this.direcciones.direccionesFP1.map((direccion) => { + return direccion.getFormData(); + }); + } + + if( this.direcciones.direccionesFP2.length > 0) { + this.datos.direccionesFP2 = this.direcciones.direccionesFP2.map((direccion) => { + return direccion.getFormData(); + }); + } + if (save) { this.datos.datosCabecera = { titulo: this.datosGenerales.titulo.val(),