From c6db00005796ebd5738ad317e386d7eceb53fb2e Mon Sep 17 00:00:00 2001 From: amazuecos Date: Tue, 15 Apr 2025 19:39:07 +0200 Subject: [PATCH 1/3] fix update pedido espera update --- .../Controllers/Produccion/Ordentrabajo.php | 2 ++ .../Produccion/OrdenTrabajoDateEntity.php | 2 +- .../Models/OrdenTrabajo/OrdenTrabajoDate.php | 2 +- ci4/app/Services/ProductionService.php | 27 +++++++++++++++---- .../assets/js/safekat/pages/produccion/ot.js | 18 +++++++++++-- 5 files changed, 42 insertions(+), 9 deletions(-) diff --git a/ci4/app/Controllers/Produccion/Ordentrabajo.php b/ci4/app/Controllers/Produccion/Ordentrabajo.php index 8f0610f9..41bd2391 100755 --- a/ci4/app/Controllers/Produccion/Ordentrabajo.php +++ b/ci4/app/Controllers/Produccion/Ordentrabajo.php @@ -147,6 +147,8 @@ class Ordentrabajo extends BaseController ]; $this->viewData["modelId"] = $orden_trabajo_id; $this->produccionService->init($orden_trabajo_id); + $this->produccionService->reInsertOrdenTrabajoDates(); + $this->produccionService->reInsertOrdenTrabajoUsers(); $this->viewData["presupuesto"] = $this->produccionService->getPresupuesto(); $this->viewData["cliente"] = $this->produccionService->getCliente(); $this->viewData["ot"] = $this->produccionService->getOrdenTrabajo(); diff --git a/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php b/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php index b796e380..e106c57c 100644 --- a/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php +++ b/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php @@ -23,7 +23,7 @@ class OrdenTrabajoDateEntity extends Entity "entrada_manipulado_at" => null, "cosido_at" => null, "solapa_at" => null, - "cosido_at" => null, + "grapado_at" => null, "retractilado_at"=> null, "retractilado5_at"=> null, "prototipo_at"=> null, diff --git a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php index 1d82ec12..555f6415 100644 --- a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php +++ b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php @@ -30,7 +30,7 @@ class OrdenTrabajoDate extends Model "entrada_manipulado_at", "cosido_at", "solapa_at", - "cosido_at", + "grapado_at", "retractilado_at", "retractilado5_at", "prototipo_at", diff --git a/ci4/app/Services/ProductionService.php b/ci4/app/Services/ProductionService.php index a1361cbf..74d96614 100644 --- a/ci4/app/Services/ProductionService.php +++ b/ci4/app/Services/ProductionService.php @@ -90,7 +90,6 @@ class ProductionService extends BaseService $this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["sin_imprimir"]; return $this; } catch (\Throwable $th) { - dd($orden_trabajo_id); throw $th; } } @@ -141,10 +140,10 @@ class ProductionService extends BaseService ]; $id = $this->otModel->insert($data); $this->init($id); - $this->updatePedidoEspera(); $this->storeOrdenTrabajoUsers(); $this->storeOrdenTrabajoDates(); $this->storeAllTareas(); + $this->updatePedidoEspera(); return $this->ot; } @@ -177,6 +176,24 @@ class ProductionService extends BaseService "orden_trabajo_id" => $this->ot->id, ]); } + public function reInsertOrdenTrabajoUsers(): int|bool|string + { + $status = false; + if($this->otUser->where('orden_trabajo_id',$this->ot->id)->countAllResults() == 0) + { + $status = $this->storeOrdenTrabajoUsers(); + } + return $status; + } + public function reInsertOrdenTrabajoDates(): int|bool|string + { + $status = false; + if($this->otDate->where('orden_trabajo_id',$this->ot->id)->countAllResults() == 0) + { + $status = $this->storeOrdenTrabajoDates(); + } + return $status; + } protected function storeAllTareas() { $this->storeOrdenTrabajoTareas(); @@ -757,8 +774,8 @@ class ProductionService extends BaseService { $result = []; $otDate = $this->otDate->where('orden_trabajo_id', $this->ot->id) - ->set([$data['name'] => $data[$data['name']]]) - ->update($data); + ->set($data['name'],$data[$data['name']]) + ->update(); $this->otDate->updateUserDateMap($this->ot->id, $data); $ot_users = $this->ot->users(); if (isset($this->ordenTrabajoConfig->DATE_USER_MAPPING[$data["name"]])) { @@ -1063,7 +1080,7 @@ class ProductionService extends BaseService $status = false; $presupuestoFiles = $this->presupuesto->files(); if (count($presupuestoFiles) == 0) { - $status = $this->otModel->update($this->ot->id, ['pedido_espera' => true]); + $status = $this->otModel->update($this->ot->id, ['is_pedido_espera' => true]); } return $status; } diff --git a/httpdocs/assets/js/safekat/pages/produccion/ot.js b/httpdocs/assets/js/safekat/pages/produccion/ot.js index 7dd458a0..27090ebd 100644 --- a/httpdocs/assets/js/safekat/pages/produccion/ot.js +++ b/httpdocs/assets/js/safekat/pages/produccion/ot.js @@ -81,6 +81,15 @@ class OrdenTrabajo { this.prepGrapado = new DatePicker(this.otForm.find("#ot-prep-grapado"), option) this.prepSolapa = new DatePicker(this.otForm.find("#ot-prep-solapa"), option) + this.prepPrototipo = new DatePicker(this.otForm.find("#ot-prep-prototipo"), option) + this.prepMarcapaginas = new DatePicker(this.otForm.find("#ot-prep-marcapaginas"), option) + this.prepRetractilado = new DatePicker(this.otForm.find("#ot-prep-retractilado"), option) + this.prepRetractilado5 = new DatePicker(this.otForm.find("#ot-prep-retractilado5"), option) + + + + + this.espiral = new DatePicker(this.otForm.find("#ot-espiral"), option) this.embalaje = new DatePicker(this.otForm.find("#ot-embalaje"), option) this.envio = new DatePicker(this.otForm.find("#ot-envio"), option) @@ -225,7 +234,7 @@ class OrdenTrabajo { if (element.presupuesto_preimpresion_id) this.createSelectMaquinaAll(selectItem) if (element.presupuesto_extra_id) this.createSelectMaquinaAll(selectItem) if (this.summaryData.impresion_interior_bn) { - let isTareaImpresionInteriorBN = this.summaryData.impresion_interior_bn?.presupuesto_linea_id == element.presupuesto_linea_id + let isTareaImpresionInteriorBN = this.summaryData.impresion_interior_bn?.presupuesto_linea_id == element.presupuesto_linea_id && element.is_corte == false if (isTareaImpresionInteriorBN) { let selectItemImposicion = this.item.find("#select-imposicion-tarea-" + element.id); this.createSelectImposicion(selectItemImposicion) @@ -235,7 +244,7 @@ class OrdenTrabajo { } } if (this.summaryData.impresion_interior_color) { - let isTareaImpresionInteriorColor = this.summaryData.impresion_interior_color?.presupuesto_linea_id == element.presupuesto_linea_id + let isTareaImpresionInteriorColor = this.summaryData.impresion_interior_color?.presupuesto_linea_id == element.presupuesto_linea_id && element.is_corte == false if (isTareaImpresionInteriorColor) { let selectItemImposicion = this.item.find("#select-imposicion-tarea-" + element.id); this.createSelectImposicion(selectItemImposicion) @@ -397,6 +406,11 @@ class OrdenTrabajo { this.prepSolapa.setDate(this.summaryData.dates.solapa_at) this.prepGrapado.setDate(this.summaryData.dates.grapado_at) + this.prepPrototipo.setDate(this.summaryData.dates.prototipo_at) + this.prepMarcapaginas.setDate(this.summaryData.dates.marcapaginas_at) + this.prepRetractilado.setDate(this.summaryData.dates.retractilado_at) + this.prepRetractilado5.setDate(this.summaryData.dates.retractilado5_at) + this.espiral.setDate(this.summaryData.dates.fecha_impresion_at) this.embalaje.setDate(this.summaryData.dates.embalaje_at) this.envio.setDate(this.summaryData.dates.envio_at) From 7ee844fb0cbe6eb3f2b03e64489a1f358f2af4ec Mon Sep 17 00:00:00 2001 From: amazuecos Date: Wed, 16 Apr 2025 09:14:16 +0200 Subject: [PATCH 2/3] colores header pdf ot --- ci4/app/Config/OrdenTrabajo.php | 58 +++++- .../Controllers/Produccion/Ordentrabajo.php | 8 +- .../PresupuestoAcabadosEntity.php | 1 + .../Presupuestos/PresupuestoEntity.php | 1 + .../Produccion/OrdenTrabajoEntity.php | 5 + .../Tarifas/Acabados/TarifaAcabadoEntity.php | 5 + .../Models/OrdenTrabajo/OrdenTrabajoModel.php | 2 +- ci4/app/Services/ProductionService.php | 179 +++++++++++++++++- .../Views/themes/vuexy/pdfs/orden_trabajo.php | 141 ++++++++------ .../assets/js/safekat/pages/pdf/otDownload.js | 1 - httpdocs/themes/vuexy/css/pdf.ot.css | 2 +- 11 files changed, 326 insertions(+), 77 deletions(-) diff --git a/ci4/app/Config/OrdenTrabajo.php b/ci4/app/Config/OrdenTrabajo.php index 2c9a9474..dcedbdc3 100644 --- a/ci4/app/Config/OrdenTrabajo.php +++ b/ci4/app/Config/OrdenTrabajo.php @@ -57,12 +57,66 @@ class OrdenTrabajo extends BaseConfig "cosido" => "#FF0B55", "grapado" => "#FEBA17", "encuadernado" => "#FEBA17", - "corte" => "#67AE6E" + "corte" => "#67AE6E" + ]; + public array $OT_WEEK_COLOR_DAY = [ + ["bg" => "#FFFFFF", "color" => "black"], + ["bg" => "yellow", "color" => "black"], + ["bg" => "purple", "color" => "white"], + ["bg" => "orange", "color" => "white"], + ["bg" => "blue", "color" => "black"], + ["bg" => "pink", "color" => "black"], + ["bg" => "#FFFFFF", "color" => "black"], + ]; + public array $OT_ENCUADERNACION_COLOR = [ + "RF" => ["bg" => "#FF9900", "color" => "white"], + "RFS" => ["bg" => "#FF9900", "color" => "white"], + "RCHV" => ["bg" => "#FF9900", "color" => "blue"], + "RCHVS" => ["bg" => "#FF9900", "color" => "blue"], + "CC2" => ["bg" => "#104861", "color" => "yellow"], + "CC2S" => ["bg" => "#104861", "color" => "yellow"], + "TDF" => ["bg" => "#E49EDD", "color" => "white"], + "TDC" => ["bg" => "#E49EDD", "color" => "blue"], + "default" => ["bg" => "#FFFF00", "color" => "red"], + ]; + public array $OT_BACKGROUND_COLOR = [ + "ferro_digital" => ["bg" => "#BFBFBF","color" => "black"], + "ferro" => ["bg" => "#BFBFBF","color" => "black"], + "prototipo" => ["bg" => "#BFBFBF","color" => "black"], + "pod" => ["bg" => "#47D359","color" => "black"], + "inaplazable" => ["bg" => "red","color" => "white"], + "default" => ["bg" => "#FFFFFF","color" => "black"] + ]; + public array $OT_PAPEL_COLOR = + [ + "blanco" => ["bg" => "#FFFFFF", "color" => "black"], + "ahuesado" => ["bg" => "#FFF2CC", "color" => "black"], + "marfil" => ["bg" => "#FFD966", "color" => "black"], + "volumen_ahuesado" => ["bg" => "#BF8F00", "color" => "black"], + "estucado_mate" => ["bg" => "#BDD7EE", "color" => "black"], + "cartulina" => ["bg" => "#C6E0B4", "color" => "black"], + "default" => ["bg" => "#FFCCFF", "color" => "black"], + ]; + public array $OT_PLASTIFICADO_COLOR = + [ + "BRIL" => ["bg" => "#00B0F0", "color" => "white"], + "MATE" => ["bg" => "#FF0000", "color" => "white"], + "SOFT_TOUCH" => ["bg" => "#00B050", "color" => "white"], + "SANDY" => ["bg" => "#782170", "color" => "white"], + "ANTIRAYADO" => ["bg" => "#E97132", "color" => "white"], + "GOFRADO" => ["bg" => "#FFFF00", "color" => "black"], + "default" => ["bg" => "#FFFFFF", "color" => "black"], + ]; + public array $OT_IMPRESION_INTERIOR_PPAL_COLOR = + [ + "ROTATIVA" => ["bg" => "white", "color" => "red"], + "POD" => ["bg" => "white", "color" => "#47D359"], + "GENERAL" => ["bg" => "white", "color" => "#A02B93"], + "default" => ["bg" => "white", "color" => "black"], ]; public function __construct() { parent::__construct(); } - } diff --git a/ci4/app/Controllers/Produccion/Ordentrabajo.php b/ci4/app/Controllers/Produccion/Ordentrabajo.php index 41bd2391..6ffd2d9d 100755 --- a/ci4/app/Controllers/Produccion/Ordentrabajo.php +++ b/ci4/app/Controllers/Produccion/Ordentrabajo.php @@ -168,7 +168,7 @@ class Ordentrabajo extends BaseController ->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name,"color" => $this->produccionService->init($q->id)->getOtColorStatus()]) ->edit( "fecha_encuadernado_at", - fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d", $q->fecha_encuadernado_at)->format("d/m/Y") : "" + fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d H:i:s", $q->fecha_encuadernado_at)->format("d/m/Y") : "" ) ->add("action", fn($q) => $q->id) ->toJson(true); @@ -183,7 +183,7 @@ class Ordentrabajo extends BaseController ->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name,"color" => $this->produccionService->init($q->id)->getOtColorStatus()]) ->edit( "fecha_encuadernado_at", - fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d", $q->fecha_encuadernado_at)->format("d/m/Y") : "" + fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d H:i:s", $q->fecha_encuadernado_at)->format("d/m/Y") : "" ) ->add("action", fn($q) => $q->id) ->toJson(true); @@ -198,7 +198,7 @@ class Ordentrabajo extends BaseController ->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name,"color" => $this->produccionService->init($q->id)->getOtColorStatus()]) ->edit( "fecha_encuadernado_at", - fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d", $q->fecha_encuadernado_at)->format("d/m/Y") : "" + fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d H:i:s", $q->fecha_encuadernado_at)->format("d/m/Y") : "" ) ->add("action", fn($q) => $q->id) ->toJson(true); @@ -213,7 +213,7 @@ class Ordentrabajo extends BaseController ->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name,"color" => $this->produccionService->init($q->id)->getOtColorStatus()]) ->edit( "fecha_encuadernado_at", - fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d", $q->fecha_encuadernado_at)->format("d/m/Y") : "" + fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d H:i:s", $q->fecha_encuadernado_at)->format("d/m/Y") : "" ) ->add("action", fn($q) => $q->id) ->toJson(true); diff --git a/ci4/app/Entities/Presupuestos/PresupuestoAcabadosEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoAcabadosEntity.php index 0709ccb9..c0ab643e 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoAcabadosEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoAcabadosEntity.php @@ -54,4 +54,5 @@ class PresupuestoAcabadosEntity extends \CodeIgniter\Entity\Entity $m = model(TarifaAcabadoModel::class); return $m->find($this->attributes["tarifa_acabado_id"]); } + } diff --git a/ci4/app/Entities/Presupuestos/PresupuestoEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoEntity.php index 9fc90892..c9c71790 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoEntity.php @@ -300,4 +300,5 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity $files = $m->where('presupuesto_id',$this->attributes['id'])->findAll(); return $files ?? []; } + } diff --git a/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php b/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php index 3ac4e474..8bc67adc 100644 --- a/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php +++ b/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php @@ -74,6 +74,11 @@ class OrdenTrabajoEntity extends Entity $m = model(OrdenTrabajoTarea::class); return $m->where("orden_trabajo_id", $this->attributes["id"])->findAll(); } + public function tareas_impresion() : array + { + $m = model(OrdenTrabajoTarea::class); + return $m->where("orden_trabajo_id", $this->attributes["id"])->where("presupuesto_linea_id IS NOT NULL", NULL, FALSE)->findAll() ?? []; + } /** * Devuelve el pedido de la orden de trabajo * diff --git a/ci4/app/Entities/Tarifas/Acabados/TarifaAcabadoEntity.php b/ci4/app/Entities/Tarifas/Acabados/TarifaAcabadoEntity.php index 818d42e1..cb96db44 100644 --- a/ci4/app/Entities/Tarifas/Acabados/TarifaAcabadoEntity.php +++ b/ci4/app/Entities/Tarifas/Acabados/TarifaAcabadoEntity.php @@ -45,4 +45,9 @@ class TarifaAcabadoEntity extends \CodeIgniter\Entity\Entity $ta_maquinas = $m->where('tarifa_acabado_id',$this->attributes['id'])->findAll(); return array_map(fn(TarifaAcabadoMaquinaEntity $ta_maquina) => $ta_maquina->maquina(),$ta_maquinas); } + + public function isUVI(): bool + { + return in_array($this->attributes["code"],["R3D","R2D"]); + } } diff --git a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoModel.php b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoModel.php index 2554d37f..440b4cad 100644 --- a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoModel.php +++ b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoModel.php @@ -73,7 +73,7 @@ class OrdenTrabajoModel extends Model ->select([ "ordenes_trabajo.id", "ordenes_trabajo.pedido_id", - "orden_trabajo_dates.fecha_encuadernado_at", + "pedidos.fecha_encuadernado as fecha_encuadernado_at", "clientes.nombre as cliente_nombre", "presupuestos.titulo as presupuesto_titulo", "ordenes_trabajo.estado", diff --git a/ci4/app/Services/ProductionService.php b/ci4/app/Services/ProductionService.php index 74d96614..72411210 100644 --- a/ci4/app/Services/ProductionService.php +++ b/ci4/app/Services/ProductionService.php @@ -16,6 +16,7 @@ use CodeIgniter\Config\BaseService; use App\Entities\Configuracion\Maquina as MaquinaEntity; use App\Entities\Produccion\OrdenTrabajoFileEntity; use App\Entities\Produccion\OrdenTrabajoTareaEntity; +use App\Entities\Tarifas\Acabados\TarifaAcabadoEntity; use App\Models\Configuracion\ConfigVariableModel; use App\Models\Configuracion\MaquinaModel; use App\Models\OrdenTrabajo\OrdenTrabajoFileModel; @@ -46,7 +47,10 @@ class ProductionService extends BaseService protected OrdenTrabajoFileModel $otFileModel; protected PedidoModel $pedidoModel; protected UserModel $userModel; + protected ConfigVariableModel $configVariableModel; protected string $defaultMaquinaCorteName = 'HT-1000'; + protected int $podValue = 0; + protected bool $isPOD = false; protected MaquinaEntity $defaultMaquinaCorte; protected MaquinaModel $maquinaModel; protected OrdenTrabajo $ordenTrabajoConfig; @@ -76,6 +80,8 @@ class ProductionService extends BaseService $this->pedidoModel = model(PedidoModel::class); $this->ordenTrabajoConfig = config('OrdenTrabajo'); $this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["sin_imprimir"]; + $this->configVariableModel = model(ConfigVariableModel::class); + $this->podValue = $this->configVariableModel->getVariable('POD')->value; } public function init(int $orden_trabajo_id): self { @@ -106,6 +112,7 @@ class ProductionService extends BaseService $this->otModel = model(OrdenTrabajoModel::class); $this->otDate = model(OrdenTrabajoDate::class); $this->otTarea = model(OrdenTrabajoTarea::class); + $this->isPOD = $this->presupuesto->tirada <= $this->podValue; return $this; } /** @@ -179,8 +186,7 @@ class ProductionService extends BaseService public function reInsertOrdenTrabajoUsers(): int|bool|string { $status = false; - if($this->otUser->where('orden_trabajo_id',$this->ot->id)->countAllResults() == 0) - { + if ($this->otUser->where('orden_trabajo_id', $this->ot->id)->countAllResults() == 0) { $status = $this->storeOrdenTrabajoUsers(); } return $status; @@ -188,8 +194,7 @@ class ProductionService extends BaseService public function reInsertOrdenTrabajoDates(): int|bool|string { $status = false; - if($this->otDate->where('orden_trabajo_id',$this->ot->id)->countAllResults() == 0) - { + if ($this->otDate->where('orden_trabajo_id', $this->ot->id)->countAllResults() == 0) { $status = $this->storeOrdenTrabajoDates(); } return $status; @@ -683,6 +688,10 @@ class ProductionService extends BaseService "peso_pedido" => $logistica_data["peso_pedido"], "imposicion" => $this->getImposicionTareaImpresion(), "tiempo_procesamiento" => $this->getTiempoProcesamientoHHMM(), + "tiempo_impresion" => $this->getTiempoTareasImpresionHHMM(), + "colors" => $this->getPdfColors(), + "isPOD" => $this->isPOD, + "uvi" => $this->getUVI() ]; } @@ -774,7 +783,7 @@ class ProductionService extends BaseService { $result = []; $otDate = $this->otDate->where('orden_trabajo_id', $this->ot->id) - ->set($data['name'],$data[$data['name']]) + ->set($data['name'], $data[$data['name']]) ->update(); $this->otDate->updateUserDateMap($this->ot->id, $data); $ot_users = $this->ot->users(); @@ -1117,6 +1126,24 @@ class ProductionService extends BaseService $seconds = array_sum($time_tareas_seconds); return float_seconds_to_hhmm_string($seconds); } + public function getTiempoTareasImpresionHHMM():string { + $tareas_impresion = $this->ot->tareas_impresion(); + $time_tareas_seconds = array_map(fn($q) => $q->tiempo_estimado ?? 0, $tareas_impresion); + $seconds = array_sum($time_tareas_seconds); + return float_seconds_to_hhmm_string($seconds); + + } + public function getUVI() : ?TarifaAcabadoEntity + { + $uvi = null; + $acabados = $this->presupuesto->acabados(); + foreach ($acabados as $key => $acabado) { + if($acabado->tarifa()->isUVI()){ + $uvi = $acabado->tarifa(); + } + } + return $uvi; + } public function updateProgress(): bool { $userDates = $this->ordenTrabajoConfig->DATE_USER_MAPPING; @@ -1142,7 +1169,7 @@ class ProductionService extends BaseService } public function getOtColorStatus(): string { - if($this->ot->dates()){ + if ($this->ot->dates()) { $this->updateColor(); } return $this->statusColor; @@ -1207,7 +1234,8 @@ class ProductionService extends BaseService $this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["grapado"]; }; } - protected function updateColor(){ + protected function updateColor() + { $this->otSinImprimirColor(); $this->otImpresionIntColor(); $this->otCosidoColor(); @@ -1219,4 +1247,141 @@ class ProductionService extends BaseService $this->otEncuadernadoColor(); $this->otCorteColor(); } + public function getEncuadernacionCode(): ?string + { + $code = ""; + $encuadernaciones = $this->presupuesto->encuadernaciones(); + if (isset($encuadernaciones[0])) { + $code = $encuadernaciones[0]->tarifa()->code; + } + return $code; + } + public function getEncuadernacionColor(): array + { + $color = $this->ordenTrabajoConfig->OT_ENCUADERNACION_COLOR["default"]; + $encuadernacion_code = $this->getEncuadernacionCode(); + if ($encuadernacion_code) { + if (isset($this->ordenTrabajoConfig->OT_ENCUADERNACION_COLOR[$encuadernacion_code])) { + $color = $this->ordenTrabajoConfig->OT_ENCUADERNACION_COLOR[$encuadernacion_code]; + } + } + return $color; + } + public function getWeekDayColor(): array + { + $color = $this->ordenTrabajoConfig->OT_WEEK_COLOR_DAY[0]; + if ($this->ot->pedido()->fecha_encuadernado) { + $week_day = Time::createFromFormat("Y-m-d H:i:s", $this->ot->pedido()->fecha_encuadernado)->getDayOfWeek(); + $color = $this->ordenTrabajoConfig->OT_WEEK_COLOR_DAY[$week_day]; + } + return $color; + } + public function getGeneralBackgroundColor() + { + $color = $this->ordenTrabajoConfig->OT_BACKGROUND_COLOR['default']; + $is_ferro_or_prototipo = ($this->presupuesto->ferro || $this->presupuesto->ferro_digital || $this->presupuesto->prototipo); + $color = $is_ferro_or_prototipo ? $this->ordenTrabajoConfig->OT_BACKGROUND_COLOR['ferro'] : $color; + $color = $this->isPOD ? $this->ordenTrabajoConfig->OT_BACKGROUND_COLOR['pod'] : $color; + $color = $this->pedido->inaplazable ? $this->ordenTrabajoConfig->OT_BACKGROUND_COLOR['inaplazable'] : $color; + return $color; + } + 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']; + } + } + + return $color; + } + 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']; + } + } + return $color; + } + public function getPlastificadoColor() + { + $acabados = $this->presupuesto->acabados(); + $color = $this->ordenTrabajoConfig->OT_PLASTIFICADO_COLOR['default']; + foreach ($acabados as $key => $acabado) { + $tarifa_acabado = $acabado->tarifa(); + if ($tarifa_acabado->code) { + $plastificado_code = $tarifa_acabado->code; + if ($plastificado_code == "BRIL") { + $color = $this->ordenTrabajoConfig->OT_PLASTIFICADO_COLOR['BRIL']; + } + if ($plastificado_code == "MATE") { + $color = $this->ordenTrabajoConfig->OT_PLASTIFICADO_COLOR['MATE']; + } + if ($plastificado_code == "ANTI") { + $color = $this->ordenTrabajoConfig->OT_PLASTIFICADO_COLOR['ANTIRAYADO']; + } + if ($plastificado_code == "SAND") { + $color = $this->ordenTrabajoConfig->OT_PLASTIFICADO_COLOR['SANDY']; + } + } + } + return $color; + } + public function getImpresionInteriorPPALColor() + { + $isRotativa = $this->presupuesto->presupuestoLineaImpresion()->isRotativa(); + $color = $isRotativa ? $this->ordenTrabajoConfig->OT_IMPRESION_INTERIOR_PPAL_COLOR['ROTATIVA'] : $this->ordenTrabajoConfig->OT_IMPRESION_INTERIOR_PPAL_COLOR['GENERAL'] ; + $color = $this->isPOD ? $this->ordenTrabajoConfig->OT_IMPRESION_INTERIOR_PPAL_COLOR['POD'] : $color; + return $color; + + } + public function getPdfColors(): array + { + return [ + "general" => $this->getGeneralBackgroundColor(), + "week_day" => $this->getWeekDayColor(), + "ot" => $this->getEncuadernacionColor(), + "papel_interior" => $this->getPapelImpresionBackgroundColor(), + "papel_cubierta" => $this->getPapelImpresionCubiertaBackgroundColor(), + "plastificado" => $this->getPlastificadoColor(), + "impresion_interior_ppal" => $this->getImpresionInteriorPPALColor() + ]; + } } diff --git a/ci4/app/Views/themes/vuexy/pdfs/orden_trabajo.php b/ci4/app/Views/themes/vuexy/pdfs/orden_trabajo.php index e4ef7af2..de716938 100644 --- a/ci4/app/Views/themes/vuexy/pdfs/orden_trabajo.php +++ b/ci4/app/Views/themes/vuexy/pdfs/orden_trabajo.php @@ -36,7 +36,7 @@ $settings = $session->get('settings');
id ?>>
-

titulo ?>

+
titulo ?>
format("d/m/Y H:i:s") ?>
@@ -46,79 +46,98 @@ $settings = $session->get('settings');
portada_path)) : '/assets/img/portada_not_found.png' ?>" />
-
py-2 rounded border-1 border-secondary"> +
;color:;">
-
- fecha_encuadernado ? week_day_humanize(Time::createFromFormat("Y-m-d H:i:s", $pedido->fecha_encuadernado)->getDayOfWeek(), true) : "" ?> +
;color:;"> + fecha_encuadernado ? week_day_humanize(Time::createFromFormat("Y-m-d H:i:s", $pedido->fecha_encuadernado)->getDayOfWeek() - 1, true) : "" ?> Comercial: first_name . " " . $cliente->comercial()->last_name ?>
-
- presupuestoLineaImpresion()->isRotativa() ? "Rotativa" : "Plana" ?> +
+ ;color:;"> + + ROTATIVA + presupuestoLineaImpresion()->isRotativa()): ?> + ROTATIVA + + GENERAL + + + +
-
+
-
"> - " id="fecha_encuadernado_at">fecha_encuadernado ? Time::createFromFormat("Y-m-d H:i:s", $pedido->fecha_encuadernado)->format('d/m/Y') : "" ?> -
-
- tarifa()->code ?? "?" : "?" ?> +
+ ;">fecha_encuadernado ? Time::createFromFormat("Y-m-d H:i:s", $pedido->fecha_encuadernado)->format('d/m/Y') : "??" ?>
- - + + - - + + - - + + - - + + - - + +
IN
IN
PO
PORT.
PL
ACABAD.
EN
ENCUAD.
MA
MANIPUL.
-
-
-
- papel_impresion()->papel_code_ot ?> -
-
border border-right border-dark"> - -
-
- papel_impresion()->papel_code_ot ?> -
-
- tarifa()->code : "" ?> +
+
+
;color:;"> + tarifa()->code ?? "?" : "?" ?>
-
-
-
-
- id ?> +
+
;color:;"> + papel_impresion()->papel_code_ot ?>
-
+
"> + +
+
;color:;"> + papel_impresion()->papel_code_ot ?> +
+
;color:;"> + tarifa()->code : "" ?> +
+ $acabado): ?> + tarifa()->isUVI()): ?> +
;color:white;"> + + tarifa()->code ?> +
+ + +
+
+
"> +
+
+ ;">id ?> +
+
barcode
@@ -132,25 +151,25 @@ $settings = $session->get('settings');
- + - + - + - - + +
ClienteCLIENTE - nombre ?> + alias ?>
TituloTITULO titulo ?>
ISBNISBN isbn ?>
CIFcif ?>PEDIDO CLIENTEid ?>
@@ -198,18 +217,18 @@ $settings = $session->get('settings');
IMP. INTERIOR
- - - - - - - - - - - -
ancho ?>xalto ?> tirada ?> tipo ?> lomo_cubierta,2,',','.') ?>
+ + + + + + + + + + + +
ancho ?>xalto ?> tirada ?> tipo ?> lomo_cubierta, 2, ',', '.') ?>
@@ -296,7 +315,7 @@ $settings = $session->get('settings'); - + @@ -319,7 +338,7 @@ $settings = $session->get('settings'); - + diff --git a/httpdocs/assets/js/safekat/pages/pdf/otDownload.js b/httpdocs/assets/js/safekat/pages/pdf/otDownload.js index 65f4aca3..11006c26 100644 --- a/httpdocs/assets/js/safekat/pages/pdf/otDownload.js +++ b/httpdocs/assets/js/safekat/pages/pdf/otDownload.js @@ -1,5 +1,4 @@ $(() => { - console.log("PDF") var opt = { margin: 2, filename: "PDF_OrdenTrabajo_" + $(".pdf-wrapper").data("id") + ".pdf", diff --git a/httpdocs/themes/vuexy/css/pdf.ot.css b/httpdocs/themes/vuexy/css/pdf.ot.css index db367ef9..97ec5c7e 100644 --- a/httpdocs/themes/vuexy/css/pdf.ot.css +++ b/httpdocs/themes/vuexy/css/pdf.ot.css @@ -39,7 +39,7 @@ body{ align-content : center; justify-content: center; font-weight: bold; - font-size : 20px; + font-size : 14px; } .esquema{ From c76f4428a6fcabd1f23cd9c23f8921a5fee3993d Mon Sep 17 00:00:00 2001 From: amazuecos Date: Wed, 16 Apr 2025 15:51:09 +0200 Subject: [PATCH 3/3] ot general features --- ci4/app/Config/OrdenTrabajo.php | 1 + .../Controllers/Produccion/Ordentrabajo.php | 5 + ...-16-153000_AddEspiralOrdenTrabajoDates.php | 41 +++ .../Presupuestos/PresupuestoEntity.php | 12 + .../Produccion/OrdenTrabajoDateEntity.php | 1 + .../Produccion/OrdenTrabajoEntity.php | 10 + ci4/app/Language/es/Produccion.php | 14 +- .../Models/OrdenTrabajo/OrdenTrabajoDate.php | 1 + ci4/app/Services/ProductionService.php | 256 +++++++++++++++++- .../vuexy/form/produccion/ot/otDates.php | 12 +- .../vuexy/form/produccion/ot/otHeader.php | 21 +- .../produccion/ot/otPreimpresionReview.php | 12 +- .../vuexy/form/produccion/ot/otProgress.php | 127 +++++---- .../vuexy/form/produccion/ot/otTask.php | 4 +- .../Views/themes/vuexy/pdfs/orden_trabajo.php | 6 +- 15 files changed, 427 insertions(+), 96 deletions(-) create mode 100644 ci4/app/Database/Migrations/2025-04-16-153000_AddEspiralOrdenTrabajoDates.php diff --git a/ci4/app/Config/OrdenTrabajo.php b/ci4/app/Config/OrdenTrabajo.php index dcedbdc3..35f58438 100644 --- a/ci4/app/Config/OrdenTrabajo.php +++ b/ci4/app/Config/OrdenTrabajo.php @@ -25,6 +25,7 @@ class OrdenTrabajo extends BaseConfig "retractilado5_at" => "retractilado5_user_id", "prototipo_at" => "prototipo_user_id", "marcapaginas_at" => "marcapaginas_user_id", + "espiral_at" => "espiral_user_id", //FERRO "pendiente_ferro_at" => "pendiente_ferro_user_id", "ferro_en_cliente_at" => "ferro_en_cliente_user_id", diff --git a/ci4/app/Controllers/Produccion/Ordentrabajo.php b/ci4/app/Controllers/Produccion/Ordentrabajo.php index 6ffd2d9d..d483680a 100755 --- a/ci4/app/Controllers/Produccion/Ordentrabajo.php +++ b/ci4/app/Controllers/Produccion/Ordentrabajo.php @@ -152,8 +152,13 @@ class Ordentrabajo extends BaseController $this->viewData["presupuesto"] = $this->produccionService->getPresupuesto(); $this->viewData["cliente"] = $this->produccionService->getCliente(); $this->viewData["ot"] = $this->produccionService->getOrdenTrabajo(); + $this->viewData["is_finalizada"] = $this->produccionService->getOrdenTrabajo()->estado == "F"; $this->viewData["user_dates"] = $this->produccionService->userDates(); $this->viewData["pedido_user_dates"] = $this->produccionService->pedidoUserDates(); + $this->viewData["colors"] = $this->produccionService->getPdfColors(); + $this->viewData["tiempo_estimado"] = $this->produccionService->getTiempoProcesamientoHHMM(); + $this->viewData["flags"] = $this->produccionService->getFlags(); + return view(static::$viewPath . $this->editRoute, $this->viewData); } diff --git a/ci4/app/Database/Migrations/2025-04-16-153000_AddEspiralOrdenTrabajoDates.php b/ci4/app/Database/Migrations/2025-04-16-153000_AddEspiralOrdenTrabajoDates.php new file mode 100644 index 00000000..bdf79a02 --- /dev/null +++ b/ci4/app/Database/Migrations/2025-04-16-153000_AddEspiralOrdenTrabajoDates.php @@ -0,0 +1,41 @@ + [ + "type" => "DATE", + "null" => true, + ], + ]; + protected array $USERS = [ + "espiral_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + ]; + + public function up() + { + $this->forge->addColumn("orden_trabajo_dates", $this->DATES); + $this->forge->addColumn("orden_trabajo_users", $this->USERS); + foreach ($this->USERS as $key => $value) { + $this->forge->addForeignKey([$key],"users",["id"]); + } + } + + public function down() + { + $this->forge->dropColumn("orden_trabajo_dates", array_keys($this->DATES)); + $this->forge->dropColumn("orden_trabajo_users", array_keys($this->USERS)); + + + } +} diff --git a/ci4/app/Entities/Presupuestos/PresupuestoEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoEntity.php index c9c71790..8d776bc7 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoEntity.php @@ -4,8 +4,10 @@ namespace App\Entities\Presupuestos; use App\Entities\Clientes\ClienteEntity; use App\Entities\Configuracion\PapelFormatoEntity; +use App\Entities\Configuracion\TipoPresupuestoEntity; use App\Models\Clientes\ClienteModel; use App\Models\Configuracion\PapelFormatoModel; +use App\Models\Configuracion\TipoPresupuestoModel; use App\Models\Presupuestos\PresupuestoAcabadosModel; use App\Models\Presupuestos\PresupuestoEncuadernacionesModel; use App\Models\Presupuestos\PresupuestoFicheroModel; @@ -300,5 +302,15 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity $files = $m->where('presupuesto_id',$this->attributes['id'])->findAll(); return $files ?? []; } + public function tipo_presupuesto() : ?TipoPresupuestoEntity + { + $tipo_presupuesto = null; + $m = model(TipoPresupuestoModel::class); + if($this->attributes["tipo_impresion_id"]){ + $tipo_presupuesto = $m->find($this->attributes['tipo_impresion_id']); + } + return $tipo_presupuesto; + + } } diff --git a/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php b/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php index e106c57c..19ad97ab 100644 --- a/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php +++ b/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php @@ -28,6 +28,7 @@ class OrdenTrabajoDateEntity extends Entity "retractilado5_at"=> null, "prototipo_at"=> null, "marcapaginas_at"=> null, + "espiral_at"=> null, //FERRO "pendiente_ferro_at" => null, "ferro_en_cliente_at" => null, diff --git a/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php b/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php index 8bc67adc..9df7e7ce 100644 --- a/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php +++ b/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php @@ -153,4 +153,14 @@ class OrdenTrabajoEntity extends Entity } return $portada_path; } + public function getEstadoText(): string + { + $estados = [ + "E" => lang('Produccion.error'), + "I" => lang('Produccion.iniciada'), + "F" => lang('Produccion.finalizada'), + "PM" => lang("Produccion.pendiente_material") + ]; + return $estados[$this->attributes["estado"]]; + } } diff --git a/ci4/app/Language/es/Produccion.php b/ci4/app/Language/es/Produccion.php index e5b622b0..cd8b95d3 100644 --- a/ci4/app/Language/es/Produccion.php +++ b/ci4/app/Language/es/Produccion.php @@ -71,6 +71,7 @@ return [ "tiempo_consumido" => "Tiempo consumido", "tiempo_estimado" => "Tiempo estimado", "finalizar_orden" => "Finalizar orden", + "reactivar_orden" => "Reactivar", "comments" => "Comentarios orden trabajo", "preview_pdf" => "Previsualizar PDF", "imprimir_codigo_safekat" => "Imprimir código SAFEKAT", @@ -105,13 +106,22 @@ return [ "pre_codbarras" => "Revisión código barras", "pre_imposicion" => "Revisión imposición", - + "iniciada" => "Iniciada", + "finalizada" => "Finalizada", + "error" => "Error", + "pendiente_material" => "Pendiente material", + "empty" => "Vacio", "errors" => [ "date_not_exist" => "Esta fecha no existe en el modelo", "attr_not_exist" => "El atributo {0,string} no pertenece al modelo Pedido" - ] + ], + + "progress_preimpresion" => "Preimpresión", + "progress_logistica" => "Ferro/Logística", + "progress_impresion" => "Impresión", + "progress_manipulado" => "Manipulado/Acabado" diff --git a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php index 555f6415..51234724 100644 --- a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php +++ b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php @@ -35,6 +35,7 @@ class OrdenTrabajoDate extends Model "retractilado5_at", "prototipo_at", "marcapaginas_at", + "espiral_at", //FERRO "pendiente_ferro_at", "ferro_en_cliente_at", diff --git a/ci4/app/Services/ProductionService.php b/ci4/app/Services/ProductionService.php index 72411210..784365a7 100644 --- a/ci4/app/Services/ProductionService.php +++ b/ci4/app/Services/ProductionService.php @@ -35,7 +35,17 @@ use Exception; */ class ProductionService extends BaseService { + /** + * Tipos de impresion para identificar linea de impresion plana/general + * + * @var array + */ public array $TIPOS_PLANA = ['lp_bn', 'lp_color', 'lp_colorhq']; + /** + * Tipos de impresion para idenficiar si es rotativa + * + * @var array + */ public array $TIPOS_ROTATIVA = ['lp_rot_bn', 'lp_rot_color']; protected OrdenTrabajoModel $otModel; @@ -48,14 +58,98 @@ class ProductionService extends BaseService protected PedidoModel $pedidoModel; protected UserModel $userModel; protected ConfigVariableModel $configVariableModel; - protected string $defaultMaquinaCorteName = 'HT-1000'; - protected int $podValue = 0; - protected bool $isPOD = false; protected MaquinaEntity $defaultMaquinaCorte; protected MaquinaModel $maquinaModel; protected OrdenTrabajo $ordenTrabajoConfig; - public string $statusColor; + + /** + * Nombre de la maquina por defecto para realizar la tarea de corte. + * + * @var string 'HT-1000' + */ + protected string $defaultMaquinaCorteName = 'HT-1000'; + /** + * Color del header en el formulario de orden de trabajo + * + * @var string + */ + public string $statusColor; + /** + * Valor límite del POD + * + * `$this->configVariableModel->getVariable('POD')->value;` + * @var integer + */ + protected int $podValue = 0; + /** + * Indica si es POD + * + * `tirada <= podValue` + * @var boolean + */ + protected bool $isPOD = false; + + /** + * Indica si la orden de trabajo contiene gofrado + * Se usa para mostrar la fecha correspondiente en la vista + * @var boolean + */ + public bool $isGofrado = false; //* CHECK DONE + /** + * Indica si la orden de trabajo contiene gofrado + * Se usa para mostrar la fecha correspondiente en la vista + * TODO Hay que implementar un boolean en `lg_tarifa_acabado` para identificar + * @var boolean + */ + public bool $isGrapado = true; //TODO + /** + * Indica si la orden de trabajo contiene espiral + * Se usa para mostrar la fecha correspondiente en la vista + * TODO Hay que implementar un boolean en `lg_tarifa_manipulado` para identificar + * DEFAULT true hasta implementacion + * @var boolean + */ + public bool $isEspiral = true; //TODO + /** + * Indica si la orden de trabajo contiene UVI + * Se usa para mostrar la fecha correspondiente en la vista + * @var boolean + */ + public bool $isUVI = false; //* CHECK DONE + /** + * Indica si la orden de trabajo contiene plastificado + * Se usa para mostrar la fecha correspondiente en la vista + * TODO Hay que implementar un boolean en `lg_tarifa_acabado` para identificar + * DEFAULT true hasta implementacion + * @var boolean + */ + public bool $isPlastificado = true; //TODO + /** + * Indica si la orden de trabajo contiene cubierta + * Se usa para mostrar la fecha correspondiente en la vista + * @var boolean + */ + public bool $isCubierta = false; //* CHECK DONE + /** + * Indica si la impresion es en color + * Se usa para mostrar la fecha correspondiente en la vista + * @var boolean + */ + public bool $isColor = false; //* CHECK DONE + /** + * Indica si la impresion es en bn + * Se usa para mostrar la fecha correspondiente en la vista + * @var boolean + */ + public bool $isBN = false; //* CHECK DONE + /** + * Indica si hay una tarea de corte + * Se usa para mostrar la fecha correspondiente en la vista + * ! Se añade por defecto siempre en una rotativa una tarea de corte + * @var boolean + */ + public bool $isCorte = false; //* CHECK DONE /** * Pedido Entity * @@ -83,10 +177,10 @@ class ProductionService extends BaseService $this->configVariableModel = model(ConfigVariableModel::class); $this->podValue = $this->configVariableModel->getVariable('POD')->value; } + public function init(int $orden_trabajo_id): self { try { - //code... $this->maquinaModel = model(MaquinaModel::class); $this->otModel = model(OrdenTrabajoModel::class); $this->ot = $this->otModel->find($orden_trabajo_id); @@ -177,12 +271,22 @@ class ProductionService extends BaseService $this->otDate->updateUserDateMap($this->ot->id, $data); return $otDateId; } + /** + * Crea un registro en `orden_trabajo_users` + * + * @return integer|boolean|string + */ protected function storeOrdenTrabajoUsers(): int|bool|string { return $this->otUser->insert([ "orden_trabajo_id" => $this->ot->id, ]); } + /** + * Crea un registro en `orden_trabajo_users` si no ha sido creado previamente + * + * @return integer|boolean|string + */ public function reInsertOrdenTrabajoUsers(): int|bool|string { $status = false; @@ -191,6 +295,11 @@ class ProductionService extends BaseService } return $status; } + /** + * Crea un registro en `orden_trabajo_dates` si no ha sido creado previamente + * + * @return integer|boolean|string + */ public function reInsertOrdenTrabajoDates(): int|bool|string { $status = false; @@ -199,6 +308,11 @@ class ProductionService extends BaseService } return $status; } + /** + * General las correspondientes tareas de la orden de trabajo en la table `orden_trabajo_tareas` + * + * @return integer|boolean|string + */ protected function storeAllTareas() { $this->storeOrdenTrabajoTareas(); @@ -208,6 +322,12 @@ class ProductionService extends BaseService $this->storeOrdenTrabajoEncuadernacionTareas(); // $this->storeOrdenTrabajoExtraTareas(); } + /** + * Regenera las tareas. + * !! Se eliminan las que hay previamente sin `softDelete` + * + * @return integer|boolean|string + */ public function resetAllTareas(): BaseResult|bool { $r = $this->otTarea->where("orden_trabajo_id", $this->ot->id)->delete(purge: true); @@ -244,6 +364,12 @@ class ProductionService extends BaseService } return $insert_query_result; } + /** + * Inserta una tarea de corte si la impresion es en `rotativa` + * + * @param PresupuestoLineaEntity $pLinea + * @return OrdenTrabajoTareaEntity|null + */ protected function storeTareaCorte(PresupuestoLineaEntity $pLinea): ?OrdenTrabajoTareaEntity { $otCorte = null; @@ -264,6 +390,11 @@ class ProductionService extends BaseService return $otCorte; } + /** + * General las tareas de acabado segun las líneas de presupuesto_acabados + * + * @return boolean + */ protected function storeOrdenTrabajoAcabadoTareas(): bool { $p_lineas = $this->presupuesto_lineas_acabado(); @@ -290,6 +421,11 @@ class ProductionService extends BaseService } return true; } + /** + * General las tareas de acabado segun las líneas de presupuesto_manipulados + * + * @return boolean + */ protected function storeOrdenTrabajoManipuladoTareas(): bool { $p_lineas = $this->presupuesto_lineas_manipulado(); @@ -316,6 +452,11 @@ class ProductionService extends BaseService } return true; } + /** + * General las tareas de acabado segun las líneas de presupuesto_preimpresion + * + * @return boolean + */ protected function storeOrdenTrabajoPreimpresionTareas(): bool { $p_lineas = $this->presupuesto_lineas_preimpresion(); @@ -342,6 +483,11 @@ class ProductionService extends BaseService } return true; } + /** + * General las tareas de acabado segun las líneas de presupuesto_encuadernaciones + * + * @return boolean + */ protected function storeOrdenTrabajoEncuadernacionTareas(): bool { $p_lineas = $this->presupuesto_lineas_encuadernaciones(); @@ -1126,19 +1272,23 @@ class ProductionService extends BaseService $seconds = array_sum($time_tareas_seconds); return float_seconds_to_hhmm_string($seconds); } - public function getTiempoTareasImpresionHHMM():string { + public function getTiempoTareasImpresionHHMM(): string + { $tareas_impresion = $this->ot->tareas_impresion(); - $time_tareas_seconds = array_map(fn($q) => $q->tiempo_estimado ?? 0, $tareas_impresion); - $seconds = array_sum($time_tareas_seconds); - return float_seconds_to_hhmm_string($seconds); - + $tiempo_seconds = 0; + foreach ($tareas_impresion as $key => $tarea) { + if ($tarea->is_corte == false) { + $tiempo_seconds += $tarea->tiempo_estimado; + } + } + return float_seconds_to_hhmm_string($tiempo_seconds); } - public function getUVI() : ?TarifaAcabadoEntity + public function getUVI(): ?TarifaAcabadoEntity { $uvi = null; $acabados = $this->presupuesto->acabados(); foreach ($acabados as $key => $acabado) { - if($acabado->tarifa()->isUVI()){ + if ($acabado->tarifa()->isUVI()) { $uvi = $acabado->tarifa(); } } @@ -1360,6 +1510,9 @@ class ProductionService extends BaseService if ($plastificado_code == "SAND") { $color = $this->ordenTrabajoConfig->OT_PLASTIFICADO_COLOR['SANDY']; } + if ($plastificado_code == "GOF") { + $color = $this->ordenTrabajoConfig->OT_PLASTIFICADO_COLOR['GOFRADO']; + } } } return $color; @@ -1367,10 +1520,9 @@ class ProductionService extends BaseService public function getImpresionInteriorPPALColor() { $isRotativa = $this->presupuesto->presupuestoLineaImpresion()->isRotativa(); - $color = $isRotativa ? $this->ordenTrabajoConfig->OT_IMPRESION_INTERIOR_PPAL_COLOR['ROTATIVA'] : $this->ordenTrabajoConfig->OT_IMPRESION_INTERIOR_PPAL_COLOR['GENERAL'] ; + $color = $isRotativa ? $this->ordenTrabajoConfig->OT_IMPRESION_INTERIOR_PPAL_COLOR['ROTATIVA'] : $this->ordenTrabajoConfig->OT_IMPRESION_INTERIOR_PPAL_COLOR['GENERAL']; $color = $this->isPOD ? $this->ordenTrabajoConfig->OT_IMPRESION_INTERIOR_PPAL_COLOR['POD'] : $color; return $color; - } public function getPdfColors(): array { @@ -1384,4 +1536,80 @@ class ProductionService extends BaseService "impresion_interior_ppal" => $this->getImpresionInteriorPPALColor() ]; } + + public function getFlags() + { + $this->color(); + return [ + "isGofrado" => $this->gofrado(), + "isEspiral" => $this->isEspiral, + "isUVI" => $this->uvi(), + "isPlastificado" => $this->isPlastificado, + "isCubierta" => $this->cubierta(), + "isColor" => $this->isColor, + "isBN" => $this->isBN, + "isCorte" => $this->corte(), + "isGrapado" => $this->isGrapado + ]; + } + public function gofrado(): bool + { + $flag = false; + $acabados = $this->presupuesto->acabados(); + foreach ($acabados as $key => $acabado) { + $tarifa_acabado = $acabado->tarifa(); + if ($tarifa_acabado->code) { + $plastificado_code = $tarifa_acabado->code; + if ($plastificado_code == "GOF") { + $flag = true; + break; + } + } + } + $this->isGofrado = $flag; + return $this->isGofrado; + } + public function uvi(): bool + { + $flag = false; + $tarifa_acabado_uvi = $this->getUVI(); + if ($tarifa_acabado_uvi) { + $flag = true; + } + $this->isUVI = $flag; + return $this->isUVI; + } + public function cubierta(): bool + { + $lineaCubierta = $this->presupuesto->presupuestoLineaCubierta(); + if ($lineaCubierta) { + $this->isCubierta = true; + } + return $this->isCubierta; + } + public function color(): bool + { + $linea_impresion = $this->presupuesto->presupuestoLineaImpresion(); + if ($linea_impresion) { + if ($linea_impresion->isColor()) { + $this->isColor = true; + $this->isBN = false; + } else { + $this->isColor = false; + $this->isBN = true; + } + } + return $this->isColor; + } + public function corte(): bool + { + $ot_tareas = $this->ot->tareas(); + foreach ($ot_tareas as $key => $tarea) { + if ($tarea->is_corte) { + $this->isCorte = true; + break; + } + } + return $this->isCorte; + } } diff --git a/ci4/app/Views/themes/vuexy/form/produccion/ot/otDates.php b/ci4/app/Views/themes/vuexy/form/produccion/ot/otDates.php index c45bb0c8..532f6237 100644 --- a/ci4/app/Views/themes/vuexy/form/produccion/ot/otDates.php +++ b/ci4/app/Views/themes/vuexy/form/produccion/ot/otDates.php @@ -22,7 +22,7 @@
- + >
@@ -31,7 +31,7 @@
- + />
@@ -39,7 +39,7 @@
- + />
@@ -49,13 +49,13 @@
- + />
- + - + @@ -242,7 +242,7 @@ $settings = $session->get('settings'); - +
Plastificado tarifa()->nombre ?> UVI ?? code : "" ?> Máquina $q->nombre, $acabados[0]->maquinas())) ?> Operariotarifa()->nombre ?> solapas ? "SI" : "NO" ?> hasSobrecubierta() ? "SI" : "NO" ?>____________________ guardas ? "SI" : "NO" ?> retractilado ? "SI" : "NO" ?> marcapaginas ? "SI" : "NO" ?> ancho ?>xalto ?> tirada ?> tirada ?> + merma ?> tipo ?> tipo_presupuesto()?->codigo ?? "" ?> lomo_cubierta, 2, ',', '.') ?>
paginas ?>tirada ?>tirada ?> ?? formas)->formas ?> maquina()->nombre ?>