From 3926a7281b4cf4452aa73cc9355a100b2cbe5aad Mon Sep 17 00:00:00 2001 From: "sanjeev.p" Date: Thu, 2 Apr 2026 18:29:57 +0530 Subject: [PATCH 1/6] TC - Validation rule UTR, CC - kyc document isctive 1 only --- app/Controllers/ClientController.php | 6 ++++-- app/Controllers/TicketController.php | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index d1bc5d9b..25f01381 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -649,7 +649,7 @@ class ClientController extends AdminController $headerData['page_name'] = 'Clients'; $data['entity'] = $this->kycEntityTypeModel->findAll(); - $data['kyc_docs'] = $this->kycDocsModel->findAll(); + $data['kyc_docs'] = $this->kycDocsModel->where('is_active', 1)->findAll(); $data['police'] = $this->policesModel->findAll(); $data['insurer'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames(); $data['tpa'] = $this->tpaBranchModel->getTpaBranchesWithTpaNames(); @@ -916,7 +916,7 @@ class ClientController extends AdminController $editData['insurers'] = $this->insurerModel->where('is_active', 1)->findAll(); $editData['insurer_branch'] = $this->insurerBranchModel->where('is_active', 1)->findAll(); $editData['clients'] = $this->clientModel->where('is_active', 1)->findAll(); - $editData['kyc_docs'] = $this->kycDocsModel->findAll(); + $editData['kyc_docs'] = $this->kycDocsModel->where('is_active', 1)->findAll(); $editData['policyGridData'] = $this->policyGridModel->findAll(); $editData['policy_types'] = $this->policyTypeModel->findAll(); $editData['policy_type'] = ['1' => 'Base Policy', '2' => 'SI Topup', '3' => 'Dependent Addon']; @@ -3761,6 +3761,8 @@ class ClientController extends AdminController 'left' ); $builder->where('c.id', $client_id); + $builder->where('kd.is_active',1); + $builder->groupBy(['kd.id', 'ck.file_name']); $query = $builder->get(); diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index 91d71085..c5e6d556 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -1307,7 +1307,7 @@ class TicketController extends BaseController 'approved_date' => ['label' => 'Approved Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Approved Date must be dd/mm/yyyy.']], 'approved_letter' => ['label' => 'Approved Letter','rules' => 'permit_empty','errors' => []], 'approved_description' => ['label' => 'Approved Description','rules' => 'permit_empty','errors' => []], - 'utr_details' => ['label' => 'UTR Details','rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9 ~!#$%&*\-_+=|:.,]+$/]','errors' => ['regex_match' => 'UTR Details only allows alphanumeric, spaces, and ~ ! # $ % & * - _ + = | : . , ']], + 'utr_details' => ['label' => 'UTR Details','rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9 ~!#$%&*\-_+=|:.,]+$/]','errors' => ['regex_match' => 'UTR Details allows only alphanumeric characters, spaces, and ~ ! # $ % & * - _ + = | : . ,']], 'settled_date' => ['label' => 'Settled Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Settled Date must be dd/mm/yyyy.']], 'settle_letter' => ['label' => 'Settle Letter','rules' => 'permit_empty','errors' => []], 'pay_initiate_date' => ['label' => 'Payment Initiate Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Payment Initiate Date must be dd/mm/yyyy.']], @@ -1418,7 +1418,7 @@ class TicketController extends BaseController 'approved_date' => ['label' => 'Approved Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Approved Date must be dd/mm/yyyy.']], 'approved_letter' => ['label' => 'Approved Letter','rules' => 'permit_empty','errors' => []], 'approved_description' => ['label' => 'Approved Description','rules' => 'permit_empty','errors' => []], - 'utr_details' => [ 'label' => 'UTR Details', 'rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9 ~!#$%&*\-_+=|:.,]+$/]','errors' => ['regex_match' => 'UTR Details only allows alphanumeric, spaces, and ~ ! # $ % & * - _ + = | : . , ']], + 'utr_details' => ['label' => 'UTR Details','rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9 ~!#$%&*\-_+=|:.,]+$/]','errors' => ['regex_match' => 'UTR Details allows only alphanumeric characters, spaces, and ~ ! # $ % & * - _ + = | : . ,']], 'settled_date' => ['label' => 'Settled Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Settled Date must be dd/mm/yyyy.']], 'settle_letter' => ['label' => 'Settle Letter','rules' => 'permit_empty','errors' => []], 'pay_initiate_date' => ['label' => 'Payment Initiate Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Payment Initiate Date must be dd/mm/yyyy.']], @@ -1672,7 +1672,7 @@ class TicketController extends BaseController 'approved_date' => ['label' => 'Approved Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Approved Date must be dd/mm/yyyy.']], 'approved_letter' => ['label' => 'Approved Letter','rules' => 'permit_empty','errors' => []], 'approved_description' => ['label' => 'Approved Description','rules' => 'permit_empty','errors' => []], - 'utr_details' => ['label' => 'UTR Details','rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9 ~!#$%&*\-_+=|:.,]+$/]','errors' => ['regex_match' => 'UTR Details only allows alphanumeric, spaces, and ~ ! # $ % & * - _ + = | : . , ']], + 'utr_details' => ['label' => 'UTR Details','rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9 ~!#$%&*\-_+=|:.,]+$/]','errors' => ['regex_match' => 'UTR Details allows only alphanumeric characters, spaces, and ~ ! # $ % & * - _ + = | : . ,']], 'errors' => [ 'regex_match' => 'UTR Details only allows alphanumeric, spaces, and ~ ! # $ % & * - _ + = | : . , '], 'settled_date' => ['label' => 'Settled Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Settled Date must be dd/mm/yyyy.']], 'settle_letter' => ['label' => 'Settle Letter','rules' => 'permit_empty','errors' => []], @@ -1784,7 +1784,7 @@ class TicketController extends BaseController 'approved_date' => ['label' => 'Approved Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Approved Date must be dd/mm/yyyy.']], 'approved_letter' => ['label' => 'Approved Letter','rules' => 'permit_empty','errors' => []], 'approved_description' => ['label' => 'Approved Description','rules' => 'permit_empty','errors' => []], - 'utr_details' => ['label' => 'UTR Details','rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9 ~!#$%&*\-_+=|:.,]+$/]','errors' => ['regex_match' => 'UTR Details only allows alphanumeric, spaces, and ~ ! # $ % & * - _ + = | : . , ']], + 'utr_details' => ['label' => 'UTR Details','rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9 ~!#$%&*\-_+=|:.,]+$/]','errors' => ['regex_match' => 'UTR Details allows only alphanumeric characters, spaces, and ~ ! # $ % & * - _ + = | : . ,']], 'settled_date' => ['label' => 'Settled Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Settled Date must be dd/mm/yyyy.']], 'settle_letter' => ['label' => 'Settle Letter','rules' => 'permit_empty','errors' => []], 'pay_initiate_date' => ['label' => 'Payment Initiate Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Payment Initiate Date must be dd/mm/yyyy.']], From 8406598b0796c40df92dfbf4052fbce15cb6cc0d Mon Sep 17 00:00:00 2001 From: "sanjeev.p" Date: Thu, 2 Apr 2026 18:53:15 +0530 Subject: [PATCH 2/6] TC - Validation rule UTR again --- app/Controllers/TicketController.php | 33 +++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index c5e6d556..49d4e615 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -1307,7 +1307,13 @@ class TicketController extends BaseController 'approved_date' => ['label' => 'Approved Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Approved Date must be dd/mm/yyyy.']], 'approved_letter' => ['label' => 'Approved Letter','rules' => 'permit_empty','errors' => []], 'approved_description' => ['label' => 'Approved Description','rules' => 'permit_empty','errors' => []], - 'utr_details' => ['label' => 'UTR Details','rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9 ~!#$%&*\-_+=|:.,]+$/]','errors' => ['regex_match' => 'UTR Details allows only alphanumeric characters, spaces, and ~ ! # $ % & * - _ + = | : . ,']], + 'utr_details' => [ + 'label' => 'UTR Details', + 'rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9 \/_-]+$/]', + 'errors' => [ + 'regex_match' => 'UTR Details allows only alphanumeric characters, spaces, and / _ -' + ] + ], 'settled_date' => ['label' => 'Settled Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Settled Date must be dd/mm/yyyy.']], 'settle_letter' => ['label' => 'Settle Letter','rules' => 'permit_empty','errors' => []], 'pay_initiate_date' => ['label' => 'Payment Initiate Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Payment Initiate Date must be dd/mm/yyyy.']], @@ -1418,7 +1424,13 @@ class TicketController extends BaseController 'approved_date' => ['label' => 'Approved Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Approved Date must be dd/mm/yyyy.']], 'approved_letter' => ['label' => 'Approved Letter','rules' => 'permit_empty','errors' => []], 'approved_description' => ['label' => 'Approved Description','rules' => 'permit_empty','errors' => []], - 'utr_details' => ['label' => 'UTR Details','rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9 ~!#$%&*\-_+=|:.,]+$/]','errors' => ['regex_match' => 'UTR Details allows only alphanumeric characters, spaces, and ~ ! # $ % & * - _ + = | : . ,']], + 'utr_details' => [ + 'label' => 'UTR Details', + 'rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9 \/_-]+$/]', + 'errors' => [ + 'regex_match' => 'UTR Details allows only alphanumeric characters, spaces, and / _ -' + ] + ], 'settled_date' => ['label' => 'Settled Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Settled Date must be dd/mm/yyyy.']], 'settle_letter' => ['label' => 'Settle Letter','rules' => 'permit_empty','errors' => []], 'pay_initiate_date' => ['label' => 'Payment Initiate Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Payment Initiate Date must be dd/mm/yyyy.']], @@ -1672,8 +1684,13 @@ class TicketController extends BaseController 'approved_date' => ['label' => 'Approved Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Approved Date must be dd/mm/yyyy.']], 'approved_letter' => ['label' => 'Approved Letter','rules' => 'permit_empty','errors' => []], 'approved_description' => ['label' => 'Approved Description','rules' => 'permit_empty','errors' => []], - 'utr_details' => ['label' => 'UTR Details','rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9 ~!#$%&*\-_+=|:.,]+$/]','errors' => ['regex_match' => 'UTR Details allows only alphanumeric characters, spaces, and ~ ! # $ % & * - _ + = | : . ,']], - 'errors' => [ 'regex_match' => 'UTR Details only allows alphanumeric, spaces, and ~ ! # $ % & * - _ + = | : . , '], + 'utr_details' => [ + 'label' => 'UTR Details', + 'rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9 \/_-]+$/]', + 'errors' => [ + 'regex_match' => 'UTR Details allows only alphanumeric characters, spaces, and / _ -' + ] + ], 'settled_date' => ['label' => 'Settled Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Settled Date must be dd/mm/yyyy.']], 'settle_letter' => ['label' => 'Settle Letter','rules' => 'permit_empty','errors' => []], 'pay_initiate_date' => ['label' => 'Payment Initiate Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Payment Initiate Date must be dd/mm/yyyy.']], @@ -1784,7 +1801,13 @@ class TicketController extends BaseController 'approved_date' => ['label' => 'Approved Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Approved Date must be dd/mm/yyyy.']], 'approved_letter' => ['label' => 'Approved Letter','rules' => 'permit_empty','errors' => []], 'approved_description' => ['label' => 'Approved Description','rules' => 'permit_empty','errors' => []], - 'utr_details' => ['label' => 'UTR Details','rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9 ~!#$%&*\-_+=|:.,]+$/]','errors' => ['regex_match' => 'UTR Details allows only alphanumeric characters, spaces, and ~ ! # $ % & * - _ + = | : . ,']], + 'utr_details' => [ + 'label' => 'UTR Details', + 'rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9 \/_-]+$/]', + 'errors' => [ + 'regex_match' => 'UTR Details allows only alphanumeric characters, spaces, and / _ -' + ] + ], 'settled_date' => ['label' => 'Settled Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Settled Date must be dd/mm/yyyy.']], 'settle_letter' => ['label' => 'Settle Letter','rules' => 'permit_empty','errors' => []], 'pay_initiate_date' => ['label' => 'Payment Initiate Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Payment Initiate Date must be dd/mm/yyyy.']], From 957cc1f2d1efdc1d5dfb394dd3b76146c0ea109f Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 3 Apr 2026 16:57:21 +0530 Subject: [PATCH 3/6] CHANGE_TPA_API_CHANGES --- app/Config/Acl.php | 2 +- app/Config/Routes.php | 4 + app/Controllers/EmployeeController.php | 424 ++++++++++++++++++++++--- app/Controllers/JobWorker.php | 20 ++ app/Controllers/TestingController.php | 167 ++++++++++ app/Libraries/JobStatusService.php | 100 ++++++ app/Views/leads_form_handler.php | 9 + 7 files changed, 682 insertions(+), 44 deletions(-) create mode 100644 app/Libraries/JobStatusService.php diff --git a/app/Config/Acl.php b/app/Config/Acl.php index b66743fb..107c754d 100644 --- a/app/Config/Acl.php +++ b/app/Config/Acl.php @@ -276,7 +276,7 @@ class Acl // ===================== INTERNAL TEST ===================== '#^/test#' => [ - 'roles' => [ADMIN_ROLE_ID], + 'roles' => [ADMIN_ROLE_ID, HEAD_ROLE_ID], 'teams' => [] ], diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 33aa40e1..a21e6106 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -887,6 +887,8 @@ $routes->get('HealthIndiaGetBenefDetails','HealthIndiaApiController::HealthIndia $routes->post("ecardRequest", "ApiServiceController::ecardRequest"); $routes->post("getTPAID", "ApiServiceController::getTPAID"); $routes->post("sendDataToTPA", "ApiServiceController::sendDataToTPA"); +$routes->get("jobStatus", "TestingController::jobStatus"); +$routes->post("jobStatus", "TestingController::jobStatus"); $routes->get('fileDownload','MediAssistApiController::fileDownload'); @@ -928,6 +930,8 @@ $routes->group('test', function($routes) { $routes->get('testingquerys','TestingController::testingquerys'); $routes->get('thzReminderCrone','ThzController::getOpenTicketsOlderThan24HoursAndAssignNextLevel'); $routes->get('chartbrewDashboardDemo','TestingController::chartbrewDashboardDemo'); + $routes->get('getVidalEnrollmentInfo','TestingController::getVidalEnrollmentInfo'); + // $routes->get('createDefaultMailTempalteInDB','TestingController::createDefaultMailTempalteInCrossDB'); // $routes->get('createDefaultMailTempalteInSameDB','TestingController::createDefaultMailTempalteInSameDB'); }); diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 8bc4d0e2..3fc7e8fe 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -2601,6 +2601,7 @@ class EmployeeController extends AdminController $employeeRest = new EmployeeRestController(); $tpa_api_service_status = $employeeRest->checkTpaApiEnable($client_policy_id, 'getTPAID', 'internel'); + $tpa_push_api_service_status = $employeeRest->checkTpaApiEnable($client_policy_id, 'sendDataToTPA', 'internel'); $slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($client_policy_id,$policy_details['client_id']); @@ -2620,7 +2621,7 @@ class EmployeeController extends AdminController $message = isset($message) ? ($message . ' The policy does not have a CD account number.') : null; } - return $this->respond(['dataStatus' => true, 'code' => 200, 'message' => $message, 'si_enhancement' => $si_enhancement_true_or_false, 'insurer_multi_event' => $insurer_details['is_multi_event'], 'tpa_api_service_status' => $tpa_api_service_status], 200); + return $this->respond(['dataStatus' => true, 'code' => 200, 'message' => $message, 'si_enhancement' => $si_enhancement_true_or_false, 'insurer_multi_event' => $insurer_details['is_multi_event'], 'tpa_api_service_status' => $tpa_api_service_status, 'tpa_push_api_service_status' => $tpa_push_api_service_status], 200); } @@ -4074,39 +4075,33 @@ class EmployeeController extends AdminController // d($not_in_nhance);die(); if (!empty($not_in_tpa) || !empty($not_in_nhance) || !empty($emp_data_wo_tpa_id)) { - if ($type === 'download') { + + $response = [ + 'not_in_tpa' => $not_in_tpa, + 'not_in_nhance' => $not_in_nhance, + 'mismatch_data' => $emp_data_wo_tpa_id, + ]; + + + if ($type === 'internal') { + return $response; + }else 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 - ); + return $this->respond(['status' => true,'code' => 200,'message' => '','data' => $response,],200); } + } else { + + if ($type === 'internal') { + return []; + } + if ($type === 'download') { return false; } - return $this->respond( - [ - 'status' => false, - 'code' => 202, - 'message' => 'No data found', - 'data' => [], - ], - 200 - ); + return $this->respond(['status' => false,'code' => 202,'message' => 'No data found','data' => [],],200); } } @@ -4161,14 +4156,15 @@ class EmployeeController extends AdminController } elseif ($tab === 'need_to_review') { // For the "Need to Review" tab, generate a Correction Excel // using the same overall pipeline as the Not in Nhance implementation. - $generationResult = $this->generateCorrectionUploadFromNeedToReview((int) $file_id, $file); + // $generationResult = $this->generateCorrectionUploadFromNeedToReview((int) $file_id, $file); + $generationResult = $this->updateEmployeeDataFromTpa([$file_id]); if (!$generationResult['status']) { return $this->respond( [ 'status' => false, 'code' => 422, - 'message' => $generationResult['message'] ?? 'Unable to generate correction upload file from Need to Review data.', + 'message' => $generationResult['message'] ?? 'Unable to process the data from Need to Review tab.', 'data' => $generationResult['data'] ?? [], ], 200 @@ -4178,12 +4174,13 @@ class EmployeeController extends AdminController $this->myLogger->logme( 'error', - 'TPA variation review completed and proceed to next clicked', - [ - 'file_id' => $file_id, - 'user_id' => get_session_userid(), - 'tab' => $tab, - ] + 'TPA variation review completed and proceed to next clicked' . json_encode( + [ + 'file_id' => $file_id, + 'user_id' => get_session_userid(), + 'tab' => $tab, + ] + ) ); return $this->respond( @@ -4193,7 +4190,7 @@ class EmployeeController extends AdminController 'message' => $tab === 'not_in_nhance' ? 'Employee upload file generated from Not in Nhance data and queued for processing.' : ($tab === 'need_to_review' - ? 'Correction upload file generated from Need to Review data and queued for processing.' + ? 'Review data update successfully.' : 'Proceed to next step recorded successfully.'), 'data' => [], ], @@ -4246,13 +4243,7 @@ class EmployeeController extends AdminController $TpaApiDataModel = new TpaApiDataModel(); // Get master emp codes from Nhance for this client & policy - $masterEmpRows = $this->employeePolicyModel->getTPADataVariationReport( - $clientId, - $clientPolicyId, - $batchFileId, - [], - true - ); + $masterEmpRows = $this->employeePolicyModel->getTPADataVariationReport($clientId,$clientPolicyId,$batchFileId,[],true); if (!is_array($masterEmpRows)) { $masterEmpRows = []; } @@ -4450,7 +4441,7 @@ class EmployeeController extends AdminController // Run the same format validation used for manual uploads. - $validationResult = $empServiceController->excelFileFormatValidation(['file_id' => $newFileId]); + $validationResult = $empServiceController->excelFileFormatValidation(['file_id' => $newFileId, 'batch_file_id' => $batchFileId]); if (isset($validationResult['error_summary']) && count($validationResult['error_summary'])) { return [ @@ -4465,6 +4456,7 @@ class EmployeeController extends AdminController 'message' => 'Employee upload file generated from Not in Nhance data and queued for processing.', 'data' => ['file_id' => $newFileId], ]; + } catch (\Throwable $e) { $this->myLogger->logme( 'error', @@ -4763,6 +4755,352 @@ class EmployeeController extends AdminController } } + /** + * Apply TPA values to `employees` for rows in the same "Need to Review" set as + * {@see generateCorrectionUploadFromNeedToReview}: same `getTPADataVariationReport` slice, + * same `reconcileDbWithTpa` matching, then persist mismatched fields from TPA instead of + * generating a correction Excel. + * + * Updatable fields mirror the correction Excel allow-list where they exist on TPA rows: + * `name`, `dob`, `gender`, `relationship` (from TPA `relation`), `email_corporate` (if present on TPA). + * Note: {@see reconcileDbWithTpa} only pairs rows when DB `relationship` matches TPA `relation`, + * so `relationship` rarely appears in `not_matching`; name/dob/gender are the usual diffs. + * + * @param array $params Expects `batch_file_id` (int, required). + * + * @return array{success:bool,message:string,data:array} + */ + public function updateEmployeeDataFromTpa(array $params) + { + try { + + $batchFileId = (int) ($params['batch_file_id'] ?? 0); + + if ($batchFileId <= 0) { + return [ + 'success' => false, + 'message' => 'batch_file_id is required and must be a positive integer.', + 'data' => [], + ]; + } + + $batchFile = $this->batchFileModel->find($batchFileId); + + if (!$batchFile) { + return [ + 'success' => false, + 'message' => 'Batch file not found.', + 'data' => ['batch_file_id' => $batchFileId], + ]; + } + + $clientId = (int) ($batchFile['client_id'] ?? 0); + $clientPolicyId = (int) ($batchFile['client_policy_id'] ?? 0); + $clientBranchId = (int) ($batchFile['client_branch_id'] ?? 0); + + if (!$clientId || !$clientPolicyId || !$clientBranchId) { + return [ + 'success' => false, + 'message' => 'Incomplete batch file information. Client / policy / branch missing.', + 'data' => [], + ]; + } + + $TpaApiDataModel = new TpaApiDataModel(); + + $dbRows = $this->employeePolicyModel->getTPADataVariationReport( + $clientId, + $clientPolicyId, + $batchFileId + ); + + if (!is_array($dbRows) || $dbRows === []) { + return [ + 'success' => false, + 'message' => 'No employee data found for this TPA variation batch.', + 'data' => [], + ]; + } + + $allowedFields = ['name', 'dob', 'relationship', 'email_corporate', 'gender']; + + $employeeModel = new EmployeeModel(); + $employeesUpdated = 0; + $rowsSkippedNoDiff = 0; + $rowsSkippedNoEmployee = 0; + + foreach ($dbRows as $dbRow) { + $tpaRows = $TpaApiDataModel->select('*') + ->where('emp_code', $dbRow['emp_code'] ?? '') + ->where('file_id', $batchFileId) + ->where('is_active', 1) + ->findAll(); + + if ($tpaRows === []) { + continue; + } + + $match = $this->reconcileDbWithTpa($dbRow, $tpaRows); + + if (($match['status'] ?? '') !== 'matched') { + continue; + } + + $tpaRecord = $match['tpa_record'] ?? []; + $notMatching = $match['not_matching'] ?? []; + + if (!is_array($notMatching) || $notMatching === []) { + $rowsSkippedNoDiff++; + continue; + } + + $employeeId = (int) ($dbRow['employee_id'] ?? 0); + + if ($employeeId <= 0) { + $rowsSkippedNoEmployee++; + continue; + } + + $employeeRow = $employeeModel->find($employeeId); + + if ( + !$employeeRow + || (int) ($employeeRow['client_id'] ?? 0) !== $clientId + ) { + $rowsSkippedNoEmployee++; + continue; + } + + $updateData = []; + + foreach ($notMatching as $field) { + if (!in_array($field, $allowedFields, true)) { + continue; + } + + if ($field === 'relationship') { + $val = $tpaRecord['relation'] ?? null; + if ($val !== null && $val !== '') { + $updateData['relationship'] = $val; + } + continue; + } + + if ($field === 'email_corporate') { + $val = $tpaRecord['email_corporate'] ?? $tpaRecord['email'] ?? null; + if ($val !== null && $val !== '') { + $updateData['email_corporate'] = $val; + } + continue; + } + + $val = $tpaRecord[$field] ?? null; + if ($val !== null && $val !== '') { + $updateData[$field] = $val; + } + } + + if ($updateData === []) { + continue; + } + + if ($employeeModel->update($employeeId, $updateData)) { + $employeesUpdated++; + } + } + + if ($employeesUpdated === 0) { + $this->myLogger->logme( + 'error', + 'updateEmployeeDataFromTpa: zero employee rows updated', + [ + 'batch_file_id' => $batchFileId, + 'rows_skipped_no_diff' => $rowsSkippedNoDiff, + 'rows_skipped_no_employee' => $rowsSkippedNoEmployee, + ] + ); + } + + return [ + 'success' => true, + 'message' => 'TPA-aligned employee updates applied where mismatches were reconciled.', + 'data' => [ + 'batch_file_id' => $batchFileId, + 'employees_updated' => $employeesUpdated, + 'rows_skipped_no_diff' => $rowsSkippedNoDiff, + 'rows_skipped_no_employee' => $rowsSkippedNoEmployee, + ], + ]; + } catch (\Throwable $e) { + $this->myLogger->logme( + 'error', + 'updateEmployeeDataFromTpa failed: ' . json_encode([ + 'message' => $e->getMessage(), + 'file' => $e->getFile(), + 'line' => $e->getLine(), + ], JSON_PRETTY_PRINT) + ); + + return [ + 'success' => false, + 'message' => 'Unable to process the data from Need to Review tab.', + 'data' => [], + ]; + } + } + + + /** + * @param array $params batch_file_id (required), file_id (optional, >0 filters employee_polices.file_id) + * @param mixed $jobId Optional queue job id when invoked from JobWorker (ignored). + * + * @return array{success:bool,message:string,data:array} + */ + public function updateTpaIdForNotInNhance($params, $jobId = null): array + { + try { + if (!is_array($params)) { + return [ + 'success' => false, + 'message' => 'Invalid parameters.', + 'data' => [], + ]; + } + + $TpaApiDataModel = new TpaApiDataModel(); + + $fileId = (int) ($params['file_id'] ?? 0); + $batchFileId = (int) ($params['batch_file_id'] ?? 0); + + if ($batchFileId <= 0) { + $this->myLogger->logme('error', 'Batch file ID missing in updateTpaIdForNotInNhance', ['params' => $params]); + + return [ + 'success' => false, + 'message' => 'Batch file ID is required.', + 'data' => [], + ]; + } + + $batchFileData = db_connect()->table('batch_files')->where('id', $batchFileId)->get()->getRowArray(); + + if (empty($batchFileData) || empty($batchFileData['client_policy_id'])) { + $this->myLogger->logme('error', 'Batch file not found or missing client_policy_id in updateTpaIdForNotInNhance', ['batch_file_id' => $batchFileId]); + + return [ + 'success' => false, + 'message' => 'Batch file not found or missing client policy.', + 'data' => [], + ]; + } + + $client_policy_data = $this->clientPolicyModel->where('id', $batchFileData['client_policy_id'])->first(); + + if (empty($client_policy_data)) { + $this->myLogger->logme('error', 'Client policy not found in updateTpaIdForNotInNhance', ['client_policy_id' => $batchFileData['client_policy_id']]); + + return [ + 'success' => false, + 'message' => 'Client policy not found.', + 'data' => [], + ]; + } + + // Get master emp codes from Nhance for this client & policy + $masterEmpRows = $this->employeePolicyModel->getTPADataVariationReport( + $batchFileData['client_id'], + $batchFileData['client_policy_id'], + $batchFileId, + [], + true + ); + if (!is_array($masterEmpRows)) { + $masterEmpRows = []; + } + $masterEmpCodes = array_values(array_filter( + array_unique(array_column($masterEmpRows, 'emp_code')), + static fn ($code) => $code !== null && $code !== '' + )); + + // Fetch Not in Nhance rows for this batch file + $notInNhanceQuery = $TpaApiDataModel->select('*') + ->where('is_active', 1) + ->where('file_id', $batchFileId); + + if ($masterEmpCodes !== []) { + $notInNhanceQuery->whereNotIn('emp_code', $masterEmpCodes); + } + + $notInNhance = $notInNhanceQuery->findAll(); + + $uhidValue = $client_policy_data['policy_no'] ?? null; + + $empPolicyIds = []; + foreach ($notInNhance as $tpaRow) { + $builder = $this->employeePolicyModel + ->select('employee_polices.id') + ->join('employees e', 'e.id = employee_polices.employee_id') + ->where('e.name', $tpaRow['name'] ?? '') + ->where('e.emp_code', $tpaRow['emp_code'] ?? '') + ->where('e.dob', $tpaRow['dob'] ?? null) + ->where('e.relationship', $tpaRow['relation'] ?? null) + ->where('e.gender', $tpaRow['gender'] ?? null) + ->where('employee_polices.client_policy_id', (int) $batchFileData['client_policy_id']) + ->where('e.client_id', (int) $batchFileData['client_id']); + + if ($fileId > 0) { + $builder->where('employee_polices.file_id', $fileId); + } + + $empPolicyRow = $builder->first(); + + if (empty($empPolicyRow['id'])) { + continue; + } + + $epId = (int) $empPolicyRow['id']; + if ($this->employeePolicyModel->update($epId, [ + 'tpa_id' => $tpaRow['tpa_id'] ?? null, + 'uhid' => $uhidValue, + ])) { + $empPolicyIds[] = $epId; + } + } + + if ($empPolicyIds === []) { + $this->myLogger->logme( + 'warning', + 'updateTpaIdForNotInNhance: zero employee_policy rows updated', + [ + 'batch_file_id' => $batchFileId, + 'not_in_nhance_count' => count($notInNhance), + ] + ); + } + + return [ + 'success' => true, + 'message' => 'TPA id / UHID applied on matching employee policies for Not in Nhance rows.', + 'data' => [ + 'employee_policies_updated' => count($empPolicyIds), + 'employee_policy_ids' => $empPolicyIds, + ], + ]; + } catch (\Throwable $e) { + $this->myLogger->logme( + 'error', + 'updateTpaIdForNotInNhance exception: ' . $e->getMessage(), + ['params' => $params, 'trace' => $e->getTraceAsString()] + ); + + return [ + 'success' => false, + 'message' => 'Unexpected error while updating TPA id from Not in Nhance data.', + 'data' => [], + ]; + } + } + // not in use once all functionality workes well in this funciton then remvoe this function function compareDbWithTpa(array $db, array $tpaRows): array diff --git a/app/Controllers/JobWorker.php b/app/Controllers/JobWorker.php index a8d12fac..b401fe8b 100755 --- a/app/Controllers/JobWorker.php +++ b/app/Controllers/JobWorker.php @@ -254,6 +254,26 @@ class JobWorker extends AdminController 'ICICIPushEmployeeDetails' => [ 'type' => 'CC', // Handler Category 'handler' => 'App\Controllers\ICICILombardController', + ], + 'getEnrollmentBatchStatus' => [ + 'type' => 'CC', // Handler Category + 'handler' => 'App\Controllers\ICICILombardController', + ], + 'fetchUHIDDetails' => [ + 'type' => 'CC', // Handler Category + 'handler' => 'App\Controllers\ICICILombardController', + ], + 'saveICICILombardAPIData' => [ + 'type' => 'CC', // Handler Category + 'handler' => 'App\Controllers\ICICILombardController', + ], + 'updateEmployeeDataFromTpa' => [ + 'type' => 'CC', // Handler Category + 'handler' => 'App\Controllers\EmployeeController', + ], + 'updateTpaIdForNotInNhance' => [ + 'type' => 'CC', // Handler Category + 'handler' => 'App\Controllers\EmployeeController', ] ]; diff --git a/app/Controllers/TestingController.php b/app/Controllers/TestingController.php index 094ef653..9bef4a08 100644 --- a/app/Controllers/TestingController.php +++ b/app/Controllers/TestingController.php @@ -10,6 +10,7 @@ use App\Models\BatchFileModel; use App\Models\InsurerBranchModel; use App\Models\RFQModel; use App\Models\EmployeeModel; +use App\Libraries\JobStatusService; use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\API\ResponseTrait; use Dompdf\Dompdf; @@ -48,6 +49,110 @@ class TestingController extends BaseController ]); } + /** + * Get latest job status by job name. + * Supports: + * - GET -> ?job_name=... + * - POST -> job_name in form/json payload + */ + public function jobStatus() + { + $jobName = trim((string) ($this->request->getGet('job_name') ?? '')); + + if ($jobName === '') { + $jobName = trim((string) ($this->request->getPost('job_name') ?? '')); + } + + if ($jobName === '') { + $jsonPayload = $this->request->getJSON(true); + if (is_array($jsonPayload)) { + $jobName = trim((string) ($jsonPayload['job_name'] ?? '')); + } + } + + $service = new JobStatusService(); + $result = $service->getJobStatusByName($jobName); + + $httpCode = 200; + if (($result['success'] ?? false) !== true) { + if ($jobName === '') { + $httpCode = 422; + } elseif (($result['message'] ?? '') === 'No job record found for given name.') { + $httpCode = 404; + } else { + $httpCode = 500; + } + } + + return $this->response->setStatusCode($httpCode)->setJSON($result); + } + + /** + * QA-only: invokes EmployeeController::updateTpaIdForNotInNhance. + * Routed under /util with authMVC — must be logged into the admin app. + * + * GET or POST: batch_file_id (required), file_id (optional, omit or 0 to skip file_id filter). + */ + public function qaUpdateTpaIdForNotInNhance() + { + $batchFileId = $this->request->getGet('batch_file_id'); + if ($batchFileId === null || $batchFileId === '') { + $batchFileId = $this->request->getPost('batch_file_id'); + } + + $fileId = $this->request->getGet('file_id'); + if ($fileId === null || $fileId === '') { + $fileId = $this->request->getPost('file_id'); + } + + if ($batchFileId === null || $batchFileId === '') { + return $this->response->setStatusCode(422)->setJSON([ + 'success' => false, + 'message' => 'batch_file_id is required (query string or POST).', + ]); + } + + $params = [ + 'batch_file_id' => (int) $batchFileId, + 'file_id' => ($fileId !== null && $fileId !== '') ? (int) $fileId : 0, + ]; + + $employeeController = new EmployeeController(); + $employeeController->initController($this->request, $this->response, service('logger')); + $result = $employeeController->updateTpaIdForNotInNhance($params); + + return $this->response->setJSON(array_merge($result, ['params' => $params])); + } + + /** + * QA-only: invokes EmployeeController::updateEmployeeDataFromTpa (Need to Review → DB updates, no Excel). + * Routed under /util with authMVC. + * + * GET or POST: batch_file_id (required). + */ + public function qaUpdateEmployeeDataFromTpa() + { + $batchFileId = $this->request->getGet('batch_file_id'); + if ($batchFileId === null || $batchFileId === '') { + $batchFileId = $this->request->getPost('batch_file_id'); + } + + if ($batchFileId === null || $batchFileId === '') { + return $this->response->setStatusCode(422)->setJSON([ + 'success' => false, + 'message' => 'batch_file_id is required (query string or POST).', + ]); + } + + $employeeController = new EmployeeController(); + $employeeController->initController($this->request, $this->response, service('logger')); + $result = $employeeController->updateEmployeeDataFromTpa([ + 'batch_file_id' => (int) $batchFileId, + ]); + + return $this->response->setJSON($result); + } + public function testcli() { echo "hi"; @@ -1609,4 +1714,66 @@ class TestingController extends BaseController ], ]; } + + public function getVidalEnrollmentInfo() + { + helper('api'); + + $url = 'https://devapigw.vidalhealthtpa.com/partner-integration/enrollment/enrollment-info'; + + $subscriptionKey = getenv('VIDAL_API_SUBSCRIPTION_KEY'); + if (empty($subscriptionKey)) { + return $this->response->setStatusCode(500)->setJSON([ + 'error' => 'Missing VIDAL_SUBSCRIPTION_KEY/VIDAL_API_SUBSCRIPTION_KEY in env', + ]); + } + + // Allow overriding payload via query/post/json; fall back to existing defaults. + $jsonPayload = $this->request->getJSON(true); + + $policyNo = (string) ( + ($this->request->getGet('policyNo') ?? '') + ?: ($this->request->getPost('policyNo') ?? '') + ?: ($jsonPayload['policyNo'] ?? '') + ?: '000/VZXSY' + ); + + $startIndex = (int) ( + ($this->request->getGet('startIndex') ?? null) + ?? ($this->request->getPost('startIndex') ?? null) + ?? ($jsonPayload['startIndex'] ?? 1) + ); + + $endIndex = (int) ( + ($this->request->getGet('endIndex') ?? null) + ?? ($this->request->getPost('endIndex') ?? null) + ?? ($jsonPayload['endIndex'] ?? 5) + ); + + $body = [ + 'policyNo' => $policyNo, + 'startIndex' => $startIndex, + 'endIndex' => $endIndex, + ]; + + $headers = [ + 'Content-Type: application/json', + 'Ocp-Apim-Subscription-Key: ' . $subscriptionKey, + ]; + + $method = "POST"; + + $rawResponse = call_third_party_api($url, $method, $headers, json_encode($body)); + + return $this->response->setStatusCode(200)->setJSON([ + 'request' => [ + 'url' => $url, + 'method' => $method, + 'headers' => $headers, + 'body' => $body, + ], + 'raw_response' => $rawResponse, + ]); + } + } diff --git a/app/Libraries/JobStatusService.php b/app/Libraries/JobStatusService.php new file mode 100644 index 00000000..8c6f14a4 --- /dev/null +++ b/app/Libraries/JobStatusService.php @@ -0,0 +1,100 @@ +jobModel = $jobModel ?? new JobModel(); + } + + public function getJobStatusByName(string $jobName): array + { + $jobName = trim($jobName); + + if ($jobName === '') { + return $this->buildResponse(false, $jobName, 'Job name is required.'); + } + + try { + $job = $this->jobModel + ->where('name', $jobName) + ->orderBy('id', 'DESC') + ->first(); + + if (!$job) { + return $this->buildResponse(false, $jobName, 'No job record found for given name.'); + } + + return [ + 'success' => true, + 'job_name' => $jobName, + 'status' => $job['status'] ?? null, + 'response' => $this->normalizeResponse($job['response'] ?? null), + 'job_id' => isset($job['id']) ? (int) $job['id'] : null, + 'uuid' => $job['uuid'] ?? null, + 'run_time' => $this->normalizeRunTime($job['run_time'] ?? null), + 'message' => 'Job status fetched successfully.', + ]; + } catch (\Throwable $e) { + log_message('error', 'JobStatusService failed for job "{job}": {message}', [ + 'job' => $jobName, + 'message' => $e->getMessage(), + ]); + + return $this->buildResponse(false, $jobName, 'Unable to fetch job status right now.'); + } + } + + protected function normalizeResponse($rawResponse) + { + // dd($rawResponse); + if ($rawResponse === null) { + return null; + } + + if (is_string($rawResponse)) { + $trimmed = trim($rawResponse); + if ($trimmed === '') { + return null; + } + + $decoded = json_decode($trimmed, true); + if (json_last_error() === JSON_ERROR_NONE) { + return $decoded; + } + + return $rawResponse; + } + + return $rawResponse; + } + + protected function normalizeRunTime($runTime) + { + if ($runTime === null || $runTime === '') { + return null; + } + + return is_numeric($runTime) ? (float) $runTime : null; + } + + protected function buildResponse(bool $success, string $jobName, string $message): array + { + return [ + 'success' => $success, + 'job_name' => $jobName, + 'status' => null, + 'response' => null, + 'job_id' => null, + 'uuid' => null, + 'run_time' => null, + 'message' => $message, + ]; + } +} diff --git a/app/Views/leads_form_handler.php b/app/Views/leads_form_handler.php index 578b1e1e..fc01d94e 100644 --- a/app/Views/leads_form_handler.php +++ b/app/Views/leads_form_handler.php @@ -460,6 +460,15 @@ if (isset($selected_lead_type)) { let shortNameTimer; $('#client_name').on('input', function() { + let lead_type = $('#lead_type').val(); + let exixting_client = $('#existing_client').is(':checked'); + + console.log(`Lead Type: ${lead_type}, Existing Client: ${exixting_client}`); + + if(lead_type == 1 || exixting_client == true){ + return false; + } + clearTimeout(shortNameTimer); shortNameTimer = setTimeout(generateShortName, 200); }); From 201766675bb4126510f0b565e823127f2385f955 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 6 Apr 2026 11:52:56 +0530 Subject: [PATCH 4/6] CHANGE_CLAIM_MODULE_FRONTEND_VALIDATION --- app/Controllers/JobWorker.php | 4 + app/Controllers/TestingController.php | 34 +- app/Controllers/TicketController.php | 61 ++- app/Controllers/VoloApiController.php | 8 + app/Models/EmployeePolicyModel.php | 5 + app/Views/claim_files_upload.php | 176 ++++-- app/Views/ticket_edit_onbording.php | 16 +- app/Views/ticket_form_gmc.php | 6 +- app/Views/ticket_form_gpa.php | 4 +- app/Views/ticket_form_handler.php | 15 +- app/Views/ticket_form_motor.php | 46 +- .../js/pages/ticket_form_input_validation.js | 506 ++++++++++++++++++ ..._kyc_additional_documents_add_more_plan.md | 119 ++++ ...6-03-31_ticket_frontend_validation_plan.md | 455 ++++++++++++++++ .../2026-04-02_job_status_service_plan.md | 191 +++++++ public/dev_logs/2026-04-03.md | 171 ++++++ ...04-03_ticket_form_input_validation_plan.md | 188 +++++++ public/dev_logs/2026-04-04.md | 81 +++ 18 files changed, 1960 insertions(+), 126 deletions(-) create mode 100644 public/assets/js/pages/ticket_form_input_validation.js create mode 100644 public/dev_logs/2026-03-31_client_kyc_additional_documents_add_more_plan.md create mode 100644 public/dev_logs/2026-03-31_ticket_frontend_validation_plan.md create mode 100644 public/dev_logs/2026-04-02_job_status_service_plan.md create mode 100644 public/dev_logs/2026-04-03.md create mode 100644 public/dev_logs/2026-04-03_ticket_form_input_validation_plan.md create mode 100644 public/dev_logs/2026-04-04.md diff --git a/app/Controllers/JobWorker.php b/app/Controllers/JobWorker.php index b401fe8b..f6d9f2eb 100755 --- a/app/Controllers/JobWorker.php +++ b/app/Controllers/JobWorker.php @@ -191,6 +191,10 @@ class JobWorker extends AdminController 'type' => 'CC', // Handler Category 'handler' => 'App\Controllers\VidalApiController', ], + 'VidalGetBenefDetailsV2' => [ + 'type' => 'CC', // Handler Category + 'handler' => 'App\Controllers\VidalApiController', + ], 'saveVidalAPIData' => [ 'type' => 'CC', // Handler Category 'handler' => 'App\Controllers\VidalApiController', diff --git a/app/Controllers/TestingController.php b/app/Controllers/TestingController.php index 9bef4a08..eecbfb45 100644 --- a/app/Controllers/TestingController.php +++ b/app/Controllers/TestingController.php @@ -1410,7 +1410,7 @@ class TestingController extends BaseController ], 200); } - /** + /** * Test Wellness SSO token generation for Medi Assist (MediBuddy). * * This uses the token-based authentication details shared by Medi Assist: @@ -1719,36 +1719,18 @@ class TestingController extends BaseController { helper('api'); - $url = 'https://devapigw.vidalhealthtpa.com/partner-integration/enrollment/enrollment-info'; + $url = 'https://devapigw.vidalhealthtpa.com/partner-integration/enrollment/info'; $subscriptionKey = getenv('VIDAL_API_SUBSCRIPTION_KEY'); if (empty($subscriptionKey)) { return $this->response->setStatusCode(500)->setJSON([ - 'error' => 'Missing VIDAL_SUBSCRIPTION_KEY/VIDAL_API_SUBSCRIPTION_KEY in env', + 'error' => 'Missing VIDAL_API_SUBSCRIPTION_KEY in env', ]); } - // Allow overriding payload via query/post/json; fall back to existing defaults. - $jsonPayload = $this->request->getJSON(true); - - $policyNo = (string) ( - ($this->request->getGet('policyNo') ?? '') - ?: ($this->request->getPost('policyNo') ?? '') - ?: ($jsonPayload['policyNo'] ?? '') - ?: '000/VZXSY' - ); - - $startIndex = (int) ( - ($this->request->getGet('startIndex') ?? null) - ?? ($this->request->getPost('startIndex') ?? null) - ?? ($jsonPayload['startIndex'] ?? 1) - ); - - $endIndex = (int) ( - ($this->request->getGet('endIndex') ?? null) - ?? ($this->request->getPost('endIndex') ?? null) - ?? ($jsonPayload['endIndex'] ?? 5) - ); + $policyNo = '000/VZXSY'; + $startIndex = 1; + $endIndex = 5; $body = [ 'policyNo' => $policyNo, @@ -1758,12 +1740,12 @@ class TestingController extends BaseController $headers = [ 'Content-Type: application/json', - 'Ocp-Apim-Subscription-Key: ' . $subscriptionKey, + 'ocp-apim-subscription-key: ' . $subscriptionKey, ]; $method = "POST"; - $rawResponse = call_third_party_api($url, $method, $headers, json_encode($body)); + $rawResponse = call_third_party_api($url, $method, $headers, $body); return $this->response->setStatusCode(200)->setJSON([ 'request' => [ diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index 49d4e615..b22e604c 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -3223,6 +3223,42 @@ class TicketController extends BaseController return $date && $date->format($format) === $value; } + /** + * Claim upload URL row: allow http(s) with path, query, port; bare host with TLD; localhost; IPv4/IPv6. + * Replaces the old strict regex that rejected ?query= and long TLDs. + */ + private function isClaimUploadUrl(string $s): bool + { + $v = trim($s); + if ($v === '' || strlen($v) > 2048) { + return false; + } + if (! preg_match('#^https?://#i', $v)) { + $v = 'https://' . $v; + } + $parts = parse_url($v); + if ($parts === false || empty($parts['host'])) { + return false; + } + $scheme = strtolower($parts['scheme'] ?? ''); + if ($scheme !== 'http' && $scheme !== 'https') { + return false; + } + $host = strtolower($parts['host']); + if ($host === 'localhost') { + return true; + } + $hostForIp = $host; + if (strlen($host) > 2 && $host[0] === '[' && substr($host, -1) === ']') { + $hostForIp = substr($host, 1, -1); + } + if (filter_var($hostForIp, FILTER_VALIDATE_IP)) { + return true; + } + + return strpos($host, '.') !== false; + } + public function upload_url() { @@ -3249,10 +3285,9 @@ class TicketController extends BaseController ], 'url.*' => [ 'label' => 'URL', - 'rules' => 'if_exist|required|regex_match[/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/]', + 'rules' => 'if_exist|required', 'errors' => [ - 'required' => 'URL is required.', - 'regex_match' => 'The URL format is invalid. Example: www.google.com or https://google.com' + 'required' => 'URL is required.', ] ], ]; @@ -3266,6 +3301,22 @@ class TicketController extends BaseController ]); } + if (! empty($data['url']) && is_array($data['url'])) { + foreach ($data['url'] as $idx => $singleUrl) { + $singleUrl = (string) $singleUrl; + if (trim($singleUrl) !== '' && ! $this->isClaimUploadUrl($singleUrl)) { + return $this->response->setStatusCode(400)->setJSON([ + 'status' => false, + 'message' => 'Input validation failed', + 'code' => 400, + 'errors' => [ + 'url.' . $idx => 'The URL format is invalid. Use https://example.com/path?x=1 or example.com', + ], + ]); + } + } + } + $get_file_data = $this->request->getFiles('file_upload') ?? []; $ticket_id = $data['ticket_id_url']; @@ -3840,7 +3891,7 @@ class TicketController extends BaseController ]); } - // YOUR REQUIRED REGEX RULE + // Same charset as claim upload `docs_name.*` / client `ticketdocname` if (!preg_match('/^[a-zA-Z0-9_\- ]+$/', $doc['document_name'])) { return $this->response->setStatusCode(400)->setJSON([ 'status' => false, @@ -3848,7 +3899,7 @@ class TicketController extends BaseController 'message' => 'Input validation failed', 'errors' => [ 'required_docs' => - "Document name '{$doc['document_name']}' can only contain letters, numbers, hyphens and underscores" + "Document Name can only contain letters, numbers, hyphens, and underscores (row " . ($index + 1) . ")" ] ]); } diff --git a/app/Controllers/VoloApiController.php b/app/Controllers/VoloApiController.php index 16d5f65b..79320a2b 100644 --- a/app/Controllers/VoloApiController.php +++ b/app/Controllers/VoloApiController.php @@ -533,6 +533,12 @@ class VoloApiController extends BaseController $dobYmd = $this->normalizeVoloDobToYmd($dobRaw); } + $dojRaw = $row['DOJ'] ?? $row['doj'] ?? null; + $dojYmd = null; + if ($dojRaw !== null && $dojRaw !== '') { + $dojYmd = $this->normalizeVoloDobToYmd($dojRaw); + } + $rel = trim((string) ($row['relation'] ?? '')); $mappedRows[] = [ 'file_id' => $file_id, @@ -544,6 +550,8 @@ class VoloApiController extends BaseController 'self' => in_array(strtoupper($rel), ['EMPLOYEE', 'SELF'], true) ? 1 : 0, 'tpa_id' => trim((string) ($row['memberId'] ?? '')), 'age' => isset($row['age']) && is_numeric($row['age']) ? (int) $row['age'] : null, + 'si' => $row['sumInsured'] ?? null, + 'doj' => $dojYmd, 'is_active' => 1, 'created_by' => $file_info[0]['created_by'] ?? null, ]; diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 70e71f6f..dac8f8d6 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -572,8 +572,12 @@ class EmployeePolicyModel extends Model employee_polices.tpa_id, employees.relationship_code as emp_relationship_code, employees.relationship as emp_relationship, + employees.email_corporate as emp_email_c, 'C' as event_type_data, + employee_polices.date_coverage, + employee_polices.basic_cover_si, + CASE WHEN emp_endorsement.field_name = 'dob' THEN DATE_FORMAT(emp_endorsement.old_value, '%d-%b-%Y') @@ -705,6 +709,7 @@ class EmployeePolicyModel extends Model employee_polices.premium AS old_si_premium, employee_polices.rata_premimum AS old_rata_premium, employee_polices.age_band, + employee_polices.date_coverage, sidata.new_basic_cover_si, sidata.new_si_premium, sidata.old_si_premium, diff --git a/app/Views/claim_files_upload.php b/app/Views/claim_files_upload.php index 9132e7e5..4a86c1bd 100644 --- a/app/Views/claim_files_upload.php +++ b/app/Views/claim_files_upload.php @@ -27,9 +27,11 @@ - +
+
Document Name
@@ -39,17 +41,7 @@
- - - +
@@ -72,7 +64,8 @@
+ enctype="multipart/form-data" novalidate + data-parsley-validation-threshold="0"> @@ -134,7 +127,8 @@ +