From 9194787e14157710912bea817481088e18cbd7da Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 9 Mar 2026 09:58:49 +0530 Subject: [PATCH] CHANGE_TPA_RECON --- app/Config/Routes.php | 2 + app/Controllers/EmployeeController.php | 122 +++++++++++++++++++++---- 2 files changed, 108 insertions(+), 16 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 2c4d629c..17126e97 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -227,6 +227,8 @@ $routes->group("/employee", ["filter" => "authMVC"], function ($routes) { $routes->get("retail-endorsement-list", "EmployeeController::retailendorsementlist"); $routes->post("retail-endorsement-save", "EmployeeController::retailendorsementsave"); $routes->get("getTPADataVariationReport/(:num)", "EmployeeController::getTPADataVariationReport/$1"); + $routes->get("getTPADataVariationReportView/(:num)", "EmployeeController::getTPADataVariationReport/$1/view"); + $routes->get("proceedTPADataVariationNextStep/(:num)", "EmployeeController::proceedTPADataVariationNextStep/$1"); $routes->get("bulkGenerateEcardAndStoreinS3", "EmployeeController::bulkGenerateEcardAndStoreinS3"); $routes->get('clearCdSession', 'EmployeeController::clearCdSession'); $routes->get('checkSessionStatus', 'EmployeeController::checkSessionStatus'); diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 01664e76..76e2b811 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -3938,14 +3938,14 @@ class EmployeeController extends AdminController } } - public function getTPADataVariationReport($file_id) + public function getTPADataVariationReport($file_id, $type = 'download') { $file_info = $this->batchFileModel->where('id', $file_id)->find(); $client_id = $file_info[0]['client_id']; $client_policy_id = $file_info[0]['client_policy_id']; $TpaApiDataModel = new TpaApiDataModel(); $emp_data_wo_tpa_id = $this->employeePolicyModel->getTPADataVariationReport($client_id, $client_policy_id, $file_id); - + //loop emp data with TPA data for matches foreach ($emp_data_wo_tpa_id as $db_key => $db_row) @@ -3965,10 +3965,10 @@ class EmployeeController extends AdminController // die(); //not_in_tpa $tpa_emp_codes = $TpaApiDataModel->select('emp_code') - ->where('file_id', $file_id) - ->where('is_active', 1) - ->groupBy('emp_code') - ->findAll(); + ->where('file_id', $file_id) + ->where('is_active', 1) + ->groupBy('emp_code') + ->findAll(); $tpa_emp_codes = array_column($tpa_emp_codes, 'emp_code'); $not_in_tpa = $this->employeePolicyModel->getTPADataVariationReport($client_id, $client_policy_id, $file_id,$tpa_emp_codes); @@ -3982,20 +3982,110 @@ class EmployeeController extends AdminController ->where('is_active',1) ->where('file_id',$file_id) ->whereNotIn('emp_code',$master_emp_codes) - ->findAll(); + ->findAll(); // d($not_in_nhance);die(); - if( !empty($not_in_tpa) || !empty($not_in_nhance) || !empty($emp_data_wo_tpa_id) ) - { - $this->exportVariationReportExcel($not_in_tpa,$not_in_nhance,$emp_data_wo_tpa_id); - } - else - { - return false; - } - // $this->exportVariationReportExcel([],[],[]); + if (!empty($not_in_tpa) || !empty($not_in_nhance) || !empty($emp_data_wo_tpa_id)) { + if ($type === 'download') { + $this->exportVariationReportExcel($not_in_tpa, $not_in_nhance, $emp_data_wo_tpa_id); + } else { + $response = [ + 'not_in_tpa' => $not_in_tpa, + 'not_in_nhance' => $not_in_nhance, + 'mismatch_data' => $emp_data_wo_tpa_id, + ]; + return $this->respond( + [ + 'status' => true, + 'code' => 200, + 'message' => '', + 'data' => $response, + ], + 200 + ); + } + } else { + if ($type === 'download') { + return false; + } + return $this->respond( + [ + 'status' => false, + 'code' => 202, + 'message' => 'No data found', + 'data' => [], + ], + 200 + ); + } + } + + public function proceedTPADataVariationNextStep($file_id) + { + try { + if (empty($file_id)) { + return $this->respond( + [ + 'status' => false, + 'code' => 400, + 'message' => 'Invalid file reference', + 'data' => [], + ], + 200 + ); + } + + $file = $this->batchFileModel->find($file_id); + + if (!$file) { + return $this->respond( + [ + 'status' => false, + 'code' => 404, + 'message' => 'File not found', + 'data' => [], + ], + 200 + ); + } + + $this->myLogger->logme( + 'error', + 'TPA variation review completed and proceed to next clicked', + [ + 'file_id' => $file_id, + 'user_id' => get_session_userid(), + ] + ); + + return $this->respond( + [ + 'status' => true, + 'code' => 200, + 'message' => 'Proceed to next step recorded successfully.', + 'data' => [], + ], + 200 + ); + } catch (\Throwable $e) { + $this->myLogger->logme( + 'error', + 'Error while processing TPA variation proceed to next: ' . $e->getMessage(), + ['file_id' => $file_id] + ); + + return $this->respond( + [ + 'status' => false, + 'code' => 500, + 'message' => 'Unable to proceed to the next step at the moment.', + 'data' => [], + ], + 200 + ); + } }