diff --git a/.env.sample b/.env.sample
index cd4743fb..e834a822 100755
--- a/.env.sample
+++ b/.env.sample
@@ -111,4 +111,12 @@ FHPL_PRIMARY_KEY_CONSTANT =
VIDAL_PRIMARY_KEY_CONSTANT =
-MEDI_ASSIST_PRIMARY_KEY_CONSTANT =
\ No newline at end of file
+MEDI_ASSIST_PRIMARY_KEY_CONSTANT =
+
+
+FHPL_TOKEN_URL =
+FHPL_BASE_URL =
+FHPL_USER_NAME =
+FHPL_PASSWORD =
+FHPL_GRANT_TYPE =
+
diff --git a/app/Config/Acl.php b/app/Config/Acl.php
index b89e53a9..371e1a21 100644
--- a/app/Config/Acl.php
+++ b/app/Config/Acl.php
@@ -17,6 +17,10 @@ class Acl
'#^/swagger#' => ['roles' => [ADMIN_ROLE_ID]],
'#^/fedeploy#' => ['roles' => [ADMIN_ROLE_ID]],
'#^/visitOffBoardCheck#' => ['roles' => [ADMIN_ROLE_ID]],
+ '#^/logs#' => ['roles' => [ADMIN_ROLE_ID]],
+ '#^/util/log_list#' => ['roles' => [ADMIN_ROLE_ID]],
+ '#^/util/view_log#' => ['roles' => [ADMIN_ROLE_ID]],
+ '#^/util/download_log#' => ['roles' => [ADMIN_ROLE_ID]],
// ===================== PUBLIC DOWNLOADS / FORMS =====================
'#^/download-#' => ['public' => true],
diff --git a/app/Config/Filters.php b/app/Config/Filters.php
index 36899e3a..b115e0ca 100755
--- a/app/Config/Filters.php
+++ b/app/Config/Filters.php
@@ -63,7 +63,7 @@ class Filters extends BaseConfig
'HttpRequestLog' => ['except' => 'cli/*'],
'Cors',
// 'AclFilter' => ['except' => ['login', 'logout', 'auth/*', 'oauth2callback','claim-form-download', 'claims-feedback-form', 'autobookstackLogin','employeeRest/*','processjob','getCommission']],
- 'SecurityInputFilter' => ['except' => ['notification/create','/ticket/crud_mail_template/*','test_mail','leads/sendMail'] ],
+ 'SecurityInputFilter' => ['except' => ['/client/notification/create','/ticket/crud_mail_template/*','test_mail','leads/sendMail'] ],
'GlobalPostFileUploadGuard'
// 'csrf',
// 'invalidchars',
diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index b31bbbfa..fef1a3dd 100755
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -22,6 +22,7 @@ $routes->get('/swagger', 'SwaggerController::index', ['filter' => 'authMVC']);
$routes->get('/fedeploy', 'DeployController::fedeploy_view', ['filter' => 'authMVC']);
$routes->post('/fedeploy', 'DeployController::fedeploy', ['filter' => 'authMVC']);
$routes->get('/visitOffBoardCheck', 'EmployeeController::visitOffBoardCheck');
+$routes->get('/metaDashboardDemo', 'TestingController::metaDashboardDemo');
// Reminder Mail Notification
@@ -36,7 +37,6 @@ $routes->get("view", "EmployeeController::viewECard/$1");
$routes->get("checkWellnessOnboardStatus/(:any)", "EmployeeController::checkWellnessOnboardStatus/$1");
$routes->get("initiateWellnessOnboard/(:any)", "EmployeeController::initiateWellnessOnboard/$1");
$routes->get("exportQCRandRFQ/(:any)", "LeadsController::exportQCRandRFQ/$1");
-$routes->get("smapletest", "ClientController::smapletest");
$routes->get("testMailAttachments", "ClientController::testMailAttachments");
$routes->get("updatePolicyTermsKey", "ClientController::updatePolicyTermsKey");
$routes->get("updateRemainderDate", "ClientController::updateRemainderDate");
@@ -216,6 +216,9 @@ $routes->group("/employee", ["filter" => "authMVC"], function ($routes) {
$routes->post("retail-endorsement-save", "EmployeeController::retailendorsementsave");
$routes->get("getTPADataVariationReport/(:num)", "EmployeeController::getTPADataVariationReport/$1");
$routes->get("bulkGenerateEcardAndStoreinS3", "EmployeeController::bulkGenerateEcardAndStoreinS3");
+ $routes->get('clearCdSession', 'EmployeeController::clearCdSession');
+ $routes->get('checkSessionStatus', 'EmployeeController::checkSessionStatus');
+
});
@@ -429,6 +432,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->get('proceedExcelFileDataValidation', 'EmployeeController::proceedExcelFileDataValidation');
$routes->get('checkTpaApiEnable', 'EmployeeRestController::checkTpaApiEnable');
$routes->get('generateDemographyDataTable', 'LeadsController::generateDemographyDataTable');
+ $routes->post('insufficientCdBalanceHrMailSend', 'EmployeeController::insufficientCdBalanceHrMailSend');
});
$routes->post("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail");
@@ -555,6 +559,8 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) {
$routes->get("getSSORedirectUrl", "ApiServiceController::getSSORedirectUrl");
$routes->get("getEmployeePolicy", "EmployeeRestController::getEmployeePolicy");
+$routes->get("downloadCdSplitUpFile", "EmployeeRestController::downloadCdSplitUpFile");
+
$routes->group("employeeRest", ['filter' => ['appSignature'] ], function ($routes) {
@@ -599,7 +605,7 @@ $routes->group("employeeRest", ['filter' => ['appSignature'] ], function ($route
});
-$routes->group("employeeRest", ["filter" => ['appSignature' , 'authJWT']], function ($routes) {
+$routes->group("employeeRest", ["filter" => ['GlobalPostFileUploadGuard', 'appSignature', 'authJWT']], function ($routes) {
$routes->post('logout', 'RestAuthenticationController::logout');
@@ -681,7 +687,10 @@ $routes->group("employeeRest", ["filter" => ['appSignature' , 'authJWT']], funct
// get insurer and policy type
$routes->get("getPolicyTypeAndInsurer", "EmployeeRestController::getPolicyTypeAndInsurer");
-
+ $routes->get("getExcelFileErrors/(:any)", "EmployeeController::getExcelFileErrors/$1");
+ $routes->get("getPolicyAndEndorsementFiles", "EmployeeRestController::getPolicyAndEndorsementFiles");
+ $routes->get("downloadPolicyFiles", "EmployeeRestController::downloadPolicyFiles");
+ $routes->post("bulkEcardDownloadAsZip", "EmployeeRestController::bulkEcardDownloadAsZip");
});
$routes->get("hrFileDownload", "EmployeeRestController::hrFileDownload");
@@ -772,11 +781,11 @@ $routes->get('fetchUHIDDetails','ICICILombardController::fetchUHIDDetails');
//Third party - testing route
$routes->get('FhplGetBenefDetails','FhplApiController::FhplGetBenefDetails');
-$routes->get('EcardRequest','VidalApiController::EcardRequest');
+$routes->get('EcardRequest','FhplApiController::EcardRequest');
$routes->get('HospitalNetwork','MediAssistApiController::HospitalNetwork');
$routes->get('VidalGetBenefDetails','VidalApiController::VidalGetBenefDetails');
$routes->get('ClaimDetail','FhplApiController::ClaimDetail');
-$routes->get('SubmitClaim','FhplApiController::SubmitClaim');
+$routes->get('SubmitClaim','VidalApiController::SubmitClaim');
$routes->get('IntimateClaim','MediAssistApiController::IntimateClaim');
$routes->get('IRSubmission','MediAssistApiController::IRSubmission');
$routes->get('ClaimStatusUpdate','MediAssistApiController::ClaimStatusUpdate');
diff --git a/app/Controllers/ApiServiceController.php b/app/Controllers/ApiServiceController.php
index 7c256f40..075a7e01 100644
--- a/app/Controllers/ApiServiceController.php
+++ b/app/Controllers/ApiServiceController.php
@@ -12,6 +12,7 @@ use App\Controllers\BaseController;
use App\Controllers\VidalApiController;
use App\Controllers\ICICILombardController;
use App\Controllers\MediAssistApiController;
+use App\Controllers\FhplApiController;
use App\Models\BatchFileModel;
use App\Models\FileModel;
use App\Helpers\TPADataCompareHelper;
@@ -26,6 +27,7 @@ class ApiServiceController extends BaseController
protected $medi_assist_primary_key;
protected $vidal_primary_key;
protected $icici_primary_key;
+ protected $fhpl_primary_key;
public function __construct()
{
@@ -34,6 +36,7 @@ class ApiServiceController extends BaseController
$this->medi_assist_primary_key = getenv('MEDI_ASSIST_PRIMARY_KEY_CONSTANT');
$this->vidal_primary_key = getenv('VIDAL_PRIMARY_KEY_CONSTANT');
$this->icici_primary_key = getenv('ICICI_PRIMARY_KEY_CONSTANT');
+ $this->fhpl_primary_key = getenv('FHPL_PRIMARY_KEY_CONSTANT');
}
// Push Claims
@@ -55,6 +58,10 @@ class ApiServiceController extends BaseController
{ // Vidal
$vidalApiController = new VidalApiController;
return $vidalApiController->SubmitClaim($claimId);
+ }else if ($tpaID == $this->fhpl_primary_key)
+ { // fhpl
+ $fhplApiController = new FhplApiController;
+ return $fhplApiController->SubmitClaim($claimId);
}else{
log_message('error', "This ticket id ( {$claimId} ) TPA has no API service enabled. TPA ID : {$tpaID}");
}
@@ -130,6 +137,12 @@ class ApiServiceController extends BaseController
$vidalApiController = new VidalApiController;
$data['eCardDownload'] = $vidalApiController->EcardRequest( $emp_code, $policy_no , $employee_policy[0]['tpa_id'] );
+ }else if($employee_policy[0]['tpa_primary_id'] == $this->fhpl_primary_key)// Fhpl
+ {
+
+ $fhplApiController = new FhplApiController;
+ $data['eCardDownload'] = $fhplApiController->EcardRequest( $emp_code, $policy_no , $employee_policy[0]['tpa_id'] );
+
}else{
if($type == "download"){
@@ -266,6 +279,17 @@ class ApiServiceController extends BaseController
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Action Triggered','data' => [] ]);
+ }else if ($tpa_id == $this->fhpl_primary_key) // Fhpl
+ {
+ $file_id = $fileModel->insert($data);
+ log_message('error', "Files table inserted successfully, File id : {$file_id}");
+ // $fhplApiController = new FhplApiController;
+ // $fhplApiController->FhplGetBenefDetails( [ 'polict_no' => $policy_no, 'file_id' =>$file_id ] );
+ $r = Jobs::addJob(['job_name' => 'FhplGetBenefDetails', 'payload' => ['policy_no' => $policy_no, 'file_id' => $file_id, 'client_policy_id' => $policy_id, 'return_type' => 'job']]);
+ log_message('error', "FhplGetBenefDetails job pushed successfully.");
+
+ return $this->respond(['status' => true, 'code' => 200, 'message' => 'Action Triggered','data' => [] ]);
+
}else{
return $this->respond(['status' => false, 'code' => 200,'message' => 'TPA not found ','data' => [] ]);
}
@@ -287,12 +311,20 @@ class ApiServiceController extends BaseController
if ($tpaID == $this->medi_assist_primary_key) { // MediAssist
$mediAssistController = new MediAssistApiController();
- return $mediAssistController->ClaimDetail($claimId);
+ $res = $mediAssistController->ClaimDetail($claimId);
+ return $this->response->setJSON(['status' => $res['status'],'message' => $res['message'] ]);
}else if ($tpaID == $this->vidal_primary_key) { // vidal
$vidalApiController = new VidalApiController;
- return $vidalApiController->ClaimDetail($claimId);
+ $res = $vidalApiController->ClaimDetail($claimId);
+ return $this->response->setJSON(['status' => $res['status'],'message' => $res['message'] ]);
+
+ }else if ($tpaID == $this->fhpl_primary_key) { // Fhpl
+
+ $fhplApiController = new FhplApiController;
+ $res = $fhplApiController->ClaimDetail($claimId);
+ return $this->response->setJSON(['status' => $res['status'],'message' => $res['message'] ]);
}else{
log_message('error', "This ticket id ( {$claimId} ) TPA has no API service enabled. TPA ID : {$tpaID}");
diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php
index 2c79d18b..894f98c4 100755
--- a/app/Controllers/ClientController.php
+++ b/app/Controllers/ClientController.php
@@ -141,6 +141,7 @@ class ClientController extends AdminController
$isDuplicate = $this->clientModel->isDuplicateByClientBranch($value, $field, $clientId, $branchId);
return $this->response->setJSON(['isDuplicate' => $isDuplicate]);
}
+
public function checkDuplicateTableFieldValue()
{
$table = $this->request->getPost('table');
@@ -162,35 +163,6 @@ class ClientController extends AdminController
return $this->response->setJSON(['isDuplicate' => $isDuplicate]);
}
- public function smapletest()
- {
- $headers = [
- 'S.No',
- 'NAME OF EMP/DEP',
- 'EMP ID',
- // 'EMP/DEP TYPE',
- // 'RELATIONSHIP CODE',
- 'DOB',
- 'GENDER',
- 'PRE EXISTING AILMENTS',
- 'BASIC COVER SI',
- 'DATE OF COVERAGE',
- 'AGE',
- 'RELATIONSHIP',
- 'REMARKS',
- 'POLICY END DATE',
- 'NO OF DAYS',
- 'TPA ID',
- 'UHID',
- // 'PREMIUM',
- 'PRO RATA PREMIUM',
- 'GST',
- 'TOTAL AMOUNT'
- ];
- $filePath = generateExcelWithHeader($headers);
- echo "Excel file created at: $filePath";
- }
-
public function testMailAttachments($email = 'venkateshraman786@gmail.com')
{
$message = '
Dear {{RECIPIENT_NAME}}, We are reaching out to request a quotation for the following insurance coverage. Please review the details below and provide your quote at your earliest convenience.
RFQ Details Client name {{CLIENT_NAME}} Coverage Type {{POLICY_LONG_NAME}} Policy Start Date {{POLICY_START_DATE}} Policy Duration {{DURATION}}
Please note: Additional terms and details are included in the attachment for your reference.
Please feel free to reach out if you require any further information to prepare the quote. We look forward to receiving your proposal.
Best regards,
Nhance India Pvt Ltd
';
@@ -510,7 +482,6 @@ class ClientController extends AdminController
// $this->loadLayout('client_onboarding', $data);
}
-
public function typeList($id = null)
{
try {
@@ -547,7 +518,6 @@ class ClientController extends AdminController
}
}
-
public function updateEmpAndPolicyStatus()
{
$return = $this->clientPolicyModel->updateStatus();
@@ -678,7 +648,7 @@ class ClientController extends AdminController
// echo "";
// print_r($data); die;
- $data['placeHolders'] = ['member_name', 'nhance_logo', 'tpa_id', 'ecard_download_link', 'client_logo', 'policy_no', 'member_summary', 'app_link', 'post_enrollment_app_link', 'client_name'];
+ $data['placeHolders'] = ['hr_name', 'member_name', 'nhance_logo', 'tpa_id', 'ecard_download_link', 'client_logo', 'policy_no', 'member_summary', 'app_link', 'post_enrollment_app_link', 'client_name'];
// dd($data['placeHolders']);
@@ -982,7 +952,7 @@ class ClientController extends AdminController
}, $rawList)) : [];
$editData['client_policy']['role'] = get_role_id();
$editData['notification'] = $this->notificationModel->select('template_name,enabled')->where('client_id', $id)->findAll();
- $editData['placeHolders'] = ['member_name', 'member_mobile', 'nhance_logo', 'tpa_id', 'ecard_download_link', 'client_logo', 'policy_no', 'member_summary', 'app_link', 'post_enrollment_app_link', 'client_name'];
+ $editData['placeHolders'] = ['hr_name', 'member_name', 'member_mobile', 'nhance_logo', 'tpa_id', 'ecard_download_link', 'client_logo', 'policy_no', 'member_summary', 'app_link', 'post_enrollment_app_link', 'client_name'];
$editData['api_data'] = $this->clientApi->where("client_id", $id)->where("is_active", 1)->first();
// dd($editData);
@@ -1015,10 +985,9 @@ class ClientController extends AdminController
]
],
'short_name' => [
- 'rules' => 'required|alpha',
+ 'rules' => 'required',
'errors' => [
'required' => 'Client Short Name is required',
- 'alpha' => 'Client Short Name can only contain alphabets.',
]
],
'pan' => [
@@ -1810,7 +1779,7 @@ class ClientController extends AdminController
}
if ($insert) {
- $branchData = $this->clientBranchModel->where('client_id', $sanitized_post_data('client_id'))->findAll();
+ $branchData = $this->clientBranchModel->where('client_id', $sanitized_post_data['client_id'])->findAll();
$branchData['role'] = get_role_id();
return $this->respond([
'status' => true,
@@ -1832,6 +1801,7 @@ class ClientController extends AdminController
$this->myLogger->logme('error', 'Client branch EDIT function called');
$data = $this->request->getPost();
+
$sanitized_post_data = sanitizeInputArrayAdvanced($data);
$id = $sanitized_post_data['branch_id_primarykey'] ?? null;
$client_id = $sanitized_post_data['client_id'] ?? null;
@@ -1839,7 +1809,7 @@ class ClientController extends AdminController
$data['pre_branch_id'] = $pre_branch_id;
- $units = $sanitized_post_data['units'] ?? null;
+ $raw_units = $this->request->getPost('units');
$emp_unit_count = 0;
$rr_unit_count = 0;
@@ -1847,12 +1817,13 @@ class ClientController extends AdminController
$total_count = 0;
$list_of_branch_units = $this->clientBranchModel->find((int)$id);
- $units = json_decode($list_of_branch_units['units']);
+ $units = !empty($list_of_branch_units['units']) ? json_decode($list_of_branch_units['units'], true) : [];
if (!is_array($units) || empty($units)) {
$client_data = $this->clientModel->where('id', $sanitized_post_data['client_id'])->first();
$default_unit = trim(($client_data['short_name'] ?? '') . '-' . ($sanitized_post_data['branch_code'] ?? ''), '-');
$sanitized_post_data['units'] = json_encode([$default_unit]);
+ $units = [$default_unit]; // Update local variable for counting
}
if (!empty($units)) {
@@ -1867,17 +1838,21 @@ class ClientController extends AdminController
$uncommonValues = [];
+
if ($total_count > 0) {
- $units = (string) $sanitized_post_data('units'); // Assuming 'units' is an array
+
+ $post_units_raw = $sanitized_post_data['units'] ?? '[]';
- $list_of_branch_units = $this->clientBranchModel->find((int)$id);
- $branch_units = json_decode($list_of_branch_units['units'], true);
- $units = json_decode($units);
-
- $uncommonValues = array_diff($branch_units, $units);
+ $branch_units = json_decode($list_of_branch_units['units'] ?? '[]', true);
+
+ // Ensure we handle both string-json and array types
+ $incoming_units = is_array($post_units_raw) ? $post_units_raw : json_decode($post_units_raw, true);
+
+ if (is_array($branch_units) && is_array($incoming_units)) {
+ $uncommonValues = array_diff($branch_units, $incoming_units);
+ }
if (count($uncommonValues) > 0) {
-
$branchData = $this->clientBranchModel->where('client_id', $client_id)->findAll();
return $this->respond([
@@ -1889,7 +1864,7 @@ class ClientController extends AdminController
], 200);
}
}
-
+
if (!isset($sanitized_post_data['sez'])) {
$sanitized_post_data['sez'] = 0;
} elseif ($sanitized_post_data['sez']) {
@@ -2036,7 +2011,7 @@ class ClientController extends AdminController
$this->myLogger->logme('error', 'Client policy CREATE function called');
$request_post_data = $this->request->getPost();
- $$sanitized_post_data = sanitizeInputArrayAdvanced($request_post_data);
+ $sanitized_post_data = sanitizeInputArrayAdvanced($request_post_data);
$policy_type_id = $sanitized_post_data['policy_type_id'] ?? null;
$client_branch_id = $sanitized_post_data['client_branch_id'] ?? null;
@@ -2070,10 +2045,12 @@ class ClientController extends AdminController
$sanitized_post_data['earned_premium_date'] = change_date_format($sanitized_post_data['earned_premium_date'] ?? null, 'd-m-Y', 'Y-m-d') ?? null;
$sanitized_post_data['claims_incurred_date'] = change_date_format($sanitized_post_data['claims_incurred_date'] ?? null, 'd-m-Y', 'Y-m-d') ?? null;
- $sanitized_post_dataa['base_policy'] = ($sanitized_post_data['base_policy'] === '' || $sanitized_post_data['base_policy'] == 0) ? null : $sanitized_post_data['base_policy'];
- $sanitized_post_data['policy_status'] = 1;
- $sanitized_post_data['inception_type'] = $sanitized_post_data['inception_type'] ? 2 : 1;
-
+ $sanitized_post_data['base_policy'] = ($sanitized_post_data['base_policy'] === '' || $sanitized_post_data['base_policy'] == 0) ? null : $sanitized_post_data['base_policy'];
+ $sanitized_post_data['policy_status'] = 1;
+ $sanitized_post_data['inception_type'] = (isset($sanitized_post_data['inception_type']) && $sanitized_post_data['inception_type'] !== "")
+ ? $sanitized_post_data['inception_type']
+ : 1;
+
@@ -2081,6 +2058,7 @@ class ClientController extends AdminController
$sanitized_post_data['enrolment_visibility'] = $sanitized_post_data['enrolment_visibility'] ?? null ? 1 : 0;
$sanitized_post_data['is_lgbtq'] = $sanitized_post_data['is_lgbtq'] ?? null ? 1 : 0;
$sanitized_post_data['wellness_vendor_id'] = !empty($sanitized_post_data['wellness_vendor_id']) ? $sanitized_post_data['wellness_vendor_id'] : null;
+ $sanitized_post_data['cd_ac_pk'] = $sanitized_post_data['cd_ac_no'] ?? null;
if ($policy_type_id == 1 || $policy_type_id == 2 || $policy_type_id == 6 || $policy_type_id == 7) {
@@ -2104,7 +2082,7 @@ class ClientController extends AdminController
$sanitized_post_data['policy_start_date'] = change_date_format($sanitized_post_data['policy_start_date'] ?? null, 'd-m-Y', 'Y-m-d');
$sanitized_post_data['policy_end_date'] = change_date_format($sanitized_post_data['policy_end_date'] ?? null, 'd-m-Y', 'Y-m-d');
$sanitized_post_data['policy_no'] = $sanitized_post_data['policy_no'] ?? null;
- if ($sanitized_post_data['inception_type'] == 2) {
+ if (isset($sanitized_post_data['inception_type']) && $sanitized_post_data['inception_type'] == 2) {
$sanitized_post_data['open_date'] = change_date_format($sanitized_post_data['open_date'] ?? null, 'd-m-Y', 'Y-m-d');
$sanitized_post_data['close_date'] = change_date_format($sanitized_post_data['close_date'] ?? null, 'd-m-Y', 'Y-m-d');
// $data['reminder_date'] = change_date_format($this->request->getPost('reminder_date'), 'd-m-Y', 'Y-m-d');
@@ -2119,9 +2097,11 @@ class ClientController extends AdminController
$insert = $this->clientPolicyModel->insert($sanitized_post_data);
if ($insert) {
+ // this function to create a policy transaction entry at the time of client policy create
+ $this->createPolicyTransactionInceptionEntry($insert, $sanitized_post_data);
$clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($sanitized_post_data['client_id']);
$clientPoliceData['role'] = get_role_id();
- return $this->respond(['status' => true, 'code' => 200, 'data' => $clientPoliceData, 'client_id' => $client_id, 'method' => 'CERATE', 'post_data' => $insert_data], 200);
+ return $this->respond(['status' => true, 'code' => 200, 'data' => $clientPoliceData, 'client_id' => $client_id, 'method' => 'CERATE', 'post_data' => $insert], 200);
} else {
return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found'], 200);
}
@@ -2303,6 +2283,29 @@ class ClientController extends AdminController
}
}
+ public function createPolicyTransactionInceptionEntry($client_policy_id, $data)
+ {
+ $data['action_type'] = 'inception';
+ $data['client_policy_id'] = $client_policy_id;
+ $data['entry_from'] = 3;
+ $data['issuer_branch'] = 1;
+ $data['issuer'] = 2;
+ $data['status'] = 'completed';
+ $data['renewal_date'] = $data['policy_end_date'];
+ $data['bro_payable_by'] = 1;
+ $insert = $this->policyTransactionModel->insert($data);
+
+ if($insert){
+
+ $pcsd_data['pt_id'] = $insert;
+ $pcsd_data['insurer_id'] = $data['insurer_id'] ?? null;
+ $pcsd_data['insurer_branch_id'] = $data['insurer_branch_id'] ?? null;
+
+ $this->PTCOShareDetailsModel->insert($pcsd_data);
+ }
+ return $insert;
+ }
+
// Save Rack Rate function
@@ -2836,7 +2839,6 @@ class ClientController extends AdminController
}
}
-
private function updatePTCoShareTableEntry($policy_transaction_data, $old_client_policy_data, $data)
{
$updated_ids = [];
@@ -2882,9 +2884,6 @@ class ClientController extends AdminController
];
}
-
-
-
public function uploadVehicleFile($params = null)
{
$this->myLogger->logme('error', 'uploadVehicleFile function called');
@@ -3604,194 +3603,6 @@ class ClientController extends AdminController
}
}
- // public function enrollmentGMCDisplayValueTransform()
- // {
- // $data = [];
-
- // if ($this->request->getPost("waiverofpreexistingdiseases_display")) {
- // $data['Waiver of Pre-existing Diseases'] = $this->request->getPost("waiverofpreexistingdiseases");
- // }
-
- // if ($this->request->getPost("waiverof1234thyearexclusions_display")) {
- // $data['Waiver of 1, 2, 3 & 4th year Exclusions'] = $this->request->getPost("waiverof1,2,3&4thyearexclusions");
- // }
-
- // if ($this->request->getPost("waiverof30dayswaitingperiod_display")) {
- // $data['Waiver of 30 days waiting period'] = $this->request->getPost("waiverof30dayswaitingperiod");
- // }
-
- // if ($this->request->getPost("suminsuredenhancement_display")) {
- // $data['Sum Insured Enhancement'] = $this->request->getPost("suminsuredenhancement");
- // }
-
- // if ($this->request->getPost("waiver_of_90_days_waiting_period_display")) {
- // $data['Waiver of 90 Days Waiting Period'] = $this->request->getPost("waiver_of_90_days_waiting_period");
- // }
-
- // if ($this->request->getPost("waiver_of_other_waiting_periods_display")) {
- // $data['Waiver of Other Waiting Periods'] = $this->request->getPost("waiver_of_other_waiting_periods");
- // }
-
- // if ($this->request->getPost("maternity_benefit_display")) {
- // $data['Maternity Benefit'] = $this->request->getPost("maternity_benefit");
- // }
-
- // if ($this->request->getPost("9monthwaitingperiodwaived_display")) {
- // $data['9-month waiting Period - waived'] = $this->request->getPost("9monthwaitingperiodwaived");
- // }
-
- // if ($this->request->getPost("maternitycoverage_display")) {
- // $data['Maternity Coverage'] = $this->request->getPost("maternitycoverage");
- // }
-
- // if ($this->request->getPost("twindelivery_display")) {
- // $data['Twin Delivery'] = $this->request->getPost("twindelivery");
- // }
-
- // if ($this->request->getPost("well_baby_well_mother_expenses_display")) {
- // $data['Well baby / Well Mother Expenses'] = $this->request->getPost("well_baby_well_mother_expenses");
- // }
-
- // if ($this->request->getPost("preandpostnatal_display")) {
- // $data['Pre and Post natal'] = $this->request->getPost("preandpostnatal");
- // }
-
- // if ($this->request->getPost("infertility_treatment_coverage_display")) {
- // $data['Infertility Treatment Coverage'] = $this->request->getPost("infertility_treatment_coverage");
- // }
-
- // if ($this->request->getPost("babyday1cover_display")) {
- // $data['Baby Day 1 Cover'] = $this->request->getPost("babyday1cover");
- // }
-
- // if ($this->request->getPost("coverfromthedateofjoining_display")) {
- // $data['Cover from the date of Joining'] = $this->request->getPost("coverfromthedateofjoining");
- // }
-
- // if ($this->request->getPost("mid_term_addition_of_new_born_newly_wedded_spouse_display")) {
- // $data['Mid Term Addition of New Born / Newly Wedded Spouse'] = $this->request->getPost("mid_term_addition_of_new_born_newly_wedded_spouse");
- // }
-
- // if ($this->request->getPost("prehospitalizationcover_display")) {
- // $data['Pre Hospitalization Cover'] = $this->request->getPost("prehospitalizationcover");
- // }
-
- // if ($this->request->getPost("posthospitalizationcover_display")) {
- // $data['Post Hospitalization Cover'] = $this->request->getPost("posthospitalizationcover");
- // }
-
- // if ($this->request->getPost("congenitaldiseasesinternal_display")) {
- // $data['Congenital Diseases - Internal'] = $this->request->getPost("congenitaldiseasesinternal");
- // }
-
- // if ($this->request->getPost("congenitaldiseasesexternal_display")) {
- // $data['Congenital Diseases - External'] = $this->request->getPost("congenitaldiseasesexternal");
- // }
-
- // if ($this->request->getPost("copayzonewisecopay_display")) {
- // $data['Co-Pay/Zone wise Co Pay'] = $this->request->getPost("copayzonewisecopay");
- // }
-
- // if ($this->request->getPost("roomrentlimit_display")) {
- // $data['Room Rent Limit'] = $this->request->getPost("roomrentlimit");
- // }
-
- // if ($this->request->getPost("icu_limit_display")) {
- // $data['ICU Limit'] = $this->request->getPost("icu_limit");
- // }
-
- // if ($this->request->getPost("proportionatedeductionclause_display")) {
- // $data['Proportionate Deduction Clause'] = $this->request->getPost("proportionatedeductionclause");
- // }
-
- // if ($this->request->getPost("ailmentcapping_display")) {
- // $data['Ailment capping'] = $this->request->getPost("ailmentcapping");
- // }
-
- // if ($this->request->getPost("ailment_capping_details_display")) {
- // $data['Ailment capping Details'] = $this->request->getPost("ailment_capping_details");
- // }
-
- // if ($this->request->getPost("corporatebuffer_display")) {
- // $data['Corporate Buffer'] = $this->request->getPost("corporatebuffer");
- // }
-
- // if ($this->request->getPost("non_admissible_contingency_corporate_buffer_display")) {
- // $data['Non-Admissible / Contingency Corporate Buffer'] = $this->request->getPost("non_admissible_contingency_corporate_buffer");
- // }
-
- // if ($this->request->getPost("ambulancecharges_display")) {
- // $data['Ambulance Charges'] = $this->request->getPost("ambulancecharges");
- // }
-
- // if ($this->request->getPost("airambulance_display")) {
- // $data['Air Ambulance'] = $this->request->getPost("airambulance");
- // }
-
- // if ($this->request->getPost("reasonableandcustomarycharges_display")) {
- // $data['Reasonable and Customary Charges'] = $this->request->getPost("reasonableandcustomarycharges");
- // }
-
- // if ($this->request->getPost("daycaretreatment_display")) {
- // $data['Day Care Treatment'] = $this->request->getPost("daycaretreatment");
- // }
-
- // if ($this->request->getPost("lasiksurgery_display")) {
- // $data['Lasik Surgery'] = $this->request->getPost("lasiksurgery");
- // }
-
- // if ($this->request->getPost("ayushtreatmentcover_display")) {
- // $data['AYUSH treatment cover'] = $this->request->getPost("ayudhtreatmentcover");
- // }
-
- // if ($this->request->getPost("moderntreatmentsasperirdai_display")) {
- // $data['Modern treatments as per IRDAI'] = $this->request->getPost("moderntreatmentsasperirdai");
- // }
-
- // if ($this->request->getPost("opd_treatment_display")) {
- // $data['OPD Treatment'] = $this->request->getPost("opd_treatment");
- // }
-
- // if ($this->request->getPost("days_of_discharge_display")) {
- // $data['Claim Intimation Clause'] = $this->request->getPost("days_of_discharge");
- // }
-
- // if ($this->request->getPost("days_from_dod_display")) {
- // $data['Claim Submission'] = $this->request->getPost("days_from_dod");
- // }
-
- // if ($this->request->getPost("terrorism_display")) {
- // $data['Terrorism'] = $this->request->getPost("terrorism");
- // }
-
- // if ($this->request->getPost("widower_cover_display")) {
- // $data['Widower Cover'] = $this->request->getPost("widower_cover");
- // }
-
- // if ($this->request->getPost("breavement_cover_display")) {
- // $data['Breavement Cover'] = $this->request->getPost("breavement_cover");
- // }
-
- // if ($this->request->getPost("special_condition_display_value")) {
-
- // $specialConditionKeyValue = $this->request->getPost("special_condition_display_value") ?? [];
- // $specialConditionKeyValue = json_decode($specialConditionKeyValue, true);
-
- // if (is_array($specialConditionKeyValue) && count($specialConditionKeyValue) > 0) {
- // $mergedArray = array_merge(...array_map(fn($item) => (array) $item, $specialConditionKeyValue));
- // $data = array_merge($data, $mergedArray);
- // }
- // }
-
- // if(isset($data) && !empty($data)){
- // return $data;
- // }else{
- // $data = [];
- // return $data;
- // }
-
- // }
-
public function enrollmentGMCDisplayValueTransform()
{
$data = [];
@@ -3866,7 +3677,6 @@ class ClientController extends AdminController
return $data;
}
-
public function getterms()
{
$client_policy_id = $this->request->getVar('client_policy_id');
@@ -4027,94 +3837,6 @@ class ClientController extends AdminController
}
}
- // public function enrollmentGPADisplayValueTransform()
- // {
- // $data = [];
-
- // if ($this->request->getPost("accidentalDeathBenefit_display")) {
- // $data['Accidental Death Benefit'] = $this->request->getPost("accidentalDeathBenefit");
- // }
- // if ($this->request->getPost("permanentTotalDisablement_display")) {
- // $data['Permanent Total Disablement'] = $this->request->getPost("permanentTotalDisablement");
- // }
- // if ($this->request->getPost("permanentPartialDisablement_display")) {
- // $data['Permanent Partial Disablement'] = $this->request->getPost("permanentPartialDisablement");
- // }
- // if ($this->request->getPost("temporaryTotalDisablementBenefit_display")) {
- // $data['Temporary Total Disablement Benefit'] = $this->request->getPost("temporaryTotalDisablementBenefit");
- // }
- // if ($this->request->getPost("medical_expenses_medical_extension_display")) {
- // $data['Medical Expenses / Medical Extension (IPD)'] = $this->request->getPost("medical_expenses_medical_extension");
- // }
- // if ($this->request->getPost("opd_treatment_cover_display")) {
- // $data['OPD Treatment Cover'] = $this->request->getPost("opd_treatment_cover");
- // }
- // if ($this->request->getPost("ambulanceCharges_display")) {
- // $data['Ambulance Charges'] = $this->request->getPost("ambulanceCharges");
- // }
- // if ($this->request->getPost("repatriation_of_mortal_remains_display")) {
- // $data['Repatriation of Mortal Remains'] = $this->request->getPost("repatriation_of_mortal_remains");
- // }
- // if ($this->request->getPost("childrenEducationWelfareFund_display")) {
- // $data['Children Education Welfare Fund'] = $this->request->getPost("childrenEducationWelfareFund");
- // }
- // if ($this->request->getPost("terrorism_display")) {
- // $data['Terrorism'] = $this->request->getPost("terrorism");
- // }
- // if ($this->request->getPost("worldwideCover_display")) {
- // $data['Worldwide Cover'] = $this->request->getPost("worldwideCover");
- // }
- // if ($this->request->getPost("family_transportation_benefits_display")) {
- // $data['Family Transportation Benefits'] = $this->request->getPost("family_transportation_benefits");
- // }
- // if ($this->request->getPost("fractures_dislocation_burns_display")) {
- // $data['Fractures / Dislocation / Burns'] = $this->request->getPost("fractures_dislocation_burns");
- // }
- // if ($this->request->getPost("coma_display")) {
- // $data['Coma'] = $this->request->getPost("coma");
- // }
- // if ($this->request->getPost("carriageofDeadBody_display")) {
- // $data['Carriage of Dead Body'] = $this->request->getPost("carriageOfDeadBody");
- // }
- // if ($this->request->getPost("compassionateVisitExpenses_display")) {
- // $data['Compassionate Visit Expenses'] = $this->request->getPost("compassionateVisitExpenses");
- // }
- // if ($this->request->getPost("travel_expenses_for_medical_treatment_display")) {
- // $data['Travel expenses for Medical Treatment'] = $this->request->getPost("travel_expenses_for_medical_treatment");
- // }
- // if ($this->request->getPost("daily_cash_allowance_display")) {
- // $data['Daily cash Allowance'] = $this->request->getPost("daily_cash_allowance");
- // }
- // if ($this->request->getPost("artifical_limb_and_prosthesis_display")) {
- // $data['Artifical Limb and Prosthesis'] = $this->request->getPost("artifical_limb_and_prosthesis");
- // }
- // if ($this->request->getPost("animalSnakeInsectBite_display")) {
- // $data['Animal/Snake/Insect Bite'] = $this->request->getPost("animalSnakeInsectBite");
- // }
- // if ($this->request->getPost("air_ambulance_display")) {
- // $data['Air Ambulance'] = $this->request->getPost("air_ambulance");
- // }
-
- // if ($this->request->getPost("gpa_special_condition_display_value")) {
-
- // $specialConditionKeyValue = $this->request->getPost("gpa_special_condition_display_value") ?? [];
- // $specialConditionKeyValue = json_decode($specialConditionKeyValue, true);
-
- // if (is_array($specialConditionKeyValue) && count($specialConditionKeyValue) > 0) {
- // $mergedArray = array_merge(...array_map(fn($item) => (array) $item, $specialConditionKeyValue));
- // $data = array_merge($data, $mergedArray);
- // }
- // }
- // // print_r($data); die;
-
- // if (isset($data) && !empty($data)) {
- // return $data;
- // } else {
- // $data = [];
- // return $data;
- // }
- // }
-
public function enrollmentGPADisplayValueTransform()
{
$data = [];
@@ -5614,32 +5336,25 @@ class ClientController extends AdminController
],
'type' => [
- 'rules' => 'required|is_natural_no_zero',
+ 'rules' => 'required',
'errors' => [
'required' => 'Vehicle type is required'
]
],
'description' => [
- 'rules' => 'required|is_natural_no_zero',
+ 'rules' => 'required',
'errors' => [
'required' => 'Vehicle description is required'
]
],
'owner' => [
- 'rules' => 'required|is_natural_no_zero',
+ 'rules' => 'required',
'errors' => [
'required' => 'Owner is required'
]
],
- 'old_onwer' => [
- 'rules' => 'permit_empty|alpha_space',
- 'errors' => [
- 'alpha_space' => 'Old owner name can contain only letters and spaces'
- ]
- ],
-
];
if (!$this->validate($rules)) {
return $this->response->setStatusCode(400)->setJSON([
@@ -6614,6 +6329,8 @@ class ClientController extends AdminController
public function sendextraparam()
{
+ // $cd = $this->view_Deposit(2, 'rest', ['client_id' => 58, 'cd_ac_pk' => 94]);
+ // dd($cd);
// $return = db_connect()->table('jobs')->where('id', 1677)->get()->getRowArray();
// $return = $this->updatePolicyTransactionDataWhileClinetPolicyUpdate(json_decode($data['payload'], true));
// dd($return);
@@ -6644,8 +6361,8 @@ class ClientController extends AdminController
// $response = $ticketServiceController->tpaClaimDumpImporter(["file_id" => 48]); //vidal
// $response = $ticketServiceController->tpaClaimDumpImporter(["file_id" => 53]); //icici
// $response = $ticketServiceController->tpaClaimDumpImporter(["file_id" => 54]); //mediassist
- // $response = $ticketServiceController->tpaClaimDumpToTicketMasterImporters(["file_id" => 48]);
- // $response = $ticketServiceController->tpaClaimDumpToTicketMasterImporters(["file_id" => 48]);
+ // $response = $ticketServiceController->tpaClaimDumpToTicketMasterImporters(["file_id" => 48]); //vidal
+ // $response = $ticketServiceController->tpaClaimDumpToTicketMasterImporters(["file_id" => 54]); //mediassist
// dd($response);
// ---------- TICKET CONTROLLER --------------------------------------------------------------------------------
@@ -6693,27 +6410,27 @@ class ClientController extends AdminController
// ----------EMP DATA SERVICE CONTROLLER--------------------------------------------------------------------------------
- $batch_data = [
- 'client_id' => 51,
- 'client_branch_id' => 40,
- 'client_policy_id' => 63,
- 'insurer_or_tpa' => "insurer",
- 'event_type' => "correction",
- 'actions' => "export",
- 'file_name' => "deletion_enhancement_test_file.xlsx",
- ];
-
// $batch_data = [
- // 'client_id' => 20,
- // 'client_policy_id' => 77,
- // 'client_branch_id' => 72,
+ // 'client_id' => 51,
+ // 'client_branch_id' => 40,
+ // 'client_policy_id' => 63,
// 'insurer_or_tpa' => "insurer",
- // // 'insurer_or_tpa' => "tpa",
- // 'event_type' => "si_enhancement",
- // 'file_name' => "si_enhancement_test_file.xlsx",
+ // 'event_type' => "correction",
// 'actions' => "export",
+ // 'file_name' => "deletion_enhancement_test_file.xlsx",
// ];
+ $batch_data = [
+ 'client_id' => 12,
+ 'client_policy_id' => 8063,
+ 'client_branch_id' => 1,
+ 'insurer_or_tpa' => "insurer",
+ // 'insurer_or_tpa' => "tpa",
+ 'event_type' => "inception",
+ 'file_name' => "si_enhancement_test_file.xlsx",
+ 'actions' => "export",
+ ];
+
// $batch_data['insurer_or_tpa'] = 'insurer';
// $batch_data['insurer_or_tpa'] = 'tpa';
@@ -6738,7 +6455,7 @@ class ClientController extends AdminController
// $res = $EmpDataServiceController->importInceptionUpdateTPAandUHID(['file_id' => 310]); dd($res);//for live
// $res = $EmpDataServiceController->getInceptionBasePremium(["13332","13333","13334","13335","13336"]); dd($res);//for live
// $res = $EmpDataServiceController->getDeletionBasePremium(["13248","13250","13249","13247"], json_decode('{"employeeIds":["13248","13250","13249","13247"],"client_id":"3927","client_policy_id":"6183","client_branch_id":"1874","cd_ac_no":"CD9751909505","endorsement_no":"END1238","count":4,"event_name":"deletion","policy_name":"GMC","user_id":"48"}', true)); dd($res);//for live
- // $res = $EmpDataServiceController->makeEntryForBDSPolicyTransaction(json_decode('{"client_policy_id":"6187","endorsement_no":null,"emp_count":5,"action_type":"inception","no_of_insured":3,"no_of_dependent":0}', true)); dd($res);//for live
+ // $res = $EmpDataServiceController->makeEntryForBDSPolicyTransaction(json_decode('{"client_policy_id":"6187","endorsement_no":"000000001","emp_count":5,"action_type":"addition","no_of_insured":3,"no_of_dependent":0, "base_premium" : "1000", "gst" : "180", "policy_issue_date" : "2025-12-31"}', true)); dd($res);//for live
// $res = $EmpDataServiceController->sendMailForDownloadingECard(['ids' => $ids, 'client_policy_id' => $client_policy_id]);
// $res = $this->employeePolicyModel->getDeletionEmployeeDataForExportExcel($batch_data, 1); dd($result);
// $res = $this->employeePolicyModel->getSIEnhancementEmployeesDataForExportExcel($batch_data, 1);
@@ -6768,6 +6485,21 @@ class ClientController extends AdminController
// $EmpDataServiceController->cashDepositCalculationForDeletion($array);
// $result = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($batch_data);
+ // $totals = 0;
+ // foreach ($result as $item) {
+ // $totals = $totals + $item->total;
+ // }
+
+ // clear_cd_balance_session();
+
+ // $data = [
+ // 'cd_balance' => session()->get('cd_balance'),
+ // 'hr_data' => session()->get('hr_data'),
+ // 'cd_balance_info' => session()->get('cd_balance_info'),
+ // get_cd_balance()
+ // ];
+
+ // dd($data);
// $result = $this->employeePolicyModel->getCorrectionEmployeesDataForExportExcel($batch_data);
// dd(db_connect()->getLastQuery());
@@ -8997,6 +8729,8 @@ class ClientController extends AdminController
$member_ecard_mail_template = $this->notificationModel->where('client_id', NULL)->where('template_name', 'member_ecard_mail')->get()->getResultArray()[0] ?? [];
$member_common_mail_template = $this->notificationModel->where('client_id', NULL)->where('template_name', 'member_common_mail')->get()->getResultArray()[0] ?? [];
+
+ $hr_cd_insufficient_balance_mail_template = $this->notificationModel->where('client_id', NULL)->where('template_name', 'hr_cd_insufficient_balance_mail')->get()->getResultArray()[0] ?? [];
$default_member_welcome_mail_template = [
'client_id' => $client_id,
@@ -9068,6 +8802,20 @@ class ClientController extends AdminController
'mail_content_copy' => null
];
+ $hr_cd_insufficient_balance_mail_template = [
+ 'client_id' => $client_id,
+ 'template_name' => 'hr_cd_insufficient_balance_mail',
+ 'subject' => $hr_cd_insufficient_balance_mail_template['subject'] ?? '',
+ 'mail_content' => $hr_cd_insufficient_balance_mail_template['mail_content'] ?? '',
+ 'mail_content_json' => $hr_cd_insufficient_balance_mail_template['mail_content_json'] ?? '',
+
+ 'created_by' => get_session_userid(),
+ 'created_at' => date('Y-m-d H:i:s'),
+ 'updated_by' => null,
+ 'updated_at' => date('Y-m-d H:i:s'),
+ 'mail_content_copy' => null
+ ];
+
$this->myLogger->logme('error', 'Default Mail Template Data ' . json_encode([
$default_member_welcome_mail_template,
$default_member_remainder_mail_template,
@@ -9081,7 +8829,8 @@ class ClientController extends AdminController
$default_member_remainder_mail_template,
$default_member_review_and_summary_mail_template,
$default_member_ecard_mail_template,
- $default_member_common_mail_template
+ $default_member_common_mail_template,
+ $hr_cd_insufficient_balance_mail_template,
]);
diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php
index ff86177d..4a4e9faf 100755
--- a/app/Controllers/EmpDataServiceController.php
+++ b/app/Controllers/EmpDataServiceController.php
@@ -33,6 +33,8 @@ use App\Models\LeadsModel;
use App\Models\LeadInstallmentPaymentDetails;
use App\Models\PolicyTransactionModel;
use App\Models\PTCOShareDetailsModel;
+use App\Models\LevelContactModel;
+
use App\Controllers\Jobs;
use App\Controllers\JobWorker;
@@ -71,6 +73,8 @@ class EmpDataServiceController extends BaseController
protected $leadInstallmentPaymentDetailesModel;
protected $policyTransactionModel;
protected $PTCOShareDetailsModel;
+ protected $LevelContactModel;
+
public function __construct()
@@ -99,6 +103,7 @@ class EmpDataServiceController extends BaseController
$this->leadInstallmentPaymentDetailesModel = new LeadInstallmentPaymentDetails();
$this->policyTransactionModel = new PolicyTransactionModel();
$this->PTCOShareDetailsModel = new PTCOShareDetailsModel();
+ $this->LevelContactModel = new LevelContactModel();
}
@@ -199,24 +204,28 @@ class EmpDataServiceController extends BaseController
$totals = $totals + $item->total;
}
- $totals = round($totals, 2);
+ $totals = round($totals);
//check CD amt insufficient only insurer, not tpa // DO NOT REMOVE THIS
if($export_data['insurer_or_tpa'] == 'insurer')
{
- if (!empty($cash_balance)) {
- if ((int) $cash_balance['balance'] < (int) $totals) {
- $this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.');
- $this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount. CASH BALANCE : {balance} and TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]);
- session()->set('cd_balance', false);
- session()->set('cd_amount', $cash_balance['balance']);
- session()->set('excel_file_amt', $totals);
- }else{
- session()->set('cd_balance', true);
- session()->set('cd_amount', $cash_balance['balance']);
- session()->set('excel_file_amt', $totals);
-
- }
+ if ((int) $cash_balance['balance'] < (int) $totals) {
+ clear_cd_balance_session(); // Clear old junk first
+
+ $cd_session_data = json_encode([
+ 'cd_balance' => false,
+ 'cd_amount' => $cash_balance['balance'],
+ 'excel_file_amt' => $totals
+ ]);
+
+ session()->set('cd_balance_info', $cd_session_data);
+ session()->set('cd_balance', 'insufficient'); // Use a string status for clarity
+
+ $hr_data = $this->getHrdataForInsufficientMailSend($export_data['client_branch_id']);
+ session()->set('hr_data', json_encode(['client_id' => $export_data['client_id'], 'hr_data' => $hr_data]));
+ }else{
+ session()->set('cd_balance', 'sufficient'); // Use a string status for clarity
+ session()->set('cd_balance_info', null);
}
}
@@ -725,17 +734,23 @@ class EmpDataServiceController extends BaseController
if($export_data['insurer_or_tpa'] == 'insurer')
{
if (!empty($cash_balance)) {
- if ((int) $cash_balance['balance'] < (int) $rounded_totals) {
- $this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.');
- $this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount. CASH BALANCE : {balance} and TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]);
- session()->set('cd_balance', false);
- session()->set('cd_amount', $cash_balance['balance']);
- session()->set('excel_file_amt', $rounded_totals);
+ if ((int) $cash_balance['balance'] < (int) $totals) {
+ clear_cd_balance_session(); // Clear old junk first
+
+ $cd_session_data = json_encode([
+ 'cd_balance' => false,
+ 'cd_amount' => $cash_balance['balance'],
+ 'excel_file_amt' => $totals
+ ]);
+
+ session()->set('cd_balance_info', $cd_session_data);
+ session()->set('cd_balance', 'insufficient'); // Use a string status for clarity
+
+ $hr_data = $this->getHrdataForInsufficientMailSend($export_data['client_branch_id']);
+ session()->set('hr_data', json_encode(['client_id' => $export_data['client_id'], 'hr_data' => $hr_data]));
}else{
- session()->set('cd_balance', true);
- session()->set('cd_amount', $cash_balance['balance']);
- session()->set('excel_file_amt', $rounded_totals);
-
+ session()->set('cd_balance', 'sufficient'); // Use a string status for clarity
+ session()->set('cd_balance_info', null);
}
}
}
@@ -1056,17 +1071,23 @@ class EmpDataServiceController extends BaseController
if($export_data['insurer_or_tpa'] != 'tpa')// check overal emp premium amt with cd balance only for insurer export, not tpa export
{
if (!empty($cash_balance)) {
- if ((int) $cash_balance['balance'] < (int) $totals) {
- $this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.');
- $this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount. CASH BALANCE : {balance} and TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]);
- session()->set('cd_balance', false);
- session()->set('cd_amount', $cash_balance['balance']);
- session()->set('excel_file_amt', $totals);
+ if ((int) $cash_balance['balance'] < (int) $totals) {
+ clear_cd_balance_session(); // Clear old junk first
+
+ $cd_session_data = json_encode([
+ 'cd_balance' => false,
+ 'cd_amount' => $cash_balance['balance'],
+ 'excel_file_amt' => $totals
+ ]);
+
+ session()->set('cd_balance_info', $cd_session_data);
+ session()->set('cd_balance', 'insufficient'); // Use a string status for clarity
+
+ $hr_data = $this->getHrdataForInsufficientMailSend($export_data['client_branch_id']);
+ session()->set('hr_data', json_encode(['client_id' => $export_data['client_id'], 'hr_data' => $hr_data]));
}else{
- session()->set('cd_balance', true);
- session()->set('cd_amount', $cash_balance['balance']);
- session()->set('excel_file_amt', $totals);
-
+ session()->set('cd_balance', 'sufficient'); // Use a string status for clarity
+ session()->set('cd_balance_info', null);
}
}
}
@@ -2185,6 +2206,7 @@ class EmpDataServiceController extends BaseController
'event_name' => $file['event_type'],
'policy_name' => $policy_name['policy_name'],
'user_id' => $user_id,
+ 'file_id' => $file_id,
]]);
$r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [
@@ -2208,7 +2230,7 @@ class EmpDataServiceController extends BaseController
//send ecard mail if the event is tpa only
if ($file['insurer_or_tpa'] == 'tpa') {
- if ($get_policy_type['policy_type_id'] != 1) {
+ if (in_array($get_policy_type['policy_type_id'], [2, 3])) {
// generate e-card and store S3
$r = Jobs::addJob(['job_name' => 'bulkGenerateEcardAndStoreinS3', 'payload' => ['client_policy_id' => $client_policy_id]]);
@@ -2624,7 +2646,7 @@ class EmpDataServiceController extends BaseController
'status' => $status_val,
]);
- if($client_policy_data['policy_type_id'] != 1){
+ if(in_array($client_policy_data['policy_type_id'], [2, 3])){
// re-generate e-card and store S3
$r = Jobs::addJob(['job_name' => 'bulkGenerateEcardAndStoreinS3', 'payload' => ['client_policy_id' => $client_policy_id]]);
}
@@ -3368,6 +3390,7 @@ class EmpDataServiceController extends BaseController
'event_name' => $file['event_type'],
'policy_name' => $policy_name['policy_name'],
'user_id' => $user_id,
+ 'file_id' => $file_id,
]]);
$r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [
@@ -3879,6 +3902,7 @@ class EmpDataServiceController extends BaseController
'event_name' => $file['event_type'],
'policy_name' => $policy_name['policy_name'],
'user_id' => $user_id,
+ 'file_id' => $file_id,
]]);
$r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [
@@ -4363,7 +4387,8 @@ class EmpDataServiceController extends BaseController
'updated_by' => $arrayData['user_id'],
'event_name' => $arrayData['event_name'],
'is_active' => 1,
- 'cd_ac_pk' => $cd_ac_pk['cd_ac_pk']
+ 'cd_ac_pk' => $cd_ac_pk['cd_ac_pk'],
+ 'file_id' => $arrayData['file_id'],
];
$response = DepositHelper::saveDeposit($data, $arrayData['user_id']);
@@ -4500,7 +4525,8 @@ class EmpDataServiceController extends BaseController
'updated_by' => $arrayData['user_id'],
'event_name' => $arrayData['event_name'],
'is_active' => 1,
- 'cd_ac_pk' => $policy_data['cd_ac_pk']
+ 'cd_ac_pk' => $policy_data['cd_ac_pk'],
+ 'file_id' => $arrayData['file_id'],
];
DepositHelper::saveDeposit($data, $arrayData['user_id']);
@@ -4530,7 +4556,8 @@ class EmpDataServiceController extends BaseController
'updated_by' => $arrayData['user_id'],
'event_name' => $arrayData['event_name'],
'is_active' => 1,
- 'cd_ac_pk' => $policy_data['cd_ac_pk']
+ 'cd_ac_pk' => $policy_data['cd_ac_pk'],
+ 'file_id' => $arrayData['file_id'],
];
DepositHelper::saveDeposit($data, $arrayData['user_id']);
@@ -4642,7 +4669,8 @@ class EmpDataServiceController extends BaseController
'updated_by' => $arrayData['user_id'],
'event_name' => $arrayData['event_name'],
'is_active' => 1,
- 'cd_ac_pk' => $insurer_id['cd_ac_pk']
+ 'cd_ac_pk' => $insurer_id['cd_ac_pk'],
+ 'file_id' => $arrayData['file_id'],
];
$response = DepositHelper::saveDeposit($data, $arrayData['user_id']);
@@ -5408,7 +5436,7 @@ class EmpDataServiceController extends BaseController
$this->myLogger->logme("error", "Policy transaction inserted successfully: " . json_encode(['insert_id' => $insert_id]));
//do not remove this commented item
- $coShareDetails = $this->ConstructPTShareData($policy_data, $insert_id, $params, $lead_data);
+ $coShareDetails = $this->ConstructPTShareData($policy_data, $insert_id, $params, $lead_data, $params['action_type']);
$pt_co_share_id = $this->PTCOShareDetailsModel->insert($coShareDetails);
$this->myLogger->logme("error", "PT Co share data inserted successfully: " . json_encode(['pt_co_share_id' => $pt_co_share_id]));
@@ -5540,7 +5568,46 @@ class EmpDataServiceController extends BaseController
return $policyTransactionData;
}
- private function ConstructPTShareData($policy_data, $pt_id, $params, $lead_data)
+ private function ConstructPTShareData($policy_data, $pt_id, $params, $lead_data, $action_type)
+ {
+ $policyTypeModel = new PolicyTypeModel();
+ $policy_type_data = $policyTypeModel->where('is_active', 1)->where('id', $policy_data['policy_type_id'])->first();
+
+ // Determine if we should negate the values
+ $multiplier = (strtolower($action_type) === 'deletion') ? -1 : 1;
+
+ $coShareData = [
+ 'pt_id' => $pt_id,
+ 'insurer_id' => $policy_data['insurer_id'],
+ 'insurer_branch_id' => $policy_data['insurer_branch_id'],
+ 'bp_amt' => ($params['base_premium'] ?? 0) * $multiplier,
+ 'cop_amt' => ($params['base_premium'] ?? 0) * $multiplier,
+ 'bp_gst_amt' => ($params['gst'] ?? 0) * $multiplier,
+ 'bp_sgst' => 9, // Usually tax percentages remain positive, but multiply if this is an amount
+ 'bp_cgst' => 9,
+ 'co_share_type' => 1,
+ 'co_share_per' => 100,
+ 'standerd_bp_per' => $policy_type_data['ebp'],
+ 'pt_policy_issue_date' => $params['policy_issue_date'] ?? null,
+ 'amount' => (($params['base_premium'] ?? 0) + ($params['gst'] ?? 0)) * $multiplier,
+ ];
+
+ if(isset($policy_data['gst']) && $policy_data['gst'] != null){
+ $coShareData['bp_igst'] = $policy_data['gst'] ?? 0;
+ $coShareData['bp_sgst'] = 0;
+ $coShareData['bp_cgst'] = 0;
+ }
+
+ // Calculate exp_amt logic
+ $agreed_per = $lead_data['agreed_percentage'] ?? $policy_type_data['ebp'] ?? 0;
+ $coShareData['exp_amt'] = ((($params['base_premium'] ?? 0) * $agreed_per) / 100) * $multiplier;
+
+ $this->myLogger->logme("error", "Constructed PT co-share data: " . json_encode($coShareData));
+
+ return $coShareData;
+ }
+
+ private function ConstructPTShareDataOld($policy_data, $pt_id, $params, $lead_data, $action_type = null)
{
$policyTypeModel = new PolicyTypeModel();
$policy_type_data = $policyTypeModel->where('is_active', 1)->where('id', $policy_data['policy_type_id'])->first();
@@ -5858,4 +5925,16 @@ class EmpDataServiceController extends BaseController
'gst' => round($amount['gst'] ?? 0, 2)
];
}
+
+ public function getHrdataForInsufficientMailSend($ref_id)
+ {
+ $data = $this->LevelContactModel
+ ->select('id, name, email')
+ ->where('ref_id', $ref_id)
+ ->where('is_active', 1)
+ ->where('contact_type', 'client')
+ ->findAll();
+
+ return $data;
+ }
}
diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php
index 6f3ab21d..8baab690 100755
--- a/app/Controllers/EmployeeController.php
+++ b/app/Controllers/EmployeeController.php
@@ -8,6 +8,7 @@ use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use App\Helpers\DepositHelper;
+use App\Helpers\MailHelper;
use App\Models\EmployeeModel;
@@ -29,6 +30,8 @@ use App\Models\AuditHistoryModel;
use App\Models\UserModel;
use App\Models\PartnerEndorsementRequestModel;
use App\Models\TpaApiDataModel;
+use App\Models\LevelContactModel;
+use App\Models\NotificationModel;
use App\Controllers\Jobs;
@@ -74,6 +77,7 @@ class EmployeeController extends AdminController
protected $auditHistory;
protected $userModel;
protected $partnerEndorsementRequestModel;
+ protected $LevelContactModel;
public function __construct()
{
@@ -97,6 +101,7 @@ class EmployeeController extends AdminController
$this->auditHistory = new AuditHistoryModel();
$this->userModel = new userModel();
$this->partnerEndorsementRequestModel = new PartnerEndorsementRequestModel();
+ $this->LevelContactModel = new LevelContactModel();
}
public function list()
@@ -331,7 +336,7 @@ class EmployeeController extends AdminController
//endof validation process
if (isset($result['error_summary']) && count($result['error_summary'])) {
if(!empty($post_data)){
- return ['status' => true, 'message' => 'file rejected with errors', 'file_id' => $file_id];
+ return ['status' => false, 'message' => 'file rejected with errors', 'file_id' => $file_id];
}else{
return $this->respond(['dataStatus' => false, 'code' => 404, 'message' => 'file rejected with errors'], 200);
}
@@ -441,6 +446,7 @@ class EmployeeController extends AdminController
batch_files.amount,
batch_files.status,
batch_files.client_branch_id,
+ DATE_FORMAT(batch_files.policy_issue_date, '%d/%m/%Y') AS policy_issue_date,
CASE
WHEN batch_files.status IN ('partially success', 'in-progress-partially', 'failed-7')
@@ -479,7 +485,17 @@ class EmployeeController extends AdminController
}
public function getExcelFileErrors($file_id, $retun_type = null)
- {
+ {
+
+ $file_data = $this->fileModel->where('id', $file_id)->first();
+ $error = json_decode($file_data['reason'] ?? '{}', true);
+ if(!empty($error) && $retun_type == 'api'){
+ $send = isset($error['error_summary'][5]) || isset($error['error_summary'][6]) ? true : false;
+ if($send){
+ return $this->respond(['status' => false, 'code' => 404, 'message' => $error['error_data'] ?? 'System error', 'data' => []], 200);
+ }
+ }
+
// $file_id = $this->request->uri->getSegment(3);
$empServiceController = new EmployeeServiceController();
@@ -4473,9 +4489,9 @@ class EmployeeController extends AdminController
public function visitOffBoard(array $params)
{
// 1. Load credentials from .env
- $apiUrl = env('WELLNESS_ONBOARD_ENDPOINT_URL');
+ $apiUrl = env('WELLNESS_ONBOARD_ENDPOINT_URL').'delete-policy-with-dependents';
$apiToken = env('WELLNESS_ONBOARD_AUTHORIZATION');
-
+ // echo $apiUrl;die();
// 2. Initialize the CI4 CURL service
$client = \Config\Services::curlrequest([
'base_uri' => $apiUrl,
@@ -4528,7 +4544,7 @@ class EmployeeController extends AdminController
'details' => $result
];
- } catch (Exception $e) {
+ } catch (\Exception $e) {
// 5. Catch network or system exceptions
$this->myLogger->logme('error', 'VISIT_OFFBOARD API Exception: ' . $e->getMessage());
return [
@@ -4539,6 +4555,69 @@ class EmployeeController extends AdminController
}
}
+ public function insufficientCdBalanceHrMailSend()
+ {
+ $post_data = $this->request->getJson(true);
+
+ if(empty($post_data) || (!isset($post_data['mails']) && !empty($post_data['mails'])) || (!isset($post_data['client_id']) && !empty($post_data['client_id']))){
+ return $this->respond(['status' => false, 'code' => 404, 'message' => 'No data send mail'], 200);
+ }
+
+ $client_data = $this->clientModel->where('is_active', 1)->where('id', $post_data['client_id'])->first();
+
+ if(empty($client_data)){
+ return $this->respond(['status' => false, 'code' => 404, 'message' => 'No client found'], 200);
+ }
+
+ $notificationModal = new NotificationModel();
+ $notification_data = $notificationModal
+ ->where('client_id', $post_data['client_id'])
+ ->where('template_name', 'hr_cd_insufficient_balance_mail')
+ ->first();
+
+ if(empty($notification_data)){
+ return $this->respond(['status' => false, 'code' => 404, 'message' => 'No template found'], 200);
+ }
+
+ if(empty($notification_data['subject']) || empty($notification_data['mail_content'])){
+ return $this->respond(['status' => false, 'code' => 404, 'message' => 'Template subject or mail content is empty'], 200);
+ }
+
+ if(empty($notification_data['enabled']) || $notification_data['enabled'] != 1){
+ return $this->respond(['status' => false, 'code' => 404, 'message' => 'Template is disabled'], 200);
+
+ }
+
+ $common['mail_type'] = "hr_cd_insufficient_balance_mail";
+ $common['client_id'] = $post_data['client_id'];
+ $subject = $notification_data['subject'];
+ $mail_content = $notification_data['mail_content'];
+
+ foreach ($post_data['mails'] as $hr_id => $hr_data) {
+
+ $mail_content = str_ireplace('{{hr_name}}', $hr_data['name'], $mail_content);
+ $mail_content = str_ireplace('{{client_name}}', $client_data['client_name'], $mail_content);
+ $res = MailHelper::send_email(['mail' => $hr_data['mail'], 'subject' => $subject, 'message' => $mail_content, 'common' => $common]);
+ }
+
+ return $this->respond(['status' => true, 'code' => 200, 'message' => 'Mail send successfully'], 200);
+
+ }
+
+ public function clearCdSession()
+ {
+ clear_cd_balance_session();
+ return $this->response->setJSON(['status' => 'cleared']);
+ }
+
+ public function checkSessionStatus()
+ {
+ // Uses your existing get_cd_balance() helper
+ $data = get_cd_balance();
+
+ // Return as JSON so JavaScript can read it
+ return $this->response->setJSON($data);
+ }
}
diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php
index fa58834a..46a82f2e 100755
--- a/app/Controllers/EmployeeRestController.php
+++ b/app/Controllers/EmployeeRestController.php
@@ -40,6 +40,9 @@ use App\Models\HRAccessControlModel;
use App\Models\InsurerModel;
use App\Models\HrFileUploadModel;
use App\Models\EmployeeRetailPolicy;
+use App\Models\BatchFileModel;
+use App\Models\ClientDepositModel;
+use App\Models\PTFileModel;
@@ -100,6 +103,7 @@ class EmployeeRestController extends AdminController
protected $hrFileUploadModel;
protected $ticketMailTemplateModel;
protected $employeeRetailPolicy;
+ protected $batchFileModel;
public function __construct()
@@ -134,6 +138,7 @@ class EmployeeRestController extends AdminController
$this->insurerModel = new InsurerModel();
$this->hrFileUploadModel = new HrFileUploadModel();
$this->ticketMailTemplateModel = new TicketMailTemplateModel();
+ $this->batchFileModel = new BatchFileModel();
}
@@ -2305,8 +2310,35 @@ class EmployeeRestController extends AdminController
}
+ if($this->request->getGet('policy_status') == 0){
+ $emp_policy_status = 'expired';
+ }else{
+ $emp_policy_status = 'active';
+ }
- $ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, client_policy.policy_type_id as policy_type_id, client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type, client_policy.policy_no as policy_no, client_policy.insurer_id as insurer_id, DATE_FORMAT(client_policy.policy_end_date, "%d-%m-%Y") AS policy_expiry_date ')
+ $db = \Config\Database::connect();
+ $emp_policy_status = $db->escape($emp_policy_status);
+
+ $ClientPolicyData = $this->clientPolicyModel
+ ->select("
+ client_policy.id as client_policy_id ,
+ client_policy.client_id as client_id,
+ client_policy.policy_type_id as policy_type_id,
+ client_policy.is_addon as is_addon ,
+ client_policy.open_for_enrollment as OpenForEnrollment ,
+ client_policy.inception_type as inception_type,
+ client_policy.policy_no as policy_no,
+ client_policy.insurer_id as insurer_id,
+ DATE_FORMAT(client_policy.policy_start_date, '%d-%m-%Y') AS policy_start_date,
+ DATE_FORMAT(client_policy.policy_end_date, '%d-%m-%Y') AS policy_expiry_date,
+ (
+ select COALESCE(ROUND(SUM(rata_premimum + gst)), 0)
+ from employee_polices
+ where is_active = 1
+ and status = $emp_policy_status
+ and client_policy_id = client_policy.id
+ ) as total_premium
+ ", false)
->where('md5(client_policy.client_id)', $this->request->getGet('client_id'))
->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id'))
->where('client_policy.is_active', 1)
@@ -2342,6 +2374,7 @@ class EmployeeRestController extends AdminController
$value['totalMembersCount'] = count($employeeDetails);
$value['membersCountOfActive'] = $activeCount;
$value['membersCountOfInactive'] = $inactiveCount;
+ $value['is_ecard_bulk_download'] = 0;
array_push($result, $value);
@@ -2443,7 +2476,13 @@ class EmployeeRestController extends AdminController
if ($this->request->is('get')) {
- $data['claim_status'] = $this->claimStatusModel->select('id,ticket_type,claim_status')->where('is_active', 1)->findAll();
+ $data['claim_status'] = $this->claimStatusModel
+ ->select('id,ticket_type, display_name as claim_status')
+ ->where('is_active', 1)
+ ->where('display_name IS NOT NULL OR display_name <> ""')
+ ->groupBy('display_name')
+ ->findAll();
+
$data['ticket_type'] = [
["ticket_type" => "1", "type_name" => "Claim-GMC"],
["ticket_type" => "2", "type_name" => "Claim-GPA"],
@@ -2460,10 +2499,12 @@ class EmployeeRestController extends AdminController
$client_id = isset($search_data['client_id']) ? (int) $search_data['client_id'] : 0;
unset($search_data['client_id']);
+ unset($search_data['client_branch_id']);
$from_date = isset($search_data['from_date']) ? $search_data['from_date'] : null;
$to_date = isset($search_data['to_date']) ? $search_data['to_date'] : null;
- unset($search_data['from_date'], $search_data['to_date']);
+ $claim_status_id = isset($search_data['claim_status_id']) ? $search_data['claim_status_id'] : null;
+ unset($search_data['from_date'], $search_data['to_date'], $search_data['claim_status_id']);
$where = [];
@@ -2474,6 +2515,11 @@ class EmployeeRestController extends AdminController
}
}
+ $claim_status_ids = [];
+ if(!empty($claim_status_id)){
+ $claim_status_ids = $this->getTicketClaimStatusIdBasedOnTheDisplayName($claim_status_id);
+ }
+
$builder = $db->table('ticket_master tm');
$builder->select([
'tm.id',
@@ -2485,6 +2531,12 @@ class EmployeeRestController extends AdminController
ELSE UPPER(tcs.display_name)
END AS status
",
+ "CASE
+ WHEN tm.tpa_claim_type IS NOT NULL OR tm.tpa_claim_type != ''
+ THEN tm.tpa_claim_type
+ ELSE 'Reimbursement'
+ END AS cl_type
+ ",
'tm.claim_number AS claim_no',
'tm.claim_status_id',
'tm.is_head_approved',
@@ -2568,6 +2620,10 @@ class EmployeeRestController extends AdminController
$builder->where($where);
}
+ if (!empty($claim_status_ids)) {
+ $builder->whereIn('claim_status_id', $claim_status_ids);
+ }
+
$builder->orderBy('tm.id', 'DESC');
$data = $builder->get()->getResultArray();
@@ -3572,6 +3628,12 @@ class EmployeeRestController extends AdminController
$get_docs_name = $this->request->getPost('claim_doc_names') ?? [];
$policy_transaction_id = $this->request->getPost('policy_transaction_id') ?? null;
+
+ if (is_string($received_data['client_id']) && preg_match('/^[a-f0-9]{32}$/i', $received_data['client_id'])) {
+ $client_data = $this->clientModel->where('MD5(id)', $received_data['client_id'])->first();
+ $received_data['client_id'] = $client_data['id'] ?? null;
+ }
+
$client_policy_data = $this->clientPolicyModel->where('id', $received_data['client_policy_id'] ?? null)->first();
$isduplicate = checkDuplicateClaim([
@@ -4471,6 +4533,7 @@ class EmployeeRestController extends AdminController
// Handle raw client_id vs MD5
if (is_string($post_data['client_id']) && preg_match('/^[a-f0-9]{32}$/i', $post_data['client_id'])) {
$client_data = $this->clientModel->where('MD5(id)', $post_data['client_id'])->first();
+ $post_data['client_id'] = $client_data['id'];
} else {
$client_data = $this->clientModel->where('id', $post_data['client_id'])->first();
}
@@ -4479,10 +4542,6 @@ class EmployeeRestController extends AdminController
return $this->respondCreated(['status' => false, 'message' => 'Invalid Client Id', 'data' => []]);
}
- $post_data['client_id'] = $client_data['id'];
-
-
-
// print_r($client_data); die;
if($client_data['hr_file_processed_by'] == 1){
@@ -4528,15 +4587,15 @@ class EmployeeRestController extends AdminController
// Prepare data
$data = [
- 'client_id' => $this->request->getPost('client_id'),
- 'client_branch_id' => $this->request->getPost('client_branch_id'),
- 'policy_id' => $this->request->getPost('policy_id'),
- 'policy_no' => $this->request->getPost('policy_no'),
+ 'client_id' => $post_data['client_id'],
+ 'client_branch_id' => $post_data['client_branch_id'],
+ 'policy_id' => $post_data['policy_id'],
+ 'policy_no' => $post_data['policy_no'],
'file_name' => $newFileName,
- 'file_action' => $this->request->getPost('file_action'),
+ 'file_action' => $post_data['file_action'],
'status' => 'Yet to start',
- 'created_by' => $this->request->getPost('created_by'),
- 'updated_by' => $this->request->getPost('created_by'),
+ 'created_by' => $post_data['created_by'],
+ 'updated_by' => $post_data['created_by'],
];
// Save into DB
@@ -4559,14 +4618,16 @@ class EmployeeRestController extends AdminController
$responce = $employeeController->employeesUplodWithEvents($post_data);
// print_r($responce); die;
- if($responce['status']){
- $file_data = $this->getDataFromHrFilesTable(['file_id' => $responce['file_id']]);
- $responce['data'] = $file_data;
- return $responce;
- }else{
- $responce['data'] = [];
- return $responce;
- }
+ return $responce;
+
+ // if(isset($responce['file_id'])){
+ // $file_data = $this->getDataFromHrFilesTable(['hr_id' => $responce['created_by']]);
+ // $responce['data'] = $file_data;
+ // return $responce;
+ // }else{
+ // $responce['data'] = [];
+ // return $responce;
+ // }
}
private function giveNotificationToClientsAccountManager($data)
@@ -4733,13 +4794,14 @@ class EmployeeRestController extends AdminController
$data = $this->getDataFromHrFileUploadTable($search_data);
$table = "hr_file_upload";
}else{
- $client_data = $this->clientModel->where('id', $search_data['client_id'])->first();
+ $client_data = $this->clientModel->where('MD5(id)', $search_data['client_id'])->first();
if($client_data['hr_file_processed_by'] == 1){
- $data = $this->getDataFromHrFileUploadTable($search_data);
- $table = "hr_file_upload 2";
- }else{
$data = $this->getDataFromHrFilesTable($search_data);
$table = "files";
+ }else{
+ $data = $this->getDataFromHrFileUploadTable($search_data);
+ $table = "hr_file_upload 2";
+
}
}
@@ -4750,8 +4812,20 @@ class EmployeeRestController extends AdminController
'table' => $table
]);
- } catch (\Exception $e) {
- return $this->failServerError($e->getMessage());
+ } catch (\Exception $th) {
+
+ $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->failServerError($th->getMessage());
}
}
@@ -4785,7 +4859,7 @@ class EmployeeRestController extends AdminController
THEN hr_file_upload.status
ELSE CONCAT(UCASE(LEFT(f.status, 1)), LCASE(SUBSTRING(f.status, 2)))
END AS status,
- '1' as file_error_status
+ '0' as file_error_status
", false)
->join('clients c', 'c.id = hr_file_upload.client_id AND c.is_active = 1', 'left')
->join('client_branch cb', 'cb.id = hr_file_upload.client_branch_id AND cb.is_active = 1', 'left')
@@ -4820,6 +4894,7 @@ class EmployeeRestController extends AdminController
}
// Execute query
+ $builder->orderBy('hr_file_upload.id', 'DESC');
$data = $builder->get()->getResultArray();
if(!empty($data)){
@@ -4840,7 +4915,7 @@ class EmployeeRestController extends AdminController
files.policy_id,
cp.policy_no,
files.file_name,
- files.action,
+ files.action as file_action,
files.created_at,
files.created_by,
files.updated_at,
@@ -4874,7 +4949,11 @@ class EmployeeRestController extends AdminController
}
if (isset($search_data['client_id']) && !empty($search_data['client_id'])) {
- $builder->where("files.client_id", $search_data['client_id']);
+ if (is_string($search_data['client_id']) && preg_match('/^[a-f0-9]{32}$/i', $search_data['client_id'])) {
+ $builder->where("MD5(files.client_id)", $search_data['client_id']);
+ } else {
+ $builder->where("files.client_id", $search_data['client_id']);
+ }
}
if (isset($search_data['file_id']) && !empty($search_data['file_id'])) {
@@ -4883,6 +4962,7 @@ class EmployeeRestController extends AdminController
// Execute query
+ $builder->orderBy('files.id', 'DESC');
$data = $builder->get()->getResultArray();
if (!empty($data)) {
@@ -5305,6 +5385,150 @@ class EmployeeRestController extends AdminController
return $this->respond(['status' => false, 'code' => 400, 'message' => 'Failed to upload the file'], 200);
}
}
-
+
+ public function getTicketClaimStatusIdBasedOnTheDisplayName($claim_status_id)
+ {
+ $claim_status_data_display_name = $this->claimStatusModel->where('is_active', 1)->where('id', $claim_status_id)->first();
+ $claim_status_data_id = $this->claimStatusModel
+ ->select('id')
+ ->where('is_active', 1)
+ ->where('display_name', $claim_status_data_display_name['display_name'])
+ ->findAll();
+
+ $claim_status_data_id = array_column($claim_status_data_id, 'id');
+ return $claim_status_data_id;
+ }
+
+ public function downloadCdSplitUpFile()
+ {
+ try {
+
+ $file_id = $this->request->getGet('id');
+
+ // Find record
+ $record = $this->batchFileModel->where('id', $file_id)->first();;
+ if (!$record) {
+ $data['message'] = 'File record not found';
+ return view('errors/404', $data);
+ }
+
+ $uploadPath = WRITEPATH . 'uploads/import_excel/';
+ $filePath = $uploadPath . $record['file_name'];
+
+ if (!file_exists($filePath)) {
+ // return $this->failNotFound("File not found on server");
+ $data['message'] = 'The Physical File Not Found';
+ return view('errors/404', $data);
+ }
+
+ // Force file download
+ return $this->response->download($filePath, null)->setFileName($record['file_name']);
+ } catch (\Exception $e) {
+ $data['message'] = 'File record not found';
+ return view('errors/404', $data);
+ }
+ }
+
+ // get policy files
+ public function getPolicyAndEndorsementFiles()
+ {
+ $cd_ac_pk = $this->request->getGet('cd_ac_pk') ?? null;
+
+ $cdModel = new ClientDepositModel();
+ $cd_data = $cdModel->where('id', $cd_ac_pk)
+ ->where('is_active', 1)
+ ->where('client_policy_id IS NOT NULL')
+ ->first();
+
+ if(empty($cd_data)){
+ $this->myLogger->logme('error', 'getPolicyAndEndorsementFiles: No Client Deposit data found for cd_ac_pk=' . $cd_ac_pk);
+ return $this->respond(['status' => false, 'code' => 404, 'message' => 'No file found', 'data' => []], 200);
+ }
+
+ $client_policy_data = $this->clientPolicyModel
+ ->where('id', $cd_data['client_policy_id'])
+ ->where('is_active', 1)
+ ->first();
+
+ if(empty($client_policy_data)){
+ $this->myLogger->logme('error', 'getPolicyAndEndorsementFiles: No Client Policy data found for client_policy_id=' . $cd_data['client_policy_id']);
+ return $this->respond(['status' => false, 'code' => 404, 'message' => 'No file found', 'data' => []], 200);
+ }
+
+ $policyTransactionModel = new PolicyTransactionModel();
+ $policy_transaction_data = $policyTransactionModel->where('is_active', 1)->where('policy_no', $client_policy_data['policy_no'])->findAll();
+
+ if(empty($policy_transaction_data)){
+ $this->myLogger->logme('error', 'getPolicyAndEndorsementFiles: No Policy Transaction data found for policy_no=' . $client_policy_data['policy_no']);
+ return $this->respond(['status' => false, 'code' => 404, 'message' => 'No file found', 'data' => []], 200);
+ }
+
+ $policy_transaction_ids = array_column($policy_transaction_data, 'id');
+
+
+ $ptFilesModel = new PTFileModel();
+ $pt_files_data = $ptFilesModel->where('is_active', 1)->whereIn('pt_id', $policy_transaction_ids)->findAll();
+
+ if(empty($pt_files_data)){
+ $this->myLogger->logme('error', 'getPolicyAndEndorsementFiles: No PT Files data found for pt_ids=' . implode(',', $policy_transaction_ids));
+ return $this->respond(['status' => false, 'code' => 404, 'message' => 'No file found', 'data' => []], 200);
+ }
+
+
+ return $this->respond(['status' => true, 'code' => 200, 'message' => 'Files found', 'data' => $pt_files_data], 200);
+
+ }
+
+ // download policy file
+ public function downloadPolicyFiles()
+ {
+ $pt_file_id = $this->request->getGet('file_id') ?? null;
+
+ if(empty($pt_file_id)){
+ return $this->respond(['status' => false, 'code' => 404, 'message' => 'File ID is required'], 200);
+ }
+
+ $uploadFilePath = WRITEPATH . 'uploads/client_kyc_documents';
+
+ $ptFilesModel = new PTFileModel();
+ $pt_files_data = $ptFilesModel->where('is_active', 1)->where('id', $pt_file_id)->first();
+
+ if(empty($pt_files_data)){
+ return $this->respond(['status' => false, 'code' => 404, 'message' => 'The Physical File Not Found in server'], 200);
+ }
+
+ $filePath = $uploadFilePath . '/' . $pt_files_data['file_name'];
+
+ if (!file_exists($filePath)) {
+ return $this->respond(['status' => false, 'code' => 404, 'message' => 'The Physical File Not Found in server'], 200);
+ }
+
+ // Force file download
+ return $this->response->download($filePath, null)->setFileName($pt_files_data['file_name']);
+ }
+
+ public function bulkEcardDownloadAsZip()
+ {
+ $received_data = $this->request->getJSON(true) ?? null;
+ $this->myLogger->logme('error', 'bulkEcardDownloadAsZip: Received payload = ' . json_encode($received_data ?? []));
+
+ if(empty($received_data['client_policy_id']) && empty($received_data['emp_policy_ids'])){
+ return $this->respond(['status' => false, 'code' => 404, 'message' => 'client_policy_id or employee_policy_ids is required'], 200);
+ }
+
+ if(empty($received_data['hr_id'])){
+ return $this->respond(['status' => false, 'code' => 404, 'message' => 'hr_id is required'], 200);
+ }
+
+ $employee_data = $this->employeePolicyModel->getEmployeeDataWithPolicyUsingClientPolicyIdOrEmployeePolicyIds($received_data);
+
+ if(empty($employee_data)){
+ return $this->respond(['status' => false, 'code' => 404, 'message' => 'No employee data found for the policy'], 200);
+ }
+
+
+ return $this->respond(['status' => true, 'code' => 200, 'message' => 'Bulk E-card download process started. Link share your mail'], 200);
+
+ }
}
diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php
index 78bf3162..84761c68 100755
--- a/app/Controllers/EmployeeServiceController.php
+++ b/app/Controllers/EmployeeServiceController.php
@@ -866,6 +866,14 @@ class EmployeeServiceController extends AdminController
// get policy and rack details
$policy_details = $this->clientPolicyModel->getPolicyDetails($file['client_id'],$file['policy_id']);
+
+ if(empty($policy_details)){
+ $message = "Policy configuration is incomplete. Cannot proceed.";
+ $this->myLogger->logme('error',($message . ' for file id ' . $file_id));
+ $this->fileModel->where('id', $file_id)->set(['status' => 'failed','reason' => json_encode(['error_summary' => array_count_values([5]),'error_data' => $message])])->update();
+ return array('error_summary' => [5], 'error_data' => $message);
+ }
+
$policy_terms = json_decode($policy_details[0]->policy_terms);
$policy_terms = (array) $policy_terms;// convert obj to array
$default_age_ratio = isset($policy_terms['age_ratio']) ? json_decode(json_encode($policy_terms['age_ratio']),true) : [];
@@ -876,6 +884,13 @@ class EmployeeServiceController extends AdminController
$slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($file['policy_id'],$file['client_id']);
// dd($slab_details);
+ if(empty($slab_details) || (isset($slab_details['slab_rates']) && empty($slab_details['slab_rates']))){
+ $message = "Policy configuration is incomplete. Cannot proceed.";
+ $this->myLogger->logme('error',($message . ' for file id ' . $file_id));
+ $this->fileModel->where('id', $file_id)->set(['status' => 'failed','reason' => json_encode(['error_summary' => array_count_values([5]),'error_data' => $message])])->update();
+ return array('error_summary' => [5], 'error_data' => $message);
+ }
+
//remove header
unset($excel_data[0]);
$relationship = $this->general_relationships;
diff --git a/app/Controllers/FhplApiController.php b/app/Controllers/FhplApiController.php
index 9497433c..f2ac8b17 100644
--- a/app/Controllers/FhplApiController.php
+++ b/app/Controllers/FhplApiController.php
@@ -69,7 +69,7 @@ class FhplApiController extends BaseController
]);
}
- public function SubmitClaim($claimId = 515)
+ public function SubmitClaim($claimId = null) // 515
{
helper('api');
@@ -99,7 +99,7 @@ class FhplApiController extends BaseController
if (count($data) && $data['filePath'] == null) {
log_message('error', "TPA CLAIM PUSH FAILED FHPL | claimId: '.$claimId.' - Claim or File Missing");
- return $this->response->setJSON(['status' => false,'message' => 'Claim or File Missing', ]);
+ return;
}
// Build absolute file path
@@ -108,7 +108,7 @@ class FhplApiController extends BaseController
if (!file_exists($pdfPath)) {
log_message('error', "TPA CLAIM PUSH FAILED FHPL | claimId: '.$claimId.' - PDF not found on server");
- return $this->response->setJSON(['status' => false,'message' => 'PDF not found on server']);
+ return;
}
// Convert PDF to Base64
@@ -117,7 +117,8 @@ class FhplApiController extends BaseController
// Generate FHPL Token
$tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
if (empty($tokenResponse['data']['access_token'])) {
- return $this->response->setJSON(['status' => false,'message' => 'FHPL Token generation failed']);
+ log_message('error', "TPA CLAIM PUSH FAILED FHPL | claimId: '.$claimId.' - FHPL Token generation failed");
+ return;
}
$token = $tokenResponse['data']['access_token'];
@@ -125,10 +126,10 @@ class FhplApiController extends BaseController
$body = [
"IssueID" => $data['dependentUniqueId'], // this key added after seeing the error in responce have to click with fhpl team
"Userid" => getenv('FHPL_USER_NAME'),
- "PolicyNo" => "111700-TATAMTORS", // $data['policyNo'],
- "UhidNo" => "OIC40830846", //$data['dependentUniqueId'],
+ "PolicyNo" => $data['policyNo'], // "111700-TATAMTORS",
+ "UhidNo" => $data['dependentUniqueId'], // "OIC40830846",
"ClaimID" => (string) $data['id'],
- "DOA" => "2025-10-11",//date('Y-m-d', strtotime($data['admissionDate'])),
+ "DOA" => date('Y-m-d', strtotime($data['admissionDate'])), //"2025-10-11",
"DateofDischarge"=> $data['dischargeDate'] ? date('Y-m-d', strtotime($data['dischargeDate'])) : null,
"ClaimedAmount" => (float) $data['requestedAmount'],
"DocumentType" => 20, // Fresh Claim
@@ -155,7 +156,7 @@ class FhplApiController extends BaseController
$response = call_third_party_api($url, 'POST', $headers, $body);
- log_message('error', 'FHPL RESPONSE | ' . json_encode($response));
+ log_message('error', 'TPA CLAIM PUSH FHPL RESPONSE | ' . json_encode($response));
if($response['status'] != true){
log_message('error', 'TPA CLAIM PUSH FAILED FHPL | claimId: '.$claimId.' | response: '.json_encode($response));
@@ -185,14 +186,17 @@ class FhplApiController extends BaseController
log_message('error', 'TPA CLAIM PUSH SUCCESS FHPL | claimId: '.$claimId.' | claimNO: '.$fhplClaimNo);
+ }else {
+ log_message('error', 'TPA CLAIM PUSH API SUCCESS BUT claimsInfo EMPTY | response: '.json_encode($response));
+ return;
}
}
-
- return $this->response->setJSON($response);
+ return;
+ // return $this->response->setJSON($response);
}
- public function ClaimDetail($claimId = 515)
+ public function ClaimDetail($claimId = null) //515
{
helper('api');
@@ -203,13 +207,13 @@ class FhplApiController extends BaseController
->get()->getRowArray();
- if(!$ticket) return $this->response->setJSON(['status'=>false,'message'=>'Invalid claim']);
+ if(!$ticket) return ['status'=>false,'message'=>'Invalid claim'];
// Generate FHPL Token
$tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
if (empty($tokenResponse['data']['access_token'])) {
- return $this->response->setJSON(['status' => false,'message' => 'FHPL Token generation failed']);
+ return ['status' => false,'message' => 'FHPL Token generation failed'];
}
$token = $tokenResponse['data']['access_token'];
@@ -219,9 +223,9 @@ class FhplApiController extends BaseController
$body = [
"UserName" => getenv('FHPL_USER_NAME'),
"Password" => getenv('FHPL_PASSWORD'),
- "PolicyNumber" => "GHI-81-25-00087313-000",//$ticket['policy_no'],
- "Fromdate" => "2025-04-26",//$ticket['claimNo'],
- "Todate" => "2025-04-27",//$ticket['claimNo'],
+ "PolicyNumber" => $ticket['policy_no'], //"GHI-81-25-00087313-000",
+ "Fromdate" => $ticket['policy_start_date'],//"2025-04-26",
+ "Todate" => $ticket['policy_end_date'],//"2025-04-27",
];
$headers = ["Authorization: Bearer ".$token,"Content-Type: application/json"];
@@ -232,12 +236,7 @@ class FhplApiController extends BaseController
if (empty($response['data'][0])) {
log_message('error', 'CLAIM STATUS FAILED | for ticket ID: ' . $claimId.' | response: '.json_encode($response));
-
- return $this->response->setJSON([
- 'status' => false,
- 'message' => 'API call failed.',
- 'data' => $response
- ]);
+ return ['status' => false,'message' => 'API call failed.','data' => $response ];
}
@@ -263,18 +262,11 @@ class FhplApiController extends BaseController
if( $status != null && isset($map[$status]))
{
$this->db->table('ticket_master')->where('id',$claimId)->update(['claim_status_id'=>$map[$status],'tpa_claim_status'=>$status]);
- // LOG UPDATE
log_message('error', "CLAIM STATUS SUCCESS | Updated ticket ID $claimId with claim status: $status");
}
-
- return $this->response->setJSON([
- 'status' => true,
- 'message' => 'Claim status updated.',
- 'updated_status' => $status,
- 'api_response' => $response
- ]);
+ return ['status' => true,'message' => 'Claim status updated.','updated_status' => $status,'api_response' => $response];
}
@@ -298,24 +290,16 @@ class FhplApiController extends BaseController
return $this->response->setJSON(['status'=>true,'updated'=>$count]);
}
- public function EcardRequest($employeeId,$policyNo,$uhid)
+ public function EcardRequest($employeeId = null,$policyNo = null,$uhid = null)
{
helper('api');
// Generate FHPL Token
$tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
-
if (empty($tokenResponse['data']['access_token'])) {
- return $this->response->setJSON(['status' => false,'message' => 'FHPL Token generation failed']);
+ log_message('error', 'Ecard Request FAILED | employeeId: '.$employeeId.' | policyNo: '.$policyNo.' | Message: FHPL Token generation failed');
+ return null;
}
-
- // Generate FHPL Token
- $tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
-
- if (empty($tokenResponse['data']['access_token'])) {
- return $this->response->setJSON(['status' => false,'message' => 'FHPL Token generation failed']);
- }
-
$token = $tokenResponse['data']['access_token'];
$url = getenv('FHPL_BASE_URL')."/api/GetEcard";
@@ -323,107 +307,402 @@ class FhplApiController extends BaseController
$body = [
"UserName" => getenv('FHPL_USER_NAME'),
"Password" => getenv('FHPL_PASSWORD'),
- "PolicyNumber" => $policyNo,
- "EmployeeID" => $employeeId
+ "PolicyNumber" => $policyNo, //'10/12/2025/16/17',
+ "EmployeeID" => $employeeId, //'101225',
];
$headers = ["Authorization: Bearer ".$token,"Content-Type: application/json"];
$response = call_third_party_api($url,'POST',$headers,$body);
+ // dd($response);
- if(($response['data']['STATUS'] ?? '')=='SUCCESS'){
- return $response['data']['E_Card'];
+ if (($response['status'] ?? false) !== true) {
+ log_message('error', 'Ecard Request FAILED | response: ' . json_encode($response));
+ return null;
}
+ if (empty($response['data'][0])) {
+ log_message('error', 'Ecard Request FAILED | Empty data | response: ' . json_encode($response));
+ return null;
+ }
+
+ $apiData = $response['data'][0];
+
+ if (($apiData['STATUS'] ?? '') === 'SUCCESS') {
+
+ $ecardUrl = $apiData['E_Card'] ?? '';
+
+ if (!empty($ecardUrl)) {
+ log_message(
+ 'info',
+ 'Ecard Request PUSH SUCCESS | employeeId: ' . $employeeId .
+ ' | policyNo: ' . $policyNo .
+ ' | ecardUrl: ' . $ecardUrl
+ );
+ return $ecardUrl;
+ }
+ }
+
+ log_message('error', 'Ecard Request FAILED | response: ' . json_encode($response));
return null;
}
public function FhplGetBenefDetails($requestData = null)
{
- helper('api');
- $policyNo = $requestData['policy_no'] ?? "10/12/2025/16/17";
- $client_policy_id = $requestData['client_policy_id'] ?? 0;
+ $function_calling_type = $requestData['return_type'] ?? 'job';
- // Generate FHPL Token
- $tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
- if (empty($tokenResponse['data']['access_token'])) {
- return $this->response->setJSON(['status' => false,'message' => 'FHPL Token generation failed']);
- }
- $token = $tokenResponse['data']['access_token'];
+ try {
+
+ helper('api');
- $url = getenv('FHPL_BASE_URL')."/api/GetEnrollmentDetailsPolicy";
+ $policyNo = $requestData['policy_no'] ?? null;
+ $client_policy_id = $requestData['client_policy_id'] ?? null;
- $headers = [
- "Authorization: Bearer ".$token,
- "Content-Type: application/json"
- ];
-
- $startIndex = 0;
- $range = 100;
- $allMembers = [];
-
- do {
- $body = [
- "UserName" => getenv('FHPL_USER_NAME'),
- "Password" => getenv('FHPL_PASSWORD'),
- "PolicyNumber" => $policyNo,
- "StartIndex" => $startIndex,
- "Range" => $range
- ];
-
- $response = call_third_party_api($url,'POST',$headers,$body);
-
- dd($response);
-
- if(empty($response['data']['Members'])){
- break;
- }
-
- $allMembers = array_merge($allMembers,$response['data']['Members']);
-
- $startIndex += $range;
-
- } while($startIndex < ($response['data']['Total'] ?? 0));
-
-
- dd($allMembers);
-
- // Now same matching logic you already have
- $employeePolicyModel = new EmployeePolicyModel();
-
- $employeePolicyData = $employeePolicyModel
- ->join('employees','employees.id=employee_polices.employee_id')
- ->where('employee_polices.client_policy_id',$client_policy_id)
- ->where('employee_polices.tpa_id IS NULL')
- ->findAll();
-
- $updated = 0;
-
- foreach($employeePolicyData as $policy){
- foreach($allMembers as $m){
-
- if(
- strtolower(trim($policy['name']))==strtolower(trim($m['Name'])) &&
- $policy['emp_code']==$m['MemberID'] &&
- strtolower($policy['relationship'])==strtolower($m['Relation'])
- ){
- $this->db->table('employee_polices')
- ->where('id',$policy['emp_policy_id'])
- ->update(['tpa_id'=>$m['UHID']]);
-
- $updated++;
+ if (empty($policyNo)) {
+ log_message('error', 'TPA ID PULL | policy_no missing in request');
+ if($function_calling_type == "job"){
+ return ['status' => false, 'message' => 'policy_no required'];
+ }else{
+ return $this->respond(['status' => false, 'message' => 'policy_no required']);
}
}
- }
- return [
- 'status'=>true,
- 'total_fetched'=>count($allMembers),
- 'updated'=>$updated
- ];
+ if (empty($client_policy_id)) {
+ log_message('error', 'TPA ID PULL | client_policy_id missing in request');
+ if($function_calling_type == "job"){
+ return ['status' => false, 'message' => 'client_policy_id required'];
+ }else{
+ return $this->respond(['status' => false, 'message' => 'client_policy_id required']);
+ }
+ }
+
+ log_message('error', "TPA ID PULL | called for policy_no: {$policyNo} , client_policy_id: {$client_policy_id}");
+
+ // Fetch file download dates
+ $batchFiles = $this->db->table('batch_files f')
+ ->select("f.created_at")
+ ->where('f.client_policy_id', $client_policy_id)
+ ->where('f.insurer_or_tpa', 'tpa')
+ ->where('f.actions', 'export')
+ ->get()
+ ->getResultArray();
+
+ if (empty($batchFiles)) {
+ log_message('error', 'TPA ID PULL FAILED | batchFiles is empty for this tpa id pull request');
+ if($function_calling_type == "job"){
+ return ['status' => false, 'message' => 'batchFiles not found'];
+ }else{
+ return $this->respond(['status' => false, 'message' => 'batchFiles not found']);
+ }
+ }
+
+ // Generate FHPL Token
+ $tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
+ if (empty($tokenResponse['data']['access_token'])) {
+ log_message('error', 'TPA ID PULL | FHPL Token generation failed');
+ if($function_calling_type == "job"){
+ return ['status' => false, 'message' => 'FHPL Token generation failed'];
+ }else{
+ return $this->respond(['status' => false, 'message' => 'FHPL Token generation failed']);
+ }
+ }
+ $token = $tokenResponse['data']['access_token'];
+
+ $url = getenv('FHPL_BASE_URL') . "/api/GetEnrollmentDetailsPolicy";
+
+ $headers = [
+ "Authorization: Bearer " . $token,
+ "Content-Type: application/json"
+ ];
+
+ $startIndex = 0;
+ $range = 100;
+ $allMembers = [];
+
+ while (true) {
+
+ $body = [
+ "UserName" => getenv('FHPL_USER_NAME'),
+ "Password" => getenv('FHPL_PASSWORD'),
+ "PolicyNumber" => $policyNo,
+ "StartIndex" => $startIndex,
+ "Range" => $range
+ ];
+
+ log_message('error', "TPA ID PULL | API parems " . json_encode([$url, 'POST', $headers, $body]));
+
+ $response = call_third_party_api($url, 'POST', $headers, $body);
+
+ if (($response['status'] ?? false) !== true) {
+ log_message('error', 'FHPL API FAILED | response: ' . json_encode($response));
+ break;
+ }
+
+ if (
+ !isset($response['data']) ||
+ !is_array($response['data']) ||
+ count($response['data']) === 0 ||
+ !array_is_list($response['data']) // PHP 8+ safe check
+ ) {
+ // STOP when data is not a valid list
+ break;
+ }
+
+ $allMembers = array_merge($allMembers, $response['data']);
+
+ // Move to next page
+ $startIndex += $range;
+ }
+
+ if(empty($allMembers))
+ {
+
+ // update file table status after the tpa id failed to update
+ if (isset($requestData['file_id']) && !empty($requestData['file_id'])) {
+ $file_model = new BatchFileModel();
+ $file_model->where('id', $requestData['file_id'])->set('status', 'failed-8')->update();
+ log_message('error', "Files table status updated for the file id : {$requestData['file_id']}");
+ } else {
+ log_message('error', "Failed to update file table status.");
+ }
+
+ log_message('error', 'TPA ID PULL API FAILED | API failed: Empty menber data for this pull request');
+
+ if($function_calling_type == "job"){
+ return ['status' => false, 'message' => 'API call failed', 'data' => 'Empty menber data for this pull request'];
+ }else{
+ return $this->respond(['status' => false, 'message' => 'API call failed', 'data' => 'Empty menber data for this pull request']);
+ }
+
+ }
+
+ // dd($allMembers);
+
+ //save API data as JSON for analysis
+ $json = json_encode($allMembers, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
+ // $filename = time() . '.json';
+ $filePath = WRITEPATH . 'tmp/'.time().'_'.$requestData['file_id'].'.json';
+ file_put_contents($filePath, $json);
+
+ //call a job for dump JSON data to DB
+ $job_details = new Jobs();
+ $r = Jobs::addJob(['job_name' => 'saveFhplAPIData', 'payload' => [ 'file_id' => $requestData['file_id'],'json_file_path' => $filePath ]]);
+
+ // ================= MATCHING LOGIC =================
+
+ $employeePolicyModel = new EmployeePolicyModel();
+
+ $employeePolicyData = $employeePolicyModel
+ ->join('employees', 'employees.id = employee_polices.employee_id')
+ ->where('employee_polices.client_policy_id', $client_policy_id)
+ ->where('employee_polices.tpa_id IS NULL')
+ ->findAll();
+
+ $updated = 0;
+
+ foreach ($employeePolicyData as $policy) {
+ $hasMatchForThisPolicy = false;
+ foreach ($allMembers as $m) {
+
+ if (
+ strtolower(trim($policy['name'])) === strtolower(trim($m['EMPLOYEE_NAME'] ?? '')) &&
+ ($policy['emp_code'] ?? '') == ($m['EMPLOYEE_ID'] ?? '') &&
+ strtolower($policy['relationship']) === strtolower($m['RELATION'] ?? '')
+ ) {
+
+ $hasMatchForThisPolicy = true;
+
+
+ $sql = "UPDATE employee_polices SET tpa_id = ? WHERE id = ?";
+ $this->db->query($sql, [$m['TPA_TPADETAIL_ID'], $policy['emp_policy_id']]);
+
+ // for e-card send
+ if(strtolower(trim($policy['relationship'])) == 'self'){
+ $employee_policy_ids[] = $policy['emp_policy_id'];
+ }
+
+ if ($this->db->affectedRows() > 0) {
+ $updated++;
+ log_message('error', "✅ Updated tpa_id={$m['TPA_TPADETAIL_ID']} for emp_policy_id={$policy['emp_policy_id']} policy={$policyNo}");
+ } else {
+ log_message('error', "⚠️ No update (already set or not matched) for emp_policy_id={$policy['emp_policy_id']} policy={$policyNo}");
+ }
+ }
+ }
+ }
+
+ // Handle NO MATCH for this policy
+ if (!$hasMatchForThisPolicy) {
+
+ $nhanceSideData = [
+ 'name' => $policy_data['name'] ?? null,
+ 'emp_code' => $policy_data['emp_code'] ?? null,
+ 'relationship' => $policy_data['relationship'] ?? null,
+ 'gender' => $policy_data['gender'] ?? null,
+ 'dob' => $policy_data['dob'] ?? null,
+ ];
+ $batch_file_success = 'partially success';
+
+ log_message(
+ 'error',
+ "❌ No match for Nhance = " . json_encode($nhanceSideData)
+ );
+ }
+
+ // send e-card
+ if(!empty($employee_policy_ids)){
+ log_message('error', "sendMailForDownloadingECard JOB PUSHED.");
+ Jobs::addJob(['job_name' => 'sendMailForDownloadingECard', 'payload' => ['ids' => $employee_policy_ids, 'client_policy_id' => $client_policy_id]]);
+ }
+
+ // update file table status after the tpa id successfully updated
+ if (isset($requestData['file_id']) && !empty($requestData['file_id'])) {
+ $file_model = new BatchFileModel();
+
+ $file_model->where('id', $requestData['file_id'])->set('status', $batch_file_success)->update();
+ log_message('error', "Files table status updated for the file id : {$requestData['file_id']}");
+ } else {
+ log_message('error', "Failed to update file table status.");
+ }
+
+ $totalCount = count($allMembers);
+
+ log_message('error', "TPA ID PULL SUCCESS | completed. Total fetched={$totalCount}, updated={$updated}");
+
+ if($function_calling_type == "job"){
+ return [
+ 'status' => true,
+ 'message' => 'Updated successfully',
+ 'total_fetched' => $totalCount,
+ 'total_updated' => $updated
+ ];
+ }else{
+ return $this->respond([
+ 'status' => true,
+ 'message' => 'Updated successfully',
+ 'total_fetched' => $totalCount,
+ 'total_updated' => $updated
+ ]);
+ }
+ } catch (\Throwable $th) {
+
+ // update file table status after the tpa id failed to update
+ if (isset($requestData['file_id']) && !empty($requestData['file_id'])) {
+ $file_model = new BatchFileModel();
+ $file_model->where('id', $requestData['file_id'])->set('status', 'failed-8')->update();
+ log_message('error', "Files table status updated for the file id : {$requestData['file_id']}");
+ } else {
+ log_message('error', "Failed to update file table status.");
+ }
+
+ $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,
+ ];
+
+ log_message('error', 'Exception thrown while calling GetBenefDetails API: ' . json_encode($errorData));
+ if($function_calling_type == "job"){
+ return ['status' => false, 'message' => 'API call failed', 'data' => $errorData];
+ }else{
+ return $this->respond(['status' => false, 'message' => 'API call failed', 'data' => $errorData]);
+ }
+ }
}
+
+ // public function FhplGetBenefDetails($requestData = null)
+ // {
+ // helper('api');
+
+ // $policyNo = $requestData['policy_no'] ?? "10/12/2025/16/17";
+ // $client_policy_id = $requestData['client_policy_id'] ?? 0;
+
+ // // Generate FHPL Token
+ // $tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
+ // if (empty($tokenResponse['data']['access_token'])) {
+ // return $this->response->setJSON(['status' => false,'message' => 'FHPL Token generation failed']);
+ // }
+ // $token = $tokenResponse['data']['access_token'];
+
+ // $url = getenv('FHPL_BASE_URL')."/api/GetEnrollmentDetailsPolicy";
+
+ // $headers = [
+ // "Authorization: Bearer ".$token,
+ // "Content-Type: application/json"
+ // ];
+
+ // $startIndex = 0;
+ // $range = 100;
+ // $allMembers = [];
+
+ // do {
+ // $body = [
+ // "UserName" => getenv('FHPL_USER_NAME'),
+ // "Password" => getenv('FHPL_PASSWORD'),
+ // "PolicyNumber" => $policyNo,
+ // "StartIndex" => $startIndex,
+ // "Range" => $range
+ // ];
+
+ // $response = call_third_party_api($url,'POST',$headers,$body);
+
+ // dd($response);
+
+ // if(empty($response['data']['Members'])){
+ // break;
+ // }
+
+ // $allMembers = array_merge($allMembers,$response['data']['Members']);
+
+ // $startIndex += $range;
+
+ // } while($startIndex < ($response['data']['Total'] ?? 0));
+
+
+ // dd($allMembers);
+
+ // // Now same matching logic you already have
+ // $employeePolicyModel = new EmployeePolicyModel();
+
+ // $employeePolicyData = $employeePolicyModel
+ // ->join('employees','employees.id=employee_polices.employee_id')
+ // ->where('employee_polices.client_policy_id',$client_policy_id)
+ // ->where('employee_polices.tpa_id IS NULL')
+ // ->findAll();
+
+ // $updated = 0;
+
+ // foreach($employeePolicyData as $policy){
+ // foreach($allMembers as $m){
+
+ // if(
+ // strtolower(trim($policy['name']))==strtolower(trim($m['Name'])) &&
+ // $policy['emp_code']==$m['MemberID'] &&
+ // strtolower($policy['relationship'])==strtolower($m['Relation'])
+ // ){
+ // $this->db->table('employee_polices')
+ // ->where('id',$policy['emp_policy_id'])
+ // ->update(['tpa_id'=>$m['UHID']]);
+
+ // $updated++;
+ // }
+ // }
+ // }
+
+ // return [
+ // 'status'=>true,
+ // 'total_fetched'=>count($allMembers),
+ // 'updated'=>$updated
+ // ];
+ // }
+
public function syncFhplClaimsToNhance()
{
helper('api');
diff --git a/app/Controllers/HealthindiaapiController.php b/app/Controllers/HealthindiaapiController.php
new file mode 100644
index 00000000..253c97b3
--- /dev/null
+++ b/app/Controllers/HealthindiaapiController.php
@@ -0,0 +1,751 @@
+db = \Config\Database::connect();
+ $this->healthIndiaTpaId = getenv('HEALTH_INDIA_PRIMARY_KEY_CONSTANT');
+ }
+
+ public function generateAuthToken()
+ {
+ $url = getenv('HEALTH_INDIA_TOKEN_URL'); // https://software.healthindiatpa.com/HIITPABROKERAPI/JWT/GenerateJWTAuth
+
+ // Basic Authentication credentials
+ $username = getenv('HEALTH_INDIA_USERNAME'); // /MU4gwfBYC71M1QnczasegH0vPM5IMbESO4iy4wbUrQ=
+ $password = getenv('HEALTH_INDIA_PASSWORD'); // KoVi+w2WGA+ET6fHN3kdBamHNsDKbA+kUtuF++4jWcg=
+
+ $ch = curl_init();
+
+ curl_setopt_array($ch, [
+ CURLOPT_URL => $url,
+ CURLOPT_RETURNTRANSFER => true,
+ CURLOPT_CUSTOMREQUEST => 'POST',
+ CURLOPT_HTTPHEADER => [
+ 'Authorization: Basic ' . base64_encode($username . ':' . $password),
+ 'Content-Type: application/json',
+ ],
+ CURLOPT_TIMEOUT => 30,
+ ]);
+
+ $response = curl_exec($ch);
+ $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+
+ if (curl_errno($ch)) {
+ log_message('error', 'HEALTH_INDIA TOKEN GENERATION FAILED | Error: ' . curl_error($ch));
+ curl_close($ch);
+ return $this->response->setJSON([
+ 'status' => false,
+ 'error' => curl_error($ch),
+ ]);
+ }
+
+ curl_close($ch);
+
+ $responseData = json_decode($response, true);
+
+ if ($httpCode === 200 && isset($responseData['status']) && $responseData['status'] === true) {
+ log_message('error', 'HEALTH_INDIA TOKEN GENERATION SUCCESS | Token: ' . ($responseData['result'][0]['access_token'] ?? 'N/A'));
+ } else {
+ log_message('error', 'HEALTH_INDIA TOKEN GENERATION FAILED | Response: ' . $response);
+ }
+
+ return $this->response->setJSON([
+ 'status' => $httpCode === 200,
+ 'http_code' => $httpCode,
+ 'data' => $responseData,
+ ]);
+ }
+
+ public function SubmitClaim($claimId = null)
+ {
+ helper('api');
+
+ log_message('error', 'TPA CLAIM PUSH HEALTH_INDIA | Started for claimId: ' . $claimId);
+
+ $data = $this->db->table('ticket_master tm')
+ ->select('
+ tm.id,
+ tm.emp_mobile as mobileNo,
+ tm.emp_mail as emailId,
+ tm.doa as admissionDate,
+ tm.dod as dischargeDate,
+ tm.hospital_name as hospitalName,
+ tm.claim_amount as claimedAmount,
+ tm.tpa_no as memberId,
+ tm.ailment as ailmentDescription,
+ cp.policy_no as policyNumber,
+ e.emp_code as employeeCode,
+ tn.note as disease,
+ cf.url as filePath,
+ tm.claim_type as claimType,
+ tm.claim_category as benefitType
+ ')
+ ->join('employees e', 'e.id = tm.emp_id', 'left')
+ ->join('client_policy cp', 'tm.client_policy_id = cp.id', 'left')
+ ->join('ticket_notes tn', 'tn.ticket_id = tm.id', 'left')
+ ->join('claim_files cf', "cf.ticket_id = tm.id AND cf.file_type = 2 AND cf.mime_type='application/pdf'", 'left')
+ ->where('tm.id', $claimId)
+ ->get()
+ ->getRowArray();
+
+ if (!$data) {
+ log_message('error', "TPA CLAIM PUSH FAILED HEALTH_INDIA | claimId: {$claimId} - Claim not found");
+ return;
+ }
+
+ if ($data['filePath'] == null) {
+ log_message('error', "TPA CLAIM PUSH FAILED HEALTH_INDIA | claimId: {$claimId} - File Missing");
+ return;
+ }
+
+ // Build absolute file path
+ $filename = basename($data['filePath']);
+ $pdfPath = WRITEPATH . 'uploads/claim_files/' . $filename;
+
+ if (!file_exists($pdfPath)) {
+ log_message('error', "TPA CLAIM PUSH FAILED HEALTH_INDIA | claimId: {$claimId} - PDF not found on server at path: {$pdfPath}");
+ return;
+ }
+
+ // Convert PDF to Base64
+ $fileContent = base64_encode(file_get_contents($pdfPath));
+
+ // Generate Health India Token
+ $tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
+ if (empty($tokenResponse['data']['result'][0]['access_token'])) {
+ log_message('error', "TPA CLAIM PUSH FAILED HEALTH_INDIA | claimId: {$claimId} - Token generation failed");
+ return;
+ }
+ $token = $tokenResponse['data']['result'][0]['access_token'];
+
+ // Map claim type: Reimbursement or Cashless
+ $claimTypeMap = [
+ 'reimbursement' => 'Reimbursement',
+ 'cashless' => 'Cashless',
+ ];
+ $mappedClaimType = $claimTypeMap[strtolower($data['claimType'] ?? 'reimbursement')] ?? 'Reimbursement';
+
+ // Map benefit type: IPD or OPD
+ $benefitTypeMap = [
+ 'ipd' => 'IPD',
+ 'opd' => 'OPD',
+ ];
+ $mappedBenefitType = $benefitTypeMap[strtolower($data['benefitType'] ?? 'ipd')] ?? 'IPD';
+
+ // Build Health India Claim Submission Request (API Section 5)
+ $body = [
+ "policY_NUMBER" => $data['policyNumber'],
+ "employeE_CODE" => $data['employeeCode'],
+ "membeR_ID" => $data['memberId'],
+ "claiM_TYPE" => $mappedClaimType,
+ "benefiT_TYPE" => $mappedBenefitType,
+ "claimeD_AMOUNT" => (string) $data['claimedAmount'],
+ "datE_OF_ADMISSION" => date('Y-m-d', strtotime($data['admissionDate'])),
+ "ailmenT_DESCRIPTION" => $data['ailmentDescription'] ?? 'NA',
+ "hospitaL_CODE" => "", // Not available in your data
+ "hospitaL_NAME" => $data['hospitalName'] ?? '',
+ "hospitaL_ADDRESS" => "", // Not available
+ "hospitaL_NUMBER" => "", // Not available
+ "pdF_BYTES" => [$fileContent]
+ ];
+
+ $url = getenv('HEALTH_INDIA_BASE_URL') . "/Intimation/GetClaimIntimation";
+
+ $headers = [
+ "Authorization: Bearer " . $token,
+ "Content-Type: application/json"
+ ];
+
+ log_message('error', 'TPA CLAIM PUSH HEALTH_INDIA | claimId: ' . $claimId . ' | URL: ' . $url . ' | payload: ' . json_encode($body));
+
+ $response = call_third_party_api($url, 'POST', $headers, $body);
+
+ log_message('error', 'TPA CLAIM PUSH HEALTH_INDIA RESPONSE | claimId: ' . $claimId . ' | response: ' . json_encode($response));
+
+ if ($response['status'] != true) {
+ log_message('error', 'TPA CLAIM PUSH FAILED HEALTH_INDIA | claimId: ' . $claimId . ' | response: ' . json_encode($response));
+ $this->db->table('ticket_master')
+ ->where('id', $claimId)
+ ->update(['tpa_push_response' => json_encode($response)]);
+ return;
+ }
+
+ if ($response['status'] === true && !empty($response['data']['result'][0]['ccn'])) {
+ $ccn = $response['data']['result'][0]['ccn'];
+ $ccnExt = $response['data']['result'][0]['ccN_EXT'] ?? '0';
+
+ $this->db->table('ticket_master')
+ ->where('id', $claimId)
+ ->update([
+ 'claim_number' => $ccn,
+ 'tpa_claim_id' => $ccn,
+ 'tpa_claim_push_reference_no' => $ccn . '(' . $ccnExt . ')',
+ 'updated_at' => date('Y-m-d H:i:s')
+ ]);
+
+ log_message('error', 'TPA CLAIM PUSH SUCCESS HEALTH_INDIA | claimId: ' . $claimId . ' | CCN: ' . $ccn . ' | CCN_EXT: ' . $ccnExt);
+ } else {
+ log_message('error', 'TPA CLAIM PUSH HEALTH_INDIA API SUCCESS BUT CCN EMPTY | claimId: ' . $claimId . ' | response: ' . json_encode($response));
+ return;
+ }
+
+ return;
+ }
+
+ public function ClaimDetail($claimId = null)
+ {
+ helper('api');
+
+ log_message('error', 'CLAIM STATUS HEALTH_INDIA | Started for claimId: ' . $claimId);
+
+ $ticket = $this->db->table('ticket_master tm')
+ ->select("tm.id, tm.tpa_claim_id as ccn, cp.policy_no, cp.policy_start_date, cp.policy_end_date, tm.emp_code")
+ ->join('client_policy cp', 'tm.client_policy_id=cp.id')
+ ->where('tm.id', $claimId)
+ ->get()->getRowArray();
+
+ if (!$ticket) {
+ log_message('error', 'CLAIM STATUS FAILED HEALTH_INDIA | claimId: ' . $claimId . ' - Invalid claim');
+ return ['status' => false, 'message' => 'Invalid claim'];
+ }
+
+ // Generate Health India Token
+ $tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
+
+ if (empty($tokenResponse['data']['result'][0]['access_token'])) {
+ log_message('error', 'CLAIM STATUS FAILED HEALTH_INDIA | claimId: ' . $claimId . ' - Token generation failed');
+ return ['status' => false, 'message' => 'Token generation failed'];
+ }
+
+ $token = $tokenResponse['data']['result'][0]['access_token'];
+
+ $url = getenv('HEALTH_INDIA_BASE_URL') . "/Claims/GetClaims";
+
+ // Using claim number wise approach (Section 7.3 - option 3)
+ $body = [
+ "policY_NUMBER" => $ticket['policy_no'],
+ "CCN" => $ticket['ccn'],
+ "CCN_EXT" => "0"
+ ];
+
+ $headers = [
+ "Authorization: Bearer " . $token,
+ "Content-Type: application/json"
+ ];
+
+ log_message('error', 'CLAIM STATUS HEALTH_INDIA | claimId: ' . $claimId . ' | Request: ' . json_encode($body));
+
+ $response = call_third_party_api($url, 'POST', $headers, $body);
+
+ log_message('error', 'CLAIM STATUS HEALTH_INDIA | claimId: ' . $claimId . ' | Response: ' . json_encode($response));
+
+ if (empty($response['data']['result'][0])) {
+ log_message('error', 'CLAIM STATUS FAILED HEALTH_INDIA | claimId: ' . $claimId . ' | Empty response data');
+ return ['status' => false, 'message' => 'API call failed.', 'data' => $response];
+ }
+
+ $claimData = $response['data']['result'][0];
+ $status = $claimData['claiM_STATUS'] ?? null;
+
+ // Status mapping based on API documentation
+ $map = [
+ "Under Process" => 5,
+ "Pending for Bill Entry" => 5,
+ "Query" => 4,
+ "Paid" => 11,
+ "Rejected" => 8,
+ "Approved" => 8,
+ "Outstanding" => 5,
+ ];
+
+ if ($status != null && isset($map[$status])) {
+ $this->db->table('ticket_master')
+ ->where('id', $claimId)
+ ->update([
+ 'claim_status_id' => $map[$status],
+ 'tpa_claim_status' => $status
+ ]);
+ log_message('error', "CLAIM STATUS SUCCESS HEALTH_INDIA | Updated claimId: {$claimId} with status: {$status}");
+ } else {
+ log_message('error', "CLAIM STATUS HEALTH_INDIA | claimId: {$claimId} | Unknown status: {$status}");
+ }
+
+ return [
+ 'status' => true,
+ 'message' => 'Claim status updated.',
+ 'updated_status' => $status,
+ 'api_response' => $response
+ ];
+ }
+
+ public function ClaimStatusUpdate()
+ {
+ helper('api');
+
+ log_message('error', 'CLAIM STATUS UPDATE BULK HEALTH_INDIA | Started');
+
+ $tickets = $this->db->table('ticket_master tm')
+ ->select("tm.id, tm.tpa_claim_id, cp.policy_no")
+ ->join('client_policy cp', 'tm.client_policy_id=cp.id')
+ ->where('tm.tpa_claim_id IS NOT NULL')
+ ->where('cp.tpa_id', $this->healthIndiaTpaId)
+ ->get()->getResultArray();
+
+ $count = 0;
+
+ foreach ($tickets as $t) {
+ $this->ClaimDetail($t['id']);
+ $count++;
+ }
+
+ log_message('error', 'CLAIM STATUS UPDATE BULK HEALTH_INDIA | Completed | Updated: ' . $count);
+
+ return $this->response->setJSON(['status' => true, 'updated' => $count]);
+ }
+
+ public function EcardRequest($employeeId = null, $policyNo = null, $memberId = null)
+ {
+ helper('api');
+
+ log_message('error', "ECARD REQUEST HEALTH_INDIA | Started | employeeId: {$employeeId} | policyNo: {$policyNo} | memberId: {$memberId}");
+
+ // Generate Health India Token
+ $tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
+ if (empty($tokenResponse['data']['result'][0]['access_token'])) {
+ log_message('error', "ECARD REQUEST FAILED HEALTH_INDIA | employeeId: {$employeeId} | policyNo: {$policyNo} | Message: Token generation failed");
+ return null;
+ }
+ $token = $tokenResponse['data']['result'][0]['access_token'];
+
+ // API Section 3.3 - Individual member e-card
+ $url = getenv('HEALTH_INDIA_BASE_URL') . "/Member/GetMemberEcard";
+
+ $body = [
+ "policY_NUMBER" => $policyNo,
+ "employeE_CODE" => $employeeId,
+ "membeR_ID" => $memberId
+ ];
+
+ $headers = [
+ "Authorization: Bearer " . $token,
+ "Content-Type: application/json"
+ ];
+
+ log_message('error', 'ECARD REQUEST HEALTH_INDIA | Request: ' . json_encode($body));
+
+ $response = call_third_party_api($url, 'POST', $headers, $body);
+
+ log_message('error', 'ECARD REQUEST HEALTH_INDIA | Response: ' . json_encode($response));
+
+ if (($response['status'] ?? false) !== true) {
+ log_message('error', 'ECARD REQUEST FAILED HEALTH_INDIA | response: ' . json_encode($response));
+ return null;
+ }
+
+ if (empty($response['data']['result'][0])) {
+ log_message('error', 'ECARD REQUEST FAILED HEALTH_INDIA | Empty data | response: ' . json_encode($response));
+ return null;
+ }
+
+ $apiData = $response['data']['result'][0];
+
+ if (($apiData['message'] ?? '') === 'SUCCESS') {
+ $ecardUrl = $apiData['membeR_ECARD'] ?? '';
+
+ if (!empty($ecardUrl)) {
+ log_message('error', "ECARD REQUEST SUCCESS HEALTH_INDIA | employeeId: {$employeeId} | policyNo: {$policyNo} | memberId: {$memberId} | ecardUrl: {$ecardUrl}");
+ return $ecardUrl;
+ }
+ }
+
+ log_message('error', 'ECARD REQUEST FAILED HEALTH_INDIA | response: ' . json_encode($response));
+ return null;
+ }
+
+ public function HealthIndiaGetBenefDetails($requestData = null)
+ {
+ $function_calling_type = $requestData['return_type'] ?? 'job';
+
+ try {
+ helper('api');
+
+ $policyNo = $requestData['policy_no'] ?? null;
+ $client_policy_id = $requestData['client_policy_id'] ?? null;
+
+ if (empty($policyNo)) {
+ log_message('error', 'TPA ID PULL HEALTH_INDIA | policy_no missing in request');
+ if ($function_calling_type == "job") {
+ return ['status' => false, 'message' => 'policy_no required'];
+ } else {
+ return $this->respond(['status' => false, 'message' => 'policy_no required']);
+ }
+ }
+
+ if (empty($client_policy_id)) {
+ log_message('error', 'TPA ID PULL HEALTH_INDIA | client_policy_id missing in request');
+ if ($function_calling_type == "job") {
+ return ['status' => false, 'message' => 'client_policy_id required'];
+ } else {
+ return $this->respond(['status' => false, 'message' => 'client_policy_id required']);
+ }
+ }
+
+ log_message('error', "TPA ID PULL HEALTH_INDIA | called for policy_no: {$policyNo}, client_policy_id: {$client_policy_id}");
+
+ // Fetch file download dates
+ $batchFiles = $this->db->table('batch_files f')
+ ->select("f.created_at")
+ ->where('f.client_policy_id', $client_policy_id)
+ ->where('f.insurer_or_tpa', 'tpa')
+ ->where('f.actions', 'export')
+ ->get()
+ ->getResultArray();
+
+ if (empty($batchFiles)) {
+ log_message('error', 'TPA ID PULL FAILED HEALTH_INDIA | batchFiles is empty for this tpa id pull request');
+ if ($function_calling_type == "job") {
+ return ['status' => false, 'message' => 'batchFiles not found'];
+ } else {
+ return $this->respond(['status' => false, 'message' => 'batchFiles not found']);
+ }
+ }
+
+ // Generate Health India Token
+ $tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
+ if (empty($tokenResponse['data']['result'][0]['access_token'])) {
+ log_message('error', 'TPA ID PULL HEALTH_INDIA | Token generation failed');
+ if ($function_calling_type == "job") {
+ return ['status' => false, 'message' => 'Token generation failed'];
+ } else {
+ return $this->respond(['status' => false, 'message' => 'Token generation failed']);
+ }
+ }
+ $token = $tokenResponse['data']['result'][0]['access_token'];
+
+ // API Section 2.3 - Bulk Enrolment data Fetch
+ $url = getenv('HEALTH_INDIA_BASE_URL') . "/Enrollment/GetEnrollmentData";
+
+ $headers = [
+ "Authorization: Bearer " . $token,
+ "Content-Type: application/json"
+ ];
+
+ $body = [
+ "policY_NUMBER" => $policyNo
+ ];
+
+ log_message('error', "TPA ID PULL HEALTH_INDIA | API params: " . json_encode(['url' => $url, 'method' => 'POST', 'body' => $body]));
+
+ $response = call_third_party_api($url, 'POST', $headers, $body);
+
+ log_message('error', "TPA ID PULL HEALTH_INDIA | API Response: " . json_encode($response));
+
+ if (($response['status'] ?? false) !== true) {
+ log_message('error', 'HEALTH_INDIA API FAILED | response: ' . json_encode($response));
+
+ // update file table status after the tpa id failed to update
+ if (isset($requestData['file_id']) && !empty($requestData['file_id'])) {
+ $file_model = new BatchFileModel();
+ $file_model->where('id', $requestData['file_id'])->set('status', 'failed-8')->update();
+ log_message('error', "Files table status updated for the file id: {$requestData['file_id']}");
+ } else {
+ log_message('error', "Failed to update file table status.");
+ }
+
+ if ($function_calling_type == "job") {
+ return ['status' => false, 'message' => 'API call failed', 'data' => $response];
+ } else {
+ return $this->respond(['status' => false, 'message' => 'API call failed', 'data' => $response]);
+ }
+ }
+
+ if (
+ !isset($response['data']['result']) ||
+ !is_array($response['data']['result']) ||
+ count($response['data']['result']) === 0
+ ) {
+ log_message('error', 'TPA ID PULL API FAILED HEALTH_INDIA | Empty member data for this pull request');
+
+ // update file table status after the tpa id failed to update
+ if (isset($requestData['file_id']) && !empty($requestData['file_id'])) {
+ $file_model = new BatchFileModel();
+ $file_model->where('id', $requestData['file_id'])->set('status', 'failed-8')->update();
+ log_message('error', "Files table status updated for the file id: {$requestData['file_id']}");
+ } else {
+ log_message('error', "Failed to update file table status.");
+ }
+
+ if ($function_calling_type == "job") {
+ return ['status' => false, 'message' => 'API call failed', 'data' => 'Empty member data for this pull request'];
+ } else {
+ return $this->respond(['status' => false, 'message' => 'API call failed', 'data' => 'Empty member data for this pull request']);
+ }
+ }
+
+ $allMembers = $response['data']['result'];
+
+ // Save API data as JSON for analysis
+ $json = json_encode($allMembers, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
+ $filePath = WRITEPATH . 'tmp/' . time() . '_' . $requestData['file_id'] . '.json';
+ file_put_contents($filePath, $json);
+
+ log_message('error', "TPA ID PULL HEALTH_INDIA | Saved JSON to: {$filePath}");
+
+ // Call a job for dump JSON data to DB
+ $job_details = new Jobs();
+ $r = Jobs::addJob([
+ 'job_name' => 'saveHealthIndiaAPIData',
+ 'payload' => [
+ 'file_id' => $requestData['file_id'],
+ 'json_file_path' => $filePath
+ ]
+ ]);
+
+ log_message('error', "TPA ID PULL HEALTH_INDIA | Job added for saving API data");
+
+ // ================= MATCHING LOGIC =================
+
+ $employeePolicyModel = new EmployeePolicyModel();
+
+ $employeePolicyData = $employeePolicyModel
+ ->join('employees', 'employees.id = employee_polices.employee_id')
+ ->where('employee_polices.client_policy_id', $client_policy_id)
+ ->where('employee_polices.tpa_id IS NULL')
+ ->findAll();
+
+ $updated = 0;
+ $batch_file_success = 'success';
+ $employee_policy_ids = [];
+
+ foreach ($employeePolicyData as $policy) {
+ $hasMatchForThisPolicy = false;
+
+ foreach ($allMembers as $m) {
+ // Match based on: employee name, employee code, and relation
+ if (
+ strtolower(trim($policy['name'])) === strtolower(trim($m['insured_Name'] ?? '')) &&
+ ($policy['emp_code'] ?? '') == ($m['employeeCode'] ?? '') &&
+ strtolower($policy['relationship']) === strtolower($m['relation'] ?? '')
+ ) {
+ $hasMatchForThisPolicy = true;
+
+ $sql = "UPDATE employee_polices SET tpa_id = ? WHERE id = ?";
+ $this->db->query($sql, [$m['memberId'], $policy['emp_policy_id']]);
+
+ // For e-card send
+ if (strtolower(trim($policy['relationship'])) == 'self') {
+ $employee_policy_ids[] = $policy['emp_policy_id'];
+ }
+
+ if ($this->db->affectedRows() > 0) {
+ $updated++;
+ log_message('error', "✅ HEALTH_INDIA | Updated tpa_id={$m['memberId']} for emp_policy_id={$policy['emp_policy_id']} policy={$policyNo}");
+ } else {
+ log_message('error', "⚠️ HEALTH_INDIA | No update (already set or not matched) for emp_policy_id={$policy['emp_policy_id']} policy={$policyNo}");
+ }
+ }
+ }
+
+ // Handle NO MATCH for this policy
+ if (!$hasMatchForThisPolicy) {
+ $nhanceSideData = [
+ 'name' => $policy['name'] ?? null,
+ 'emp_code' => $policy['emp_code'] ?? null,
+ 'relationship' => $policy['relationship'] ?? null,
+ 'gender' => $policy['gender'] ?? null,
+ 'dob' => $policy['dob'] ?? null,
+ ];
+ $batch_file_success = 'partially success';
+
+ log_message('error', "❌ HEALTH_INDIA | No match for Nhance = " . json_encode($nhanceSideData));
+ }
+ }
+
+ // Send e-card
+ if (!empty($employee_policy_ids)) {
+ log_message('error', "HEALTH_INDIA | sendMailForDownloadingECard JOB PUSHED.");
+ Jobs::addJob([
+ 'job_name' => 'sendMailForDownloadingECard',
+ 'payload' => [
+ 'ids' => $employee_policy_ids,
+ 'client_policy_id' => $client_policy_id
+ ]
+ ]);
+ }
+
+ // Update file table status after the tpa id successfully updated
+ if (isset($requestData['file_id']) && !empty($requestData['file_id'])) {
+ $file_model = new BatchFileModel();
+ $file_model->where('id', $requestData['file_id'])->set('status', $batch_file_success)->update();
+ log_message('error', "Files table status updated for the file id: {$requestData['file_id']} with status: {$batch_file_success}");
+ } else {
+ log_message('error', "Failed to update file table status.");
+ }
+
+ $totalCount = count($allMembers);
+
+ log_message('error', "TPA ID PULL SUCCESS HEALTH_INDIA | completed. Total fetched={$totalCount}, updated={$updated}");
+
+ if ($function_calling_type == "job") {
+ return [
+ 'status' => true,
+ 'message' => 'Updated successfully',
+ 'total_fetched' => $totalCount,
+ 'total_updated' => $updated
+ ];
+ } else {
+ return $this->respond([
+ 'status' => true,
+ 'message' => 'Updated successfully',
+ 'total_fetched' => $totalCount,
+ 'total_updated' => $updated
+ ]);
+ }
+ } catch (\Throwable $th) {
+ // Update file table status after the tpa id failed to update
+ if (isset($requestData['file_id']) && !empty($requestData['file_id'])) {
+ $file_model = new BatchFileModel();
+ $file_model->where('id', $requestData['file_id'])->set('status', 'failed-8')->update();
+ log_message('error', "Files table status updated for the file id: {$requestData['file_id']}");
+ } else {
+ log_message('error', "Failed to update file table status.");
+ }
+
+ $errorData = [
+ 'message' => $th->getMessage(),
+ 'file' => $th->getFile(),
+ 'line' => $th->getLine(),
+ 'code' => $th->getCode(),
+ 'trace' => $th->getTraceAsString(),
+ 'trace_array' => $th->getTrace(),
+ 'function' => $th->getTrace()[0]['function'] ?? null,
+ 'class' => $th->getTrace()[0]['class'] ?? null,
+ ];
+
+ log_message('error', 'Exception thrown while calling HealthIndiaGetBenefDetails API: ' . json_encode($errorData));
+
+ if ($function_calling_type == "job") {
+ return ['status' => false, 'message' => 'API call failed', 'data' => $errorData];
+ } else {
+ return $this->respond(['status' => false, 'message' => 'API call failed', 'data' => $errorData]);
+ }
+ }
+ }
+
+ public function syncHealthIndiaClaimsToNhance()
+ {
+ helper('api');
+
+ log_message('error', 'SYNC CLAIMS HEALTH_INDIA | Started');
+
+ // Generate Health India Token
+ $tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
+
+ if (empty($tokenResponse['data']['result'][0]['access_token'])) {
+ log_message('error', 'SYNC CLAIMS FAILED HEALTH_INDIA | Token generation failed');
+ return $this->response->setJSON(['status' => false, 'message' => 'Token generation failed']);
+ }
+
+ $token = $tokenResponse['data']['result'][0]['access_token'];
+
+ $url = getenv('HEALTH_INDIA_BASE_URL') . "/ClaimsMIS/GetClaimsMIS";
+
+ $headers = [
+ "Authorization: Bearer " . $token,
+ "Content-Type: application/json"
+ ];
+
+ $policies = $this->db->table('client_policy')
+ ->where('tpa_id', $this->healthIndiaTpaId)
+ ->get()->getResultArray();
+
+ $finalResult = [];
+
+ foreach ($policies as $policy) {
+ $body = [
+ "policY_NUMBER" => $policy['policy_no']
+ ];
+
+ log_message('error', 'SYNC CLAIMS HEALTH_INDIA | Fetching for policy: ' . $policy['policy_no']);
+
+ $response = call_third_party_api($url, 'POST', $headers, $body);
+
+ if (!empty($response['data']['result'])) {
+ $finalResult = array_merge($finalResult, $response['data']['result']);
+ log_message('error', 'SYNC CLAIMS HEALTH_INDIA | Fetched ' . count($response['data']['result']) . ' claims for policy: ' . $policy['policy_no']);
+ }
+ }
+
+ log_message('error', 'SYNC CLAIMS HEALTH_INDIA | Total claims fetched: ' . count($finalResult));
+
+ // Insert / update ticket_master
+ $insertedCount = 0;
+ foreach ($finalResult as $row) {
+ $status = $row['Claim_Status'] ?? 'Under Process';
+
+ $map = [
+ "Under Process" => 5,
+ "Pending for Bill Entry" => 5,
+ "Paid" => 11,
+ "Rejected" => 8,
+ "Approved" => 8,
+ "Outstanding" => 5,
+ ];
+
+ $claimStatus = $map[$status] ?? 1;
+
+ // Check if claim already exists
+ $existing = $this->db->table('ticket_master')
+ ->where('tpa_claim_id', $row['CLAIM_NUMBER'])
+ ->get()->getRowArray();
+
+ if (!$existing) {
+ $this->db->table('ticket_master')->insert([
+ 'policy_no' => $row['Policy_No'] ?? '',
+ 'claim_number' => $row['CLAIM_NUMBER'] ?? '',
+ 'tpa_claim_id' => $row['CLAIM_NUMBER'] ?? '',
+ 'emp_code' => $row['Employee_Code'] ?? '',
+ 'insured_name' => $row['PATIENT_NAME'] ?? '',
+ 'claim_amount' => $row['INTIMATED_AMOUNT'] ?? 0,
+ 'hospital_name' => $row['HOSPITAL_NAME'] ?? '',
+ 'doa' => !empty($row['DATEOF_ADMISSION']) ? date('Y-m-d', strtotime($row['DATEOF_ADMISSION'])) : null,
+ 'dod' => !empty($row['DATEOF_DISCHARGE']) ? date('Y-m-d', strtotime($row['DATEOF_DISCHARGE'])) : null,
+ 'claim_status_id' => $claimStatus,
+ 'tpa_id' => $this->healthIndiaTpaId,
+ 'created_at' => date('Y-m-d H:i:s')
+ ]);
+ $insertedCount++;
+ log_message('error', 'SYNC CLAIMS HEALTH_INDIA | Inserted claim: ' . ($row['CLAIM_NUMBER'] ?? 'N/A'));
+ } else {
+ log_message('error', 'SYNC CLAIMS HEALTH_INDIA | Skipped existing claim: ' . ($row['CLAIM_NUMBER'] ?? 'N/A'));
+ }
+ }
+
+ log_message('error', 'SYNC CLAIMS HEALTH_INDIA | Completed | Total: ' . count($finalResult) . ' | Inserted: ' . $insertedCount);
+
+ return $this->response->setJSON([
+ 'status' => true,
+ 'total' => count($finalResult),
+ 'inserted' => $insertedCount
+ ]);
+ }
+}
\ No newline at end of file
diff --git a/app/Controllers/JobWorker.php b/app/Controllers/JobWorker.php
index 160c6fe9..f2020755 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',
],
+ 'FhplGetBenefDetails' => [
+ 'type' => 'CC', // Handler Category
+ 'handler' => 'App\Controllers\FhplApiController',
+ ],
'bdsDumpExcelFileFormatValidation' => [
'type' => 'CC', // Handler Category
'handler' => 'App\Controllers\PolicyTransactionController',
diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php
index 8154fc82..c8413098 100644
--- a/app/Controllers/LeadsController.php
+++ b/app/Controllers/LeadsController.php
@@ -437,7 +437,7 @@ class LeadsController extends BaseController
];
$request_data = $this->request->getPost();
$data = sanitizeInputArrayAdvanced($request_data);
- if($data['lead_form_type'] == 2){
+ if (isset($data['lead_form_type']) && (int)$data['lead_form_type'] === 2) {
$rules['client_type'] = [
'rules' => 'required',
'errors' => ['required' => 'Client Type is required']
diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php
index 7c46bc9a..7017dd07 100755
--- a/app/Controllers/MasterController.php
+++ b/app/Controllers/MasterController.php
@@ -449,7 +449,7 @@ class MasterController extends AdminController
$insert = $this->insurerBranchModel->insert($sanitized_post_data);
if($insert){
- for ($i = 0; $i < count($sanitized_post_data('name')); $i++) {
+ for ($i = 0; $i < count($sanitized_post_data['name']); $i++) {
// Prepare data to insert
$sanitized_post_data_for_level = [
'contact_type' => 'insurer',
@@ -465,7 +465,7 @@ class MasterController extends AdminController
}
if($insert){
- $branchData = $this->insurerBranchModel->where('insurer_id', $sanitized_post_data_for_level['insurer_id'])->findAll();
+ $branchData = $this->insurerBranchModel->where('insurer_id', $sanitized_post_data['insurer_id'])->findAll();
echo json_encode(array("status" => true , 'data' => $branchData));
}else{
echo json_encode(array("status" => false));
@@ -497,6 +497,9 @@ class MasterController extends AdminController
{
$this->myLogger->logme('error','Edit Insurer general info function called');
+ $postData = $this->request->getPost();
+ $logoFile = $this->request->getFile('insurer_logo');
+
$rules = [
'name' => [
'rules' => 'required',
@@ -513,22 +516,30 @@ class MasterController extends AdminController
]
],
'insurer_logo' => [
- 'rules' => 'if_exist|is_image[insurer_logo]|max_size[insurer_logo,200]|ext_in[insurer_logo,jpg,jpeg,png]',
+ 'rules' => 'permit_empty|is_image[insurer_logo]|max_size[insurer_logo,200]|ext_in[insurer_logo,jpg,jpeg,png]',
'errors' => [
'is_image' => 'The uploaded file must be an image',
'max_size' => 'File size should not exceed 200 KB',
- 'ext_in' => 'Allowed file types: jpg, jpeg, png',
+ 'ext_in' => 'Only JPG, JPEG, and PNG files are allowed.',
]
],
];
- if (!$this->validate($rules)) {
- return $this->response->setStatusCode(400)->setJSON([
- 'status' => false,
- 'message' => 'Input validation failed',
- 'code' => 400,
- 'errors' => $this->validator->getErrors()
- ]);
+ if (!$this->validateData($postData, $rules)) {
+ $errors = $this->validator->getErrors();
+
+ $mainMessage = 'Input validation failed';
+
+ if (isset($errors['insurer_logo']) && (strpos($errors['insurer_logo'], 'Security') !== false || strpos($errors['insurer_logo'], 'Forbidden') !== false)) {
+ $mainMessage = 'File upload rejected: Security policy violation.';
+ }
+
+ return $this->response->setStatusCode(400)->setJSON([
+ 'status' => false,
+ 'message' => $mainMessage, // This will change based on the error
+ 'code' => 400,
+ 'errors' => $this->validator->getErrors()
+ ]);
}
$uploadFilePath = ROOTPATH . 'public/uploads/logo/';
@@ -2168,72 +2179,74 @@ class MasterController extends AdminController
public function createCDMasterData()
{
$this->myLogger->logme("error", 'Create CD Master Data API called.');
- $rules = [
-
- // ======================
- // Client / Insurer Mapping
- // ======================
- 'client_id' => [
- 'rules' => 'required|is_natural_no_zero',
- 'errors' => [
- 'required' => 'Client is required'
- ]
- ],
-
- 'insurer_id' => [
- 'rules' => 'required|is_natural_no_zero',
- 'errors' => [
- 'required' => 'Insurer is required'
- ]
- ],
-
- 'insurer_branch_id' => [
- 'rules' => 'required|is_natural_no_zero',
- 'errors' => [
- 'required' => 'Insurer branch is required'
- ]
- ],
-
- // ======================
- // CD Account Details
- // ======================
- 'opening_date' => [
- 'rules' => 'required|valid_date[d-m-Y]',
- 'errors' => [
- 'required' => 'Opening date is required',
- 'valid_date' => 'Opening date must be in DD-MM-YYYY format'
- ]
- ],
-
- 'cd_ac_no' => [
- 'rules' => 'required|trim',
- 'errors' => [
- 'required' => 'CD account number is required'
- ]
- ],
-
- 'opening_bal' => [
- 'rules' => 'required|numeric|greater_than_equal_to[0]',
- 'errors' => [
- 'required' => 'Opening amount is required',
- 'numeric' => 'Opening amount must be numeric',
- 'greater_than_equal_to' => 'Opening amount cannot be negative'
- ]
- ],
- ];
- if (!$this->validate($rules)) {
- return $this->response->setStatusCode(400)->setJSON([
- 'status' => false,
- 'message' => 'Input validation failed',
- 'code' => 400,
- 'errors' => $this->validator->getErrors()
- ]);
- }
$data = $this->request->getPost();
$sanitized_post_data = sanitizeInputArrayAdvanced($data);
+ $id = $sanitized_post_data['PrimaryKey'] ?? null;
+ if($id === null){
+ $rules = [
+
+ // ======================
+ // Client / Insurer Mapping
+ // ======================
+ 'client_id' => [
+ 'rules' => 'required|is_natural_no_zero',
+ 'errors' => [
+ 'required' => 'Client is required'
+ ]
+ ],
+
+ 'insurer_id' => [
+ 'rules' => 'required|is_natural_no_zero',
+ 'errors' => [
+ 'required' => 'Insurer is required'
+ ]
+ ],
+
+ 'insurer_branch_id' => [
+ 'rules' => 'required|is_natural_no_zero',
+ 'errors' => [
+ 'required' => 'Insurer branch is required'
+ ]
+ ],
+
+ // ======================
+ // CD Account Details
+ // ======================
+ 'opening_date' => [
+ 'rules' => 'required|valid_date[d-m-Y]',
+ 'errors' => [
+ 'required' => 'Opening date is required',
+ 'valid_date' => 'Opening date must be in DD-MM-YYYY format'
+ ]
+ ],
+
+ 'cd_ac_no' => [
+ 'rules' => 'required|trim',
+ 'errors' => [
+ 'required' => 'CD account number is required'
+ ]
+ ],
+
+ 'opening_bal' => [
+ 'rules' => 'required|numeric|greater_than_equal_to[0]',
+ 'errors' => [
+ 'required' => 'Opening amount is required',
+ 'numeric' => 'Opening amount must be numeric',
+ 'greater_than_equal_to' => 'Opening amount cannot be negative'
+ ]
+ ],
+ ];
+ if (!$this->validate($rules)) {
+ return $this->response->setStatusCode(400)->setJSON([
+ 'status' => false,
+ 'message' => 'Input validation failed',
+ 'code' => 400,
+ 'errors' => $this->validator->getErrors()
+ ]);
+ }
+ }
$this->myLogger->logme("error", 'Received POST data: ' . json_encode($data));
- $id = $sanitized_post_data['PrimaryKey'] ?? null;
$date = (string) ($sanitized_post_data['opening_date'] ?? '');
$sanitized_post_data['opening_date'] = date('Y-m-d', strtotime($date));
$this->myLogger->logme("error", 'Formatted opening_date: ' . $data['opening_date']);
diff --git a/app/Controllers/MediAssistApiController.php b/app/Controllers/MediAssistApiController.php
index 9ce9be18..0452c797 100644
--- a/app/Controllers/MediAssistApiController.php
+++ b/app/Controllers/MediAssistApiController.php
@@ -518,7 +518,7 @@ class MediAssistApiController extends BaseController
->getRowArray();
if (!$ticket) {
- return $this->response->setJSON(['status' => false,'message' => 'Invalid Claim ID' ]);
+ return ['status' => false,'message' => 'Invalid Claim ID' ];
}
// REQUEST BODY
@@ -548,8 +548,6 @@ class MediAssistApiController extends BaseController
}
-
-
// $body = [
// "policyNo" => "97000063250400000031",
// "startDate" => "01/11/2025",
@@ -568,11 +566,7 @@ class MediAssistApiController extends BaseController
if ($response['status'] != true || empty($response['data']['claimsData'][0])) {
log_message('error', 'CLAIM STATUS FAILED | for ticket ID: ' . $claimId.' | response: '.json_encode($response));
- return $this->response->setJSON([
- 'status' => false,
- 'message' => 'API call failed.',
- 'data' => $response
- ]);
+ return ['status' => false,'message' => 'API call failed.','data' => $response ];
}
// Extract claim status
@@ -634,12 +628,7 @@ class MediAssistApiController extends BaseController
// LOG UPDATE
log_message('error', "CLAIM STATUS SUCCESS | Updated ticket ID $claimId with claim status: $currentStatus");
- return $this->response->setJSON([
- 'status' => true,
- 'message' => 'Claim status updated.',
- 'updated_status' => $currentStatus,
- 'api_response' => $response
- ]);
+ return ['status' => true,'message' => 'Claim status updated.','updated_status' => $currentStatus,'api_response' => $response];
}
public function IRSubmission($claimId = null) // 585 this id for test
diff --git a/app/Controllers/NotificationController.php b/app/Controllers/NotificationController.php
index 0d85df18..8014f0c5 100755
--- a/app/Controllers/NotificationController.php
+++ b/app/Controllers/NotificationController.php
@@ -52,6 +52,7 @@ class NotificationController extends AdminController
// Create Or Update the Notification
public function createNotification()
{
+
$form_data['template_name'] = $this->camelCaseToSnakeCase($this->request->getPost('template_name'));
$form_data['subject'] = $this->request->getPost('subject');
$form_data['mail_content'] = $this->request->getPost('mailContent');
@@ -93,7 +94,8 @@ class NotificationController extends AdminController
'member_ecard_mail_btn',
'member_review_and_summary_mail_btn',
'account_maneger_summary_mail_btn',
- 'client_hr_summary_mail_btn'
+ 'client_hr_summary_mail_btn',
+ 'hr_cd_insufficient_balance_mail_btn',
];
$data = [];
$emptyTemplate = [];
diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php
index dc57d03f..592e7405 100644
--- a/app/Controllers/PolicyTransactionController.php
+++ b/app/Controllers/PolicyTransactionController.php
@@ -2273,6 +2273,9 @@
// print_r($data);
// die;
+ $file_data = $this->request->getFiles() ?? null;
+ $data['file_data'] = $file_data ?? null;
+
if (!isset($data['policy_with_corr'])) {
$data['policy_with_corr'] = 0;
} elseif ($data['policy_with_corr']) {
@@ -2416,6 +2419,11 @@
$this->handleCompletedStatus($data, $insert);
$this->insertOrUpdateCoShareDetails($data, $insert);
+ // policy file upload
+ if(isset($data['doc_name']) && isset($data['file_data']) && !empty($data['doc_name']) && !empty($data['file_data'])){
+ $this->uploadFile($data['doc_name'], $data['file_data'], $insert);
+ }
+
return $this->respond(['status' => true, 'message' => 'Endorsement transaction created successfully'], 200);
}
@@ -2688,6 +2696,20 @@
// dd(db_connect()->getLastQuery() ,$pt_bp_amt);
$data['base_cd_amount'] = $pt_bp_amt['amount'] ?? null;
+ $ptFileQuery = $this->PTFileModel
+ ->join('policy_transaction', 'pt_files.pt_id = policy_transaction.id')
+ ->where('pt_files.pt_id', $id)
+ ->where('pt_files.is_active', 1);
+
+ if (!in_array(get_role_id(), [1, 5]) && empty(array_intersect(user_team(), [MANAGEMENT_TEAM_ID, FINANCE_TEAM_ID, BUSINESS_TEAM_ID]))) {
+
+ if (get_role_id() == 4 && in_array(POS_TEAM_ID, user_team())) {
+ $ptFileQuery->where('pt_files.created_by', get_session_userid());
+ }
+ }
+
+ $data['pt_files'] = $ptFileQuery->findAll();
+
if ($data) {
return $this->respond(['status' => true, 'data' => $data, 'pt_id' => $pt_id], 200);
} else {
diff --git a/app/Controllers/TestingController.php b/app/Controllers/TestingController.php
index 75d4d578..f6769af2 100644
--- a/app/Controllers/TestingController.php
+++ b/app/Controllers/TestingController.php
@@ -17,6 +17,8 @@ use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Style\Fill;
use PhpOffice\PhpSpreadsheet\Style\Border;
+use Firebase\JWT\JWT;
+
class TestingController extends BaseController
{
use ResponseTrait;
@@ -983,5 +985,44 @@ class TestingController extends BaseController
}
+ public function metaDashboardDemo()
+ {
+
+ // 🔐 Move this to .env in real projects
+ $METABASE_SECRET_KEY = '6a9ec3d833576923ea04078188fe26cad17b5de351ab3ce349dd2c2d07b5d0cd';
+
+ $payload = [
+ 'resource' => [
+ 'dashboard' => 1
+ ],
+ 'params' => (object)[], // MUST be object for Metabase
+ 'exp' => time() + (10 * 60) // 10 minutes
+ ];
+
+ $token = JWT::encode($payload, $METABASE_SECRET_KEY, 'HS256');
+
+ // // You can either return token only
+ // return $this->response->setJSON([
+ // 'token' => $token,
+ // 'iframe_url' => "https://your-metabase-domain/embed/dashboard/{$token}#bordered=true&titled=true"
+ // ]);
+ if($this->request->getGet('api') == 1)
+ {
+ return $this->respond([
+ 'status' => 'success',
+ 'message' => 'Form data received successfully!',
+ 'data' => [
+ 'metabaseToken' => $token,
+ 'metabaseUrl' => 'https://nsights.nhanceindia.in']
+ ]);
+ }
+
+ return view('meta_dashboard_demo_one', [
+ 'metabaseToken' => $token,
+ 'metabaseUrl' => 'https://nsights.nhanceindia.in',
+ ]);
+ }
+
+
}
diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php
index 1dbe0636..abb02e17 100644
--- a/app/Controllers/TicketController.php
+++ b/app/Controllers/TicketController.php
@@ -1151,9 +1151,9 @@ class TicketController extends BaseController
'errors' => ['required' => 'Employee Email is required']
],
- 'client_name' => [
+ 'client_id' => [
'rules' => 'required',
- 'errors' => ['required' => 'Client Name is required']
+ 'errors' => ['required' => 'Client ID is required']
],
'insurer_id' => [
@@ -1335,9 +1335,9 @@ class TicketController extends BaseController
'errors' => ['required' => 'Employee Email is required']
],
- 'client_name' => [
+ 'client_id' => [
'rules' => 'required',
- 'errors' => ['required' => 'Client Name is required']
+ 'errors' => ['required' => 'Client ID is required']
],
'insurer_id' => [
diff --git a/app/Controllers/TicketServiceController.php b/app/Controllers/TicketServiceController.php
index 14c1b19a..602f0708 100644
--- a/app/Controllers/TicketServiceController.php
+++ b/app/Controllers/TicketServiceController.php
@@ -9,6 +9,11 @@ use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use Kint\Kint;
use App\Libraries\TpaClaimsImportFactory;
use App\Libraries\TPAClaimsImportServices\FhplClaimImportService;
+use App\Libraries\TPAClaimsImportServices\MediAssistClaimImportService;
+use App\Libraries\TPAClaimsImportServices\AbhiClaimImportService;
+use App\Libraries\TPAClaimsImportServices\RcareClaimImportService;
+use App\Libraries\TPAClaimsImportServices\VidalClaimImportService;
+use App\Libraries\TPAClaimsImportServices\IciciClaimImportService;
use App\Libraries\TPAClaimsImportServices\BaseTpaClaimImportService;
use App\Models\ClaimDumpFileModel;
@@ -1858,23 +1863,21 @@ class TicketServiceController extends BaseController
public function tpaClaimDumpImporter($params)
{
- try {
+ $file_id = $params['file_id'] ?? null; // Move outside try to ensure catch can see it
- $file_id = $params['file_id'] ?? null;
- $file_path = WRITEPATH . 'uploads/claim_dump_excel/';
+ try {
+ $file_path = WRITEPATH . 'uploads' . DIRECTORY_SEPARATOR . 'claim_dump_excel' . DIRECTORY_SEPARATOR;
if (!$file_id) {
return ['status' => false, 'message' => 'File ID is missing'];
}
- $fileData = $this->claimDumpFileModel->where('id', $file_id)->first();
-
+ $fileData = $this->claimDumpFileModel->find((int)$file_id);
if (!$fileData) {
return ['status' => false, 'message' => 'Invalid file ID. No file data found'];
}
$file_full_path = $file_path . $fileData['file_name'];
-
if (!is_file($file_full_path)) {
return ['status' => false, 'message' => 'Claim dump file not found'];
}
@@ -1882,106 +1885,97 @@ class TicketServiceController extends BaseController
$handler = TpaClaimsImportFactory::make($fileData['tpa_id'] ?? 0);
$result = $handler->runTpaClaimDumpInsert($file_full_path, $file_id);
- // ---------- Prepare update data ----------
- $data = [];
-
if (!empty($result['status']) && $result['status'] === true) {
- $data['status'] = 'success';
- $data['reason'] = null;
+ Jobs::addJob(['job_name' => 'tpaClaimDumpToTicketMasterImporters', 'payload' => ['file_id' => $file_id]]);
} else {
- $data['status'] = 'failed';
-
- $errorMessage = $result['message'] ?? 'Unknown import error';
-
- $reason = [
- 'error_summary' => array_count_values([5]),
- 'error_data' => $errorMessage
- ];
-
- $data['reason'] = json_encode($reason, JSON_UNESCAPED_UNICODE);
- }
-
- // dd($data);
- // ---------- Update DB ----------
- $sql = "UPDATE claim_dump_files SET status = ?, reason = ? WHERE id = ?";
-
- $updated = db_connect()->query(
- $sql,
- [
- $data['status'] ?? null,
- $data['reason'] ?? null,
- $file_id
- ]
- );
-
- if (!$updated) {
- $this->myLogger->logme('error', 'Claim dump file update failed for file_id: ' . $file_id);
- }
-
- dd(db_connect()->getLastQuery()->getQuery());
-
- if(!empty($result['status']) && $result['status'] === true){
- $r = Jobs::addJob(['job_name' => 'tpaClaimDumpToTicketMasterImporters', 'payload' => ['file_id' => $file_id]]);
+ // FORCE FAIL LOGIC
+ $this->markAsFailed($file_id, $result['message'] ?? 'System error contact admin', $fileData['created_by'] ?? null);
}
return $result;
-
} catch (\Throwable $th) {
+ $this->myLogger->logme("error", 'TPA_CLAIM_IMPORTER_JOB : ' . $th->getMessage());
- $this->myLogger->logme(
- "error",
- 'TPA_CLAIM_IMPORTER_JOB : ' .
- $th->getMessage() . ' | Line: ' . $th->getLine()
- );
+ if (!empty($file_id)) {
+ $this->markAsFailed($file_id, 'System error contact admin');
+ }
return [
'status' => false,
'message' => 'TPA Claim dump import failed',
- 'error_data' => [
- 'message' => $th->getMessage(),
- 'file' => $th->getFile(),
- 'line' => $th->getLine(),
- 'trace' => $th->getTraceAsString()
- ]
+ 'error_data' => $th->getMessage()
];
}
}
+ private function markAsFailed($file_id, $message, $user_id = null)
+ {
+ $reason = json_encode([
+ 'error_summary' => [5 => 1],
+ 'error_data' => $message
+ ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
+
+ $data = [
+ 'status' => 'failed',
+ 'reason' => $reason,
+ 'updated_by' => $user_id
+ ];
+
+ // Using the direct update(id, data) method is often more reliable inside try/catch
+ return $this->claimDumpFileModel->update($file_id, $data);
+ }
+
public function tpaClaimDumpToTicketMasterImporters($params)
{
- try {
+ $file_id = $params['file_id'] ?? null;
+ $fileData = null;
+
+ try {
+ if (!$file_id) {
+ return ['status' => false, 'message' => 'File ID is missing'];
+ }
- $file_id = $params['file_id'] ?? null;
$fileData = $this->claimDumpFileModel->where('id', $file_id)->first();
if (!$fileData) {
- return ['status' => false, 'message' => 'Invalid file ID No file data found to import'];
+ return ['status' => false, 'message' => 'Invalid file ID. No file data found to import'];
}
$handler = TpaClaimsImportFactory::make($fileData['tpa_id'] ?? 0);
$result = $handler->runTicketMasterInsert($params);
+ if (!empty($result['status']) && $result['status'] === true) {
+ // Success: Update the status to success
+ $this->claimDumpFileModel->update($file_id, [
+ 'status' => 'success',
+ 'reason' => null
+ ]);
+ } else {
+ // Logic failure: The runTicketMasterInsert returned status false
+ $this->markAsFailed(
+ $file_id,
+ $result['message'] ?? 'System error contact admin',
+ $fileData['created_by'] ?? null
+ );
+ }
+
return $result;
-
} catch (\Throwable $th) {
+ // Log the full error
+ $this->myLogger->logme("error", 'TICKET_MASTER_CLAIM_IMPORTER_JOB :' . $th->getMessage() . ' at line ' . $th->getLine());
- $this->myLogger->logme("error", 'TICKET_MASTER_CLAIM_IMPORTER_JOB :' .($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,
- ];
+ // CRITICAL: Even if the code crashes, try to mark the file as failed
+ if ($file_id) {
+ $this->markAsFailed($file_id, 'Fatal Crash: ' . $th->getMessage(), $fileData['created_by'] ?? null);
+ }
return [
'status' => false,
'message' => $th->getMessage(),
- 'error_data' => json_encode($errorData, JSON_PRETTY_PRINT)
+ 'error_data' => [
+ 'line' => $th->getLine(),
+ 'file' => $th->getFile()
+ ]
];
}
}
diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php
index daaadb9f..d2a32ac1 100755
--- a/app/Controllers/UserController.php
+++ b/app/Controllers/UserController.php
@@ -114,13 +114,11 @@ class UserController extends AdminController
// Employee Code
// ======================
'emp_code' => [
- 'rules' => 'required|alpha_numeric|min_length[3]|max_length[20]|is_unique[user_profiles.emp_code,id,{PrimaryKey}]',
+ 'rules' => 'required|min_length[3]|max_length[15]',
'errors' => [
'required' => 'Employee Code is required',
- 'alpha_numeric' => 'Employee Code must be alphanumeric',
'min_length' => 'Employee Code must be at least 3 characters',
- 'max_length' => 'Employee Code cannot exceed 20 characters',
- 'is_unique' => 'Employee Code already exists'
+ 'max_length' => 'Employee Code cannot exceed 15 characters',
]
],
@@ -141,11 +139,10 @@ class UserController extends AdminController
// Email
// ======================
'email' => [
- 'rules' => 'required|valid_email|is_unique[user_profiles.email,id,{PrimaryKey}]',
+ 'rules' => 'required|valid_email',
'errors' => [
'required' => 'Email is required',
'valid_email' => 'Please enter a valid email address',
- 'is_unique' => 'Email already exists'
]
],
@@ -153,11 +150,10 @@ class UserController extends AdminController
// Mobile
// ======================
'mobile' => [
- 'rules' => 'required|regex_match[/^[6-9][0-9]{9}$/]|is_unique[user_profiles.mobile,id,{PrimaryKey}]',
+ 'rules' => 'required|regex_match[/^[6-9][0-9]{9}$/]',
'errors' => [
'required' => 'Mobile number is required',
'regex_match' => 'Enter a valid 10-digit mobile number starting with 6, 7, 8, or 9',
- 'is_unique' => 'Mobile number already exists'
]
],
@@ -302,13 +298,11 @@ class UserController extends AdminController
// Employee Code
// ======================
'emp_code' => [
- 'rules' => 'required|alpha_numeric|min_length[3]|max_length[20]|is_unique[user_profiles.emp_code,id,{PrimaryKey}]',
+ 'rules' => 'required|min_length[3]|max_length[15]',
'errors' => [
'required' => 'Employee Code is required',
- 'alpha_numeric' => 'Employee Code must be alphanumeric',
'min_length' => 'Employee Code must be at least 3 characters',
- 'max_length' => 'Employee Code cannot exceed 20 characters',
- 'is_unique' => 'Employee Code already exists'
+ 'max_length' => 'Employee Code cannot exceed 15 characters',
]
],
@@ -329,11 +323,10 @@ class UserController extends AdminController
// Email
// ======================
'email' => [
- 'rules' => 'required|valid_email|is_unique[user_profiles.email,id,{PrimaryKey}]',
+ 'rules' => 'required|valid_email',
'errors' => [
'required' => 'Email is required',
'valid_email' => 'Please enter a valid email address',
- 'is_unique' => 'Email already exists'
]
],
@@ -341,11 +334,10 @@ class UserController extends AdminController
// Mobile
// ======================
'mobile' => [
- 'rules' => 'required|regex_match[/^[6-9][0-9]{9}$/]|is_unique[user_profiles.mobile,id,{PrimaryKey}]',
+ 'rules' => 'required|regex_match[/^[6-9][0-9]{9}$/]',
'errors' => [
'required' => 'Mobile number is required',
'regex_match' => 'Enter a valid 10-digit mobile number starting with 6, 7, 8, or 9',
- 'is_unique' => 'Mobile number already exists'
]
],
diff --git a/app/Controllers/VidalApiController.php b/app/Controllers/VidalApiController.php
index 0c0bc293..f84364a9 100644
--- a/app/Controllers/VidalApiController.php
+++ b/app/Controllers/VidalApiController.php
@@ -254,8 +254,8 @@ class VidalApiController extends BaseController
if($response['data']['status'] == 'SUCCESS')
{
- $claimNO = $response['data']['data']['claimNO'] ?? null;
- $claimInwardNO = $response['data']['data']['claimInwardNO'] ?? null;
+ $claimNO = $response['data']['data']['claimNo'] ?? null;
+ $claimInwardNO = $response['data']['data']['claimInwardNo'] ?? null;
if(!empty($claimNO) && !empty($claimInwardNO)){
@@ -263,7 +263,7 @@ class VidalApiController extends BaseController
$this->db->table('ticket_master')
->where('id',$claimId)
- ->update([ 'tpa_claim_push_reference_no' => $claimInwardNO , 'tpa_claim_id' => $claimNO ]);
+ ->update([ 'tpa_claim_push_reference_no' => $claimInwardNO , 'tpa_claim_id' => $claimNO , 'claim_number' => $claimNO ]);
return;
@@ -442,7 +442,7 @@ class VidalApiController extends BaseController
->getRowArray();
if (!$ticket) {
- return $this->response->setJSON(['status' => false,'message' => 'Invalid Claim ID' ]);
+ return ['status' => false,'message' => 'Invalid Claim ID' ];
}
$body = [];
@@ -467,11 +467,7 @@ class VidalApiController extends BaseController
if ($response['status'] != true || empty($response['data']['data']['claims'][0])) {
log_message('error', 'CLAIM STATUS FAILED | for ticket ID: ' . $claimId.' | response: '.json_encode($response));
- return $this->response->setJSON([
- 'status' => false,
- 'message' => 'API call failed.',
- 'data' => $response
- ]);
+ return ['status' => false, 'message' => 'API call failed.','data' => $response];
}
// Extract claim status
@@ -504,12 +500,7 @@ class VidalApiController extends BaseController
// LOG UPDATE
log_message('error', "CLAIM STATUS SUCCESS | Updated ticket ID $claimId with claim status: $currentStatus");
- return $this->response->setJSON([
- 'status' => true,
- 'message' => 'Claim status updated.',
- 'updated_status' => $currentStatus,
- 'api_response' => $response
- ]);
+ return ['status' => true,'message' => 'Claim status updated.','updated_status' => $currentStatus,'api_response' => $response];
}
public function ClaimStatusUpdate()
@@ -804,7 +795,7 @@ class VidalApiController extends BaseController
//call a job for dump JSON data to DB
$job_details = new Jobs();
- $r = Jobs::addJob(['job_name' => 'saveMediAssitAPIData', 'payload' => [ 'file_id' => $requestData['file_id'],'json_file_path' => $filePath ]]);
+ $r = Jobs::addJob(['job_name' => 'saveVidalAPIData', 'payload' => [ 'file_id' => $requestData['file_id'],'json_file_path' => $filePath ]]);
// now update DB
diff --git a/app/Filters/AuthMVC.php b/app/Filters/AuthMVC.php
index 298a72b9..ef2da046 100755
--- a/app/Filters/AuthMVC.php
+++ b/app/Filters/AuthMVC.php
@@ -23,11 +23,11 @@ class AuthMVC implements FilterInterface
// }
// Fingerprint validation
- // $fp = generateFingerprint();
- // // log_message('error',$fp);
- // if (session()->get('fingerprint') !== $fp) {
- // return AuthLogout::logout();
- // }
+ $fp = generateFingerprint();
+ // log_message('error',$fp);
+ if (session()->get('fingerprint') !== $fp) {
+ return AuthLogout::logout();
+ }
}
diff --git a/app/Filters/GlobalPostFileUploadGuard.php b/app/Filters/GlobalPostFileUploadGuard.php
index 4cc82ba8..76117240 100644
--- a/app/Filters/GlobalPostFileUploadGuard.php
+++ b/app/Filters/GlobalPostFileUploadGuard.php
@@ -39,7 +39,7 @@ class GlobalPostFileUploadGuard implements FilterInterface
];
protected array $blockedExtensions = [
- 'php', 'phtml', 'pht', 'phar', 'php3', 'php4', 'php5', 'php7', 'php8', 'phps',
+ 'php', 'phtml', 'html', 'pht', 'phar', 'php3', 'php4', 'php5', 'php7', 'php8', 'phps',
'cgi', 'fcgi', 'pl', 'py', 'rb', 'lua', 'tcl', 'go', 'rs', 'jar', 'class',
'exe', 'dll', 'com', 'bat', 'cmd', 'msi', 'vbs', 'ps1', 'scr',
'sh', 'bash', 'zsh', 'apk', 'app', 'deb', 'rpm', 'bin', 'run',
@@ -100,7 +100,7 @@ class GlobalPostFileUploadGuard implements FilterInterface
}
// --- 2. Double Extension Attack Check ---
- if (preg_match('/\.(php|phtml|phar|exe|sh|bat|cmd|js|jsp|asp|aspx|py|pl)\./i', $originalName)) {
+ if (preg_match('/\.(php|html|phtml|phar|exe|sh|bat|cmd|js|jsp|asp|aspx|py|pl)\./i', $originalName)) {
$this->block("Double extension attack", $clientIp, $uri, $inputName, $originalName, $mime, $extension, $size);
}
diff --git a/app/Helpers/DepositHelper.php b/app/Helpers/DepositHelper.php
index 495797f3..05521df4 100755
--- a/app/Helpers/DepositHelper.php
+++ b/app/Helpers/DepositHelper.php
@@ -67,7 +67,8 @@ class DepositHelper
'balance' => $newBalance, // Include the new balance in the data array
'cd_ac_pk'=> isset($data['cd_ac_pk'])?$data['cd_ac_pk']:null,
'record_date' => $data['record_date'] ?? null,
- 'policy_transaction_id' => $data['pt_id'] ?? null
+ 'policy_transaction_id' => $data['pt_id'] ?? null,
+ 'file_id' => $data['file_id'],
];
// Insert data and get the insert ID
diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php
index db769589..5b5d6b7b 100755
--- a/app/Helpers/excel_util_helper.php
+++ b/app/Helpers/excel_util_helper.php
@@ -3173,6 +3173,13 @@ if (!function_exists('check_rto_data')) {
$vehicle_no = strtoupper(trim($row[2])); // Example: TN10AB1234
$new_vehicle = strtolower(trim($row[2]));
+ if(!validate_indian_vehicle_number($vehicle_no)['status']){
+ return [
+ 'status' => false,
+ 'error' => 'Invalid Vehicle Number. Format should be like TN82AX2024 (no spaces or special characters).'
+ ];
+ };
+
// BH Series: 22BH1234AA
$bhPattern = '/^[0-9]{2}BH[0-9]{4}[A-Z]{2}$/';
diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php
index cc46a3cd..5327f8d5 100755
--- a/app/Helpers/sendMailNotification.php
+++ b/app/Helpers/sendMailNotification.php
@@ -116,6 +116,21 @@ class sendMailNotification
$tpa_id = $params['tpa_id'];
$common = $params['common'];
+ $mailAttachmentModel = new MailAttachmentModel();
+ $attachment_data = $mailAttachmentModel
+ ->select('file_path, file_name')
+ ->where('notification_id', $notification['id'])
+ ->where('is_active', 1)
+ ->findAll();
+
+ $attachments = [];
+ foreach ($attachment_data as $data) {
+ $attachments[] = [
+ "filePath" => WRITEPATH . $data['file_path'],
+ "fileName" => $data['file_name']
+ ];
+ }
+
$mail_content = $notification['mail_content'];
$mail = $get_emp_email_and_other_details['email_corporate'];
@@ -160,7 +175,7 @@ class sendMailNotification
$mail_content = view('mail_template', $data);
- $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'common' => $common];
+ $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'],'attachments' => $attachments, 'reply_to' => $client_data['reply_to'], 'common' => $common];
return $wholeData;
diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php
index 79e4ddf9..178ec18a 100755
--- a/app/Helpers/utility_helper.php
+++ b/app/Helpers/utility_helper.php
@@ -947,21 +947,37 @@ if (!function_exists('validateExcelFile')) {
function validateExcelFile($file)
{
- $allowed = [
+ // 1. Check if the file was uploaded without errors
+ if (! $file->isValid() || $file->hasMoved()) {
+ return false;
+ }
+
+ // 2. Size check (16MB)
+ if ($file->getSizeByUnit('mb') > 16) {
+ return false;
+ }
+
+ // 3. Define allowed types
+ $allowedMimes = [
'application/vnd.ms-excel',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
- 'application/vnd.oasis.opendocument.spreadsheet'
+ 'application/vnd.oasis.opendocument.spreadsheet',
+ 'application/zip',
+ 'application/octet-stream'
];
- // if ($file->getError() !== UPLOAD_ERR_OK) return 'Upload error';
- // if ($file->getSize() > (16 * 1024 * 1024)) return 'File too large';
- // if (!in_array($file->getClientMimeType(), $allowed, true)) return 'Invalid file type';
-
- if ($file->getError() !== UPLOAD_ERR_OK) return false;
- if ($file->getSize() > (16 * 1024 * 1024)) return false;
- if (!in_array($file->getClientMimeType(), $allowed, true)) return false;
+ $allowedExtensions = ['xls', 'xlsx', 'ods', 'xlsm'];
- return true;
+ // Get the actual values using CI4 methods
+ $mime = $file->getClientMimeType();
+ $extension = $file->getExtension(); // This is the CI4 method
+
+ // 4. Validate
+ if (in_array($mime, $allowedMimes) || in_array($extension, $allowedExtensions)) {
+ return true;
+ }
+
+ return false;
}
}
@@ -1101,3 +1117,34 @@ if (!function_exists('convertGoogleDriveToDownloadLink')) {
}
}
+if (!function_exists('get_cd_balance')) {
+ function get_cd_balance(): array
+ {
+ $session = session();
+
+ return [
+ 'has_cd_balance' => $session->has('cd_balance'),
+ 'cd_balance' => $session->get('cd_balance') ?? null,
+ 'hr_data' => $session->get('hr_data') ?? [],
+ 'cd_balance_info' => $session->get('cd_balance_info') ?? [],
+ ];
+ }
+}
+
+if (!function_exists('clear_cd_balance_session')) {
+ function clear_cd_balance_session(): void
+ {
+ $session = session();
+
+ $session->remove('cd_balance');
+ $session->remove('hr_data');
+ $session->remove('cd_balance_info');
+
+ log_message('error', 'clear_cd_balance_session clered');
+ }
+}
+
+
+
+
+
diff --git a/app/Libraries/TPAClaimsImportServices/AbhiClaimImportService.php b/app/Libraries/TPAClaimsImportServices/AbhiClaimImportService.php
index 21818613..1f9837b9 100644
--- a/app/Libraries/TPAClaimsImportServices/AbhiClaimImportService.php
+++ b/app/Libraries/TPAClaimsImportServices/AbhiClaimImportService.php
@@ -114,6 +114,8 @@ class AbhiClaimImportService extends BaseTpaClaimImportService
// Misc
'diagnosis' => 'claim_description',
'healthcard_id' => 'tpa_no',
+ 'claim_type' => 'tpa_claim_type',
+
];
protected $statusMapping = [
@@ -174,9 +176,7 @@ class AbhiClaimImportService extends BaseTpaClaimImportService
}
$ticketMasterModel = new TicketMasterModel();
- $ticketMasterModel->insertBatch($data);
-
- return true;
+ return $ticketMasterModel->insertBatch($data);
}
@@ -187,9 +187,7 @@ class AbhiClaimImportService extends BaseTpaClaimImportService
}
$builder = $this->db->table('claims_dump_abhi');
- $builder->insertBatch($data);
-
- return true;
+ return $builder->updateBatch($data, 'id');
}
@@ -200,9 +198,7 @@ class AbhiClaimImportService extends BaseTpaClaimImportService
}
$builder = $this->db->table('claims_dump_abhi');
- $builder->insertBatch($data);
-
- return true;
+ return $builder->updateBatch($data, 'id');
}
@@ -307,7 +303,7 @@ class AbhiClaimImportService extends BaseTpaClaimImportService
if ($isduplicate) {
$reason = "This claim already exists in our system.";
- $rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
+ $rejecetd_reason[] = ["id" => $row['id'], "master_reject_reason" => $reason];
continue;
}
@@ -326,23 +322,15 @@ class AbhiClaimImportService extends BaseTpaClaimImportService
if (!empty($employee_data)) {
$item['emp_id'] = $employee_data['id'] ?? null;
$item['emp_name'] = $employee_data['name'] ?? null;
+ $item['emp_code'] = $employee_data['emp_code'] ?? null;
$item['emp_mail'] = $employee_data['email_corporate'] ?? null;
$item['emp_mobile'] = $employee_data['mobile'] ?? null;
$item['insured_emp_id'] = $employee_data['insured_emp_id'] ?? null;
$item['insured_name'] = $employee_data['insured_name'] ?? null;
} else {
- $reason = sprintf(
- 'The policy number "%s" does not exist in our system. ' .
- 'Details - Client ID: %s, Client Policy ID: %s, Employee Number: %s, Relationship: %s',
- $row['insurer_policy_number'],
- $file_data['client_id'],
- $file_data['client_policy_id'],
- $row['employee_number'],
- $item['relationship']
- );
-
- $rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
+ $reason = 'This employee not exist in our system.';
+ $rejecetd_reason[] = ["id" => $row['id'], "master_reject_reason" => $reason];
continue;
}
diff --git a/app/Libraries/TPAClaimsImportServices/BaseTpaClaimImportService.php b/app/Libraries/TPAClaimsImportServices/BaseTpaClaimImportService.php
index 1485dee2..d2b715cc 100644
--- a/app/Libraries/TPAClaimsImportServices/BaseTpaClaimImportService.php
+++ b/app/Libraries/TPAClaimsImportServices/BaseTpaClaimImportService.php
@@ -27,79 +27,49 @@ abstract class BaseTpaClaimImportService
*/
public function runTpaClaimDumpInsert(string $filePath, int $fileId): array
{
- $this->db->transStart();
+ // 1. Start Transaction
+ $this->db->transBegin();
- $fileData = $this->claimDumpFileModel->where('id', $fileId)->first();
+ try {
+ $fileData = $this->claimDumpFileModel->where('id', $fileId)->first();
- if (env('FHPL_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
- $rows = $this->readExcelBySheetName($filePath, 'Claims&Preauth');
- } else if (env('R_CARE_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
- $rows = $this->readExcelBySheetName($filePath, 'CL');
- // $AL = $this->readExcelBySheetName($filePath, 'AL');
- // $rows = array_merge($CL, $AL);
- } else {
- $rows = $this->readExcel($filePath);
- }
- // dd($rows);
+ // Determine sheet name logic...
+ if (env('FHPL_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
+ $rows = $this->readExcelBySheetName($filePath, 'Claims&Preauth');
+ } else if (env('R_CARE_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
+ $rows = $this->readExcelBySheetName($filePath, 'CL');
+ } else {
+ $rows = $this->readExcel($filePath);
+ }
- if (empty($rows)) {
- return ['status' => false, 'message' => 'Excel file contains no data or wrong file upload'];
- }
+ if (empty($rows)) {
+ $this->db->transRollback(); // ROLLBACK BEFORE RETURN
+ return ['status' => false, 'message' => 'Excel file contains no data or wrong file upload'];
+ }
- $tpaInsertData = $this->mapTPAData($rows, $fileId);
- // dd($tpaInsertData);
+ $tpaInsertData = $this->mapTPAData($rows, $fileId);
- if (empty($tpaInsertData)) {
- return ['status' => false, 'message' => 'These records already exist in the system.'];
- }
+ if (empty($tpaInsertData)) {
+ $this->db->transRollback(); // ROLLBACK BEFORE RETURN
+ return ['status' => false, 'message' => 'These records already exist in the system.'];
+ }
- if (env('FHPL_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
- $ClaimsDumpFhplModel = $this->db->table('claims_dump_fhpl');
- $return_res = $ClaimsDumpFhplModel->insertBatch($tpaInsertData);
- } else if (env('R_CARE_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
- $ClaimsDumpIciciModel = $this->db->table('claims_dump_reliance');
- $return_res = $ClaimsDumpIciciModel->insertBatch($tpaInsertData);
- } else if (env('ICICI_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
- $ClaimsDumpIciciModel = $this->db->table('claims_dump_icici');
- $return_res = $ClaimsDumpIciciModel->insertBatch($tpaInsertData);
- } else if (env('ABHI_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
- // $ClaimsDumpAbhiModel = $this->db->table('claims_dump_abhi');
- // $return_res = $ClaimsDumpAbhiModel->insertBatch($tpaInsertData);
$return_res = $this->bulkInsertTPATable($tpaInsertData);
- } else if (env('VIDAL_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
- $ClaimsDumpVidalModel = $this->db->table('claims_dump_vidal');
- $return_res = $ClaimsDumpVidalModel->insertBatch($tpaInsertData);
- } else if (env('MEDI_ASSIST_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
- $ClaimsDumpMediAssistModel = $this->db->table('claims_dump_medi_assist');
- $return_res = $ClaimsDumpMediAssistModel->insertBatch($tpaInsertData);
- } else{
+ if ($return_res !== true) {
+ $this->db->transRollback(); // ROLLBACK BEFORE RETURN
+ return ['status' => false, 'message' => 'TPA Import bulk insert failed'];
+ }
+
+ // 2. Commit if everything is fine
+ $this->db->transCommit();
+ return ['status' => true, 'message' => 'File uploaded successfully', 'record_count' => count($tpaInsertData)];
+
+ } catch (\Throwable $e) {
+ // 3. Rollback on any crash/exception
+ $this->db->transRollback();
+ return ['status' => false, 'message' => 'System error : ' . $e->getMessage()];
}
-
- // $return_res = $this->bulkInsertTPATable($tpaInsertData);
-
- if (!$return_res) {
- return ['status' => false, 'message' => 'TPA Import bulk insert failed'];
- }
-
- $this->db->transComplete();
-
- if ($this->db->transStatus() === false) {
-
- $error = $this->db->error();
-
- $error_data = [
- 'message' => $error['message'] ?: 'Unknown DB error',
- 'code' => $error['code'] ?? null,
- 'last_query' => (string) $this->db->getLastQuery()
- ];
-
- // dd($error_data);
- // unset($error_data['last_query']);
- return ['status' => false, 'message' => 'TPA Import transaction failed', 'error_data' => $error_data];
- }
-
- return ['status' => true, 'message' => 'File uploaded successfully', 'record_count' => count($tpaInsertData ?? [])];
}
/**
@@ -107,34 +77,65 @@ abstract class BaseTpaClaimImportService
*/
public function runTicketMasterInsert(array $params): array
{
- $this->db->transStart();
+ // 1. Start manual transaction
+ $this->db->transBegin();
- $file_id = $params['file_id'];
+ try {
+ $file_id = $params['file_id'];
+ $ticketMasterData = $this->mapClaimMasterData($file_id);
- $ticketMasterData = $this->mapClaimMasterData($file_id);
+ // Check if mapping failed
+ if (!$ticketMasterData['status']) {
+ $this->db->transRollback(); // ALWAYS rollback before early return
+ return $ticketMasterData;
+ }
- if (!$ticketMasterData['status']) {
- return $ticketMasterData;
+ $message = '';
+ $hasExecutedTask = false;
+
+ // Process Mapped Data
+ if (!empty($ticketMasterData['mapped_array'])) {
+ $insert_res = $this->importClaimMaster($ticketMasterData['mapped_array']);
+ if (!$insert_res) {
+ $this->db->transRollback();
+ return ['status' => false, 'message' => 'Ticket Master Claim bulk insert failed'];
+ }
+ $message .= 'Ticket Master Claim bulk insert success. ';
+ $hasExecutedTask = true;
+ }
+
+ // Process Rejected Reasons
+ if (!empty($ticketMasterData['rejected_reason_array'])) {
+ $update_res = $this->updateTicketMasterRejectedReasonInTPATable($ticketMasterData['rejected_reason_array']);
+ if (!$update_res) {
+ $this->db->transRollback();
+ return ['status' => false, 'message' => 'Updating rejected reasons failed'];
+ }
+
+ $message .= empty($ticketMasterData['mapped_array'])
+ ? 'Those employees not in our system. '
+ : 'Ticket Master Claim rejected reason updated successfully. ';
+ $hasExecutedTask = true;
+ }
+
+ // If nothing was processed but no error occurred
+ if (!$hasExecutedTask) {
+ $this->db->transRollback();
+ return ['status' => false, 'message' => 'No data found to process.'];
+ }
+
+ // 2. Commit the transaction
+ $this->db->transCommit();
+ return ['status' => true, 'message' => trim($message)];
+
+ } catch (\Throwable $th) {
+ // 3. Rollback on crash
+ $this->db->transRollback();
+ return [
+ 'status' => false,
+ 'message' => 'System error during Ticket Master Insert: ' . $th->getMessage()
+ ];
}
-
- $return_res = $this->importClaimMaster($ticketMasterData['mapped_array']);
-
- if(!$return_res){
- return ['status' => false, 'message' => 'Ticket Master Claim bulk insert failed'];
- }
-
- $this->updateTicketMasterRejectedReasonInTPATable($ticketMasterData['rejected_reason_array']);
-
- $this->db->transComplete();
-
- if ($this->db->transStatus() === false) {
- return ['status' => false, 'message' => 'Ticket Master Claim bulk insert failed'];
- }
-
-
-
- return ['status' => true, 'message' => 'Ticket Master Claim inserted successfully'];
-
}
/**
@@ -278,6 +279,7 @@ abstract class BaseTpaClaimImportService
->where('is_active', 1)
->where('file_id', $params['file_id'])
->where('ticket_id IS NULL')
+ ->where('master_reject_reason IS NULL')
->countAllResults();
$batch_size = 100;
@@ -291,6 +293,7 @@ abstract class BaseTpaClaimImportService
->where('is_active', 1)
->where('file_id', $params['file_id'])
->where('ticket_id IS NULL')
+ ->where('master_reject_reason IS NULL')
->get()
->getResultArray();
@@ -308,6 +311,7 @@ abstract class BaseTpaClaimImportService
'employees.email_corporate AS emp_mail',
'employees.mobile AS emp_mobile',
'employees.name AS emp_name',
+ 'employees.emp_code AS emp_code',
// insured employee
'insured.id AS insured_emp_id',
diff --git a/app/Libraries/TPAClaimsImportServices/FhplClaimImportService.php b/app/Libraries/TPAClaimsImportServices/FhplClaimImportService.php
index 72614418..58dd1282 100644
--- a/app/Libraries/TPAClaimsImportServices/FhplClaimImportService.php
+++ b/app/Libraries/TPAClaimsImportServices/FhplClaimImportService.php
@@ -177,10 +177,7 @@ class FhplClaimImportService extends BaseTpaClaimImportService
// Payment
'cheque_no' => 'utr_details',
'uhid_no' => 'tpa_no',
-
- 'priority' => 1,
- 'mode_of_intimation' => 5,
- 'ticket_type_id' => 1,
+ 'claim_type' => 'tpa_claim_type',
];
protected $statusMapping = [
@@ -239,9 +236,7 @@ class FhplClaimImportService extends BaseTpaClaimImportService
}
$ticketMasterModel = new TicketMasterModel();
- $ticketMasterModel->insertBatch($data);
-
- return true;
+ return $ticketMasterModel->insertBatch($data);
}
@@ -252,9 +247,7 @@ class FhplClaimImportService extends BaseTpaClaimImportService
}
$builder = $this->db->table('claims_dump_fhpl');
- $builder->insertBatch($data);
-
- return true;
+ return $builder->updateBatch($data, 'id');
}
@@ -265,9 +258,7 @@ class FhplClaimImportService extends BaseTpaClaimImportService
}
$builder = $this->db->table('claims_dump_fhpl');
- $builder->insertBatch($data);
-
- return true;
+ return $builder->updateBatch($data, 'id');
}
@@ -372,7 +363,7 @@ class FhplClaimImportService extends BaseTpaClaimImportService
if ($isduplicate) {
$reason = "This claim already exists in our system.";
- $rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
+ $rejecetd_reason[] = ["id" => $row['id'], "master_reject_reason" => $reason];
continue;
}
@@ -391,23 +382,15 @@ class FhplClaimImportService extends BaseTpaClaimImportService
if (!empty($employee_data)) {
$item['emp_id'] = $employee_data['id'] ?? null;
$item['emp_name'] = $employee_data['name'] ?? null;
+ $item['emp_code'] = $employee_data['emp_code'] ?? null;
$item['emp_mail'] = $employee_data['email_corporate'] ?? null;
$item['emp_mobile'] = $employee_data['mobile'] ?? null;
$item['insured_emp_id'] = $employee_data['insured_emp_id'] ?? null;
$item['insured_name'] = $employee_data['insured_name'] ?? null;
} else {
- $reason = sprintf(
- 'The policy number "%s" does not exist in our system. ' .
- 'Details - Client ID: %s, Client Policy ID: %s, Employee Number: %s, Relationship: %s',
- $row['insurer_policy_number'],
- $file_data['client_id'],
- $file_data['client_policy_id'],
- $row['employee_number'],
- $item['relationship']
- );
-
- $rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
+ $reason = 'This employee not exist in our system.';
+ $rejecetd_reason[] = ["id" => $row['id'], "master_reject_reason" => $reason];
continue;
}
diff --git a/app/Libraries/TPAClaimsImportServices/IciciClaimImportService.php b/app/Libraries/TPAClaimsImportServices/IciciClaimImportService.php
index b89221ae..f2717fd5 100644
--- a/app/Libraries/TPAClaimsImportServices/IciciClaimImportService.php
+++ b/app/Libraries/TPAClaimsImportServices/IciciClaimImportService.php
@@ -100,7 +100,8 @@ class IciciClaimImportService extends BaseTpaClaimImportService
'cheque_number' => 'utr_details',
'uhid' => 'tpa_no',
- 'rejected_query_desc' => 'claim_description',
+ 'rejected_query_desc' => 'claim_description',
+ 'type_of_claim' => 'tpa_claim_type',
];
protected $statusMapping = [
@@ -168,9 +169,7 @@ class IciciClaimImportService extends BaseTpaClaimImportService
}
$ticketMasterModel = new TicketMasterModel();
- $ticketMasterModel->insertBatch($data);
-
- return true;
+ return $ticketMasterModel->insertBatch($data);
}
@@ -181,9 +180,7 @@ class IciciClaimImportService extends BaseTpaClaimImportService
}
$builder = $this->db->table('claims_dump_icici');
- $builder->insertBatch($data);
-
- return true;
+ return $builder->upsertBatch($data, 'id');
}
@@ -194,9 +191,7 @@ class IciciClaimImportService extends BaseTpaClaimImportService
}
$builder = $this->db->table('claims_dump_icici');
- $builder->insertBatch($data);
-
- return true;
+ return $builder->updateBatch($data, 'id');
}
@@ -301,7 +296,7 @@ class IciciClaimImportService extends BaseTpaClaimImportService
if ($isduplicate) {
$reason = "This claim already exists in our system.";
- $rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
+ $rejecetd_reason[] = ["id" => $row['id'], "master_reject_reason" => $reason];
continue;
}
@@ -320,23 +315,15 @@ class IciciClaimImportService extends BaseTpaClaimImportService
if (!empty($employee_data)) {
$item['emp_id'] = $employee_data['id'] ?? null;
$item['emp_name'] = $employee_data['name'] ?? null;
+ $item['emp_code'] = $employee_data['emp_code'] ?? null;
$item['emp_mail'] = $employee_data['email_corporate'] ?? null;
$item['emp_mobile'] = $employee_data['mobile'] ?? null;
$item['insured_emp_id'] = $employee_data['insured_emp_id'] ?? null;
$item['insured_name'] = $employee_data['insured_name'] ?? null;
} else {
- $reason = sprintf(
- 'The policy number "%s" does not exist in our system. ' .
- 'Details - Client ID: %s, Client Policy ID: %s, Employee Number: %s, Relationship: %s',
- $row['insurer_policy_number'],
- $file_data['client_id'],
- $file_data['client_policy_id'],
- $row['employee_number'],
- $item['relationship']
- );
-
- $rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
+ $reason = 'This employee not exist in our system.';
+ $rejecetd_reason[] = ["id" => $row['id'], "master_reject_reason" => $reason];
continue;
}
diff --git a/app/Libraries/TPAClaimsImportServices/MediAssistClaimImportService.php b/app/Libraries/TPAClaimsImportServices/MediAssistClaimImportService.php
index 7326567d..ad5a8657 100644
--- a/app/Libraries/TPAClaimsImportServices/MediAssistClaimImportService.php
+++ b/app/Libraries/TPAClaimsImportServices/MediAssistClaimImportService.php
@@ -49,7 +49,7 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService
["excel_column" => ["col_name" => "intimation_id", "col_index" => 30], "db_column" => "intimation_id"],
["excel_column" => ["col_name" => "intimation_date", "col_index" => 31], "db_column" => "intimation_date"],
["excel_column" => ["col_name" => "settled_date", "col_index" => 32], "db_column" => "settled_date"],
- ["excel_column" => ["col_name" => "ClaimSource", "col_index" => 33], "db_column" => "claim_source"],
+ ["excel_column" => ["col_name" => "ClaimSource", "col_index" => 33], "db_column" => "ClaimSource"],
["excel_column" => ["col_name" => "claim_mode_of_rcpt", "col_index" => 34], "db_column" => "claim_mode_of_rcpt"],
["excel_column" => ["col_name" => "claim_type", "col_index" => 35], "db_column" => "claim_type"],
["excel_column" => ["col_name" => "claim_sub_type", "col_index" => 36], "db_column" => "claim_sub_type"],
@@ -72,16 +72,16 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService
["excel_column" => ["col_name" => "hospital_state", "col_index" => 53], "db_column" => "hospital_state"],
["excel_column" => ["col_name" => "hospital_pincode", "col_index" => 54], "db_column" => "hospital_pincode"],
["excel_column" => ["col_name" => "hospital_address", "col_index" => 55], "db_column" => "hospital_address"],
- ["excel_column" => ["col_name" => "Clinic_DoctorName_Hospital", "col_index" => 56], "db_column" => "clinic_doctorname_hospital"],
- ["excel_column" => ["col_name" => "OPD_pincode", "col_index" => 57], "db_column" => "opd_pincode"],
- ["excel_column" => ["col_name" => "payable_amount_OPD_Consultation", "col_index" => 58], "db_column" => "payable_amount_opd_consultation"],
- ["excel_column" => ["col_name" => "payable_amount_Dental", "col_index" => 59], "db_column" => "payable_amount_dental"],
- ["excel_column" => ["col_name" => "payable_amount_Diagnostics", "col_index" => 60], "db_column" => "payable_amount_diagnostics"],
- ["excel_column" => ["col_name" => "payable_amount_Other", "col_index" => 61], "db_column" => "payable_amount_other"],
- ["excel_column" => ["col_name" => "payable_amount_Pharmacy", "col_index" => 62], "db_column" => "payable_amount_pharmacy"],
- ["excel_column" => ["col_name" => "payable_amount_Vaccination", "col_index" => 63], "db_column" => "payable_amount_vaccination"],
- ["excel_column" => ["col_name" => "payable_amount_Miscellaneous_Charges", "col_index" => 64], "db_column" => "payable_amount_miscellaneous_charges"],
- ["excel_column" => ["col_name" => "payable_amount_Health_Checkup", "col_index" => 65], "db_column" => "payable_amount_health_checkup"],
+ ["excel_column" => ["col_name" => "Clinic_DoctorName_Hospital", "col_index" => 56], "db_column" => "Clinic_DoctorName_Hospital"],
+ ["excel_column" => ["col_name" => "OPD_pincode", "col_index" => 57], "db_column" => "OPD_pincode"],
+ ["excel_column" => ["col_name" => "payable_amount_OPD_Consultation", "col_index" => 58], "db_column" => "payable_amount_OPD_Consultation"],
+ ["excel_column" => ["col_name" => "payable_amount_Dental", "col_index" => 59], "db_column" => "payable_amount_Dental"],
+ ["excel_column" => ["col_name" => "payable_amount_Diagnostics", "col_index" => 60], "db_column" => "payable_amount_Diagnostics"],
+ ["excel_column" => ["col_name" => "payable_amount_Other", "col_index" => 61], "db_column" => "payable_amount_Other"],
+ ["excel_column" => ["col_name" => "payable_amount_Pharmacy", "col_index" => 62], "db_column" => "payable_amount_Pharmacy"],
+ ["excel_column" => ["col_name" => "payable_amount_Vaccination", "col_index" => 63], "db_column" => "payable_amount_Vaccination"],
+ ["excel_column" => ["col_name" => "payable_amount_Miscellaneous_Charges", "col_index" => 64], "db_column" => "payable_amount_Miscellaneous_Charges"],
+ ["excel_column" => ["col_name" => "payable_amount_Health_Checkup", "col_index" => 65], "db_column" => "payable_amount_Health_Checkup"],
["excel_column" => ["col_name" => "deduction_amount_copay", "col_index" => 66], "db_column" => "deduction_amount_copay"],
["excel_column" => ["col_name" => "deduction_amount_excess_ailment", "col_index" => 67], "db_column" => "deduction_amount_excess_ailment"],
["excel_column" => ["col_name" => "deduction_amount_excess_policy", "col_index" => 68], "db_column" => "deduction_amount_excess_policy"],
@@ -153,6 +153,7 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService
// Payment
'utr_no' => 'utr_details',
+ 'claim_type' => 'tpa_claim_type',
];
protected $statusMapping = [
@@ -166,7 +167,6 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService
'Cashless Document Awaited' => 3,
];
-
/**
* ABSTRACT FUNCTIONs
*/
@@ -177,9 +177,8 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService
}
$builder = $this->db->table('claims_dump_medi_assist');
- $builder->insertBatch($data);
+ return $builder->insertBatch($data);
- return true;
}
@@ -190,9 +189,7 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService
}
$ticketMasterModel = new TicketMasterModel();
- $ticketMasterModel->insertBatch($data);
-
- return true;
+ return $ticketMasterModel->insertBatch($data);
}
@@ -216,9 +213,7 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService
}
$builder = $this->db->table('claims_dump_medi_assist');
- $builder->insertBatch($data);
-
- return true;
+ return $builder->updateBatch($data, 'id');
}
@@ -319,7 +314,7 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService
if ($isduplicate) {
$reason = "This claim already exists in our system.";
- $rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
+ $rejecetd_reason[] = ["id" => $row['id'], "master_reject_reason" => $reason];
continue;
}
@@ -338,23 +333,15 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService
if (!empty($employee_data)) {
$item['emp_id'] = $employee_data['id'] ?? null;
$item['emp_name'] = $employee_data['name'] ?? null;
+ $item['emp_code'] = $employee_data['emp_code'] ?? null;
$item['emp_mail'] = $employee_data['email_corporate'] ?? null;
$item['emp_mobile'] = $employee_data['mobile'] ?? null;
$item['insured_emp_id'] = $employee_data['insured_emp_id'] ?? null;
$item['insured_name'] = $employee_data['insured_name'] ?? null;
} else {
- $reason = sprintf(
- 'The policy number "%s" does not exist in our system. ' .
- 'Details - Client ID: %s, Client Policy ID: %s, Employee Number: %s, Relationship: %s',
- $row['insurer_policy_number'],
- $file_data['client_id'],
- $file_data['client_policy_id'],
- $row['employee_number'],
- $item['relationship']
- );
-
- $rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
+ $reason = 'This employee not exist in our system.';
+ $rejecetd_reason[] = ["id" => $row['id'], "master_reject_reason" => $reason];
continue;
}
diff --git a/app/Libraries/TPAClaimsImportServices/RcareClaimImportService.php b/app/Libraries/TPAClaimsImportServices/RcareClaimImportService.php
index 4808d89e..b77b035f 100644
--- a/app/Libraries/TPAClaimsImportServices/RcareClaimImportService.php
+++ b/app/Libraries/TPAClaimsImportServices/RcareClaimImportService.php
@@ -159,9 +159,7 @@ class RcareClaimImportService extends BaseTpaClaimImportService
}
$ticketMasterModel = new TicketMasterModel();
- $ticketMasterModel->insertBatch($data);
-
- return true;
+ return $ticketMasterModel->insertBatch($data);
}
@@ -172,9 +170,7 @@ class RcareClaimImportService extends BaseTpaClaimImportService
}
$builder = $this->db->table('claims_dump_reliance');
- $builder->insertBatch($data);
-
- return true;
+ return $builder->updateBatch($data, 'id');
}
@@ -185,9 +181,7 @@ class RcareClaimImportService extends BaseTpaClaimImportService
}
$builder = $this->db->table('claims_dump_reliance');
- $builder->insertBatch($data);
-
- return true;
+ return $builder->updateBatch($data, 'id');
}
@@ -291,7 +285,7 @@ class RcareClaimImportService extends BaseTpaClaimImportService
if ($isduplicate) {
$reason = "This claim already exists in our system.";
- $rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
+ $rejecetd_reason[] = ["id" => $row['id'], "master_reject_reason" => $reason];
continue;
}
@@ -310,23 +304,15 @@ class RcareClaimImportService extends BaseTpaClaimImportService
if (!empty($employee_data)) {
$item['emp_id'] = $employee_data['id'] ?? null;
$item['emp_name'] = $employee_data['name'] ?? null;
+ $item['emp_code'] = $employee_data['emp_code'] ?? null;
$item['emp_mail'] = $employee_data['email_corporate'] ?? null;
$item['emp_mobile'] = $employee_data['mobile'] ?? null;
$item['insured_emp_id'] = $employee_data['insured_emp_id'] ?? null;
$item['insured_name'] = $employee_data['insured_name'] ?? null;
} else {
- $reason = sprintf(
- 'The policy number "%s" does not exist in our system. ' .
- 'Details - Client ID: %s, Client Policy ID: %s, Employee Number: %s, Relationship: %s',
- $row['insurer_policy_number'],
- $file_data['client_id'],
- $file_data['client_policy_id'],
- $row['employee_number'],
- $item['relationship']
- );
-
- $rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
+ $reason = 'This employee not exist in our system.';
+ $rejecetd_reason[] = ["id" => $row['id'], "master_reject_reason" => $reason];
continue;
}
diff --git a/app/Libraries/TPAClaimsImportServices/VidalClaimImportService.php b/app/Libraries/TPAClaimsImportServices/VidalClaimImportService.php
index b8bc92b8..fee2cc9f 100644
--- a/app/Libraries/TPAClaimsImportServices/VidalClaimImportService.php
+++ b/app/Libraries/TPAClaimsImportServices/VidalClaimImportService.php
@@ -163,7 +163,6 @@ class VidalClaimImportService extends BaseTpaClaimImportService
["excel_column" => "Last Document Received date", "db_column" => "last_document_received_date"],
];
-
protected $mapping = [
["excel_column" => ["col_name" => "TPA Policy Number", "col_index" => 0], "db_column" => "tpa_policy_number"],
@@ -312,7 +311,6 @@ class VidalClaimImportService extends BaseTpaClaimImportService
["excel_column" => ["col_name" => "Last Document Received date", "col_index" => 113], "db_column" => "last_document_received_date"],
];
-
protected $ticketMasterMapping = [
// Policy / Claim identifiers
@@ -346,9 +344,9 @@ class VidalClaimImportService extends BaseTpaClaimImportService
// Meta
'file_id' => 'file_id',
+ 'type_of_claim' => 'tpa_claim_type',
];
-
protected $statusMapping = [
'CL Paid with Settlement Letter' => 11,
'CL Rejected' => 8,
@@ -380,9 +378,7 @@ class VidalClaimImportService extends BaseTpaClaimImportService
}
$ticketMasterModel = new TicketMasterModel();
- $ticketMasterModel->insertBatch($data);
-
- return true;
+ return $ticketMasterModel->insertBatch($data);
}
@@ -393,9 +389,7 @@ class VidalClaimImportService extends BaseTpaClaimImportService
}
$builder = $this->db->table('claims_dump_vidal');
- $builder->insertBatch($data);
-
- return true;
+ return $builder->updateBatch($data, 'id');
}
@@ -406,9 +400,7 @@ class VidalClaimImportService extends BaseTpaClaimImportService
}
$builder = $this->db->table('claims_dump_vidal');
- $builder->insertBatch($data);
-
- return true;
+ return $builder->updateBatch($data, 'id');
}
@@ -514,7 +506,7 @@ class VidalClaimImportService extends BaseTpaClaimImportService
if ($isduplicate) {
$reason = "This claim already exists in our system.";
- $rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
+ $rejecetd_reason[] = ["id" => $row['id'], "master_reject_reason" => $reason];
continue;
}
@@ -534,22 +526,14 @@ class VidalClaimImportService extends BaseTpaClaimImportService
$item['emp_id'] = $employee_data['id'] ?? null;
$item['emp_name'] = $employee_data['name'] ?? null;
$item['emp_mail'] = $employee_data['email_corporate'] ?? null;
+ $item['emp_code'] = $employee_data['emp_code'] ?? null;
$item['emp_mobile'] = $employee_data['mobile'] ?? null;
$item['insured_emp_id'] = $employee_data['insured_emp_id'] ?? null;
$item['insured_name'] = $employee_data['insured_name'] ?? null;
} else {
- $reason = sprintf(
- 'The policy number "%s" does not exist in our system. ' .
- 'Details - Client ID: %s, Client Policy ID: %s, Employee Number: %s, Relationship: %s',
- $row['insurer_policy_number'],
- $file_data['client_id'],
- $file_data['client_policy_id'],
- $row['employee_number'],
- $item['relationship']
- );
-
- $rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
+ $reason = 'This employee not exist in our system.';
+ $rejecetd_reason[] = ["id" => $row['id'], "master_reject_reason" => $reason];
continue;
}
diff --git a/app/Models/ClientDepositModel.php b/app/Models/ClientDepositModel.php
index 8a61b204..7aa4ff7b 100755
--- a/app/Models/ClientDepositModel.php
+++ b/app/Models/ClientDepositModel.php
@@ -30,6 +30,7 @@ class ClientDepositModel extends Model
"cd_ac_pk",
"record_date",
"policy_transaction_id",
+ "file_id",
];
diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php
index fa7672ec..b11c97f6 100755
--- a/app/Models/ClientPolicyModel.php
+++ b/app/Models/ClientPolicyModel.php
@@ -303,6 +303,8 @@ class ClientPolicyModel extends Model
$caseSql = "";
}
+ $url = base_url('downloadCdSplitUpFile?id=');
+
// Fetch the deposit data based on client and insurer IDs
$query = $this->db->table('cash_deposit')
->select('cash_deposit.*')
@@ -312,6 +314,12 @@ class ClientPolicyModel extends Model
// ->select('policies.name as policy_name')
->select('policy_type.policy_type')
->select('user_profiles.first_name as username')
+ ->select("CASE
+ WHEN cash_deposit.file_id IS NOT NULL AND cash_deposit.file_id != ''
+ THEN CONCAT(" . $this->db->escape($url) . ", cash_deposit.file_id)
+ ELSE NULL
+ END AS split_up_url",
+ false)
->select($caseSql)
->join('user_profiles', 'user_profiles.id = cash_deposit.created_by', 'left')
->join('insurers', 'insurers.id = cash_deposit.insurer_id', 'left')
@@ -337,7 +345,9 @@ class ClientPolicyModel extends Model
}
$query->orderBy('cash_deposit.id', 'DESC');
- return $query->get()->getResult();
+ $data = $query->get()->getResult();
+
+ return $data;
}
diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php
index 70f0485c..395e97bf 100755
--- a/app/Models/EmployeePolicyModel.php
+++ b/app/Models/EmployeePolicyModel.php
@@ -280,6 +280,14 @@ class EmployeePolicyModel extends Model
'cp.policy_no',
'cp.policy_type_id',
'cp.is_addon',
+ '(
+ select id from employees
+ where emp_code = emp.emp_code
+ and client_id = emp.client_id
+ and lower(relationship) = "self"
+ and is_active = 1
+ limit 1
+ ) as self_employee_id',
$ecard_download_link
])
->join('employees emp', 'employee_polices.employee_id = emp.id')
@@ -494,7 +502,6 @@ class EmployeePolicyModel extends Model
) as batch_data ON employee_polices.id = batch_data.emp_policy_id
WHERE employee_polices.client_policy_id = :client_policy_id:
- AND (employee_polices.:id: IS NULL OR employee_polices.:id: = '')
AND employees.client_branch_id = :client_branch_id:
AND employee_polices.is_active = 1
AND employee_polices.status = 'active'
@@ -502,6 +509,14 @@ class EmployeePolicyModel extends Model
AND employees.emp_status = 'active'
";
+ if($insurer_or_tpa == 'insurer'){
+ $sql .= "AND (employee_polices.uhid IS NULL OR employee_polices.uhid <> '')";
+ }
+
+ if($insurer_or_tpa == 'tpa'){
+ $sql .= "AND (employee_polices.tpa_id IS NULL OR employee_polices.tpa_id <> '')";
+ }
+
$binds = ["datas" => $datas,"event" => $event
,"insurer_or_tpa" => $insurer_or_tpa
,"client_policy_id" => $client_policy_id
diff --git a/app/Models/PolicyTransactionModel.php b/app/Models/PolicyTransactionModel.php
index 98243549..74df001c 100644
--- a/app/Models/PolicyTransactionModel.php
+++ b/app/Models/PolicyTransactionModel.php
@@ -2540,6 +2540,9 @@
pt.ref,
pt.data_received_date,
+ pt.endorse_eff_date,
+ pt.policy_start_date,
+ pt.policy_end_date,
pt.renewal_date,
pt.installment,
nhance_branch.branch_name as nhance_branch,
@@ -2699,6 +2702,9 @@
pt.ref,
pt.data_received_date,
+ pt.endorse_eff_date,
+ pt.policy_start_date,
+ pt.policy_end_date,
pt.renewal_date,
pt.installment,
nhance_branch.branch_name as nhance_branch,
@@ -3143,6 +3149,9 @@
pt.ref,
pt.data_received_date,
+ pt.endorse_eff_date,
+ pt.policy_start_date,
+ pt.policy_end_date,
pt.renewal_date,
pt.installment,
nhance_branch.branch_name as nhance_branch,
@@ -3303,6 +3312,9 @@
pt.ref,
pt.data_received_date,
+ pt.endorse_eff_date,
+ pt.policy_start_date,
+ pt.policy_end_date,
pt.renewal_date,
pt.installment,
nhance_branch.branch_name as nhance_branch,
@@ -3490,6 +3502,9 @@
pt.ref,
pt.data_received_date,
+ pt.endorse_eff_date,
+ pt.policy_start_date,
+ pt.policy_end_date,
pt.renewal_date,
pt.installment,
nhance_branch.branch_name as nhance_branch,
@@ -3676,7 +3691,7 @@
$result = $query->getResultArray();
// $countofalldata = count($result);
// dd($result);
- dd($this->db->getLastQuery()->getQuery());
+ // dd($this->db->getLastQuery()->getQuery());
$keys = [];
$filtered = [];
diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php
index 845a6fe2..f2feb0d5 100644
--- a/app/Models/TicketMasterModel.php
+++ b/app/Models/TicketMasterModel.php
@@ -92,6 +92,7 @@ class TicketMasterModel extends Model
'claim_description',
'required_docs',
'policy_transaction_id',
+ 'tpa_claim_type',
];
diff --git a/app/Views/UserList.php b/app/Views/UserList.php
index 28cde270..ca47296c 100755
--- a/app/Views/UserList.php
+++ b/app/Views/UserList.php
@@ -581,7 +581,7 @@ table.dataTable tbody td {
Cancel
- Submit
+ Submit
@@ -884,7 +884,20 @@ table.dataTable tbody td {
+getFlashdata('error')) : ?>
+ getFlashdata('error') as $error) : ?>
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php
index 364a2da4..ede380ea 100644
--- a/app/Views/leads_form.php
+++ b/app/Views/leads_form.php
@@ -2156,10 +2156,9 @@
$('.btnDiv').show();
$('.claim-row').hide();
-
- $('.emp_title').text('No of Employees')
- $('.depnd_title').text('No of Dependents')
- $('.total_title').text('Total Lives')
+ $('.emp_title_text').text('No of Employees')
+ $('.depnd_title_text').text('No of Dependents')
+ $('.total_title_text').text('Total Lives')
$('.renewalFields').find('select, input').removeAttr('required');
$('.renewalFields').hide();
@@ -2193,9 +2192,9 @@
$('.btnDiv').hide();
$('.claim-row').show();
- $('.emp_title').text('No of Employees at Inception')
- $('.depnd_title').text(' No of Dependents at Inception')
- $('.total_title').text('Total Lives at Inception')
+ $('.emp_title_text').text('No of Employees at Inception')
+ $('.depnd_title_text').text(' No of Dependents at Inception')
+ $('.total_title_text').text('Total Lives at Inception')
$('.freshFields').find('select, input').removeAttr('required');
$('.freshFields').hide();
diff --git a/app/Views/leads_non_eb.php b/app/Views/leads_non_eb.php
index 2f59fe29..ebdf741b 100644
--- a/app/Views/leads_non_eb.php
+++ b/app/Views/leads_non_eb.php
@@ -738,9 +738,9 @@
$('.claim-row').hide();
- $('.emp_title').text('No of Employees')
- $('.depnd_title').text('No of Dependents')
- $('.total_title').text('Total Lives')
+ $('.emp_title_text').text('No of Employees')
+ $('.depnd_title_text').text('No of Dependents')
+ $('.total_title_text').text('Total Lives')
$('.renewalFields').find('select, input').removeAttr('required');
$('.renewalFields').hide();
@@ -775,9 +775,9 @@
$('.btnDiv').hide();
$('.claim-row').show();
- $('.emp_title').text('No of Employees at Inception')
- $('.depnd_title').text(' No of Dependents at Inception')
- $('.total_title').text('Total Lives at Inception')
+ $('.emp_title_text').text('No of Employees at Inception')
+ $('.depnd_title_text').text(' No of Dependents at Inception')
+ $('.total_title_text').text('Total Lives at Inception')
$('.freshFields').find('select, input').removeAttr('required');
$('.freshFields').hide();
@@ -812,7 +812,6 @@
}
}
-
}
var allContacts = "";
function getBranchData(input,inputType) {
diff --git a/app/Views/meta_dashboard_demo_one.php b/app/Views/meta_dashboard_demo_one.php
new file mode 100644
index 00000000..4652f9e9
--- /dev/null
+++ b/app/Views/meta_dashboard_demo_one.php
@@ -0,0 +1,33 @@
+
+
+
+
+ Metabase Dashboard
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/Views/notification.php b/app/Views/notification.php
index 5248c2bf..7948a3a4 100755
--- a/app/Views/notification.php
+++ b/app/Views/notification.php
@@ -131,6 +131,8 @@
$member_review_and_summary_mail = 0;
$account_maneger_summary_mail = 0;
$client_hr_summary_mail = 0;
+ $hr_cd_insufficient_balance_mail = 0;
+
if (isset($notification)) {
foreach ($notification as $value) {
@@ -161,6 +163,10 @@
if ($value['template_name'] == 'client_hr_summary_mail') {
$client_hr_summary_mail = $value['enabled'];
}
+
+ if ($value['template_name'] == 'hr_cd_insufficient_balance_mail') {
+ $hr_cd_insufficient_balance_mail = $value['enabled'];
+ }
}
}
?>
@@ -265,6 +271,7 @@
+
+
+
+
@@ -988,6 +1015,89 @@
+
+
+