mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en editar y rellenar el presupuesto
This commit is contained in:
@ -102,6 +102,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$datosPresupuesto->acabadosCubierta = $this->getAcabadosCubierta();
|
||||
$datosPresupuesto->acabadosSobrecubierta = $this->getAcabadosSobrecubierta();
|
||||
|
||||
$datosPresupuesto->tipo_libro = "";
|
||||
$datosPresupuesto->color_impresion = 'negro';
|
||||
$datosPresupuesto->calidad_impresion = 'estandar';
|
||||
$datosPresupuesto->tapa = 'blanda';
|
||||
|
||||
$datosPresupuesto->clienteList = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null);
|
||||
|
||||
$this->viewData['formAction'] = route_to('crearPresupuestoCliente');
|
||||
@ -152,6 +157,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$datosPresupuesto->acabadosCubierta = $this->getAcabadosCubierta();
|
||||
$datosPresupuesto->acabadosSobrecubierta = $this->getAcabadosSobrecubierta();
|
||||
|
||||
$datosPresupuesto->tipo_libro = $this->getTipoLibro($presupuestoEntity->tipo_impresion_id ?? null);
|
||||
[$datosPresupuesto->color_impresion, $datosPresupuesto->calidad_impresion] =
|
||||
$this->getTipoInterior($presupuestoEntity->id ?? null);
|
||||
$datosPresupuesto->tapa = $this->getTapa($presupuestoEntity->tipo_impresion_id ?? null);
|
||||
|
||||
$datosPresupuesto->clienteList = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null);
|
||||
|
||||
$this->viewData['formAction'] = route_to('updateCosidotapablanda', $id);
|
||||
@ -160,17 +170,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
$this->viewData['presupuestoEntity'] = $presupuestoEntity;
|
||||
$this->viewData['datosPresupuesto'] = $datosPresupuesto;
|
||||
|
||||
|
||||
$cambios_lineas = $this->getLineasPresupuesto($presupuestoEntity)[0];
|
||||
$this->viewData['updated']->cambios_lineas=$cambios_lineas;
|
||||
|
||||
$cambios_en_servicios = $this->getLineasServicios($presupuestoEntity)[0];
|
||||
$this->viewData['updated']->cambios_servicios=$cambios_en_servicios;
|
||||
|
||||
$cambios_en_direcciones = $this->getLineasDirecciones($presupuestoEntity)[0];
|
||||
$this->viewData['updated']->cambios_direcciones=$cambios_en_direcciones;
|
||||
|
||||
|
||||
// Si se ha llamado a esta funcion porque se ha duplicado el presupuesto
|
||||
// se actualiza la bbdd para que sólo ejecute algunas funciones una vez
|
||||
@ -1496,60 +1495,54 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getLineasPresupuesto($presupuestoEntity){
|
||||
$lineas = (new PresupuestoLineaModel())->getLineasPresupuesto($presupuestoEntity->id);
|
||||
|
||||
$input_data = [];
|
||||
$input_data['presupuesto'] = $presupuestoEntity;
|
||||
|
||||
return PresupuestoService::checkLineasPresupuesto($input_data, $lineas);
|
||||
}
|
||||
|
||||
protected function getLineasServicios($presupuestoEntity){
|
||||
|
||||
$serviciosPresupuesto = (object)array();
|
||||
|
||||
$serviciosPresupuesto->serviciosAcabado = (new PresupuestoAcabadosModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
|
||||
$serviciosPresupuesto->serviciosPreimpresion = (new PresupuestoPreimpresionesModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
|
||||
$serviciosPresupuesto->serviciosEncuadernacion = (new PresupuestoEncuadernacionesModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
|
||||
$serviciosPresupuesto->serviciosManipulado = (new PresupuestoManipuladosModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
|
||||
$serviciosPresupuesto->serviciosExtra = (new PresupuestoServiciosExtraModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
|
||||
|
||||
$input_data = [];
|
||||
$input_data['presupuesto_id'] = $presupuestoEntity->id;
|
||||
$input_data['tipo_impresion_id'] = $presupuestoEntity->tipo_impresion_id;
|
||||
$input_data['tirada'] = $presupuestoEntity->tirada;
|
||||
$input_data['POD'] = $this->getPOD();
|
||||
$input_data['paginas'] = $presupuestoEntity->paginas;
|
||||
$input_data['is_duplicado'] = $presupuestoEntity->is_duplicado;
|
||||
|
||||
if($presupuestoEntity->papel_formato_personalizado){
|
||||
$input_data['ancho'] = $presupuestoEntity->ancho;
|
||||
$input_data['alto'] = $presupuestoEntity->alto;
|
||||
}
|
||||
else{
|
||||
$model = model("App\Models\Configuracion\PapelFormatoModel");
|
||||
$papel = $model->find($presupuestoEntity->papel_formato_id);
|
||||
if($papel){
|
||||
$input_data['ancho'] = $papel->ancho;
|
||||
$input_data['alto'] = $papel->alto;
|
||||
}
|
||||
else{
|
||||
$input_data['ancho'] = 0;
|
||||
$input_data['alto'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return PresupuestoService::checkLineasServicios($input_data, $serviciosPresupuesto);
|
||||
}
|
||||
|
||||
protected function getLineasDirecciones($presupuestoEntity){
|
||||
|
||||
$model = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
|
||||
$direccionesEnvio = $model->where('presupuesto_id', $presupuestoEntity->id)->findAll();
|
||||
|
||||
return PresupuestoService::checkLineasEnvios($direccionesEnvio);
|
||||
}
|
||||
|
||||
protected function getTipoLibro($tipo_impresion_id){
|
||||
if($tipo_impresion_id == 1 || $tipo_impresion_id == 2){
|
||||
return 'fresado';
|
||||
}
|
||||
else if ($tipo_impresion_id == 3 || $tipo_impresion_id == 4){
|
||||
return 'cosido';
|
||||
}
|
||||
else if ($tipo_impresion_id == 5 || $tipo_impresion_id == 6){
|
||||
return 'espiral';
|
||||
}
|
||||
else if ($tipo_impresion_id == 7 || $tipo_impresion_id == 8){
|
||||
return 'wireo';
|
||||
}
|
||||
else if ($tipo_impresion_id == 21){
|
||||
return 'grapado';
|
||||
}
|
||||
else
|
||||
return '';
|
||||
}
|
||||
protected function getTipoInterior($presupuestoId){
|
||||
|
||||
$calidad = 'estandar';
|
||||
$color = 'negro';
|
||||
|
||||
$model = model('App\Models\Presupuestos\PresupuestoLineaModel');
|
||||
$data = $model->where('presupuestoId', $presupuestoId)->findAll();;
|
||||
foreach($data as $linea){
|
||||
|
||||
if (strpos($linea->tipo, "hq") !== false) { // $linea->tipo contains the substring "hq"
|
||||
$calidad='premium';
|
||||
}
|
||||
if (strpos($linea->tipo, "hq") !== false) { // $linea->tipo contains the substring "hq"
|
||||
$color='color';
|
||||
}
|
||||
}
|
||||
return [$color, $calidad];
|
||||
|
||||
}
|
||||
|
||||
protected function getTapa($tipo_impresion_id ){
|
||||
|
||||
$tapa = 'blanda';
|
||||
|
||||
if($tipo_impresion_id == 1 || $tipo_impresion_id == 3 ||
|
||||
$tipo_impresion_id == 5 || $tipo_impresion_id == 7)
|
||||
$tapa = 'dura';
|
||||
|
||||
return $tapa;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user