Merge branch 'fix/bugs-ot' into 'main'

Fix/bugs ot

See merge request jjimenez/safekat!752
This commit is contained in:
Alvaro
2025-04-28 06:13:50 +00:00
4 changed files with 140 additions and 126 deletions

View File

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

View File

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

View File

@ -12,7 +12,7 @@
<div id="accordionOtTasksTip" class="accordion-collapse collapse show" data-bs-parent="#accordionOtTasks"> <div id="accordionOtTasksTip" class="accordion-collapse collapse show" data-bs-parent="#accordionOtTasks">
<div class="accordion-body"> <div class="accordion-body">
<div class="card text-center"> <div class="card">
<div class="card-header"> <div class="card-header">
<div class="nav-align-top"> <div class="nav-align-top">
<ul class="nav nav-pills" role="tablist"> <ul class="nav nav-pills" role="tablist">

View File

@ -81,7 +81,7 @@ $settings = $session->get('settings');
<div class="col-3 h-100"> <div class="col-3 h-100">
<div class="row px-2 d-flex flex justify-content-between align-items-center"> <div class="row px-2 d-flex flex justify-content-between align-items-center">
<div class="col-6 w-100 text-center"> <div class="col-6 w-100 text-center">
<span id="fecha_encuadernado_at" style="color:<?= $colors["general"]["color"] ?>;"><strong><?= $pedido->fecha_encuadernado ? Time::createFromFormat("Y-m-d H:i:s", $pedido->fecha_encuadernado)->format('d/m/Y') : "??" ?></strong></span> <span id="fecha_encuadernado_at" style="color:<?= $colors["general"]["color"] ?>;"><strong><?= $pedido->fecha_encuadernado ? Time::createFromFormat("Y-m-d H:i:s", $pedido->fecha_encuadernado)->format('d/m/Y') : "" ?></strong></span>
</div> </div>
</div> </div>
<div class="row px-2 mt-2 h-100"> <div class="row px-2 mt-2 h-100">
@ -113,18 +113,18 @@ $settings = $session->get('settings');
<div class="col-5"> <div class="col-5">
<div class="row"> <div class="row">
<div class="col-12 w-50 text-center" style="background-color: <?= $colors["ot"]["bg"] ?>;color:<?= $colors["ot"]["color"] ?>;"> <div class="col-12 w-50 text-center" style="background-color: <?= $colors["ot"]["bg"] ?>;color:<?= $colors["ot"]["color"] ?>;">
<strong><?= isset($encuadernaciones[0]) ? $encuadernaciones[0]->tarifa()->code ?? "?" : "?" ?></strong> <strong><?= isset($encuadernaciones[0]) ? $encuadernaciones[0]->tarifa()->code ?? "" : "" ?></strong>
</div> </div>
</div> </div>
<div class="row h-75"> <div class="row h-75">
<div class="col-6 square text-center" style="background-color: <?= $colors["papel_interior"]["bg"] ?>;color:<?= $colors["papel_interior"]["color"] ?>;"> <div class="col-6 square text-center" style="background-color: <?= $colors["papel_interior"]["bg"] ?>;color:<?= $colors["papel_interior"]["color"] ?>;">
<?= $linea_impresion->papel_impresion()->papel_code_ot ?> <?= $linea_impresion?->papel_impresion()->papel_code_ot ?>
</div> </div>
<div class="col-6 square text-center <?= $linea_impresion->isColor() ? "cmyk" : "bn" ?>"> <div class="col-6 square text-center <?= $linea_impresion->isColor() ? "cmyk" : "bn" ?>">
<?= $tiempo_impresion ?> <?= $tiempo_impresion ?>
</div> </div>
<div class="col-6 square text-center" style="background-color: <?= $colors["papel_cubierta"]["bg"] ?>;color:<?= $colors["papel_cubierta"]["color"] ?>;"> <div class="col-6 square text-center" style="background-color: <?= $colors["papel_cubierta"]["bg"] ?>;color:<?= $colors["papel_cubierta"]["color"] ?>;">
<?= $linea_cubierta->papel_impresion()->papel_code_ot ?> <?= $linea_cubierta?->papel_impresion()->papel_code_ot ?>
</div> </div>
<div class="col-6 square text-center" style="background-color: <?= $colors["plastificado"]["bg"] ?>;color:<?= $colors["plastificado"]["color"] ?>;"> <div class="col-6 square text-center" style="background-color: <?= $colors["plastificado"]["bg"] ?>;color:<?= $colors["plastificado"]["color"] ?>;">
<?= isset($acabados[0]) ? $acabados[0]->tarifa()->code : "" ?> <?= isset($acabados[0]) ? $acabados[0]->tarifa()->code : "" ?>
@ -267,49 +267,51 @@ $settings = $session->get('settings');
</div> </div>
</div> </div>
</div> </div>
<div class="row mb-2"> <?php if ($linea_cubierta): ?>
<div class="section-title cubierta">IMP. CUBIERTA</div> <div class="row mb-2">
<div class="col-12"> <div class="section-title cubierta">IMP. CUBIERTA</div>
<div class="col-12">
<table> <table>
<tr> <tr>
<td rowspan="3" class="row-logo-impresion"><img src="<?= site_url($linea_cubierta->get_impresion_logo()) ?>" width="35px" height="35px"></td> <td rowspan="3" class="row-logo-impresion"><img src="<?= site_url($linea_cubierta->get_impresion_logo()) ?>" width="35px" height="35px"></td>
<th>Tintas</th> <th>Tintas</th>
<th>Ejemplares</th> <th>Ejemplares</th>
<th>Maquina</th> <th>Maquina</th>
<th>Marcapaginas</th> <th>Marcapaginas</th>
<th>Tiempo</th> <th>Tiempo</th>
</tr> </tr>
<tr> <tr>
<td><?= $linea_cubierta->tinta() ?></td> <td><?= $linea_cubierta->tinta() ?></td>
<td><?= $presupuesto->tirada ?></td> <td><?= $presupuesto->tirada ?></td>
<td><strong><?= $linea_cubierta->maquina()->nombre ?></strong></td> <td><strong><?= $linea_cubierta->maquina()->nombre ?></strong></td>
<td><?= $presupuesto->marcapaginas ? "SI" : "NO" ?></td> <td><?= $presupuesto->marcapaginas ? "SI" : "NO" ?></td>
<td><?= float_seconds_to_hhmm_string($linea_cubierta->horas_maquina * 3600) ?></td> <td><?= float_seconds_to_hhmm_string($linea_cubierta->horas_maquina * 3600) ?></td>
</tr> </tr>
<tr> <tr>
<td colspan="1"><?= json_decode($linea_cubierta->formas)->maquina_ancho ?>x<?= json_decode($linea_cubierta->formas)->maquina_alto ?></td> <td colspan="1"><?= json_decode($linea_cubierta->formas)->maquina_ancho ?>x<?= json_decode($linea_cubierta->formas)->maquina_alto ?></td>
<td colspan="1"><?= $papel_formato->ancho ?>x<?= $papel_formato->alto ?></td> <td colspan="1"><?= $papel_formato->ancho ?>x<?= $papel_formato->alto ?></td>
<td colspan="2"><?= $linea_cubierta->papel_impresion ?></td> <td colspan="2"><?= $linea_cubierta->papel_impresion ?></td>
<td colspan="2"><?= $linea_cubierta->papel_impresion()->gramaje . " " . "gr" ?></td> <td colspan="2"><?= $linea_cubierta->papel_impresion()->gramaje . " " . "gr" ?></td>
</tr> </tr>
</table> </table>
<div class="comments"> <div class="comments">
<div class="flex-row cubierta">Comentarios cubierta</div> <div class="flex-row cubierta">Comentarios cubierta</div>
<div class="comment-content"> <div class="comment-content">
<p> <p>
</p> </p>
</div>
</div> </div>
</div> </div>
</div>
</div> </div>
<?php endif; ?>
<div class="row mb-2"> <div class="row mb-2">
<div class="section-title encuadernacion">ENCUADERNACIÓN</div> <div class="section-title encuadernacion">ENCUADERNACIÓN</div>
<div class="col-12"> <div class="col-12">
<div class="col-1 w-10 mb-2 text-center" style="background-color: <?= $colors["ot"]["bg"] ?>;color:<?= $colors["ot"]["color"] ?>;"> <div class="col-1 w-10 mb-2 text-center" style="background-color: <?= $colors["ot"]["bg"] ?>;color:<?= $colors["ot"]["color"] ?>;">
<span class="fs-bold"><?= isset($encuadernaciones[0]) ? $encuadernaciones[0]->tarifa()->code ?? "?" : "?" ?></span> <span class="fs-bold"><?= isset($encuadernaciones[0]) ? $encuadernaciones[0]->tarifa()->code ?? "" : "" ?></span>
</div> </div>
<table> <table>
<tr> <tr>