ot new features

This commit is contained in:
amazuecos
2025-05-01 06:02:22 +02:00
parent cf4c4df80a
commit a259d76e5e
32 changed files with 760 additions and 134 deletions

View File

@ -5,6 +5,7 @@ namespace App\Entities\Produccion;
use App\Entities\Configuracion\Imposicion;
use App\Entities\Configuracion\Maquina;
use App\Entities\Presupuestos\PresupuestoAcabadosEntity;
use App\Entities\Presupuestos\PresupuestoEncuadernacionesEntity;
use App\Entities\Presupuestos\PresupuestoLineaEntity;
use App\Entities\Presupuestos\PresupuestoManipuladosEntity;
use App\Models\Configuracion\ImposicionModel;
@ -12,6 +13,7 @@ use App\Models\Configuracion\MaquinaModel;
use App\Models\OrdenTrabajo\OrdenTrabajoModel;
use App\Models\OrdenTrabajo\OrdenTrabajoTareaProgressDate;
use App\Models\Presupuestos\PresupuestoAcabadosModel;
use App\Models\Presupuestos\PresupuestoEncuadernacionesModel;
use App\Models\Presupuestos\PresupuestoLineaModel;
use App\Models\Presupuestos\PresupuestoManipuladosModel;
use CodeIgniter\Entity\Entity;
@ -23,6 +25,11 @@ class OrdenTrabajoTareaEntity extends Entity
"id" => null,
"orden_trabajo_id" => null,
"presupuesto_linea_id" => null,
"presupuesto_acabado_id" => null,
"presupuesto_preimpresion_id" => null,
"presupuesto_encuadernado_id" => null,
"presupuesto_extra_id" => null,
"presupuesto_manipulado_id" => null,
"nombre" => null,
"orden" => null,
"maquina_id" => null,
@ -96,10 +103,15 @@ class OrdenTrabajoTareaEntity extends Entity
*
* @return PresupuestoLineaEntity
*/
public function presupuesto_linea(): PresupuestoLineaEntity
public function presupuesto_linea(): ?PresupuestoLineaEntity
{
$presupuesto_linea = null;
$m = model(PresupuestoLineaModel::class);
return $m->find($this->attributes["presupuesto_linea_id"]);
if ($this->attributes['presupuesto_linea_id']) {
$presupuesto_linea = $m->find($this->attributes["presupuesto_linea_id"]);
}
return $presupuesto_linea;
}
/**
* Devuelve la maquina original del presupuesto linea
@ -108,17 +120,35 @@ class OrdenTrabajoTareaEntity extends Entity
*/
public function maquina_presupuesto_linea(): Maquina
{
return $this->presupuesto_linea()->maquina();
return $this->presupuesto_linea()?->maquina();
}
/**
* Devuelve el presupuesto acabado origen de esta tarea
*
* @return PresupuestoAcabadosEntity
*/
public function presupuesto_acabado(): PresupuestoAcabadosEntity
public function presupuesto_acabado(): ?PresupuestoAcabadosEntity
{
$presupuesto_acabado = null;
$m = model(PresupuestoAcabadosModel::class);
return $m->find($this->attributes["presupuesto_linea_id"]);
if ($this->attributes["presupuesto_acabado_id"]) {
$presupuesto_acabado = $m->find($this->attributes["presupuesto_acabado_id"]);
}
return $presupuesto_acabado;
}
/**
* Devuelve el presupuesto enducadernacion origen de esta tarea
*
* @return PresupuestoEncuadernacionesEntity
*/
public function presupuesto_encuadernacion(): ?PresupuestoEncuadernacionesEntity
{
$presupuesto_encuadernacion = null;
$m = model(PresupuestoEncuadernacionesModel::class);
if ($this->attributes["presupuesto_encuadernado_id"]) {
$presupuesto_encuadernacion = $m->find($this->attributes["presupuesto_encuadernado_id"]);
}
return $presupuesto_encuadernacion;
}
/**
* Devuelve el presupuesto acabado origen de esta tarea
@ -152,8 +182,8 @@ class OrdenTrabajoTareaEntity extends Entity
{
$dates = $this->progress_dates();
$intervals = [];
$init = [];
$end = [];
$init = null;
$end = null;
foreach ($dates as $key => $date) {
if ($date->estado == "I") {
if ($date->action_at) {
@ -161,7 +191,7 @@ class OrdenTrabajoTareaEntity extends Entity
}
}
if ($date->estado == "S" || $date->estado == "F") {
if ($date->action_at) {
if ($date->action_at && $init) {
$end = Time::createFromFormat('Y-m-d H:i:s', $date->action_at);
$intervals[] = $init->difference($end)->getSeconds();
}
@ -182,4 +212,24 @@ class OrdenTrabajoTareaEntity extends Entity
}
return $isTareaCosido;
}
public function isImpresion() : bool
{
return $this->attributes['presupuesto_linea_id'] != null;
}
public function isAcabado() : bool
{
return $this->attributes['presupuesto_acabado_id'] != null;
}
public function isManipulado() : bool
{
return $this->attributes['presupuesto_manipulado_id'] != null;
}
public function isEncuadernado() : bool
{
return $this->attributes['presupuesto_encuadernado_id'] != null;
}
public function isCorte() : bool
{
return $this->attributes['is_corte'];
}
}