diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 3b9d49b1..f83d1d66 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -402,6 +402,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->match(['get', 'post', 'delete'], 'rtoMaster', 'MasterController::rtoMaster'); $routes->get('checkDuplicateCdAccount', 'MasterController::checkDuplicateCdAccount'); $routes->get('proceedExcelFileDataValidation', 'EmployeeController::proceedExcelFileDataValidation'); + $routes->get('checkTpaApiEnable', 'EmployeeRestController::checkTpaApiEnable'); }); $routes->post("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail"); diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 91086329..5e336e4f 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -54,6 +54,7 @@ use Illuminate\Http\Request; use App\Controllers\EmployeeServiceController; use App\Models\ClaimFilesModel; use App\Models\TicketMailTemplateModel; +use App\Models\TpaApiSeviceModel; use Composer\Pcre\Preg; use Kreait\Firebase\Factory; use Kreait\Firebase\Messaging\CloudMessage; @@ -2189,7 +2190,7 @@ class EmployeeRestController extends AdminController // print_r($params);die; $wholeData =sendMailNotification::sendMailNotification('member_review_and_summary_mail', $params); $mail_send_return = MailHelper::send_email($wholeData[0]); - $this->myLogger->logme("info", $mail_send_return); + $this->myLogger->logme("error", $mail_send_return); if (isset($wholeData[0])) { @@ -2200,7 +2201,7 @@ class EmployeeRestController extends AdminController { foreach ($account_manager_wholeData as $key => $value) { $mail_send_return1 = MailHelper::send_email($value); - $this->myLogger->logme("info", $mail_send_return1); + $this->myLogger->logme("error", $mail_send_return1); } }else{ $this->myLogger->logme("error", 'Account Manager Mail Configuration not Enable for this client'); @@ -2213,7 +2214,7 @@ class EmployeeRestController extends AdminController { foreach ($client_hr_wholeData as $key => $value) { $mail_send_return2 = MailHelper::send_email($value); - $this->myLogger->logme("info", $mail_send_return2); + $this->myLogger->logme("error", $mail_send_return2); } }else{ $this->myLogger->logme("error", 'Client HR Mail Configuration not Enable for this client'); @@ -3720,7 +3721,7 @@ class EmployeeRestController extends AdminController ])->setStatusCode(404); } - $this->myLogger->logme('info', "Policy type IDs fetched: " . json_encode($policy_type_ids)); + $this->myLogger->logme('error', "Policy type IDs fetched: " . json_encode($policy_type_ids)); $ticket_type = $this->ticketController->ticketType; $filtered = []; @@ -3748,9 +3749,9 @@ class EmployeeRestController extends AdminController 'name' => $mappedName ]; - $this->myLogger->logme('info', "Ticket type resolved: ID={$ticketTypeId}, Name={$mappedName}"); + $this->myLogger->logme('error', "Ticket type resolved: ID={$ticketTypeId}, Name={$mappedName}"); } else { - $this->myLogger->logme('warning', "No valid ticket type mapping for policy_type_id={$ticketTypeId}"); + $this->myLogger->logme('error', "No valid ticket type mapping for policy_type_id={$ticketTypeId}"); } } @@ -4462,22 +4463,105 @@ class EmployeeRestController extends AdminController return $this->failServerError($e->getMessage()); } } + + public function hrFileUploadMasters() + { + try { + //for inception upload + $data['actions'] = ['addition' => 'Addition (Employee + Dependents)', 'missed_inception' => 'Missed Inception (Employee + Dependents)', 'dependent_addition' => 'Dependent Addition (Only Dependents)', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement']; + + return $this->respond([ + 'status' => true, + 'message' => 'File inception upload masters', + 'data' => $data + ]); + } catch (\Exception $e) { + return $this->failServerError($e->getMessage()); + } + } + + public function checkTpaApiEnable($policy_id = null, $api_name = null, $return_type = 'api') + { + $this->myLogger->logme('error', '--- START checkTpaApiEnable ---'); + + try { + // Step 1: Handle input parameters + if (empty($policy_id)) { + $policy_id = $this->request->getGet('policy_id'); + $api_name = $this->request->getGet('api_name'); + log_message('error', "Input parameters fetched from GET: policy_id={$policy_id}, api_name={$api_name}"); + } else { + log_message('error', "Input parameters received directly: policy_id={$policy_id}, api_name={$api_name}"); + } + + // Step 2: Validate policy_id + if (empty($policy_id)) { + log_message('error', 'Policy ID is empty'); + if ($return_type == 'api') { + return $this->respond(['status' => false, 'code' => 200, 'message' => 'Policy ID missing']); + } + return false; + } + + // Step 3: Fetch policy data + log_message('error', "Fetching policy data for policy_id={$policy_id}"); + $policy_data = $this->clientPolicyModel + ->where('is_active', 1) + ->where('id', $policy_id) + ->first(); + + if (empty($policy_data)) { + log_message('error', "Policy data not found for policy_id={$policy_id}"); + if ($return_type == 'api') { + return $this->respond(['status' => false, 'code' => 200, 'message' => 'Policy data not found']); + } + return false; + } + + // Step 4: Check for TPA ID + if (empty($policy_data['tpa_id'])) { + log_message('error', "TPA ID not found for policy_id={$policy_id}"); + if ($return_type == 'api') { + return $this->respond(['status' => false, 'code' => 200, 'message' => 'TPA ID not found']); + } + return false; + } + + $tpa_id = $policy_data['tpa_id']; + log_message('error', "Found TPA ID={$tpa_id} for policy_id={$policy_id}"); + + // Step 5: Check if API service is enabled + log_message('error', "Checking TPA API service for TPA ID={$tpa_id} and API name={$api_name}"); + $tpaApiServiceModel = new TpaApiSeviceModel(); + $api_data = $tpaApiServiceModel + ->where('is_active', 1) + ->where('api_name', $api_name) + ->where('tpa_id', $tpa_id) + ->first(); + + if (!empty($api_data)) { + log_message('error', "API '{$api_name}' is enabled for TPA ID={$tpa_id}"); + if ($return_type == 'api') { + return $this->respond(['status' => true, 'code' => 200, 'message' => 'API services enabled']); + } + return true; + } else { + log_message('error', "API '{$api_name}' is NOT enabled for TPA ID={$tpa_id}"); + if ($return_type == 'api') { + return $this->respond(['status' => false, 'code' => 200, 'message' => 'API services not enabled']); + } + return false; + } + } catch (\Throwable $th) { + log_message('error', 'Exception in checkTpaApiEnable: ' . $th->getMessage()); + if ($return_type == 'api') { + return $this->respond(['status' => false, 'code' => 500, 'message' => 'Internal Server Error']); + } + return false; + } finally { + log_message('error', '--- END checkTpaApiEnable ---'); + } + } - - public function hrFileUploadMasters() - { - try { - //for inception upload - $data['actions'] = ['addition' => 'Addition (Employee + Dependents)', 'missed_inception' => 'Missed Inception (Employee + Dependents)', 'dependent_addition' => 'Dependent Addition (Only Dependents)', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement']; - - return $this->respond([ - 'status' => true, - 'message' => 'File inception upload masters', - 'data' => $data - ]); - } catch (\Exception $e) { - return $this->failServerError($e->getMessage()); - } - } } \ No newline at end of file diff --git a/app/Models/TpaApiSeviceModel.php b/app/Models/TpaApiSeviceModel.php new file mode 100644 index 00000000..9801614a --- /dev/null +++ b/app/Models/TpaApiSeviceModel.php @@ -0,0 +1,19 @@ +