diff --git a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php index 7949c4f0..55970f1d 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php @@ -1381,6 +1381,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $datos_presupuesto['faja'] = $faja; + $reqData['datosCabecera'] ?? []; + $datos_presupuesto['direcciones_fp_checks'] = $reqData['direcciones_fp_checks'] ?? null; + $id = $model_presupuesto->insertarPresupuestoCliente( $id, $selected_tirada, @@ -1713,6 +1716,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $data['direccionesFerroPrototipo'] = $direccionesFerroPrototipo; } + $data['direccionesFPChecks'] = $presupuesto->getDireccionFPChecks(); + if (intval($presupuesto->estado_id) == 2) { $data['resumen']['base'] = $presupuesto->total_antes_descuento; $data['resumen']['total_envio'] = round( diff --git a/ci4/app/Database/Migrations/2025-06-28-194500_ConfigDireccionesFerroPrototipo.php b/ci4/app/Database/Migrations/2025-06-28-194500_ConfigDireccionesFerroPrototipo.php new file mode 100644 index 00000000..e0727199 --- /dev/null +++ b/ci4/app/Database/Migrations/2025-06-28-194500_ConfigDireccionesFerroPrototipo.php @@ -0,0 +1,24 @@ +forge->addColumn('presupuestos', [ + 'direcciones_fp_checks' => [ + 'type' => 'JSON', + 'null' => false, + 'default' => '{"addFP1isAddMain": "0", "addFP2isAddMain": "0", "addFP2isaddFP1": "0"}', + 'comment' => 'valores de los checks de las direcciones ferro/prototipo', + ], + ]); + } + + public function down() + { + $this->forge->dropColumn('presupuestos', 'direcciones_fp_checks'); + } +} diff --git a/ci4/app/Entities/Presupuestos/PresupuestoEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoEntity.php index c7d0edc3..e0f5f9cc 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoEntity.php @@ -116,6 +116,12 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity 'lomo_redondo' => null, 'cabezada' => null, 'envio_base' => null, + 'direcciones_fp_checks' => [ + 'addFP1isAddMain' => "0", + 'addFP2isAddMain' => "0", + 'addFP2isaddFP1' => "0" + ], + ]; protected $casts = [ "cliente_id" => "int", @@ -188,6 +194,7 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity 'papel_interior_diferente' => "boolean", 'paginasCuadernillo' => "int", 'lomo_redondo' => "boolean", + 'direcciones_fp_checks' => 'json', ]; /** * Devuelve la entity con un campo `presupuesto_lineas` con las lineas de presupuesto asociadas @@ -324,4 +331,15 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity } return $tipo_presupuesto; } + + public function getDireccionFPChecks() + { + return $this->attributes['direcciones_fp_checks'] ?? []; + } + + public function setDireccionFPChecks($value) + { + $this->attributes['direcciones_fp_checks'] = is_array($value) ? json_encode($value) : $value; + return $this; + } } diff --git a/ci4/app/Models/Presupuestos/PresupuestoModel.php b/ci4/app/Models/Presupuestos/PresupuestoModel.php index d4689b02..6b5e9d42 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoModel.php @@ -138,6 +138,7 @@ class PresupuestoModel extends \App\Models\BaseModel 'lomo_redondo', 'cabezada', 'envio_base', + 'direcciones_fp_checks', ]; protected $returnType = "App\Entities\Presupuestos\PresupuestoEntity"; @@ -525,6 +526,8 @@ class PresupuestoModel extends \App\Models\BaseModel 'iva_reducido' => $iva_reducido, 'excluir_rotativa' => $excluir_rotativa, + 'direcciones_fp_checks' => $data['direcciones_fp_checks'] ? json_encode($data['direcciones_fp_checks']) : null, + ]; /* Actualizacion */ if ($id != 0) { diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js index 58415511..bcc21c6d 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js @@ -105,7 +105,7 @@ class Direcciones { - cargarDatos(datos, datosGenerales, direccionesFP = []) { + cargarDatos(datos, datosGenerales, direccionesFP = [], direccionesFPChecks = {}) { self = this; @@ -130,7 +130,6 @@ class Direcciones { }); }, 0); - $('#tiradaEnvios-' + datosGenerales.selectedTirada).trigger('click'); if (datos.entrega_taller == 1) { @@ -198,6 +197,17 @@ class Direcciones { }); } + + if(direccionesFPChecks.addFP1isAddMain && direccionesFPChecks.addFP1isAddMain === "true") { + this.sameAddPrincipalFP1.prop('checked', true); + } + + if (direccionesFPChecks.addFP2isFP1 && direccionesFPChecks.addFP2isFP1 === "true") { + this.sameAddFP1.prop('checked', true); + } + else if( direccionesFPChecks.addFP2isAddMain && direccionesFPChecks.addFP2isAddMain === "true") { + this.sameAddPrincipalFP2.prop('checked', true); + } } catch (e) { console.error(e); $('#loader').modal('hide'); @@ -684,6 +694,14 @@ class Direcciones { else return null; } + + getDireccionesFPChecks() { + return { + addFP1isAddMain: this.sameAddPrincipalFP1.is(':checked'), + addFP2isAddMain: this.sameAddPrincipalFP2.is(':checked'), + addFP2isFP1: this.sameAddFP1.is(':checked') + }; + } } diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js index fea4333e..c98fd81f 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js @@ -801,7 +801,6 @@ class PresupuestoCliente { } if( this.direcciones.direccionesFP1.length > 0) { - this.datos.direccionesFP1 = this.direcciones.direccionesFP1[0].getFormData(); } @@ -809,6 +808,8 @@ class PresupuestoCliente { this.datos.direccionesFP2 = this.direcciones.direccionesFP2[0].getFormData(); } + this.datos.direcciones_fp_checks = this.direcciones.getDireccionesFPChecks(); + if (save) { this.datos.datosCabecera = { titulo: this.datosGenerales.titulo.val(), @@ -848,8 +849,9 @@ class PresupuestoCliente { self.direcciones.handleChangeCliente(); self.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales, - response.data.direccionesFerroPrototipo && response.data.direccionesFerroPrototipo.length > 0 ? - response.data.direccionesFerroPrototipo : [] + (response.data.direccionesFerroPrototipo && response.data.direccionesFerroPrototipo.length > 0) ? + response.data.direccionesFerroPrototipo : [] , + response.data.direccionesFPChecks ? JSON.parse(response.data.direccionesFPChecks) : {} ); try {