feat/ot-datatable-news

This commit is contained in:
amazuecos
2025-05-02 07:56:28 +02:00
parent 9283059f9d
commit 5138681718
14 changed files with 346 additions and 65 deletions

View File

@ -283,6 +283,62 @@ class Ordentrabajo extends BaseController
->add("action", fn($q) => $q->id)
->toJson(true);
}
public function datatable_news()
{
$logo = config(LogoImpresion::class);
$q = $this->otModel->getDatatableQuery();
return DataTable::of($q)
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name, "color" => $this->produccionService->init($q->id)->getOtColorStatus()])
->edit(
"fecha_encuadernado_at",
fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d H:i:s", $q->fecha_encuadernado_at)->format("d/m/Y") : ""
)
->add("action", fn($q) => $q->id)
->toJson(true);
}
public function datatable_prod()
{
$logo = config(LogoImpresion::class);
$q = $this->otModel->getDatatableQuery()->where('presupuestos.ferro',1)->where("ferro_ok_at is NOT NULL", NULL, FALSE);
return DataTable::of($q)
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name, "color" => $this->produccionService->init($q->id)->getOtColorStatus()])
->edit(
"fecha_encuadernado_at",
fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d H:i:s", $q->fecha_encuadernado_at)->format("d/m/Y") : ""
)
->add("action", fn($q) => $q->id)
->toJson(true);
}
public function datatable_waiting()
{
$logo = config(LogoImpresion::class);
$q = $this->otModel->getDatatableQuery()->where('ordenes_trabajo.is_pedido_espera',1);
return DataTable::of($q)
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name, "color" => $this->produccionService->init($q->id)->getOtColorStatus()])
->edit(
"fecha_encuadernado_at",
fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d H:i:s", $q->fecha_encuadernado_at)->format("d/m/Y") : ""
)
->add("action", fn($q) => $q->id)
->toJson(true);
}
public function datatable_revision_com()
{
$logo = config(LogoImpresion::class);
$q = $this->otModel->getDatatableQuery()->where('presupuestos.ferro',1)->where("ferro_ok_at is NOT NULL", NULL, FALSE);
return DataTable::of($q)
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name, "color" => $this->produccionService->init($q->id)->getOtColorStatus()])
->edit(
"fecha_encuadernado_at",
fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d H:i:s", $q->fecha_encuadernado_at)->format("d/m/Y") : ""
)
->add("action", fn($q) => $q->id)
->toJson(true);
}
public function papel_gramaje_datatable()
{
@ -585,8 +641,15 @@ class Ordentrabajo extends BaseController
$validated = $this->validation->run($bodyData, "orden_trabajo_tarea_progress_date");
// return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "data" => $this->validation->getValidated(),"errors" => $this->validation->getErrors()]);
if ($validated) {
$r = $this->produccionService->storeOrdenTrabajoTareaProgressDate($this->validation->getValidated());
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r, "data" => $bodyData]);
$validatedData = $this->validation->getValidated();
$r = $this->produccionService->storeOrdenTrabajoTareaProgressDate($validatedData);
$otTareaEntity = $this->otTarea->find($validatedData['ot_tarea_id']);
$data = [
"tiempo_trabajado" => float_seconds_to_hhmm_string($otTareaEntity->tiempo_trabajado()),
"tarea" => $otTareaEntity,
"estado" => $validatedData['estado'],
];
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r, "data" => $data]);
} else {
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
}