This commit is contained in:
amazuecos
2024-12-26 13:37:18 +01:00
parent c05b117c77
commit 2d9b1603a3
5 changed files with 67 additions and 12 deletions

View File

@ -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;