From 96c825197bf2d7c9d6f6cc4b67789013df2991b2 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 13 Nov 2025 18:14:19 +0530 Subject: [PATCH] FEAT_HR_SAMPL_FILE_DOWNLOAD --- app/Config/Routes.php | 2 +- app/Controllers/EmployeeController.php | 41 ++++++++++++++++------ app/Controllers/EmployeeRestController.php | 13 +++++++ 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 6912a8e..d5cc961 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -462,7 +462,7 @@ $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->get("employeeRest/downloadSampleExcel", "EmployeeRestController::downloadSampleExcel"); 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 fb01044..0cd0fdd 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -3522,6 +3522,8 @@ class EmployeeRestController extends AdminController } + + //-------------------------------------------------------------------------------------------- public function hrFileUpload() { @@ -3658,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