revision ot v2

This commit is contained in:
amazuecos
2025-05-04 17:25:53 +02:00
parent db70c57fb3
commit fb7f2a28d9
30 changed files with 897 additions and 169 deletions

View File

@ -178,7 +178,7 @@ class OrdenTrabajoTareaEntity extends Entity
$m = model(OrdenTrabajoTareaProgressDate::class);
return $m->where('ot_tarea_id', $this->attributes["id"])->findAll() ?? [];
}
public function lastState() : ?OrdenTrabajoTareaProgressDateEntity
public function lastState(): ?OrdenTrabajoTareaProgressDateEntity
{
$m = model(OrdenTrabajoTareaProgressDate::class);
$progressDates = $m->where('ot_tarea_id', $this->attributes["id"])->orderBy('action_at', 'DESC')->first();
@ -193,12 +193,12 @@ class OrdenTrabajoTareaEntity extends Entity
foreach ($dates as $key => $date) {
if ($date->estado == "I") {
if ($date->action_at) {
$init = Time::createFromFormat('Y-m-d H:i:s', $date->action_at);
$init = $date->action_at;
}
}
if ($date->estado == "S" || $date->estado == "F") {
if ($date->action_at && $init) {
$end = Time::createFromFormat('Y-m-d H:i:s', $date->action_at);
$end = $date->action_at;
$intervals[] = $init->difference($end)->getSeconds();
}
}
@ -218,23 +218,23 @@ class OrdenTrabajoTareaEntity extends Entity
}
return $isTareaCosido;
}
public function isImpresion() : bool
public function isImpresion(): bool
{
return $this->attributes['presupuesto_linea_id'] != null;
}
public function isAcabado() : bool
public function isAcabado(): bool
{
return $this->attributes['presupuesto_acabado_id'] != null;
}
public function isManipulado() : bool
public function isManipulado(): bool
{
return $this->attributes['presupuesto_manipulado_id'] != null;
}
public function isEncuadernado() : bool
public function isEncuadernado(): bool
{
return $this->attributes['presupuesto_encuadernado_id'] != null;
}
public function isCorte() : bool
public function isCorte(): bool
{
return $this->attributes['is_corte'];
}

View File

@ -2,6 +2,7 @@
namespace App\Entities\Produccion;
use App\Entities\Usuarios\UserEntity;
use App\Models\OrdenTrabajo\OrdenTrabajoTarea;
use CodeIgniter\Entity\Entity;
@ -27,5 +28,14 @@ class OrdenTrabajoTareaProgressDateEntity extends Entity
$m = model(OrdenTrabajoTarea::class);
return $m->find($this->attributes["ot_tarea_id"]);
}
public function user() : ?UserEntity
{
$user = null;
if($this->attributes['action_user_id'])
{
$user = auth()->getProvider()->findById($this->attributes['action_user_id']);
}
return $user;
}
}