From d38e253fbc938b6b2482c5730c53c036c1939605 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 13 Nov 2025 16:28:34 +0530 Subject: [PATCH] FIX_HR_SMPL_DOWNLOAD_LINK --- app/Config/Routes.php | 2 ++ app/Controllers/EmployeeRestController.php | 30 +++++++++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index fb8e437..6912a8e 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -462,6 +462,8 @@ $routes->post("employeeRest/changePassword", "RestAuthenticationController::chan $routes->post("employeeRest/verifyPassword", "RestAuthenticationController::verifyPassword"); $routes->post("employeeRest/verifyOtp", "RestAuthenticationController::verifyOtp"); $routes->post("employeeRest/checkPassword", "RestAuthenticationController::checkPassword"); +$routes->get("employeeRest/downloadSampleExcel/(:any)", "EmployeeController::downloadSampleExcelFile/$1"); + // $routes->post("employeeRest/createOrUpdateEmployeePolicySiAmount", "EmployeeRestController::createOrUpdateEmployeePolicySiAmount"); diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index f8bf125..fb01044 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -800,9 +800,17 @@ class EmployeeRestController extends AdminController $empServiceController = new EmployeeServiceController(); $result = $empServiceController->excelFileFormatValidation(['file_id' => $file_id]); if(isset($result['error_summary']) && count($result['error_summary'])) - { - $result = $empServiceController->getExcelErrorData($file_id); - return $this->respond(['status' => 'failed', 'code' => 404, 'message' => "file upload failed with errors",'data' => $result], 200); + { + if(isset($result['error_type'])){ + $result = $empServiceController->getExcelErrorData($file_id); + return $this->respond(['status' => 'failed', 'code' => 404, 'message' => "file upload failed with errors",'data' => $result], 200); + }else { + $message = "file upload failed with errors"; + if(isset($result['error_data'])){ + $message = $result['error_data']; + } + return $this->respond(['status' => 'failed', 'code' => 404, 'message' => $message,'data' => $result], 200); + } } @@ -1094,9 +1102,19 @@ class EmployeeRestController extends AdminController }else{ return $this->respond(['status' => 'failed', 'code' => 404, 'message' => "Client id and Client Policy id is Not Match!" ], 404); } - } catch (\Exception $e) { - $this->myLogger->logme("error", ($e->getMessage().' --- '.$e->getLine() . '----' . $e->getTraceAsString())); - return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500); + } catch (\Throwable $th) { + $this->myLogger->logme("error", ($th->getMessage().' --- '.$th->getLine() . '----' . $th->getTraceAsString())); + $errorData = [ + 'message' => $th->getMessage(), + 'file' => $th->getFile(), + 'line' => $th->getLine(), + 'code' => $th->getCode(), + 'trace' => $th->getTraceAsString(), + 'trace_array' => $th->getTrace(), // full array version (optional) + 'function' => $th->getTrace()[0]['function'] ?? null, + 'class' => $th->getTrace()[0]['class'] ?? null, + ]; + return $this->respond(['status' => 'failed','code' => 500,'data' => $th->getMessage(), 'error_data' => $errorData], 500); }