tiempo real tarea empty when created

This commit is contained in:
amazuecos
2025-04-28 08:00:39 +02:00
parent bf21a336b1
commit 3abf45ca6e
2 changed files with 99 additions and 87 deletions

View File

@ -212,33 +212,33 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
return $q;
}
/**
/**
* Obtiene las lineas de presupuesto del actual presupuesto
*
* @return ?PresupuestoLineaEntity
*/
public function presupuestoLineaImpresion(): ?PresupuestoLineaEntity
{
$model = model(PresupuestoLineaModel::class);
$q = $model->where('presupuesto_id', $this->attributes["id"])->whereIn("tipo", ["lp_rot_bn", "lp_rot_color", "lp_color", "lp_colorhq", "lp_bn", "lp_bnhq"])->first();
return $q;
}
/**
* Obtiene las lineas de presupuesto del actual presupuesto
*
* @return PresupuestoLineaEntity
*/
public function presupuestoLineaImpresion(): PresupuestoLineaEntity
public function presupuestoLineaCubierta(): ?PresupuestoLineaEntity
{
$model = model(PresupuestoLineaModel::class);
$q = $model->where('presupuesto_id', $this->attributes["id"])->whereIn("tipo",["lp_rot_bn","lp_rot_color","lp_color","lp_colorhq","lp_bn","lp_bnhq"])->first();
$q = $model->where('presupuesto_id', $this->attributes["id"])->whereIn("tipo", ["lp_cubierta"])->first();
return $q;
}
/**
* Obtiene las lineas de presupuesto del actual presupuesto
*
* @return PresupuestoLineaEntity
*/
public function presupuestoLineaCubierta(): PresupuestoLineaEntity
{
$model = model(PresupuestoLineaModel::class);
$q = $model->where('presupuesto_id', $this->attributes["id"])->whereIn("tipo",["lp_cubierta"])->first();
return $q;
}
/**
/**
* Obtiene las lineas de presupuesto del actual presupuesto
*
* @return PresupuestoLineaEntity
@ -247,70 +247,73 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
{
$model = model(PresupuestoLineaModel::class);
$q = $model->where('presupuesto_id', $this->attributes["id"])->whereIn("tipo",["lp_sobrecubierta"])->first();
$q = $model->where('presupuesto_id', $this->attributes["id"])->whereIn("tipo", ["lp_sobrecubierta"])->first();
return $q;
}
public function hasSobrecubierta() : bool
public function hasSobrecubierta(): bool
{
$hasSobrecubierta = false;
$model = model(PresupuestoLineaModel::class);
$q = $model->where('presupuesto_id', $this->attributes["id"])->whereIn("tipo",["lp_sobrecubierta"])->countAllResults();
if($q > 0){
$q = $model->where('presupuesto_id', $this->attributes["id"])->whereIn("tipo", ["lp_sobrecubierta"])->countAllResults();
if ($q > 0) {
$hasSobrecubierta = true;
}
return $hasSobrecubierta;
}
public function cliente() : ClienteEntity
public function cliente(): ?ClienteEntity
{
$m = model(ClienteModel::class);
return $m->find($this->attributes["cliente_id"]);
if ($this->attributes['cliente_id']) {
return $m->find($this->attributes["cliente_id"]);
} else {
return null;
}
}
public function encuadernaciones(): array
{
$m = model(PresupuestoEncuadernacionesModel::class);
return $m->where("presupuesto_id",$this->attributes["id"])->findAll();
return $m->where("presupuesto_id", $this->attributes["id"])->findAll();
}
public function acabados(): array
{
$m = model(PresupuestoAcabadosModel::class);
return $m->where("presupuesto_id",$this->attributes["id"])->findAll();
return $m->where("presupuesto_id", $this->attributes["id"])->findAll();
}
public function preimpresiones(): array
{
$m = model(PresupuestoPreimpresionesModel::class);
return $m->where("presupuesto_id",$this->attributes["id"])->findAll();
return $m->where("presupuesto_id", $this->attributes["id"])->findAll();
}
public function manipulados(): array
{
$m = model(PresupuestoManipuladosModel::class);
return $m->where("presupuesto_id",$this->attributes["id"])->findAll();
return $m->where("presupuesto_id", $this->attributes["id"])->findAll();
}
public function extras(): array
{
$m = model(PresupuestoServiciosExtraModel::class);
return $m->where("presupuesto_id",$this->attributes["id"])->findAll();
return $m->where("presupuesto_id", $this->attributes["id"])->findAll();
}
public function papel_formato() : PapelFormatoEntity
public function papel_formato(): PapelFormatoEntity
{
$m = model(PapelFormatoModel::class);
return $m->find($this->attributes["papel_formato_id"]);
}
public function files(): array
public function files(): array
{
$m = model(PresupuestoFicheroModel::class);
$files = $m->where('presupuesto_id',$this->attributes['id'])->findAll();
$files = $m->where('presupuesto_id', $this->attributes['id'])->findAll();
return $files ?? [];
}
public function tipo_presupuesto() : ?TipoPresupuestoEntity
public function tipo_presupuesto(): ?TipoPresupuestoEntity
{
$tipo_presupuesto = null;
$m = model(TipoPresupuestoModel::class);
if($this->attributes["tipo_impresion_id"]){
if ($this->attributes["tipo_impresion_id"]) {
$tipo_presupuesto = $m->find($this->attributes['tipo_impresion_id']);
}
return $tipo_presupuesto;
}
}

View File

@ -365,7 +365,7 @@ class ProductionService extends BaseService
$ot_tareas["maquina_id"] = $p_linea_maquina->id;
$ot_tareas["imposicion_id"] = null;
$ot_tareas["tiempo_estimado"] = $p_linea->horas_maquina * 3600;
$ot_tareas["tiempo_real"] = $p_linea->horas_maquina * 3600; //? Tiempo real se inserta manual?
$ot_tareas["tiempo_real"] = 0;
$insert_query_result = $this->otTarea->insert($ot_tareas);
$ot_tareas = [];
$this->storeTareaCorte($p_linea);
@ -389,7 +389,7 @@ class ProductionService extends BaseService
'maquina_id' => $this->defaultMaquinaCorte->id,
'orden' => $this->defaultMaquinaCorte->orden_planning,
'tiempo_estimado' => $pLinea->rotativa_tiempo_corte * 60,
'tiempo_real' => $pLinea->rotativa_tiempo_corte * 60,
'tiempo_real' => 0,
'is_corte' => true,
'tipo_corte' => "bobina",
]);
@ -1526,58 +1526,68 @@ class ProductionService extends BaseService
}
public function getPapelImpresionBackgroundColor()
{
$papel = $this->presupuesto->presupuestoLineaImpresion()->papel_generico();
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['default'];
$papel_code = $papel->code_ot;
if ($papel_code) {
if (strpos($papel_code, "BCLOF")) {
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['blanco'];
}
if (strpos($papel_code, "AH") && $papel->code == "OFF2") {
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['ahuesado'];
}
if (strpos($papel_code, "MARF")) {
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['marfil'];
}
if (strpos($papel_code, "VOLAH")) {
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['volumen_ahuesado'];
}
if ($papel_code == "EM") {
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['estucado_mate'];
}
if ($papel_code == "CGE") {
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['cartulina'];
}
}
if ($this->presupuesto->presupuestoLineaImpresion()) {
return $color;
$papel = $this->presupuesto->presupuestoLineaImpresion()->papel_generico();
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['default'];
$papel_code = $papel->code_ot;
if ($papel_code) {
if (strpos($papel_code, "BCLOF")) {
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['blanco'];
}
if (strpos($papel_code, "AH") && $papel->code == "OFF2") {
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['ahuesado'];
}
if (strpos($papel_code, "MARF")) {
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['marfil'];
}
if (strpos($papel_code, "VOLAH")) {
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['volumen_ahuesado'];
}
if ($papel_code == "EM") {
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['estucado_mate'];
}
if ($papel_code == "CGE") {
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['cartulina'];
}
}
return $color;
} else {
return $this->ordenTrabajoConfig->OT_PAPEL_COLOR['blanco'];
}
}
public function getPapelImpresionCubiertaBackgroundColor()
{
$papel = $this->presupuesto->presupuestoLineaCubierta()->papel_generico();
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['default'];
$papel_code = $papel->code_ot;
if ($papel_code) {
if (strpos($papel_code, "BCLOF")) {
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['blanco'];
}
if (strpos($papel_code, "AH") && $papel->code == "OFF2") {
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['ahuesado'];
}
if (strpos($papel_code, "MARF")) {
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['marfil'];
}
if (strpos($papel_code, "VOLAH")) {
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['volumen_ahuesado'];
}
if ($papel_code == "EM") {
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['estucado_mate'];
}
if ($papel_code == "CGE") {
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['cartulina'];
if ($this->presupuesto->presupuestoLineaCubierta()) {
$papel = $this->presupuesto->presupuestoLineaCubierta()->papel_generico();
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['default'];
$papel_code = $papel->code_ot;
if ($papel_code) {
if (strpos($papel_code, "BCLOF")) {
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['blanco'];
}
if (strpos($papel_code, "AH") && $papel->code == "OFF2") {
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['ahuesado'];
}
if (strpos($papel_code, "MARF")) {
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['marfil'];
}
if (strpos($papel_code, "VOLAH")) {
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['volumen_ahuesado'];
}
if ($papel_code == "EM") {
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['estucado_mate'];
}
if ($papel_code == "CGE") {
$color = $this->ordenTrabajoConfig->OT_PAPEL_COLOR['cartulina'];
}
}
return $color;
} else {
return $this->ordenTrabajoConfig->OT_PAPEL_COLOR['blanco'];
}
return $color;
}
public function getPlastificadoColor()
{
@ -1815,7 +1825,7 @@ class ProductionService extends BaseService
}
return $podDates;
} catch (\Throwable $th) {
return[ "error" => $th->getMessage()];
return ["error" => $th->getMessage()];
}
}
/**
@ -1845,10 +1855,9 @@ class ProductionService extends BaseService
return $workdays;
}
public function updatePodDates() : bool
public function updatePodDates(): bool
{
$dates = $this->createDatesForPOD();
return $this->pedidoModel->update($this->pedido->id,$dates);
return $this->pedidoModel->update($this->pedido->id, $dates);
}
}