mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
121 lines
3.5 KiB
PHP
121 lines
3.5 KiB
PHP
<?php
|
|
|
|
namespace App\Entities\Produccion;
|
|
|
|
use App\Entities\Configuracion\Imposicion;
|
|
use App\Entities\Configuracion\Maquina;
|
|
use App\Entities\Presupuestos\PresupuestoAcabadosEntity;
|
|
use App\Entities\Presupuestos\PresupuestoLineaEntity;
|
|
use App\Entities\Presupuestos\PresupuestoManipuladosEntity;
|
|
use App\Models\Configuracion\ImposicionModel;
|
|
use App\Models\Configuracion\MaquinaModel;
|
|
use App\Models\OrdenTrabajo\OrdenTrabajoModel;
|
|
use App\Models\Presupuestos\PresupuestoAcabadosModel;
|
|
use App\Models\Presupuestos\PresupuestoLineaModel;
|
|
use App\Models\Presupuestos\PresupuestoManipuladosModel;
|
|
use CodeIgniter\Entity\Entity;
|
|
|
|
class OrdenTrabajoTareaEntity extends Entity
|
|
{
|
|
protected $attributes = [
|
|
"id" => null,
|
|
"orden_trabajo_id" => null,
|
|
"presupuesto_linea_id" => null,
|
|
"nombre" => null,
|
|
"orden" => null,
|
|
"maquina_id" => null,
|
|
"imposicion_id" => null,
|
|
"tiempo_estimado" => null,
|
|
"tiempo_real" => null,
|
|
"is_corte" => null,
|
|
"tipo_corte" => null,
|
|
"comment" => null,
|
|
];
|
|
protected $datamap = [];
|
|
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
|
protected $casts = [
|
|
"id" => "integer",
|
|
"orden_trabajo_id" => "integer",
|
|
"presupuesto_linea_id" => "?integer",
|
|
"nombre" => "string",
|
|
"orden" => "integer",
|
|
"maquina_id" => "?integer",
|
|
"imposicion_id" => "?integer",
|
|
"tiempo_estimado" => "?float",
|
|
"tiempo_real" => "?float",
|
|
"is_corte" => "boolean",
|
|
"tipo_corte" => "string",
|
|
"comment" => "?string"
|
|
];
|
|
|
|
/**
|
|
* Orden de trabajo de la tarea
|
|
*
|
|
* @return OrdenTrabajoEntity
|
|
*/
|
|
public function orden_trabajo() : OrdenTrabajoEntity
|
|
{
|
|
$m = model(OrdenTrabajoModel::class);
|
|
return $m->find($this->attributes["orden_trabajo_id"]);
|
|
}
|
|
/**
|
|
* Tarea orden de trabajo con orden de trabajo
|
|
*
|
|
* @return self
|
|
*/
|
|
public function withOrdenTrabajo() : self
|
|
{
|
|
$this->attributes["orden_trabajo"] = $this->orden_trabajo();
|
|
return $this;
|
|
}
|
|
/**
|
|
* Devuelve la maquina actual de esta tarea
|
|
*
|
|
* @return Maquina
|
|
*/
|
|
public function maquina_actual() : Maquina
|
|
{
|
|
$m = model(MaquinaModel::class);
|
|
return $m->find($this->attributes["maquina_id"]);
|
|
}
|
|
/**
|
|
* Devuelve el presupuesto linea origen de esta tarea
|
|
*
|
|
* @return PresupuestoLineaEntity
|
|
*/
|
|
public function presupuesto_linea() : PresupuestoLineaEntity
|
|
{
|
|
$m = model(PresupuestoLineaModel::class);
|
|
return $m->find($this->attributes["presupuesto_linea_id"]);
|
|
}
|
|
/**
|
|
* Devuelve la maquina original del presupuesto linea
|
|
*
|
|
* @return Maquina
|
|
*/
|
|
public function maquina_presupuesto_linea() : Maquina
|
|
{
|
|
return $this->presupuesto_linea()->maquina();
|
|
}
|
|
/**
|
|
* Devuelve el presupuesto acabado origen de esta tarea
|
|
*
|
|
* @return PresupuestoAcabadosEntity
|
|
*/
|
|
public function presupuesto_acabado() : PresupuestoAcabadosEntity
|
|
{
|
|
$m = model(PresupuestoAcabadosModel::class);
|
|
return $m->find($this->attributes["presupuesto_linea_id"]);
|
|
}
|
|
public function imposicion() : ?Imposicion
|
|
{
|
|
$m = model(ImposicionModel::class);
|
|
$imposicion = null;
|
|
if($this->attributes["imposicion_id"]){
|
|
$imposicion = $m->find($this->attributes["imposicion_id"]);
|
|
}
|
|
return $imposicion;
|
|
}
|
|
|
|
}
|