From 2d9b1603a31099859e7a6c9f4eb5926b425dbcd7 Mon Sep 17 00:00:00 2001 From: amazuecos Date: Thu, 26 Dec 2024 13:37:18 +0100 Subject: [PATCH] tareas --- ci4/app/Config/Routes.php | 2 + .../Controllers/Produccion/Ordentrabajo.php | 7 ++++ ci4/app/Services/ProductionService.php | 30 +++++++++------ .../vuexy/components/tables/ot_task_table.php | 3 +- .../assets/js/safekat/pages/produccion/ot.js | 37 +++++++++++++++++++ 5 files changed, 67 insertions(+), 12 deletions(-) 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 @@ - + + diff --git a/httpdocs/assets/js/safekat/pages/produccion/ot.js b/httpdocs/assets/js/safekat/pages/produccion/ot.js index c668e978..5f706832 100644 --- a/httpdocs/assets/js/safekat/pages/produccion/ot.js +++ b/httpdocs/assets/js/safekat/pages/produccion/ot.js @@ -6,11 +6,44 @@ class OrdenTrabajo this.item = domItem this.otForm = this.item.find("#ot-edit-form") this.modelId = this.item.data("id"); + this.tareasTableItem = this.item.find("#ot-task-table"); + this.datatableColumns = [ + { data: 'orden', searchable: true, sortable: true }, + { data: 'nombre', searchable: true, sortable: true }, + { data: 'maquina_presupuesto_linea', searchable: true, sortable: true }, + { data: 'maquina_tarea', searchable: false, sortable: false ,render : this._renderMaquinaSelectTable.bind(this)}, + { data: 'imposicion_id', searchable: false, sortable: false }, + { data: 'tiempo_estimado', searchable: false, sortable: false }, + { data: 'tiempo_real', searchable: false, sortable: false }, + { data: 'action', searchable: false, sortable: false }, + ] + + + } init(){ + this.initDatatableTareas() console.log(this.getFormData()) } + initDatatableTareas(){ + this.datatableTareas = this.tareasTableItem.DataTable({ + processing: true, + layout: { + topStart: 'pageLength', + topEnd: 'search', + bottomStart: 'info', + bottomEnd: 'paging' + }, + serverSide: true, + pageLength: 10, + language: { + url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" + }, + columns: this.datatableColumns, + ajax: '/produccion/ordentrabajo/tareas/datatable/' + this.modelId + }); + } getFormData() { let data = {} this.otForm.serializeArray().forEach((e) => { @@ -22,6 +55,10 @@ class OrdenTrabajo _handleGetData(){ const ajax = new Ajax(`/produccion/ordentrabajo/${this.modelId}`) } + _renderMaquinaSelectTable(d,t){ + return `` + + }