fechas pedido and imposiciones

This commit is contained in:
amazuecos
2025-04-14 08:05:03 +02:00
parent 08a91294b4
commit e9827c3557
18 changed files with 315 additions and 106 deletions

View File

@ -118,7 +118,26 @@ class Ordentrabajo extends BaseController
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
}
}
public function update_orden_trabajo_pedido_date()
{
try {
$bodyData = $this->request->getPost();
$r = $this->produccionService->init($bodyData["orden_trabajo_id"])->updateOrdenTrabajoPedidoDate($bodyData);
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r["status"], "user" => $r["user"], "data" => $bodyData]);
} catch (\Throwable $th) {
return $this->response->setJSON(["errors" => $th->getMessage(), "status" => false])->setStatusCode(500);
}
}
public function update_orden_trabajo_pedido()
{
try {
$bodyData = $this->request->getPost();
$r = $this->produccionService->init($bodyData["orden_trabajo_id"])->updateOrdenTrabajoPedido($bodyData);
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r,"data" => $bodyData]);
} catch (\Throwable $th) {
return $this->response->setJSON(["errors" => $th->getMessage(), "status" => false])->setStatusCode(500);
}
}
public function edit($orden_trabajo_id)
{
// Breadcrumbs
@ -132,6 +151,8 @@ class Ordentrabajo extends BaseController
$this->viewData["cliente"] = $this->produccionService->getCliente();
$this->viewData["ot"] = $this->produccionService->getOrdenTrabajo();
$this->viewData["user_dates"] = $this->produccionService->userDates();
$this->viewData["pedido_user_dates"] = $this->produccionService->pedidoUserDates();
return view(static::$viewPath . $this->editRoute, $this->viewData);
}
@ -233,8 +254,7 @@ class Ordentrabajo extends BaseController
->edit("tiempo_estimado", fn($q) => float_seconds_to_hhmm_string($q->tiempo_estimado))
->edit("tiempo_real", fn($q) => float_seconds_to_hhmm_string($q->tiempo_real))
->edit("maquina_tarea", fn($q) => ["id" => $q->id, "maquina_id" => $q->maquina_tarea, "maquina_name" => $q->maquina_nombre])
->add("imposicion", fn($q) => ["id" => $q->id, "imposicion_id" => $q->imposicion_id, "name" => $q->imposicion_name,"is_presupuesto_linea" => $q->presupuesto_linea_id ? true : false ])
->add("imposicion", fn($q) => ["id" => $q->id, "imposicion_id" => $q->imposicion_id, "name" => $q->imposicion_name, "is_presupuesto_linea" => $q->presupuesto_linea_id ? true : false])
->toJson(true);
}
public function get_pdf($orden_trabajo_id)
@ -244,7 +264,6 @@ class Ordentrabajo extends BaseController
public function upload_orden_trabajo_portada()
{
try {
//code...
$file = $this->request->getFile("portada_file");
$bodyData = $this->request->getPost();
$id = $bodyData["orden_trabajo_id"];
@ -252,6 +271,12 @@ class Ordentrabajo extends BaseController
$fullpath = null;
if ($file->isValid() && !$file->hasMoved()) {
$fullpath = $file->store('ordenes_trabajo_portadas');
$otEntity = $this->otModel->find($id);
if ($otEntity->portada_path) {
if (file_exists($otEntity->full_path)) {
unlink($otEntity->full_path);
}
}
$r = $this->otModel->update($id, ["portada_path" => $fullpath]);
}
return $this->response->setJSON(["message" => "Portada subida", "data" => $r]);
@ -259,7 +284,7 @@ class Ordentrabajo extends BaseController
if ($fullpath) {
delete_files($fullpath);
}
return $this->response->setJSON(["message" => "Portada error", "error" => $th->getMessage()])->setStatusCode($th->getCode());
return $this->response->setJSON(["message" => "Portada error", "error" => $th->getMessage()])->setStatusCode(500);
}
}
public function delete_orden_trabajo_portada($orden_trabajo_id)
@ -283,7 +308,7 @@ class Ordentrabajo extends BaseController
try {
$ot = $this->otModel->find($orden_trabajo_id);
if ($ot->portada_path) {
$filePath = WRITEPATH . 'uploads/' . $ot->portada_path;
$filePath = $ot->full_path;
if (file_exists($filePath)) {
$mimeType = mime_content_type($filePath);