From ebf0a9d5d71f617a04042c1c3137c73be100d0e3 Mon Sep 17 00:00:00 2001 From: amazuecos Date: Mon, 14 Apr 2025 20:41:23 +0200 Subject: [PATCH] feat colors --- ci4/app/Config/OrdenTrabajo.php | 12 +++ .../Controllers/Produccion/Ordentrabajo.php | 10 +-- .../Produccion/OrdenTrabajoDateEntity.php | 37 ++++++++- ci4/app/Services/ProductionService.php | 79 ++++++++++++++++++- .../vuexy/components/tables/ot_table.php | 2 +- .../components/datatables/otDatatable.js | 30 ++++++- 6 files changed, 154 insertions(+), 16 deletions(-) diff --git a/ci4/app/Config/OrdenTrabajo.php b/ci4/app/Config/OrdenTrabajo.php index 1d91e1d2..bde32b99 100644 --- a/ci4/app/Config/OrdenTrabajo.php +++ b/ci4/app/Config/OrdenTrabajo.php @@ -40,6 +40,18 @@ class OrdenTrabajo extends BaseConfig "fecha_encuadernado" => "fecha_encuadernado_change_user_id", "fecha_entrega_externo" => "fecha_entrega_externo_change_user_id", ]; + public array $OT_COLORS = [ + "sin_imprimir" => "#FF6363", + "impreso_int" => "#AFDDFF", + "impreso_cub" => "#3A59D1", + "plastificado" => "#FFD63A", + "solapas" => "#4F1C51", + "preparado" => "#FF0B55", + "cosido" => "#FF0B55", + "grapado" => "#FEBA17", + "encuadernado" => "#FEBA17", + "corte" => "#67AE6E" + ]; public function __construct() { diff --git a/ci4/app/Controllers/Produccion/Ordentrabajo.php b/ci4/app/Controllers/Produccion/Ordentrabajo.php index 5bbff500..a7a59257 100755 --- a/ci4/app/Controllers/Produccion/Ordentrabajo.php +++ b/ci4/app/Controllers/Produccion/Ordentrabajo.php @@ -133,7 +133,7 @@ class Ordentrabajo extends BaseController try { $bodyData = $this->request->getPost(); $r = $this->produccionService->init($bodyData["orden_trabajo_id"])->updateOrdenTrabajoPedido($bodyData); - return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r,"data" => $bodyData]); + return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r, "data" => $bodyData]); } catch (\Throwable $th) { return $this->response->setJSON(["errors" => $th->getMessage(), "status" => false])->setStatusCode(500); } @@ -163,7 +163,7 @@ class Ordentrabajo extends BaseController $q = $this->otModel->getDatatableQuery()->where("ordenes_trabajo.estado", "F"); // return $this->response->setJSON($q->get()->getResultArray()); return DataTable::of($q) - ->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name]) + ->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") : "" @@ -178,7 +178,7 @@ class Ordentrabajo extends BaseController $q = $this->otModel->getDatatableQuery()->whereIn("ordenes_trabajo.estado", ["I", "PM"]); // return $this->response->setJSON($q->get()->getResultArray()); return DataTable::of($q) - ->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name]) + ->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") : "" @@ -193,7 +193,7 @@ class Ordentrabajo extends BaseController $q = $this->otModel->getDatatableQuery()->where("ferro_ok_at", null); // return $this->response->setJSON($q->get()->getResultArray()); return DataTable::of($q) - ->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name]) + ->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") : "" @@ -208,7 +208,7 @@ class Ordentrabajo extends BaseController $q = $this->otModel->getDatatableQuery()->where("ferro_ok_at is NOT NULL", NULL, FALSE); // return $this->response->setJSON($q->get()->getResultArray()); return DataTable::of($q) - ->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name]) + ->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") : "" diff --git a/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php b/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php index 352e3ac8..0142b0bf 100644 --- a/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php +++ b/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php @@ -43,9 +43,38 @@ class OrdenTrabajoDateEntity extends Entity 'deleted_at', ]; - protected $casts = [ - ]; - - + protected $casts = []; + public function sinImprimirStatus(): bool + { + return !( + $this->attributes['interior_bn_at'] == null + && $this->attributes['interior_color_at'] == null + && $this->attributes['cubierta_at'] == null + ); + } + public function impresionInteriorStatus():bool + { + return $this->attributes['interior_bn_at']|| $this->attributes['interior_color_at']; + } + public function impresionCubiertaStatus():bool + { + return $this->attributes['cubierta_at'] != null; + } + public function plastificadoStatus():bool + { + return $this->attributes['plastificado_at'] != null; + } + public function encuadernadoStatus():bool + { + return $this->attributes['encuadernacion_at'] != null; + } + public function preparacionInterioresStatus():bool + { + return $this->attributes['preparacion_interiores_at'] != null; + } + public function corteStatus():bool + { + return $this->attributes['corte_at'] != null; + } } diff --git a/ci4/app/Services/ProductionService.php b/ci4/app/Services/ProductionService.php index ade89a42..1392dde4 100644 --- a/ci4/app/Services/ProductionService.php +++ b/ci4/app/Services/ProductionService.php @@ -50,6 +50,7 @@ class ProductionService extends BaseService protected MaquinaEntity $defaultMaquinaCorte; protected MaquinaModel $maquinaModel; protected OrdenTrabajo $ordenTrabajoConfig; + public string $statusColor; /** * Pedido Entity @@ -74,6 +75,7 @@ class ProductionService extends BaseService $this->otFileModel = model(OrdenTrabajoFileModel::class); $this->pedidoModel = model(PedidoModel::class); $this->ordenTrabajoConfig = config('OrdenTrabajo'); + $this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["sin_imprimir"]; } public function init(int $orden_trabajo_id): self { @@ -83,6 +85,7 @@ class ProductionService extends BaseService $pedido = $this->ot->pedido(); $this->setPedido($pedido); $this->defaultMaquinaCorte = $this->maquinaModel->where('nombre', $this->defaultMaquinaCorteName)->first(); + $this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["sin_imprimir"]; return $this; } /** @@ -631,6 +634,7 @@ class ProductionService extends BaseService "tareas_preimpresion" => $this->tareas_preimpresion(), "tareas_impresion" => $this->tareas_impresion(), "tiempo_procesamiento" => $this->getTiempoProcesamientoHHMM(), + "statusColor" => $this->getOtColorStatus(), ]; return $summary; } @@ -1107,10 +1111,81 @@ class ProductionService extends BaseService } $progreso = (float) $fill_dates / $total * 100; - $status = $this->otModel->update($this->ot->id, ["progreso" => round($progreso,2)]); - }else{ + $status = $this->otModel->update($this->ot->id, ["progreso" => round($progreso, 2)]); + } else { $status = $this->otModel->update($this->ot->id, ["progreso" => 100]); } return $status; } + public function getOtColorStatus(): string + { + if($this->ot->dates()){ + $this->updateColor(); + } + return $this->statusColor; + } + protected function otSinImprimirColor() + { + if ($this->ot->dates()->sinImprimirStatus()) { + $this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["sin_imprimir"]; + }; + } + protected function otImpresionIntColor() + { + if ($this->ot->dates()->impresionInteriorStatus()) { + $this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["impreso_int"]; + }; + } + protected function otImpresionCubiertaColor() + { + if ($this->ot->dates()->impresionCubiertaStatus()) { + $this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["impreso_cub"]; + }; + } + protected function otPlastificadoColor() + { + if ($this->ot->dates()->plastificadoStatus()) { + $this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["plastificado"]; + }; + } + protected function otSolapaColor() + { + + } + protected function otEncuadernadoColor() + { + if ($this->ot->dates()->encuadernadoStatus()) { + $this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["encuadernado"]; + }; + } + protected function otPreparadoColor() + { + if ($this->ot->dates()->preparacionInterioresStatus()) { + $this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["preparado"]; + }; + } + protected function otCorteColor() + { + if ($this->ot->dates()->corteStatus()) { + $this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["corte"]; + }; + } + protected function otCosidoColor() + { + } + protected function otGrapadoColor() + { + } + protected function updateColor(){ + $this->otSinImprimirColor(); + $this->otImpresionIntColor(); + $this->otCosidoColor(); + $this->otImpresionCubiertaColor(); + $this->otPlastificadoColor(); + $this->otSolapaColor(); + $this->otPreparadoColor(); + $this->otGrapadoColor(); + $this->otEncuadernadoColor(); + $this->otCorteColor(); + } } diff --git a/ci4/app/Views/themes/vuexy/components/tables/ot_table.php b/ci4/app/Views/themes/vuexy/components/tables/ot_table.php index a611a1c4..21388a84 100644 --- a/ci4/app/Views/themes/vuexy/components/tables/ot_table.php +++ b/ci4/app/Views/themes/vuexy/components/tables/ot_table.php @@ -1,6 +1,6 @@
- +
diff --git a/httpdocs/assets/js/safekat/components/datatables/otDatatable.js b/httpdocs/assets/js/safekat/components/datatables/otDatatable.js index d3e9dd80..c2052b33 100644 --- a/httpdocs/assets/js/safekat/components/datatables/otDatatable.js +++ b/httpdocs/assets/js/safekat/components/datatables/otDatatable.js @@ -55,6 +55,7 @@ class OrdenTrabajoDatatable { }, columnDefs: [ { className: 'dt-center', targets: '_all' }, + ], serverSide: true, pageLength: 25, @@ -62,7 +63,10 @@ class OrdenTrabajoDatatable { url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" }, columns: this.datatableColumns, - ajax: '/produccion/ordentrabajo/datatable' + ajax: '/produccion/ordentrabajo/datatable', + createdRow: (row,data,dataIndex) => { + $(row).css("background-color",data.logo.color) + } }); } initPendientes() { @@ -76,6 +80,7 @@ class OrdenTrabajoDatatable { }, columnDefs: [ { className: 'dt-center', targets: '_all' }, + ], serverSide: true, pageLength: 25, @@ -83,7 +88,10 @@ class OrdenTrabajoDatatable { url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" }, columns: this.datatableColumns, - ajax: '/produccion/ordentrabajo/datatable_pendientes' + ajax: '/produccion/ordentrabajo/datatable_pendientes', + createdRow: (row,data,dataIndex) => { + $(row).css("background-color",data.logo.color) + } }); } initFerroPendiente() { @@ -97,11 +105,18 @@ class OrdenTrabajoDatatable { }, serverSide: true, pageLength: 25, + columnDefs: [ + { className: 'dt-center', targets: '_all' }, + + ], language: { url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" }, columns: this.datatableColumns, - ajax: '/produccion/ordentrabajo/datatable_ferro_pendiente' + ajax: '/produccion/ordentrabajo/datatable_ferro_pendiente', + createdRow: (row,data,dataIndex) => { + $(row).css("background-color",data.logo.color) + } }); } initFerroOk() { @@ -114,12 +129,19 @@ class OrdenTrabajoDatatable { bottomEnd: 'paging' }, serverSide: true, + columnDefs: [ + { className: 'dt-center', targets: '_all' }, + + ], pageLength: 25, language: { url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" }, columns: this.datatableColumns, - ajax: '/produccion/ordentrabajo/datatable_ferro_ok' + ajax: '/produccion/ordentrabajo/datatable_ferro_ok', + createdRow: (row,data,dataIndex) => { + $(row).css("background-color",data.logo.color) + } }); }