diff --git a/ci4/app/Controllers/Produccion/Ordentrabajo.php b/ci4/app/Controllers/Produccion/Ordentrabajo.php index 2d3baeca..0784d246 100755 --- a/ci4/app/Controllers/Produccion/Ordentrabajo.php +++ b/ci4/app/Controllers/Produccion/Ordentrabajo.php @@ -375,7 +375,11 @@ class Ordentrabajo extends BaseController public function maquina_plana_datatable() { // return $this->response->setStatusCode(400); + $padreId = $this->request->getGet('padre_id'); $q = $this->produccionService->maquinaPlanaDatatableQuery(); + if ($padreId) { + $q->where('lg_maquinas.padre_id', $padreId); + } return DataTable::of($q) ->edit("tiempoReal", fn($q) => $q->tiempoReal) ->add("action", fn($q) => ["title" => lang('Produccion.datatable.filter_by_machine'), 'data' => $q]) @@ -496,10 +500,7 @@ class Ordentrabajo extends BaseController public function planning_plana_datatable() { $query = $this->produccionService->planningPlanaQueryDatatable(); - $padreId = $this->request->getGet('padre_id'); - if ($padreId) { - $query->where('lg_maquinas.padre_id', $padreId); - } + 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") : "") @@ -523,7 +524,7 @@ class Ordentrabajo extends BaseController { $q = $this->request->getGet('q'); $padreId = $this->request->getGet('padre_id'); - $result = $this->produccionService->querySelectMaquinaPlanningPlana($q,$padreId); + $result = $this->produccionService->querySelectMaquinaPlanningPlana($q, $padreId); return $this->response->setJSON($result); } public function select_maquina_padre_planning_plana() @@ -535,7 +536,8 @@ class Ordentrabajo extends BaseController public function select_papel_planning_plana() { $q = $this->request->getGet('q'); - $result = $this->produccionService->querySelectPapelPlanningPlana($q); + $maquinaId = $this->request->getGet('maquina_id'); + $result = $this->produccionService->querySelectPapelPlanningPlana($q,$maquinaId); return $this->response->setJSON($result); } public function tarea_toggle_corte($orden_trabajo_id) diff --git a/ci4/app/Language/es/Produccion.php b/ci4/app/Language/es/Produccion.php index 9552d726..6e999e6b 100755 --- a/ci4/app/Language/es/Produccion.php +++ b/ci4/app/Language/es/Produccion.php @@ -144,6 +144,7 @@ return [ ], "maquinas_planas" => "Máquinas planas", + "select_maquina_padre" => "Seleccione una máquina", "progress_ferro" => "Ferro", "progress_preimpresion" => "Preimpresión", "progress_logistica" => "Logística", diff --git a/ci4/app/Services/ProductionService.php b/ci4/app/Services/ProductionService.php index 8332b322..e53a8fd6 100755 --- a/ci4/app/Services/ProductionService.php +++ b/ci4/app/Services/ProductionService.php @@ -199,6 +199,7 @@ class ProductionService extends BaseService public function __construct() { $this->otModel = model(OrdenTrabajoModel::class); + $this->maquinaModel = model(MaquinaModel::class); $this->otDate = model(OrdenTrabajoDate::class); $this->otTarea = model(OrdenTrabajoTarea::class); $this->otUser = model(OrdenTrabajoUser::class); @@ -227,8 +228,6 @@ class ProductionService extends BaseService public function init(int $orden_trabajo_id): self { try { - $this->maquinaModel = model(MaquinaModel::class); - $this->otModel = model(OrdenTrabajoModel::class); $ot = $this->otModel->find($orden_trabajo_id); if ($ot == null) { throw new Exception(lang('Produccion.errors.ot_not_found', ['ot_id' => $orden_trabajo_id])); @@ -777,6 +776,7 @@ class ProductionService extends BaseService ->join("lg_imposiciones", "lg_imposiciones.id = orden_trabajo_tareas.imposicion_id", "left") ->whereIn("presupuesto_linea.tipo", $this->TIPOS_ROTATIVA) ->where('lg_maquinas.is_rotativa', true) + ->where('lg_maquinas.tipo', 'impresion') ->where("orden_trabajo_tareas.deleted_at", null) ->orderBy("orden_trabajo_tareas.orden", "ASC") ->groupBy('ordenes_trabajo.id'); @@ -819,6 +819,7 @@ class ProductionService extends BaseService // ->where("orden_trabajo_tareas.orden_trabajo_id", $this->ot->id) ->whereIn("presupuesto_linea.tipo", $this->TIPOS_PLANA) ->where('lg_maquinas.is_rotativa', false) + ->where('lg_maquinas.tipo', 'impresion') ->where("orden_trabajo_tareas.deleted_at", null) ->orderBy("orden_trabajo_tareas.orden", "ASC") ->groupBy('ordenes_trabajo.id'); @@ -928,10 +929,12 @@ class ProductionService extends BaseService ->join("orden_trabajo_tareas", "orden_trabajo_tareas.orden_trabajo_id = ordenes_trabajo.id", "left") ->join("presupuesto_linea", "presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id", "left") ->join("presupuestos", "presupuestos.id = presupuesto_linea.presupuesto_id", "right") - ->join('lg_maquinas',"lg_maquinas.id = orden_trabajo_tareas.maquina_id","left") + ->join('lg_maquinas', "lg_maquinas.id = orden_trabajo_tareas.maquina_id", "left") ->where("orden_trabajo_tareas.deleted_at", null) ->where("orden_trabajo_tareas.presupuesto_linea_id IS NOT NULL", NULL, FALSE) ->whereIn("presupuesto_linea.tipo", $this->TIPOS_PLANA) + ->where('lg_maquinas.tipo', 'impresion') + // ->where('lg_maquinas.padre_id', 0) ->groupBy('lg_maquinas.id'); @@ -1353,7 +1356,7 @@ class ProductionService extends BaseService } return $query->get()->getResultArray(); } - public function querySelectMaquinaPlanningPlana($q,?string $padreId) + public function querySelectMaquinaPlanningPlana($q, ?string $padreId) { $query = $this->otModel->builder()->select([ "orden_trabajo_tareas.maquina_id as id", @@ -1370,8 +1373,8 @@ class ProductionService extends BaseService if ($q) { $query->like('lg_maquinas.nombre', $q); } - if($padreId){ - $query->where('lg_maquinas.padre_id',$padreId); + if ($padreId) { + $query->where('lg_maquinas.padre_id', $padreId); } return $query->get()->getResultArray(); } @@ -1385,10 +1388,8 @@ class ProductionService extends BaseService ->join("presupuesto_linea", "presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id", "left") ->join("lg_maquinas", "lg_maquinas.id = orden_trabajo_tareas.maquina_id", "left") ->join("lg_maquinas mp", "mp.id = lg_maquinas.padre_id", "left") - ->whereIn("presupuesto_linea.tipo", $this->TIPOS_PLANA) ->where('lg_maquinas.is_rotativa', false) - ->where('mp.is_padre', 0) - ->where("orden_trabajo_tareas.deleted_at", null) + ->where('lg_maquinas.is_padre !=', 0) ->groupBy("mp.id"); if ($q) { $query->like('lg_maquinas.nombre', $q); @@ -1415,7 +1416,7 @@ class ProductionService extends BaseService } return $query->get()->getResultArray(); } - public function querySelectPapelPlanningPlana($q) + public function querySelectPapelPlanningPlana($q, ?string $maquinaId) { $query = $this->otModel->builder()->select([ "lg_papel_impresion.id", @@ -1433,6 +1434,9 @@ class ProductionService extends BaseService if ($q) { $query->like('lg_papel_impresion.nombre', $q); } + if ($maquinaId) { + $query->where('orden_trabajo_tareas.maquina_id', $maquinaId); + } return $query->get()->getResultArray(); } public function tareaUpdateMaquinaCorte($orden_trabajo_id): bool diff --git a/ci4/app/Views/themes/vuexy/components/tables/planning_plana_table.php b/ci4/app/Views/themes/vuexy/components/tables/planning_plana_table.php index ab28244c..454cb84c 100755 --- a/ci4/app/Views/themes/vuexy/components/tables/planning_plana_table.php +++ b/ci4/app/Views/themes/vuexy/components/tables/planning_plana_table.php @@ -24,7 +24,6 @@