mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
carga de checks de misma direccion FP implementados en presupuesto cliente
This commit is contained in:
@ -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(
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class ConfigDireccionesFerroPrototipo extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->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');
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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')
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user