mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
get file and upload_files methods
This commit is contained in:
@ -168,7 +168,7 @@ class Ordentrabajo extends BaseController
|
|||||||
->add("logo", fn($q) => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)))
|
->add("logo", fn($q) => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)))
|
||||||
->edit(
|
->edit(
|
||||||
"fecha_encuadernado_at",
|
"fecha_encuadernado_at",
|
||||||
fn($q) =>$q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d", $q->fecha_encuadernado_at)->format("d/m/Y") : ""
|
fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d", $q->fecha_encuadernado_at)->format("d/m/Y") : ""
|
||||||
)
|
)
|
||||||
->add("action", fn($q) => $q->id)
|
->add("action", fn($q) => $q->id)
|
||||||
->toJson(true);
|
->toJson(true);
|
||||||
@ -260,7 +260,7 @@ class Ordentrabajo extends BaseController
|
|||||||
$otEntity = $this->otModel->find($orden_trabajo_id);
|
$otEntity = $this->otModel->find($orden_trabajo_id);
|
||||||
$pathActualFile = $otEntity->portada_path;
|
$pathActualFile = $otEntity->portada_path;
|
||||||
$fullPath = WRITEPATH . 'uploads/' . $pathActualFile;
|
$fullPath = WRITEPATH . 'uploads/' . $pathActualFile;
|
||||||
if(file_exists($fullPath)){
|
if (file_exists($fullPath)) {
|
||||||
delete_files($fullPath);
|
delete_files($fullPath);
|
||||||
}
|
}
|
||||||
$r = $this->otModel->update($otEntity->id, ["portada_path" => null]);
|
$r = $this->otModel->update($otEntity->id, ["portada_path" => null]);
|
||||||
@ -289,7 +289,7 @@ class Ordentrabajo extends BaseController
|
|||||||
return DataTable::of($q)
|
return DataTable::of($q)
|
||||||
->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") : "")
|
->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") : "")
|
||||||
->add("metros_check", fn($q) => $q->otId)
|
->add("metros_check", fn($q) => $q->otId)
|
||||||
->add("corte", fn($q) => ["otId" => $q->otId,"tipo_corte" => $this->produccionService->ordenTrabajoTareaCorte($q->otId)])
|
->add("corte", fn($q) => ["otId" => $q->otId, "tipo_corte" => $this->produccionService->ordenTrabajoTareaCorte($q->otId)])
|
||||||
->add("action", fn($q) => $q)
|
->add("action", fn($q) => $q)
|
||||||
->toJson(true);
|
->toJson(true);
|
||||||
}
|
}
|
||||||
@ -303,22 +303,26 @@ class Ordentrabajo extends BaseController
|
|||||||
->add("action", fn($q) => $q)
|
->add("action", fn($q) => $q)
|
||||||
->toJson(true);
|
->toJson(true);
|
||||||
}
|
}
|
||||||
public function select_maquina_planning_rot(){
|
public function select_maquina_planning_rot()
|
||||||
|
{
|
||||||
$q = $this->request->getGet('q');
|
$q = $this->request->getGet('q');
|
||||||
$result = $this->produccionService->querySelectMaquinaPlanningRotativa($q);
|
$result = $this->produccionService->querySelectMaquinaPlanningRotativa($q);
|
||||||
return $this->response->setJSON($result);
|
return $this->response->setJSON($result);
|
||||||
}
|
}
|
||||||
public function select_papel_planning_rot(){
|
public function select_papel_planning_rot()
|
||||||
|
{
|
||||||
$q = $this->request->getGet('q');
|
$q = $this->request->getGet('q');
|
||||||
$result = $this->produccionService->querySelectPapelPlanningRot($q);
|
$result = $this->produccionService->querySelectPapelPlanningRot($q);
|
||||||
return $this->response->setJSON($result);
|
return $this->response->setJSON($result);
|
||||||
}
|
}
|
||||||
public function select_maquina_planning_plana(){
|
public function select_maquina_planning_plana()
|
||||||
|
{
|
||||||
$q = $this->request->getGet('q');
|
$q = $this->request->getGet('q');
|
||||||
$result = $this->produccionService->querySelectMaquinaPlanningPlana($q);
|
$result = $this->produccionService->querySelectMaquinaPlanningPlana($q);
|
||||||
return $this->response->setJSON($result);
|
return $this->response->setJSON($result);
|
||||||
}
|
}
|
||||||
public function select_papel_planning_plana(){
|
public function select_papel_planning_plana()
|
||||||
|
{
|
||||||
$q = $this->request->getGet('q');
|
$q = $this->request->getGet('q');
|
||||||
$result = $this->produccionService->querySelectPapelPlanningPlana($q);
|
$result = $this->produccionService->querySelectPapelPlanningPlana($q);
|
||||||
return $this->response->setJSON($result);
|
return $this->response->setJSON($result);
|
||||||
@ -326,7 +330,46 @@ class Ordentrabajo extends BaseController
|
|||||||
public function tarea_toggle_corte($orden_trabajo_id)
|
public function tarea_toggle_corte($orden_trabajo_id)
|
||||||
{
|
{
|
||||||
$status = $this->produccionService->tareaUpdateMaquinaCorte($orden_trabajo_id);
|
$status = $this->produccionService->tareaUpdateMaquinaCorte($orden_trabajo_id);
|
||||||
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $status ]);
|
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $status]);
|
||||||
|
}
|
||||||
|
public function get_files() {
|
||||||
|
$bodyData = $this->request->getPost();
|
||||||
|
$files = $this->produccionService->init($bodyData["orden_trabajo_id"])->getOtFiles();
|
||||||
|
$response = [];
|
||||||
|
foreach ($files as $key => $file) {
|
||||||
|
$file_ci4 = new File($file->file_path);
|
||||||
|
$response[] = [
|
||||||
|
"name" => $file->name,
|
||||||
|
"size" => $file_ci4->getSize(),
|
||||||
|
"hash" => $file->hash()
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return json_encode($response);
|
||||||
|
}
|
||||||
|
public function upload_files()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
//code...
|
||||||
|
$otFiles = [];
|
||||||
|
$bodyData = $this->request->getPost();
|
||||||
|
$files = $this->request->getFileMultiple('file');
|
||||||
|
$response = $this->produccionService
|
||||||
|
->init($bodyData["orden_trabajo_id"])
|
||||||
|
->storeOtFiles($files);
|
||||||
|
return $this->response->setJSON([
|
||||||
|
"message" => lang("App.global_alert_save_success"),
|
||||||
|
"data" => $response,
|
||||||
|
"status" => true
|
||||||
|
]);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
return $this->response->setJSON(
|
||||||
|
[
|
||||||
|
"message" => lang("App.global_alert_save_error"),
|
||||||
|
"data" => $th,
|
||||||
|
"error" => $th->getMessage(),
|
||||||
|
"status" => false
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user