diff --git a/app/Config/Routes.php b/app/Config/Routes.php index fb8e437..d5cc961 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", "EmployeeRestController::downloadSampleExcel"); + // $routes->post("employeeRest/createOrUpdateEmployeePolicySiAmount", "EmployeeRestController::createOrUpdateEmployeePolicySiAmount"); diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 564fc92..dcb7ec7 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -412,27 +412,48 @@ class EmployeeController extends AdminController * @return redirect back with an error message if the file is not found, otherwise sends the file to the user for download. */ - public function downloadSampleExcelFile($actionType = null) + public function downloadSampleExcelFile($actionType = null, $return_type = 0) { // $actionType = $this->request->getGet(); $filePath = ''; + // Path to your file if ($actionType == 'inception') { - $filePath = ROOTPATH . 'public/sample_excel/sample_inception.xls'; + $filePath = ($return_type == 1) + ? base_url('public/sample_excel/sample_inception.xls') + : ROOTPATH . 'public/sample_excel/sample_inception.xls'; } else if ($actionType == 'correction') { - $filePath = ROOTPATH . 'public/sample_excel/sample_correction .xls'; + $filePath = ($return_type == 1) + ? base_url('public/sample_excel/sample_correction.xls') + : ROOTPATH . 'public/sample_excel/sample_correction.xls'; } else if ($actionType == 'si_enhancement') { - $filePath = ROOTPATH . 'public/sample_excel/sample_si_enhancement.xls'; + $filePath = ($return_type == 1) + ? base_url('public/sample_excel/sample_si_enhancement.xls') + : ROOTPATH . 'public/sample_excel/sample_si_enhancement.xls'; } else if ($actionType == 'dependent_addtion') { - $filePath = ROOTPATH . 'public/sample_excel/sample_dependent_addition.xls'; + $filePath = ($return_type == 1) + ? base_url('public/sample_excel/sample_dependent_addition.xls') + : ROOTPATH . 'public/sample_excel/sample_dependent_addition.xls'; } else if ($actionType == 'addition') { - $filePath = ROOTPATH . 'public/sample_excel/sample_addition.xls'; + $filePath = ($return_type == 1) + ? base_url('public/sample_excel/sample_addition.xls') + : ROOTPATH . 'public/sample_excel/sample_addition.xls'; } else if ($actionType == 'deletion') { - $filePath = ROOTPATH . 'public/sample_excel/sample_deletion.xls'; + $filePath = ($return_type == 1) + ? base_url('public/sample_excel/sample_deletion.xls') + : ROOTPATH . 'public/sample_excel/sample_deletion.xls'; } else if ($actionType == 'enrollment') { - $filePath = ROOTPATH . 'public/sample_excel/enrollment.xlsx'; - }else if ($actionType == 'missed_inception') { - $filePath = ROOTPATH . 'public/sample_excel/sample_inception.xls'; + $filePath = ($return_type == 1) + ? base_url('public/sample_excel/enrollment.xlsx') + : ROOTPATH . 'public/sample_excel/enrollment.xlsx'; + } else if ($actionType == 'missed_inception') { + $filePath = ($return_type == 1) + ? base_url('public/sample_excel/sample_inception.xls') + : ROOTPATH . 'public/sample_excel/sample_inception.xls'; + } + + if($return_type == 1){ + return $filePath; } // Check if the file exists diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index d9a4d7b..0cd0fdd 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); } @@ -1782,7 +1800,7 @@ class EmployeeRestController extends AdminController $post_branch_id = $this->request->getGet('post_branch_id'); - if ($pre_client_id != null) { + if (!empty($pre_client_id)) { $client = $this->clientModel->where('id', $pre_client_id)->first(); @@ -1810,16 +1828,14 @@ class EmployeeRestController extends AdminController return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 404); } - } elseif ($post_client_id != null) { + } elseif (!empty($post_client_id)) { - $restAuthController = new RestAuthenticationController; $queryParams = [ 'client_id' => $post_client_id, 'client_branch_id' => $post_branch_id ]; - return $restAuthController->callThirdPartyGETAPI($queryParams, 'getClientDetails'); } else { @@ -3506,6 +3522,8 @@ class EmployeeRestController extends AdminController } + + //-------------------------------------------------------------------------------------------- public function hrFileUpload() { @@ -3642,6 +3660,17 @@ class EmployeeRestController extends AdminController } } + public function downloadSampleExcel() + { + $employeeController = new EmployeeController(); + $file_path = $employeeController->downloadSampleExcelFile('enrollment', 1); + if(empty($file_path)){ + return $this->respond(['status' => "success", 'code' => 404, 'data' => "", "message" => "Sample file not avilable"], 200); + }else{ + return $this->respond(['status' => "success", 'code' => 200, 'data' => $file_path], 200); + } + + } } \ No newline at end of file diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index e12a157..69d9e5e 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -1570,8 +1570,7 @@ class RestAuthenticationController extends AdminController if (isset($employeeData['employee_id']) && password_verify($old_password, $employeeData['password'])) { // Hash new password - // $newHashedPassword = password_hash($new_password, PASSWORD_DEFAULT); - $newHashedPassword = $new_password; + $newHashedPassword = password_hash($new_password, PASSWORD_DEFAULT); // Update password and clear OTP $updated = $this->employeeModel->update($employeeData['employee_id'], [