diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 718e504b..fb3beb7d 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -746,6 +746,7 @@ $routes->group('produccion', ['namespace' => 'App\Controllers\Produccion'], func $routes->post("update", 'Ordentrabajo::update_orden_trabajo'); $routes->post("upload/portada", 'Ordentrabajo::upload_orden_trabajo_portada'); $routes->delete("portada/(:num)", 'Ordentrabajo::delete_orden_trabajo_portada/$1'); + $routes->get("color/(:num)", 'Ordentrabajo::get_orden_trabajo_color_status/$1'); /**====================== * FILES diff --git a/ci4/app/Controllers/Produccion/Ordentrabajo.php b/ci4/app/Controllers/Produccion/Ordentrabajo.php index a7a59257..8f0610f9 100755 --- a/ci4/app/Controllers/Produccion/Ordentrabajo.php +++ b/ci4/app/Controllers/Produccion/Ordentrabajo.php @@ -328,26 +328,26 @@ class Ordentrabajo extends BaseController } public function planning_rotativa_datatable() { - $q = $this->produccionService->planningRotativaQueryDatatable(); - return DataTable::of($q) + $query = $this->produccionService->planningRotativaQueryDatatable(); + return DataTable::of($query) ->edit("fecha_entrega_real_at", fn($q) => $q->fecha_entrega_real_at ? Time::createFromFormat("Y-m-d", $q->fecha_entrega_real_at)->format("d/m/Y") : "") ->add("metros_check", fn($q) => $q->otId) ->add("corte", fn($q) => ["otId" => $q->otId, "tipo_corte" => $this->produccionService->ordenTrabajoTareaCorte($q->otId)]) - ->add("action", fn($q) => $q) + ->add("action", fn($q) => ["data" => $q]) ->toJson(true); } public function planning_plana_datatable() { - $q = $this->produccionService->planningPlanaQueryDatatable(); + $query = $this->produccionService->planningPlanaQueryDatatable(); $padreId = $this->request->getGet('padre_id'); if ($padreId) { - $q->where('lg_maquinas.padre_id', $padreId); + $query->where('lg_maquinas.padre_id', $padreId); } - return DataTable::of($q) + return DataTable::of($query) ->edit("tiempo_real_sum", fn($q) => $q->tiempo_real_sum) ->edit("fecha_entrega_real_at", fn($q) => $q->fecha_entrega_real_at ? Time::createFromFormat("Y-m-d", $q->fecha_entrega_real_at)->format("d/m/Y") : "") ->add("pliegos_check", fn($q) => $q->otId) - ->add("action", fn($q) => $q) + ->add("action", fn($q) => ["data" => $q ]) ->toJson(true); } public function select_maquina_planning_rot() @@ -431,4 +431,9 @@ class Ordentrabajo extends BaseController ); } } + public function get_orden_trabajo_color_status(int $orden_trabajo_id) + { + $color = $this->produccionService->init($orden_trabajo_id)->getOtColorStatus(); + return $this->response->setJSON(["color" => $color]); + } } diff --git a/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php b/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php index c14bfa37..3ac4e474 100644 --- a/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php +++ b/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php @@ -87,12 +87,12 @@ class OrdenTrabajoEntity extends Entity public function dates(): ?OrdenTrabajoDateEntity { $m = model(OrdenTrabajoDate::class); - return $m->where('orden_trabajo_id',$this->attributes["id"])->first(); + return $m->where('orden_trabajo_id', $this->attributes["id"])->first(); } public function users(): ?OrdenTrabajoUserEntity { $m = model(OrdenTrabajoUser::class); - return $m->where('orden_trabajo_id',$this->attributes["id"])->first(); + return $m->where('orden_trabajo_id', $this->attributes["id"])->first(); } /** @@ -109,24 +109,24 @@ class OrdenTrabajoEntity extends Entity $this->attributes["dates"] = $ot_dates->fill($data); return $this; } - public function getBarCode() : string + public function getBarCode(): string { $barcode = new TypeCode128(); $renderer = new PngRenderer(); $barcodeData = $barcode->getBarcode($this->pedido()->presupuesto()->id); - return base64_encode($renderer->render($barcodeData,200, 50)); + return base64_encode($renderer->render($barcodeData, 200, 50)); } - public function files() : array + public function files(): array { $m = model(OrdenTrabajoFileModel::class); - return $m->where('orden_trabajo_id',$this->attributes['id'])->findAll() ?? []; + return $m->where('orden_trabajo_id', $this->attributes['id'])->findAll() ?? []; } - public function pedidoEsperaBy() : ?UserEntity + public function pedidoEsperaBy(): ?UserEntity { $m = model(UserModel::class); - if($this->attributes['pedido_espera_by']){ + if ($this->attributes['pedido_espera_by']) { return $m->findById($this->attributes['pedido_espera_by']); - }else{ + } else { return null; } } @@ -139,10 +139,10 @@ class OrdenTrabajoEntity extends Entity helper('filesystem'); $path = WRITEPATH . 'uploads/' . $this->attributes["portada_path"]; $portada_path = null; - if($path){ - if(file_exists($path)){ + if ($path) { + if (file_exists($path)) { $portada_path = $path; - }else{ + } else { $portada_path = null; } } diff --git a/ci4/app/Services/ProductionService.php b/ci4/app/Services/ProductionService.php index c073dc38..a1361cbf 100644 --- a/ci4/app/Services/ProductionService.php +++ b/ci4/app/Services/ProductionService.php @@ -79,14 +79,20 @@ class ProductionService extends BaseService } public function init(int $orden_trabajo_id): self { - $this->maquinaModel = model(MaquinaModel::class); - $this->otModel = model(OrdenTrabajoModel::class); - $this->ot = $this->otModel->find($orden_trabajo_id); - $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; + try { + //code... + $this->maquinaModel = model(MaquinaModel::class); + $this->otModel = model(OrdenTrabajoModel::class); + $this->ot = $this->otModel->find($orden_trabajo_id); + $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; + } catch (\Throwable $th) { + dd($orden_trabajo_id); + throw $th; + } } /** * Establece el pedido sobre el que se va a trabajar diff --git a/ci4/app/Views/themes/vuexy/components/modals/modalOtTaskManual.php b/ci4/app/Views/themes/vuexy/components/modals/modalOtTaskManual.php new file mode 100644 index 00000000..acae2131 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/components/modals/modalOtTaskManual.php @@ -0,0 +1,36 @@ + +
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/produccion/ot/otTask.php b/ci4/app/Views/themes/vuexy/form/produccion/ot/otTask.php index 94dbbd9f..1b0a54d8 100644 --- a/ci4/app/Views/themes/vuexy/form/produccion/ot/otTask.php +++ b/ci4/app/Views/themes/vuexy/form/produccion/ot/otTask.php @@ -41,9 +41,13 @@ -