FIX_ISSUE
This commit is contained in:
parent
00d115b745
commit
dc17e48d8b
@ -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());
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user