diff --git a/ci4/app/Controllers/Produccion/Ordentrabajo.php b/ci4/app/Controllers/Produccion/Ordentrabajo.php index 35f7334c..1b802ecb 100755 --- a/ci4/app/Controllers/Produccion/Ordentrabajo.php +++ b/ci4/app/Controllers/Produccion/Ordentrabajo.php @@ -332,7 +332,8 @@ class Ordentrabajo extends BaseController $status = $this->produccionService->tareaUpdateMaquinaCorte($orden_trabajo_id); return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $status]); } - public function get_files() { + public function get_files() + { $bodyData = $this->request->getPost(); $files = $this->produccionService->init($bodyData["orden_trabajo_id"])->getOtFiles(); $response = []; @@ -353,9 +354,14 @@ class Ordentrabajo extends BaseController $otFiles = []; $bodyData = $this->request->getPost(); $files = $this->request->getFileMultiple('file'); - $response = $this->produccionService - ->init($bodyData["orden_trabajo_id"]) - ->storeOtFiles($files); + $ps = $this->produccionService->init($bodyData["orden_trabajo_id"]); + $existingFiles = json_decode($bodyData["oldFiles"]); + $ps->deleteOtFiles($existingFiles); + if($files){ + $response = $ps->storeOtFiles($files); + }else{ + $response = null; + } return $this->response->setJSON([ "message" => lang("App.global_alert_save_success"), "data" => $response,