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] 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() }) }