diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 07768449..145f37ef 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -885,6 +885,8 @@ $routes->group('produccion', ['namespace' => 'App\Controllers\Produccion'], func $routes->delete('reset/tareas/(:num)', 'Ordentrabajo::reset_tareas/$1'); $routes->get('summary/(:num)', 'Ordentrabajo::get_orden_trabajo_summary/$1', ['as' => 'getOrdenTrabajoSumary']); $routes->get('datatable', 'Ordentrabajo::datatable', ['as' => 'datatableOrdenTrabajo']); + $routes->get('tareas/datatable/(:num)', 'Ordentrabajo::tareas_datatable/$1', ['as' => 'datatableTareasOrdenTrabajo']); + }); }); /* diff --git a/ci4/app/Controllers/Produccion/Ordentrabajo.php b/ci4/app/Controllers/Produccion/Ordentrabajo.php index a278ca37..9b89ab6a 100755 --- a/ci4/app/Controllers/Produccion/Ordentrabajo.php +++ b/ci4/app/Controllers/Produccion/Ordentrabajo.php @@ -79,6 +79,13 @@ class Ordentrabajo extends BaseController $r = $this->produccionService->init($orden_trabajo_id)->resetAllTareas(); return $this->response->setJSON(["message" => "Tareas reseteadas" ,"status" => $r]); } + public function tareas_datatable(int $orden_trabajo_id){ + $q = $this->produccionService->init($orden_trabajo_id)->taskDatatableQuery($orden_trabajo_id); + // return $this->response->setJSON($q->get()->getResultArray()); + return DataTable::of($q) + ->add("action" ,fn($q) => $q->id) + ->toJson(true); + } } \ No newline at end of file diff --git a/ci4/app/Services/ProductionService.php b/ci4/app/Services/ProductionService.php index 3f6c63a7..c6e7aafe 100644 --- a/ci4/app/Services/ProductionService.php +++ b/ci4/app/Services/ProductionService.php @@ -96,9 +96,9 @@ class ProductionService extends BaseService $this->otModel->save($ot); $ot_id = $this->otModel->getInsertID(); $ot->id = $ot_id; + $this->init($ot_id); $this->storeOrdenTrabajoDates($ot); $this->storeAllTareas(); - $this->init($ot_id); return $ot; } @@ -127,9 +127,9 @@ class ProductionService extends BaseService $this->storeOrdenTrabajoEncuadernacionTareas(); $this->storeOrdenTrabajoExtraTareas(); } - public function resetAllTareas() : BaseResult|bool + public function resetAllTareas(): BaseResult|bool { - $r = $this->otTarea->where("orden_trabajo_id",$this->ot->id)->delete(purge:true); + $r = $this->otTarea->where("orden_trabajo_id", $this->ot->id)->delete(purge: true); $this->storeAllTareas(); return $r; } @@ -316,24 +316,32 @@ class ProductionService extends BaseService /** * Query para mostrar en datatable * - * @param integer $ot_id Primary key de la orden de trabajo * @return BaseBuilder */ - public function taskDatatableQuery(int $ot_id): BaseBuilder + public function taskDatatableQuery(): BaseBuilder { $q = $this->otModel->builder()->select([ + "orden_trabajo_tareas.id", "orden_trabajo_tareas.orden", "orden_trabajo_tareas.nombre", - "presupuesto_lineas.maquina_id as maquina_tarea", - "orden_trabajo_tareas.maquina_id as maquina_presupuesto_linea", - "lg_imposiciones.id", + "lgmp.nombre as maquina_presupuesto_linea", + "orden_trabajo_tareas.maquina_id as maquina_tarea", + "lg_maquinas.nombre as maquina_nombre", + "lg_imposiciones.id as imposicion_id", "orden_trabajo_tareas.tiempo_estimado", "orden_trabajo_tareas.tiempo_real" ]) ->join("orden_trabajo_tareas", "orden_trabajo_tareas.orden_trabajo_id = ordenes_trabajo.id", "left") - ->join("presupuesto_lineas", "presupuesto_lineas.id = orden_trabajo_tareas.presupuesto_linea_id") - ->join("lg_maquinas", "lg_maquinas.id = orden_trabajo_tareas.maquina_id") - ->where("orden_trabajo_tareas.orden_trabajo_id", $ot_id) + ->join("presupuesto_linea", "presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id", "left") + ->join("presupuesto_acabados", "presupuesto_acabados.id = orden_trabajo_tareas.presupuesto_acabado_id", "left") + ->join("presupuesto_manipulados", "presupuesto_manipulados.id = orden_trabajo_tareas.presupuesto_manipulado_id", "left") + ->join("presupuesto_preimpresiones", "presupuesto_preimpresiones.id = orden_trabajo_tareas.presupuesto_preimpresion_id", "left") + ->join("presupuesto_encuadernaciones", "presupuesto_encuadernaciones.id = orden_trabajo_tareas.presupuesto_encuadernado_id", "left") + ->join("presupuesto_serviciosExtra", "presupuesto_serviciosExtra.id = orden_trabajo_tareas.presupuesto_extra_id", "left") + ->join("lg_maquinas", "lg_maquinas.id = orden_trabajo_tareas.maquina_id", "left") + ->join("lg_maquinas as lgmp", "lgmp.id = presupuesto_linea.maquina_id", "left") + ->join("lg_imposiciones", "lg_imposiciones.id = orden_trabajo_tareas.imposicion_id", "left") + ->where("orden_trabajo_tareas.orden_trabajo_id", $this->ot->id) ->where("orden_trabajo_tareas.deleted_at", null) ->orderBy("orden_trabajo_tareas.orden", "DESC"); return $q; diff --git a/ci4/app/Views/themes/vuexy/components/tables/ot_task_table.php b/ci4/app/Views/themes/vuexy/components/tables/ot_task_table.php index a390a9e6..026cc919 100644 --- a/ci4/app/Views/themes/vuexy/components/tables/ot_task_table.php +++ b/ci4/app/Views/themes/vuexy/components/tables/ot_task_table.php @@ -3,11 +3,12 @@