From dc17e48d8b0397a3939ee5b01627779b56c05572 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 6 Feb 2026 15:38:42 +0530 Subject: [PATCH] FIX_ISSUE --- app/Controllers/EmployeeRestController.php | 30 ++++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 1040c97e..583f33c7 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -606,7 +606,9 @@ class EmployeeRestController extends AdminController public function getEmployeeAndDependenceByClientId() { try { + $empData = $this->employeePolicyModel->getEmployeePolicy(client_id: $this->request->getGet('client_id'), policy_id: $this->request->getGet('client_policy_id'), status: 0, branch_id: $this->request->getGet('client_branch_id')); + $empData = array_slice($empData, 0, 5); if ($empData) { return $this->respond(['status' => 'success', 'code' => 200, 'data' => $empData], 200); @@ -4723,28 +4725,40 @@ class EmployeeRestController extends AdminController try { $file_id = $this->request->getGet('id') ?? $id; + $client_id = $this->request->getGet('client_id') ?? null; + + $client_data = []; + if(!empty($client_id)){ + if (is_string($client_id) && preg_match('/^[a-f0-9]{32}$/i', $client_id)) { + $client_data = $this->clientModel->where('MD5(id)', $client_id)->first(); + } else { + $client_data = $this->clientModel->where('id', $client_id)->first(); + } + } // Find record - $record = $this->hrFileUploadModel->where('id', (int)$file_id)->find(); - - // print_rr( $record);die; + if($client_data && $client_data['hr_file_processed_by'] == 1){ + $record = $this->fileModel->where('id', (int)$file_id)->find(); + $uploadPath = WRITEPATH . 'uploads/excel/'; + }else{ + $record = $this->hrFileUploadModel->where('id', (int)$file_id)->find(); + $uploadPath = WRITEPATH . 'uploads/hr_files/'; + } if (!$record) { return $this->failNotFound("File record not found"); } - $uploadPath = WRITEPATH . 'uploads/hr_files/'; - $filePath = $uploadPath . $record[0]['file_name']; + $filePath = $uploadPath . $record[0]['file_name']; if (!file_exists($filePath)) { - // return $this->failNotFound("File not found on server"); - $data['message'] = 'The Physical File Not Found'; - return view('errors/404', $data); + return $this->failNotFound("File not found on server"); } // Force file download return $this->response->download($filePath, null) ->setFileName($record[0]['file_name']); + } catch (\Exception $e) { return $this->failServerError($e->getMessage()); }