MERGE_TEST_HR_CHANGES

This commit is contained in:
Ubuntu 2026-02-05 09:21:12 +05:30
commit 7e49baad76
58 changed files with 4040 additions and 1641 deletions

View File

@ -112,3 +112,11 @@ FHPL_PRIMARY_KEY_CONSTANT =
VIDAL_PRIMARY_KEY_CONSTANT =
MEDI_ASSIST_PRIMARY_KEY_CONSTANT =
FHPL_TOKEN_URL =
FHPL_BASE_URL =
FHPL_USER_NAME =
FHPL_PASSWORD =
FHPL_GRANT_TYPE =

View File

@ -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],

View File

@ -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',

View File

@ -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');

View File

@ -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}");

View File

@ -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 = '<style>body{font-family:Arial,sans-serif;color:#333;line-height:1.6;margin:0;padding:0}.email-container{width:100%;max-width:600px;margin:0 auto;padding:20px;border:1px solid #e0e0e0;background-color:#f9f9f9}.header{background-color:#4a90e2;color:#fff;padding:15px;text-align:center}.header h1{margin:0;font-size:24px}.content{padding:20px;background-color:#fff}.content h2{color:#4a90e2;font-size:20px;margin-top:0}.content p{margin:10px 0}.details-table{width:100%;border-collapse:collapse;margin-top:20px}.details-table td,.details-table th{border:1px solid #ddd;padding:10px;text-align:left}.details-table th{background-color:#f2f2f2}.footer{margin-top:20px;font-size:12px;color:#777;text-align:center}.attachment-note{margin-top:20px;padding:10px;background-color:#f7f7f7;border-left:4px solid #4a90e2;font-style:italic}</style><div class=email-container><div class=header><h1>Request for Quotation (RFQ)</h1></div><div class=content><h2>Dear {{RECIPIENT_NAME}},</h2><p>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.<h2>RFQ Details</h2><table data-custom-table-css="table" class=details-table><tr><th>Client name<td>{{CLIENT_NAME}}<tr><th>Coverage Type<td>{{POLICY_LONG_NAME}}<tr><th>Policy Start Date<td>{{POLICY_START_DATE}}<tr><th>Policy Duration<td>{{DURATION}}</table><div class=attachment-note>Please note: Additional terms and details are included in the attachment for your reference.</div><p>Please feel free to reach out if you require any further information to prepare the quote. We look forward to receiving your proposal.<p>Best regards,<p><strong>Nhance India Pvt Ltd</strong><br></div><div class=footer><p>© Nhance India Pvt Ltd. All rights reserved.</div></div>';
@ -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 "<pre>";
// 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
$list_of_branch_units = $this->clientBranchModel->find((int)$id);
$branch_units = json_decode($list_of_branch_units['units'], true);
$units = json_decode($units);
$post_units_raw = $sanitized_post_data['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([
@ -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,9 +2045,11 @@ 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['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['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());
@ -8998,6 +8730,8 @@ class ClientController extends AdminController
$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,
'template_name' => 'member_welcome_mail',
@ -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,
]);

View File

@ -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);
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);
}else{
session()->set('cd_balance', true);
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', 'sufficient'); // Use a string status for clarity
session()->set('cd_balance_info', null);
}
}
}
@ -1057,16 +1072,22 @@ class EmpDataServiceController extends BaseController
{
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);
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);
}
}
}
@ -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;
}
}

View File

@ -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')
@ -480,6 +486,16 @@ 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);
}
}

View File

@ -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;
}
// 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,8 +4949,12 @@ class EmployeeRestController extends AdminController
}
if (isset($search_data['client_id']) && !empty($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'])) {
$builder->where("files.id", $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)) {
@ -5306,5 +5386,149 @@ class EmployeeRestController extends AdminController
}
}
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);
}
}

View File

@ -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;

View File

@ -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,32 +307,105 @@ 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)
{
$function_calling_type = $requestData['return_type'] ?? 'job';
try {
helper('api');
$policyNo = $requestData['policy_no'] ?? "10/12/2025/16/17";
$client_policy_id = $requestData['client_policy_id'] ?? 0;
$policyNo = $requestData['policy_no'] ?? null;
$client_policy_id = $requestData['client_policy_id'] ?? null;
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']);
}
}
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'])) {
return $this->response->setJSON(['status' => false,'message' => 'FHPL Token generation failed']);
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'];
@ -363,7 +420,8 @@ class FhplApiController extends BaseController
$range = 100;
$allMembers = [];
do {
while (true) {
$body = [
"UserName" => getenv('FHPL_USER_NAME'),
"Password" => getenv('FHPL_PASSWORD'),
@ -372,24 +430,67 @@ class FhplApiController extends BaseController
"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);
dd($response);
if(empty($response['data']['Members'])){
if (($response['status'] ?? false) !== true) {
log_message('error', 'FHPL API FAILED | response: ' . json_encode($response));
break;
}
$allMembers = array_merge($allMembers,$response['data']['Members']);
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;
}
} while($startIndex < ($response['data']['Total'] ?? 0));
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.");
}
dd($allMembers);
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 =================
// Now same matching logic you already have
$employeePolicyModel = new EmployeePolicyModel();
$employeePolicyData = $employeePolicyModel
@ -401,28 +502,206 @@ class FhplApiController extends BaseController
$updated = 0;
foreach ($employeePolicyData as $policy) {
$hasMatchForThisPolicy = false;
foreach ($allMembers as $m) {
if (
strtolower(trim($policy['name']))==strtolower(trim($m['Name'])) &&
$policy['emp_code']==$m['MemberID'] &&
strtolower($policy['relationship'])==strtolower($m['Relation'])
strtolower(trim($policy['name'])) === strtolower(trim($m['EMPLOYEE_NAME'] ?? '')) &&
($policy['emp_code'] ?? '') == ($m['EMPLOYEE_ID'] ?? '') &&
strtolower($policy['relationship']) === strtolower($m['RELATION'] ?? '')
) {
$this->db->table('employee_polices')
->where('id',$policy['emp_policy_id'])
->update(['tpa_id'=>$m['UHID']]);
$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,
'total_fetched'=>count($allMembers),
'updated'=>$updated
'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()
{

View File

@ -0,0 +1,751 @@
<?php
namespace App\Controllers;
use App\Controllers\BaseController;
use App\Models\BatchFileModel;
use App\Models\EmployeePolicyModel;
use App\Models\TpaApiDataModel;
use App\Models\ClientPolicyModel;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\HTTP\IncomingRequest;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\API\ResponseTrait;
use App\Controllers\Jobs;
class HealthIndiaApiController extends BaseController
{
use ResponseTrait;
protected $db;
protected $healthIndiaTpaId;
public function __construct()
{
$this->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
]);
}
}

View File

@ -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',

View File

@ -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']

View File

@ -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,19 +516,27 @@ 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)) {
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' => 'Input validation failed',
'message' => $mainMessage, // This will change based on the error
'code' => 400,
'errors' => $this->validator->getErrors()
]);
@ -2168,6 +2179,10 @@ class MasterController extends AdminController
public function createCDMasterData()
{
$this->myLogger->logme("error", 'Create CD Master Data API called.');
$data = $this->request->getPost();
$sanitized_post_data = sanitizeInputArrayAdvanced($data);
$id = $sanitized_post_data['PrimaryKey'] ?? null;
if($id === null){
$rules = [
// ======================
@ -2229,11 +2244,9 @@ class MasterController extends AdminController
'errors' => $this->validator->getErrors()
]);
}
$data = $this->request->getPost();
$sanitized_post_data = sanitizeInputArrayAdvanced($data);
}
$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']);

View File

@ -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

View File

@ -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 = [];

View File

@ -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 {

View File

@ -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',
]);
}
}

View File

@ -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' => [

View File

@ -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'];
}
$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()
]
];
}
}

View File

@ -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'
]
],

View File

@ -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

View File

@ -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();
}
}

View File

@ -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);
}

View File

@ -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

View File

@ -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}$/';

View File

@ -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;

View File

@ -947,22 +947,38 @@ 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';
$allowedExtensions = ['xls', 'xlsx', 'ods', 'xlsm'];
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;
// 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;
}
}
if (!function_exists('generate_ecard_download_link_based_on_tpa')) {
@ -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');
}
}

View File

@ -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;
}

View File

@ -27,79 +27,49 @@ abstract class BaseTpaClaimImportService
*/
public function runTpaClaimDumpInsert(string $filePath, int $fileId): array
{
$this->db->transStart();
// 1. Start Transaction
$this->db->transBegin();
try {
$fileData = $this->claimDumpFileModel->where('id', $fileId)->first();
// 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');
// $AL = $this->readExcelBySheetName($filePath, 'AL');
// $rows = array_merge($CL, $AL);
} else {
$rows = $this->readExcel($filePath);
}
// dd($rows);
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);
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{
}
// $return_res = $this->bulkInsertTPATable($tpaInsertData);
if (!$return_res) {
if ($return_res !== true) {
$this->db->transRollback(); // ROLLBACK BEFORE RETURN
return ['status' => false, 'message' => 'TPA Import bulk insert failed'];
}
$this->db->transComplete();
// 2. Commit if everything is fine
$this->db->transCommit();
return ['status' => true, 'message' => 'File uploaded successfully', 'record_count' => count($tpaInsertData)];
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];
} catch (\Throwable $e) {
// 3. Rollback on any crash/exception
$this->db->transRollback();
return ['status' => false, 'message' => 'System error : ' . $e->getMessage()];
}
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();
try {
$file_id = $params['file_id'];
$ticketMasterData = $this->mapClaimMasterData($file_id);
// Check if mapping failed
if (!$ticketMasterData['status']) {
$this->db->transRollback(); // ALWAYS rollback before early return
return $ticketMasterData;
}
$return_res = $this->importClaimMaster($ticketMasterData['mapped_array']);
$message = '';
$hasExecutedTask = false;
if(!$return_res){
// 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'];
}
$this->updateTicketMasterRejectedReasonInTPATable($ticketMasterData['rejected_reason_array']);
$this->db->transComplete();
if ($this->db->transStatus() === false) {
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;
}
return ['status' => true, 'message' => 'Ticket Master Claim inserted successfully'];
// 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()
];
}
}
/**
@ -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',

View File

@ -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;
}

View File

@ -101,6 +101,7 @@ class IciciClaimImportService extends BaseTpaClaimImportService
'cheque_number' => 'utr_details',
'uhid' => 'tpa_no',
'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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -30,6 +30,7 @@ class ClientDepositModel extends Model
"cd_ac_pk",
"record_date",
"policy_transaction_id",
"file_id",
];

View File

@ -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;
}

View File

@ -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

View File

@ -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 = [];

View File

@ -92,6 +92,7 @@ class TicketMasterModel extends Model
'claim_description',
'required_docs',
'policy_transaction_id',
'tpa_claim_type',
];

View File

@ -581,7 +581,7 @@ table.dataTable tbody td {
<div class="form-group text-right m-b-0">
<button class="btn app-btn-outline-secondary mr-2 " type="button" data-dismiss="modal" aria-hidden="true">Cancel</button>
<button class="btn app-btn-secondary waves-effect waves-light" id="btnSubmit">Submit</button>
<button type="submit" class="btn app-btn-secondary waves-effect waves-light" id="btnSubmit">Submit</button>
<!-- <button type="button" class="btn btn-secondry waves-effect waves-light mr-1" data-dismiss="modal" aria-hidden="true">Close</button> -->
</div>
</form>
@ -884,7 +884,20 @@ table.dataTable tbody td {
</table>
</div>
</div>
<?php if (session()->getFlashdata('error')) : ?>
<?php foreach (session()->getFlashdata('error') as $error) : ?>
<script>
toastr.error("<?= esc($error) ?>", "Validation Error");
</script>
<?php endforeach; ?>
<script>
var errorModal = new bootstrap.Modal(
document.getElementById('con-close-modal')
);
errorModal.show();
</script>
<?php endif; ?>
<script>
var table;
$(document).ready(function () {
@ -1900,18 +1913,35 @@ table.dataTable tbody td {
<script>
$(document).on('click', '#btnAdd', function() {
$('#first_name').val('');
$('#last_name').val('');
$('#email').val('');
$('#mobile').val('');
$('#emp_code').val('');
$('#nhance_branch_id').val('0');
$('#rm_id').val('0');
$('#UserForm').attr('action', '<?php echo base_url('/user/create');?>');
let myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
myModal.show(); // open modal
// Reset the form
$('#UserForm')[0].reset();
$('#UserId').val('');
// Specifically reset Select2 if you are using it
$('#nhance_branch_id').val('').trigger('change');
$('#rm_id').val('').trigger('change');
// Update Modal Title and Action
$('.modal-title').text('Add User');
$('#btnSubmit').text('Submit');
$('#UserForm').attr('action', '<?php echo base_url('/user/create');?>');
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
myModal.show();
});
// $(document).on('click', '#btnAdd', function(){
// $('#first_name').val('');
// $('#last_name').val('');
// $('#email').val('');
// $('#mobile').val('');
// $('#emp_code').val('');
// $('#nhance_branch_id').val('0');
// $('#rm_id').val('0');
// $('#UserForm').attr('action', '<?php echo base_url('/user/create');?>');
// let myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
// myModal.show(); // open modal
// });
$(document).on('click', '#btnNhancePartnerAdd', function(){
$('#partner_name').val('');
$('#email_addr').val('');

View File

@ -168,6 +168,7 @@
data-event_type="<?= $file['event_type'] ?>"
data-actions="<?= $file['actions'] ?>"
data-client_branch_id="<?= $file['client_branch_id'] ?>"
data-issue_date="<?= $file['policy_issue_date'] ?>"
onclick="getBatchFileData(this)" class="dropdown-item upload_button" ><i class="mdi mdi-upload mr-2 text-muted font-18 vertical-middle"></i>Re-Upload</a>
<?php } ?>
@ -215,6 +216,7 @@
<input type="hidden" id="batch_file_insurer_or_tpa" name="insurer_or_tpa">
<input type="hidden" id="batch_file_action_type" name="action_type">
<input type="hidden" id="batch_file_event_type" name="event_type">
<input type="hidden" id="batch_file_issue_date" name="policy_issue_date">
<input type="file" id="import_file_data" name="import_file_data" required
accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet">
@ -329,6 +331,7 @@
let insurer_or_tpa = $(input).data('insurer_or_tpa')
let event_type = $(input).data('event_type')
let actions = $(input).data('actions')
let issue_date = $(input).data('issue_date')
console.log('client_id', client_id);
console.log('client_policy_id', client_policy_id);
@ -336,6 +339,7 @@
console.log('insurer_or_tpa', insurer_or_tpa);
console.log('event_type', event_type);
console.log('actions', actions);
console.log('issue_date', issue_date);
$('#batch_file_client_id').val(client_id);
$('#batch_file_policy_id').val(client_policy_id);
@ -343,6 +347,7 @@
$('#batch_file_insurer_or_tpa').val(insurer_or_tpa);
$('#batch_file_action_type').val(actions);
$('#batch_file_event_type').val(event_type);
$('#batch_file_issue_date').val(issue_date);
var myModal = new bootstrap.Modal(document.getElementById('batch_file_upload_modal'));

View File

@ -1,54 +1,90 @@
<form action="<?= base_url('fedeploy'); ?>" method="post" enctype="multipart/form-data">
<div class="container-fluid-min">
<div class="card mb-1">
<!---- new ----->
<div class="row">
<div class="col-12">
<div class="card-body">
<div class="custom-form">
<form role="form" class="parsley-examples" action="<?= base_url('fedeploy'); ?>" method="post" enctype="multipart/form-data">
<!-- Single zip upload -->
<div>
<label for="zip_file">Zip File</label>
<input type="file" name="zip_file" id="zip_file" required>
<div class="form-group row">
<label for="zip_file" class="col-md-4 col-form-label">Zip File</label>
<div class="col-md-5">
<div class="input-icon">
<input type="file" class="form-control" id="zip_file" name="zip_file" >
<i class="mdi mdi-upload additional-icon"></i>
</div>
</div>
</div>
<div>
<label for="zip_folder">Zip Folder (inside zip to deploy)</label>
<select name="zip_folder" id="zip_folder">
<!-- Zip Folder-->
<div class="form-group row">
<label for="zip_folder" class="col-md-4 col-form-label">Zip Folder (inside zip to deploy)</label>
<div class="col-md-5">
<select name="zip_folder" id="zip_folder" class="form-control">
<option value="web/">web/</option>
<!-- <option value="dist/">dist/</option> -->
</select>
</div>
</div>
<div>
<label for="s3_bucket">S3 Bucket</label>
<select name="s3_bucket" id="s3_bucket">
<div class="form-group row">
<label class="col-md-4 col-form-label" for="s3_bucket">S3 Bucket</label>
<div class="col-md-5">
<select name="s3_bucket" id="s3_bucket" class="form-control">
<option value="uat-benefits-app-bucket">UAT Benefits</option>
<option value="uat-hr-app-bucket">UAT HR</option>
<option value="benefits-app-bucket">Live Benefits</option>
<option value="live-hr-app-bucket">Live HR</option>
</select>
</div>
<div>
<label for="s3_prefix">S3 Prefix</label>
<input type="text" name="s3_prefix" id="s3_prefix" value="/*">
</div>
<div>
<label for="cf_distribution_id">CloudFront Distribution ID (optional)</label>
<!-- <input type="text" name="cf_distribution_id" id="cf_distribution_id" value="E1MKRK4U5MZ3BD"> -->
<select name="cf_distribution_id" id="cf_distribution_id">
<!-- S3 Prefix -->
<div class="form-group row">
<label class="col-md-4 col-form-label" for="s3_prefix">S3 Prefix</label>
<div class="col-md-5">
<input type="text" name="s3_prefix" id="s3_prefix" value="/*" class="form-control">
</div>
</div>
<!-- CloudFront Distribution -->
<div class="form-group row">
<label for="cf_distribution_id" class="col-md-4 col-form-label">CloudFront Distribution ID (optional)</label>
<div class="col-md-5">
<select name="cf_distribution_id" id="cf_distribution_id" class="form-control">
<option value="EUBZ8CDSV9KZZ">UAT Benefits</option>
<option value="E9TNPRI9ITM1M">UAT HR</option>
<option value="E1MKRK4U5MZ3BD">Live Benefits</option>
<option value="E3TE01DPKHTD8B">Live HR</option>
</select>
</div>
<div>
<label for="cf_paths">
CloudFront Invalidation Paths (comma or newline separated, e.g. <code>/hr/*,/hr/special/*</code>)
</label>
<input type="text" name="cf_paths" id="cf_paths" value="/*">
<!-- If you prefer multi-line, use <textarea> instead of <input> -->
</div>
<button type="submit">Deploy</button>
<!-- CloudFront Invalidation -->
<div class="form-group row">
<label class="col-md-4 col-form-label" for="cf_paths"> CloudFront Invalidation Paths (comma or newline separated, e.g. <code>/hr/*,/hr/special/*</code>) </label>
<div class="col-md-5 d-flex align-items-center">
<input type="text" name="cf_paths" id="cf_paths" value="/*" class="form-control">
</div>
</div>
<!-- Buttons -->
<div class="form-group row">
<div class="col-md-12 text-right">
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="btnSubmit">Deploy</button>
</div>
</div>
</form>
</div>
</div>
</div> <!-- end col-->
</div>
<!---- ends ------>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function () {
const bucketToDistributionMap = {

View File

@ -191,18 +191,29 @@ input:checked + .slider:before {
<script>
$(document).ready(function() {
$('#insurer_logo').on('change', function() {
PreviewImage();
});
$("#insurer_general_form").submit(function(events) {
events.preventDefault();
var isValid = $('#insurer_General_PrimaryKey').parsley().validate();
// var isValid = $('#insurer_General_PrimaryKey').parsley().validate();
var isValid = $('#insurer_general_form').parsley().validate();
var PrimaryKey = $('#insurer_General_PrimaryKey').val();
if (!isValid) {
console.log('Form is Empty', 'Warning');
return ;
}
var PrimaryKey = $('#insurer_General_PrimaryKey').val();
var form_action = '';
var formElement = $('#insurer_general_form')[0];
var formData = new FormData(formElement);
// DEBUG: Log formData to see if it's empty
for (var pair of formData.entries()) {
console.log(pair[0]+ ', ' + pair[1]);
}
if (isValid) {
if (PrimaryKey === '') {
@ -300,16 +311,46 @@ input:checked + .slider:before {
});
function PreviewImage()
{
function PreviewImage() {
var fileInput = document.getElementById("insurer_logo");
var preview = document.getElementById("uploadPreview");
var defaultAvatar = '<?= base_url() . "public/assets/images/avatar_2x.png" ?>';
// If no file is selected (or cleared by validation), reset preview and stop
if (!fileInput.files || !fileInput.files[0]) {
preview.src = defaultAvatar;
return;
}
var file = fileInput.files[0];
var fileName = file.name.toLowerCase();
var parts = fileName.split('.');
// VALIDATION: Extensions and Double Extensions (e.g. .php.jpeg)
var allowedExtensions = /(\.jpg|\.jpeg|\.png)$/i;
if (!allowedExtensions.exec(fileName) || parts.length > 2) {
toastr.error("Security violation: Invalid format or double extension.", "Blocked");
fileInput.value = ""; // Clear the field
preview.src = defaultAvatar; // RESET PREVIEW
return;
}
// VALIDATION: Size (200KB)
if ((file.size / 1024) > 200) {
toastr.warning("File size exceeds 200 KB limit.", "Warning");
fileInput.value = ""; // Clear the field
preview.src = defaultAvatar; // RESET PREVIEW
return;
}
// SUCCESS: Read and Preview
var oFReader = new FileReader();
oFReader.readAsDataURL(document.getElementById("insurer_logo").files[0]);
oFReader.readAsDataURL(file);
oFReader.onload = function(oFREvent) {
document.getElementById("uploadPreview").src = oFREvent.target.result;
preview.src = oFREvent.target.result;
};
};
}
//-----------------------------------------------------------------------------------------------------

View File

@ -5,6 +5,354 @@
}
</style>
<style>
.demo-button {
/* background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); */
color: white;
border: none;
padding: 16px 32px;
font-size: 16px;
font-weight: 700;
border-radius: 12px;
cursor: pointer;
font-family: 'Manrope', sans-serif;
box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
transition: all 0.3s ease;
letter-spacing: 0.5px;
}
.demo-button:hover {
transform: translateY(-2px);
box-shadow: 0 15px 30px rgba(102, 126, 234, 0.5);
}
/* Modal Overlay */
.modal-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: var(--bg-overlay);
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
opacity: 0;
visibility: hidden;
transition: all 0.3s ease;
backdrop-filter: blur(4px);
}
.modal-overlay.active {
opacity: 1;
visibility: visible;
}
/* Modal Container */
.modal-container {
background: var(--bg-modal);
border-radius: 20px;
box-shadow: var(--shadow-lg);
/* max-width: 600px; */
width: 100%;
max-height: 85vh;
overflow: hidden;
transform: scale(0.9) translateY(20px);
transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
display: flex;
flex-direction: column;
}
.modal-overlay.active .modal-container {
transform: scale(1) translateY(0);
}
/* Modal Header */
.modal-header {
padding: 10px 26px;
border-bottom: 2px solid var(--border-color);
background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
flex-shrink: 0;
}
.modal-title {
font-family: 'Manrope', sans-serif;
font-size: 24px;
font-weight: 700;
color: var(--text-primary);
margin-bottom: 8px;
}
.modal-subtitle {
font-size: 14px;
color: var(--text-secondary);
font-weight: 400;
}
/* Toggle Section */
.toggle-section {
padding: 14px 25px;
background: #fefefe;
border-bottom: 1px solid var(--border-color);
flex-shrink: 0;
}
.toggle-container {
display: flex;
align-items: center;
justify-content: space-between;
}
.toggle-label {
font-family: 'Manrope', sans-serif;
font-size: 15px;
font-weight: 600;
color: var(--text-primary);
}
/* Toggle Switch */
.toggle-switch {
position: relative;
width: 54px;
height: 28px;
cursor: pointer;
}
.toggle-switch input {
opacity: 0;
width: 0;
height: 0;
}
.toggle-slider {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #cbd5e1;
border-radius: 34px;
transition: all 0.3s ease;
}
.toggle-slider:before {
content: "";
position: absolute;
height: 22px;
width: 22px;
left: 3px;
bottom: 3px;
background-color: white;
border-radius: 50%;
transition: all 0.3s ease;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.toggle-switch input:checked + .toggle-slider {
background: #02a8b5;
}
.toggle-switch input:checked + .toggle-slider:before {
transform: translateX(26px);
}
/* HR List Section */
.hr-list-section {
max-height: 300px;
overflow-y: auto;
padding: 0;
display: none;
flex: 1 1 auto;
min-height: 0;
}
.hr-list-section.active {
display: block;
}
.hr-item {
padding: 5px 32px;
border-bottom: 1px solid var(--border-color);
display: flex;
align-items: center;
transition: background 0.2s ease;
cursor: pointer;
}
.hr-item:hover {
background: #f9fafb;
}
.hr-item:last-child {
border-bottom: none;
}
/* Checkbox Styling */
.hr-checkbox {
position: relative;
display: flex;
align-items: center;
margin-right: 16px;
}
.hr-checkbox input[type="checkbox"] {
position: absolute;
opacity: 0;
cursor: pointer;
}
.checkbox-custom {
width: 22px;
height: 22px;
border: 2px solid #cbd5e1;
border-radius: 6px;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s ease;
background: white;
}
.hr-checkbox input:checked ~ .checkbox-custom {
background: #02a8b5;
border-color: #667eea;
}
.checkbox-custom:after {
content: "";
display: none;
width: 6px;
height: 10px;
border: solid white;
border-width: 0 2px 2px 0;
transform: rotate(45deg);
}
.hr-checkbox input:checked ~ .checkbox-custom:after {
display: block;
}
/* HR Info */
.hr-info {
flex: 1;
}
.hr-name {
font-family: 'Manrope', sans-serif;
font-size: 16px;
font-weight: 700;
color: var(--text-primary);
margin-bottom: 4px;
}
.hr-email {
font-size: 13px;
font-weight: 500;
color: var(--text-secondary);
}
/* Modal Footer */
.modal-footer {
padding: 24px 32px;
background: #fafafa;
display: flex;
gap: 12px;
justify-content: flex-end;
flex-shrink: 0;
border-top: 1px solid var(--border-color);
}
.btn {
padding: 12px 24px;
border: none;
border-radius: 10px;
font-size: 15px;
font-weight: 600;
cursor: pointer;
font-family: 'Manrope', sans-serif;
transition: all 0.2s ease;
letter-spacing: 0.3px;
}
.btn-submit {
/* background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); */
color: white;
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}
.btn-submit:hover {
transform: translateY(-2px);
box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}
.btn-submit:disabled {
opacity: 0.5;
cursor: not-allowed;
transform: none;
}
/* Scrollbar Styling */
.hr-list-section::-webkit-scrollbar {
width: 8px;
}
.hr-list-section::-webkit-scrollbar-track {
background: #f1f5f9;
}
.hr-list-section::-webkit-scrollbar-thumb {
background: #cbd5e1;
border-radius: 4px;
}
.hr-list-section::-webkit-scrollbar-thumb:hover {
background: #94a3b8;
}
/* Empty State */
.empty-state {
padding: 60px 32px;
text-align: center;
color: var(--text-secondary);
}
.empty-state-icon {
font-size: 48px;
margin-bottom: 16px;
opacity: 0.5;
}
.empty-state-text {
font-size: 15px;
font-weight: 500;
}
/* Animations */
@keyframes slideIn {
from {
opacity: 0;
transform: translateY(10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.hr-item {
animation: slideIn 0.3s ease;
animation-fill-mode: backwards;
}
.hr-item:nth-child(1) { animation-delay: 0.05s; }
.hr-item:nth-child(2) { animation-delay: 0.1s; }
.hr-item:nth-child(3) { animation-delay: 0.15s; }
.hr-item:nth-child(4) { animation-delay: 0.2s; }
.hr-item:nth-child(5) { animation-delay: 0.25s; }
</style>
<div class="tab-pane fade" id="KYC-DOC-tab">
<div class="row">
<div class="col-xl-12">
@ -146,6 +494,10 @@
</form>
</div>
</div>
<!-- Demo Button -->
<button style="display: none" class="demo-button" onclick="openModal()">Open HR Email Modal</button>
</div>
</div>
@ -159,12 +511,57 @@
<!-- end row -->
</div>
<div class="modal fade" id="payout_modal" tabindex="-1" role="dialog" aria-hidden="true" aria-modal="true" data-backdrop="static" data-backdrop="static"
data-keyboard="false"
tabindex="-1">
<div class="modal-dialog modal-lg" style="max-width: 800px;">
<div class="modal-content">
<div class="modal-header" style="background-color: gainsboro;">
<h5 class="modal-title" id="myCenterModalLabel"> Insufficient CD Balance HR Notification</h5>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body" id="modal_body">
<!-- Form -->
<form id="hrEmailForm">
<input type="hidden", id="client_id_for_hr_mail_send" name="client_id" >
<!-- Toggle Section -->
<div class="toggle-section">
<div class="toggle-container">
<label class="toggle-label">Insufficient Balance HR Mail Send</label>
<label class="toggle-switch">
<input type="checkbox" id="mailToggle" onchange="toggleHRList()">
<span class="toggle-slider"></span>
</label>
</div>
</div>
<!-- HR List Section -->
<div class="hr-list-section" id="hrListSection">
<!-- HR items will be dynamically generated here -->
</div>
<!-- Footer Buttons -->
<div class="modal-footer">
<button type="button" class="btn btn-cancel" onclick="cancelModal()">Cancel</button>
<button type="submit" class="btn btn-submit" id="submitBtn">Send Notification</button>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
var client_id_param2 = 0;
var client_branch_id_param2 = 0;
var client_policy_param2 = 0;
var hr_data = [];
$(document).ready(function() {
// Initialize select2
@ -719,19 +1116,22 @@
var messageShown = false; // Flag to prevent duplicate messages
//function for checking the session
function checkCDBalance() {
function checkCDBalanceOld() {
const get_cd_balance = <?= json_encode(get_cd_balance()) ?>;
console.log({ get_cd_balance });
<?php if (session()->has('cd_balance')): ?>
var cdBalance = <?php echo json_encode(session()->get('cd_balance')); ?>;
var cdAmount = <?php echo json_encode(session()->get('cd_amount')); ?>;
var excel_file_amt = <?php echo json_encode(session()->get('excel_file_amt')); ?>;
hr_data = <?php echo json_encode(session()->get('hr_data')); ?>;
console.log("cdBalance : ", cdBalance);
console.log("cdAmount : ", cdAmount);
console.log("excel_file_amt : ", excel_file_amt);
console.log({cdBalance, cdAmount, excel_file_amt, hr_data})
// Only show message once and if status is false
if (cdBalance === false && !messageShown) {
if (get_cd_balance?.cd_balance === false && !messageShown) {
// toastr.warning('Insufficient CD Balance deducated. Please wait the file will be downloaded', 'WARNING');
var message1 = 'Insufficient CD Balance deducted. Please wait the file will be downloaded<br>' +
'<strong>CD Amount:</strong> ₹' + (cdAmount || 0) + '<br>' +
@ -742,8 +1142,11 @@
timeOut: 10000,
extendedTimeOut: 3000
});
messageShown = true; // Prevent showing message again
stopInterval();
openModal();
} else if (cdBalance === true) {
console.log("CD Balance is sufficient");
stopInterval();
@ -760,6 +1163,53 @@
<?php endif; ?>
}
async function checkCDBalance() {
try {
// 1. Fetch the LATEST session data from the server
const response = await fetch('checkSessionStatus');
const cdData = await response.json();
console.log('Current Session Data:', cdData);
// 2. Check if cd_balance_info exists and isn't empty
if (cdData.has_cd_balance && cdData.cd_balance_info) {
if(cdData.cd_balance === 'sufficient'){
stopInterval(); // Stop checking once we find the error
console.log("CD Balance is sufficient");
return;
}
let cd_balance_info = JSON.parse(cdData.cd_balance_info) ?? null;
let hr_info = cdData.hr_data ? JSON.parse(cdData.hr_data) : null;
// If balance is marked as false (insufficient)
if (cd_balance_info.cd_balance === false) {
stopInterval(); // Stop checking once we find the error
toastr.warning(
`Insufficient CD Balance.<br>Balance: ₹${cd_balance_info.cd_amount}`,
'WARNING',
{ allowHtml: true }
);
if(hr_info) {
$('#client_id_for_hr_mail_send').val(hr_info.client_id);
window.hr_data = hr_info.hr_data;
}
openModal();
// 3. Clear the session now that we've handled it
fetch('clearCdSession');
}
}
} catch (error) {
console.error('Error checking CD balance:', error);
}
}
// Start the interval
function startInterval() {
if (!submitInterval) {
@ -796,6 +1246,7 @@
//------------------------------------------------------------------------------------------------------
</script>
<script>
function togglePolicyIssueDate() {
@ -874,3 +1325,198 @@
}
</script>
<script>
// Sample HR data (replace this with your actual data source)
const hrData = [
{ id: 1, name: 'Rajesh Kumar', email: 'rajesh.kumar@company.com' },
{ id: 2, name: 'Priya Sharma', email: 'priya.sharma@company.com' },
{ id: 3, name: 'Arun Patel', email: 'arun.patel@company.com' },
{ id: 4, name: 'Arun Patel', email: 'arun.patel@company.com' },
{ id: 5, name: 'Arun Patel', email: 'arun.patel@company.com' },
];
// Open Modal
function openModal() {
// document.getElementById('hrModal').classList.add('active');
var myModal = new bootstrap.Modal(document.getElementById('payout_modal'));
myModal.show();
}
// Toggle HR List
function toggleHRList() {
const toggle = document.getElementById('mailToggle');
const hrListSection = document.getElementById('hrListSection');
if (toggle.checked) {
hrListSection.classList.add('active');
renderHRList();
} else {
hrListSection.classList.remove('active');
}
}
// Render HR List
function renderHRList() {
const hrListSection = document.getElementById('hrListSection');
if (hr_data.length === 0) {
hrListSection.innerHTML = `
<div class="empty-state">
<div class="empty-state-icon">📭</div>
<div class="empty-state-text">No HR contacts available</div>
</div>
`;
return;
}
hrListSection.innerHTML = hr_data.map(hr => `
<div class="hr-item" onclick="toggleCheckbox(${hr.id}, event)">
<label class="hr-checkbox">
<input type="checkbox" name="hr_emails[]" value="${hr.id}" data-email="${hr.email}" data-name="${hr.name}" id="hr_${hr.id}">
<span class="checkbox-custom"></span>
</label>
<div class="hr-info">
<div class="hr-name">${hr.name}</div>
<div class="hr-email">${hr.email}</div>
</div>
</div>
`).join('');
}
// Toggle checkbox when clicking on the item
function toggleCheckbox(hrId, event) {
// Prevent double toggle if clicking directly on checkbox
if (event && event.target.tagName === 'INPUT') {
return;
}
const checkbox = document.getElementById(`hr_${hrId}`);
checkbox.checked = !checkbox.checked;
}
// Cancel Modal with Confirmation
function cancelModal() {
// document.getElementById('confirmDialog').classList.add('active');
Swal.fire({
title: "Cancel Confirmation",
text: "Are you sure you want to cancel? No emails will be sent to HR.",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: "Yes, Procced!"
}).then((result) => {
if(result.isConfirmed){
confirmCancel()
}else{
return false
}
});
}
// Confirm Cancel
function confirmCancel() {
setTimeout(() => {
$('.close').click();
resetForm();
}, 300);
}
// Reset Form
function resetForm() {
document.getElementById('hrEmailForm').reset();
document.getElementById('hrListSection').classList.remove('active');
}
$('#hrEmailForm').on('submit', function (e) {
e.preventDefault();
const client_id = $('#client_id_for_hr_mail_send').val();
const mailToggle = $('#mailToggle');
const selectedHRs = $('input[name="hr_emails[]"]:checked');
if (!mailToggle.is(':checked')) {
toastr.warning('Please Enable the mail option.', 'WARNING');
return;
}
if (selectedHRs.length === 0) {
toastr.warning('Please select at least one HR.', 'WARNING');
return;
}
// Prepare mails object
const sendingMails = {};
selectedHRs.each(function () {
const hrId = $(this).val();
const hrEmail = $(this).data('email');
const hrName = $(this).data('name');
sendingMails[hrId] = {
mail: hrEmail,
name: hrName
};
});
const formData = {
mails: sendingMails,
client_id: client_id,
mail_enable_key: mailToggle.is(':checked') ? 1 : 0
};
console.log('Form Data:', formData);
const $submitBtn = $('#submitBtn');
$submitBtn.prop('disabled', true).text('Sending...');
const url = '<?= base_url('util/insufficientCdBalanceHrMailSend') ?>';
$.ajax({
url: url,
type: 'POST',
data: JSON.stringify(formData),
contentType: 'application/json',
dataType: 'json',
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') || ''
},
success: function (data) {
console.log('Response Success:', data);
if (data.status === true) {
toastr.success(data.message, 'SUCCESS');
} else {
toastr.warning(data.message, 'WARNING');
}
},
error: function (xhr, status, error) {
console.error('Response Error:', error);
toastr.error('Something went wrong. Please try again.', 'ERROR');
},
complete: function () {
// Reset button state
$submitBtn.prop('disabled', false).text('Send Notification');
confirmCancel();
}
});
});
const modal = document.getElementById('payout_modal');
const modalDialog = modal.querySelector('.modal-dialog');
modal.addEventListener('mousedown', function (e) {
if (!modalDialog.contains(e.target)) {
e.preventDefault();
e.stopImmediatePropagation();
return false;
}
}, true); // 👈 capture phase
</script>

View File

@ -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();

View File

@ -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) {

View File

@ -0,0 +1,33 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Metabase Dashboard</title>
<!-- Metabase embed script -->
<script defer src="<?= esc($metabaseUrl) ?>/app/embed.js"></script>
<script>
function defineMetabaseConfig(config) {
window.metabaseConfig = config;
}
defineMetabaseConfig({
theme: {
preset: "light"
},
isGuest: true,
instanceUrl: "<?= esc($metabaseUrl) ?>"
});
</script>
</head>
<body>
<metabase-dashboard
token="<?= esc($metabaseToken) ?>"
with-title="true"
with-downloads="true">
</metabase-dashboard>
</body>
</html>

View File

@ -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'];
}
}
}
?></p>
@ -265,6 +271,7 @@
</div>
</div>
</div>
<!-- member review and summary mail -->
<div class="form-group col-md-6 mail-row">
<div class="mail-section">
@ -283,6 +290,26 @@
</div>
</div>
<!-- Hr cd insifficient mail -->
<div class="form-group col-md-6 mail-row">
<div class="mail-section">
<div class="left">
<label class="switch">
<input id="hr_cd_insufficient_balance_mail_btn" type="checkbox" name="hr_cd_insufficient_balance_mail_btn" <?= $hr_cd_insufficient_balance_mail == 1 ? 'checked' : '' ?>>
<span class="slider round"></span>
</label>
<span class="ml-2"> HR CD Insufficient Balance Mail</span>
</div>
<div class="right">
<a href="" data-toggle="modal" id="hr_cd_insufficient_balance_mail" onclick="getMailTemplateData(this)" data-target="#hr_cd_insufficient_balance_mail_modal">
<i class="mdi mdi-pencil"></i>
</a>
</div>
</div>
</div>
</div>
@ -988,6 +1015,89 @@
</div> <!-- /.modal-dialog -->
</div> <!-- /.modal -->
<!-- 7 Modal content for the Large example => CD balance insufficent HR mail sent -->
<div class="modal fade" id="hr_cd_insufficient_balance_mail_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
aria-hidden="true" aria-modal="true" data-backdrop="static">
<div class="modal-dialog modal-full-width">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myLargeModalLabel"> HR CD Insufficient Balance Mail <span id="nameOfThePolicy"></span></h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<div class="text-center" id="no_data"></div>
<form role="form" class="parsley-examples" method="post" id="hr_cd_insufficient_balance_mail_form" enctype="multipart/form-data">
<div class="form-group">
<div class="form-row" id="rac_rate_dropdown">
<div class="form-group col-md-2">
<label for="template_name">Template Name</label>
</div>
<div class="form-group col-md-5">
<input type="text" id="template_name" name="template_name" value="HR CD Insufficient Balance Mail" readonly class="form-control" placeholder="Template Name">
</div>
</div>
<div class="form-row" id="rac_rate_dropdown">
<div class="form-group col-md-2">
<label for="subject">Subject</label>
</div>
<div class="form-group col-md-5">
<input type="text" id="subject" name="subject" class="form-control" placeholder="Subject">
</div>
<div class="form-group col-md-5 testmail" style="display: none;">
<a class="btn btn-primary waves-effect waves-light mr-1 setid" onclick="testMailSend(this,'send')">Test Mail</a>
<a class="btn btn-primary waves-effect waves-light mr-1 setid" onclick="PreviewTheMail(this,'preview','client_hr_summary_mail')">Preview Mail</a>
</div>
</div>
<div class="hr_cd_insufficient_balance_mail_section">
<div class="form-row" id="rac_rate_dropdown">
<div class="form-group col-md-12">
<select id="hr_cd_insufficient_balance_mail_customButton" class="form-control" style="border:none; right:6px; width:auto; position:absolute; z-index:1; top:17px; height:32px; float:right;" onchange="copyToClipboard(this)">
<option value="">PlaceHolders</option>
<?php foreach ($placeHolders as $value): ?>
<?php if (in_array($value, ['hr_name', 'client_name'])): ?>
<?php $valueChange = ucwords(str_replace('_',' ',$value)); ?>
<option value="{{<?php echo $value; ?>}}"><?php echo $valueChange; ?></option>
<?php endif; ?>
<?php endforeach; ?>
</select>
<span id="copy-feedback" style="display: none; position: absolute; top:50px; right:10px; color:green; font-size:12px;">Copied to clipboard!</span>
</div>
</div>
<hr>
<!-- Unlayer editor -->
<div class="form-row" id="rac_rate_dropdown">
<div class="form-group col-md-12">
<div id="hr_cd_insufficient_balance_mail_editor_container" style="height:600px;"></div>
</div>
</div>
<div id="editor"></div>
<input type="file" id="Question_title_fileInput" style="display:none;">
</div>
</div> <!-- /.form-group -->
<div class="form-group text-right m-b-0 hr_cd_insufficient_balance_mail_action">
<button type="button" class="btn btn-primary waves-effect waves-light mr-1 preview_button">Preview</button>
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="btnGridSubmit_2">Submit</button>
</div>
<div class="hr_cd_insufficient_balance_mail_preview"></div>
</form>
</div> <!-- /.modal-body -->
</div> <!-- /.modal-content -->
</div> <!-- /.modal-dialog -->
</div> <!-- /.modal -->
<div class="modal fade" id="preview_modal" tabindex="-1" role="dialog" aria-hidden="false" aria-modal="true" data-backdrop="static">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
@ -1524,7 +1634,7 @@
<form class="ajax" onsubmit="submitAttachmentForm(event, this)">
<div style="display:flex; align-items:center; gap:10px; white-space:nowrap;">
<div>
<input type="file" name="file" required
<input type="file" name="file"
style="width:100%; min-width:160px;
padding: 0 !important;
background-color: transparent !important;
@ -1548,7 +1658,7 @@
newRow.innerHTML = `<td><form class="ajax" onsubmit="submitAttachmentForm(event, this)">
<div style="display:flex; align-items:center; gap:10px; white-space:nowrap;">
<div>
<input type="file" name="file" required
<input type="file" name="file"
style="width:100%; min-width:160px;
padding: 0 !important;
background-color: transparent !important;
@ -1614,7 +1724,6 @@
const formData = new FormData(form);
formData.append('template_name', template_name);
formData.append('client_id', client_id);
console.log(formData.template_name);
const fileInput = form.querySelector('input[type="file"]');
// Check if a file is selected
@ -1842,7 +1951,14 @@
function getMailTemplateData(element) {
template_name = element.id;
const validTemplates = [
"account_maneger_summary_mail", "member_reminder_mail","member_common_mail", "member_ecard_mail", "member_welcome_mail", "member_review_and_summary_mail", "client_hr_summary_mail"
"account_maneger_summary_mail",
"member_reminder_mail",
"member_common_mail",
"member_ecard_mail",
"member_welcome_mail",
"member_review_and_summary_mail",
"client_hr_summary_mail",
"hr_cd_insufficient_balance_mail"
];
console.log(`:) getMailTemplateData function called for ${template_name}`); // REF : PS
if (!validTemplates.includes(template_name)) {
@ -1980,23 +2096,15 @@
// Use the editor instance instead of unlayer directly
editor.exportHtml(function(data) {
var formData = $('#account_maneger_summary_mail_form').serializeArray();
// Append Unlayer editor data
formData.push({
name: 'mailContent',
value: data.html
});
formData.push({
name: 'client_id',
value: $('#general_PrimaryKey').val()
});
formData.push({
name: 'mailJson',
value: JSON.stringify(data.design)
});
var formData = new FormData($('#account_maneger_summary_mail_form')[0]);
console.log(formData);
// Append Unlayer data
formData.append('mailContent', data.html);
formData.append('client_id', $('#general_PrimaryKey').val());
formData.append('mailJson', JSON.stringify(data.design));
console.log([...formData.entries()]);
// Show loading indicators
$('.loader').fadeIn();
@ -2009,6 +2117,8 @@
type: "POST",
data: formData,
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
$('#account_maneger_summary_mail_modal').find('.close').click();
toastr.success('Template saved successfully');
@ -2040,23 +2150,15 @@
// Use the editor instance instead of unlayer directly
editor.exportHtml(function(data) {
var formData = $('#member_welcome_mail_form').serializeArray();
// Append Unlayer editor data
formData.push({
name: 'mailContent',
value: data.html
});
formData.push({
name: 'client_id',
value: $('#general_PrimaryKey').val()
});
formData.push({
name: 'mailJson',
value: JSON.stringify(data.design)
});
var formData = new FormData($('#member_welcome_mail_form')[0]);
console.log(formData);
// Append Unlayer data
formData.append('mailContent', data.html);
formData.append('client_id', $('#general_PrimaryKey').val());
formData.append('mailJson', JSON.stringify(data.design));
console.log([...formData.entries()]);
// Show loading indicators
$('.loader').fadeIn();
@ -2069,6 +2171,8 @@
type: "POST",
data: formData,
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
$('#member_welcome_mail_modal').find('.close').click();
toastr.success('Template saved successfully');
@ -2100,23 +2204,15 @@
// Use the editor instance instead of unlayer directly
editor.exportHtml(function(data) {
var formData = $('#member_reminder_mail_form').serializeArray();
// Append Unlayer editor data
formData.push({
name: 'mailContent',
value: data.html
});
formData.push({
name: 'client_id',
value: $('#general_PrimaryKey').val()
});
formData.push({
name: 'mailJson',
value: JSON.stringify(data.design)
});
var formData = new FormData($('#member_reminder_mail_form')[0]);
console.log(formData);
// Append Unlayer data
formData.append('mailContent', data.html);
formData.append('client_id', $('#general_PrimaryKey').val());
formData.append('mailJson', JSON.stringify(data.design));
console.log([...formData.entries()]);
// Show loading indicators
$('.loader').fadeIn();
@ -2129,6 +2225,8 @@
type: "POST",
data: formData,
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
$('#member_reminder_mail_modal').find('.close').click();
toastr.success('Template saved successfully');
@ -2160,23 +2258,15 @@
// Use the editor instance instead of unlayer directly
editor.exportHtml(function(data) {
var formData = $('#member_ecard_mail_form').serializeArray();
// Append Unlayer editor data
formData.push({
name: 'mailContent',
value: data.html
});
formData.push({
name: 'client_id',
value: $('#general_PrimaryKey').val()
});
formData.push({
name: 'mailJson',
value: JSON.stringify(data.design)
});
var formData = new FormData($('#member_ecard_mail_form')[0]);
console.log(formData);
// Append Unlayer data
formData.append('mailContent', data.html);
formData.append('client_id', $('#general_PrimaryKey').val());
formData.append('mailJson', JSON.stringify(data.design));
console.log([...formData.entries()]);
// Show loading indicators
$('.loader').fadeIn();
@ -2189,6 +2279,8 @@
type: "POST",
data: formData,
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
$('#member_ecard_mail_modal').find('.close').click();
toastr.success('Template saved successfully');
@ -2221,21 +2313,15 @@
// Use the editor instance instead of unlayer directly
editor.exportHtml(function(data) {
var formData = $('#member_common_mail_form').serializeArray();
// Append Unlayer editor data
formData.push({
name: 'mailContent',
value: data.html
});
formData.push({
name: 'client_id',
value: $('#general_PrimaryKey').val()
});
formData.push({
name: 'mailJson',
value: JSON.stringify(data.design)
});
var formData = new FormData($('#member_common_mail_form')[0]);
// Append Unlayer data
formData.append('mailContent', data.html);
formData.append('client_id', $('#general_PrimaryKey').val());
formData.append('mailJson', JSON.stringify(data.design));
console.log([...formData.entries()]);
// Show loading indicators
$('.loader').fadeIn();
@ -2248,6 +2334,8 @@
type: "POST",
data: formData,
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
$('#member_common_mail_modal').find('.close').click();
toastr.success('Template saved successfully');
@ -2279,23 +2367,15 @@
// Use the editor instance instead of unlayer directly
editor.exportHtml(function(data) {
var formData = $('#member_review_and_summary_mail_form').serializeArray();
// Append Unlayer editor data
formData.push({
name: 'mailContent',
value: data.html
});
formData.push({
name: 'client_id',
value: $('#general_PrimaryKey').val()
});
formData.push({
name: 'mailJson',
value: JSON.stringify(data.design)
});
var formData = new FormData($('#member_review_and_summary_mail_form')[0]);
console.log(formData);
// Append Unlayer data
formData.append('mailContent', data.html);
formData.append('client_id', $('#general_PrimaryKey').val());
formData.append('mailJson', JSON.stringify(data.design));
console.log([...formData.entries()]);
// Show loading indicators
$('.loader').fadeIn();
@ -2308,6 +2388,8 @@
type: "POST",
data: formData,
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
$('#member_review_and_summary_mail_modal').find('.close').click();
toastr.success('Template saved successfully');
@ -2339,23 +2421,16 @@
// Use the editor instance instead of unlayer directly
editor.exportHtml(function(data) {
var formData = $('#client_hr_summary_mail_form').serializeArray();
// Append Unlayer editor data
formData.push({
name: 'mailContent',
value: data.html
});
formData.push({
name: 'client_id',
value: $('#general_PrimaryKey').val()
});
formData.push({
name: 'mailJson',
value: JSON.stringify(data.design)
});
var formData = new FormData($('#client_hr_summary_mail_form')[0]);
// Append Unlayer data
formData.append('mailContent', data.html);
formData.append('client_id', $('#general_PrimaryKey').val());
formData.append('mailJson', JSON.stringify(data.design));
console.log([...formData.entries()]);
console.log(formData);
// Show loading indicators
$('.loader').fadeIn();
@ -2368,6 +2443,63 @@
type: "POST",
data: formData,
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
$('#client_hr_summary_mail_modal').find('.close').click();
toastr.success('Template saved successfully');
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Something Went Wrong!', 'warning');
}, 1000);
}
});
});
});
$('#hr_cd_insufficient_balance_mail_form').submit(function(event) {
event.preventDefault();
// Check if editor instance exists
if (!editor) {
console.error("Editor not initialized");
toastr.error("Editor not ready. Please try again.");
return;
}
// Use the editor instance instead of unlayer directly
editor.exportHtml(function(data) {
var formData = new FormData($('#hr_cd_insufficient_balance_mail_form')[0]);
// Append Unlayer data
formData.append('mailContent', data.html);
formData.append('client_id', $('#general_PrimaryKey').val());
formData.append('mailJson', JSON.stringify(data.design));
console.log([...formData.entries()]);
// Show loading indicators
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var form_action = '<?= base_url("client/notification/create") ?>';
$.ajax({
url: form_action,
type: "POST",
data: formData,
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
$('#client_hr_summary_mail_modal').find('.close').click();
toastr.success('Template saved successfully');
@ -2485,6 +2617,10 @@
name: 'client_hr_summary_mail_btn',
value: $('#client_hr_summary_mail_btn').prop('checked')
});
formData.push({
name: 'hr_cd_insufficient_balance_mail_btn',
value: $('#hr_cd_insufficient_balance_mail_btn').prop('checked')
});
var form_action = '<?= base_url("client/notification/update_enable") ?>';
$('.loader').fadeIn();

View File

@ -151,7 +151,8 @@
</style>
<div class="row" id="endorsement_form" style="display: none;">
<div class="tab-pane fade active show" id="form">
<div class="row" id="endorsement_form">
<div class="col-12">
<div class="card">
<div class="card-body">
@ -386,6 +387,27 @@
</div>
</div>
<!-- Policy Docs Row -->
<div class="row" id="policy_docs" style="display: none;">
<div class="col-md-12">
<div id="accordion_23" class="mb-0">
<label id="policyAccordion" class="m-1 d-flex justify-content-between align-items-center">
<span class="font-color-black">Policy Docs</span>
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseTwentyTwo"
aria-expanded="true">
<i id="icon" class="mdi mdi-chevron-up mr-1 text-primary" style="font-size: 28px;"></i>
</a>
</label>
<div class="card mb-1">
<div id="collapseTwentyTwo" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_23">
<div class="card-body" id="policy_docs_div" style="background-color: #F5FFFF !important; border-radius: 10px; box-shadow: 4px 4px 4px 4px #00000040;">
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Premium Details -->
<div class="row">
<div class="col-md-12">
@ -576,6 +598,7 @@
</div>
</div>
</div>
</div>
<!-- end form row -->
<script>
@ -1017,6 +1040,8 @@
$('#cop_yes').val(0);
}
$('#policy_tranction_primarykey_for_file_upload').val(res.data.id);
$('#client_policy_id_for_file_upload').val(res.data.client_policy_id);
$('#policy_tranction_primarykey').val(res.data.id);
$('#client_type').val(res.data.client_type).trigger('change');
$('#client_id').val(res.data.client_id).change();
@ -1048,6 +1073,10 @@
$('#policy_start_date').val(res.data.policy_start_date);
$('#policy_end_date').val(res.data.policy_end_date);
$('#insurer_id').val(res.data.insurer_branch_id + '-' + res.data.insurer_id);
$('#client_type').addClass('readonly-select ');
$('#client_id').addClass('readonly-select ').select2('destroy');
$('#client_branch_id').addClass('readonly-select ').select2('destroy');
$('#client_policy_id').addClass('readonly-select ').select2('destroy');
}, 1500)
$('#policy_no').val(res.data.policy_no);
@ -1067,12 +1096,16 @@
$('#cd_ac_no').val(res.data.cd_ac_no);
$('#ct_type').val(res.data.ct_type);
$('#hide_file_upload').show()
if (res.data.policy_with_corr == 1) {
$('#policy_with_corr').prop('checked', true);
} else {
$('#policy_with_corr').prop('checked', false);
}
appendFileTableBody(res.data.pt_files);
// if (res.data.is_cd_reduce_from_bds == 1) {
// $('#is_cd_reduce_from_bds').prop('checked', true).prop('checked', false);
// } else {

View File

@ -363,10 +363,9 @@ table.dataTable thead th {
</div><!-- end col -->
</div>
<!-- end table row -->
<?php include('pt_endorsement_form_file_upload_tab.php'); ?>
<?php include('policy_transaction_endorsement_form.php'); ?>
<script>
document.addEventListener("DOMContentLoaded", function() {
const table = document.getElementById("tickets-table");
@ -448,6 +447,7 @@ table.dataTable thead th {
});
});
</script>
<script>
var client_list = '';
var branch_list = '';
@ -461,6 +461,7 @@ table.dataTable thead th {
$(document).ready(function() {
getClientAndBranchAndPolicy()
addHTMLInput();
<?php if (session()->has('create_failed')) : ?>
toastr.error('<?= session()->getFlashdata('create_failed') ?>', 'Failed');
@ -506,6 +507,8 @@ table.dataTable thead th {
className: 'btn app-btn-primary mr-2',
action: function (e, dt, node, config) {
hide_list_show_add();
addHTMLInput(null, 'policy_docs_div');
$('#policy_docs').show()
},
attr: { id: 'btnAdd' }
},
@ -614,15 +617,16 @@ table.dataTable thead th {
$('#endorsement_form_id')[0].reset();
$('#client_id').val('').change();
$('#client_policy_id').val('').change();
$('#endorsement_form').show();
$('#endorsement_list').hide();
$('#endorsement_filter').hide();
$('#invoice_no_div').hide();
$('#invoice_no').attr('required', false)
$('#pt_onboarding').show();
$('#endorsement_list').hide();
$('#endorsement_filter').hide();
}
function show_list_hide_add() {
$('#endorsement_form').hide()
$('#pt_onboarding').hide()
$('#endorsement_list').show()
$('#endorsement_filter').show()
@ -836,7 +840,6 @@ table.dataTable thead th {
})
</script>
<script>
$(document).ready(function() {
getURLParams()
@ -1034,4 +1037,87 @@ table.dataTable thead th {
});
}
function addHTMLInput(data = null, container_id = 'dynamic-form-container')
{
console.log('container_id', container_id);
const container = document.getElementById(container_id);
let required = ''
let required_star = ''
if(container_id == 'dynamic-form-container'){
required = 'required';
required_star = '*';
}
console.log('container', container);
const newRow = document.createElement('div');
newRow.className = 'form-row dynamic-form-row';
newRow.innerHTML = `
<div class="form-group col-md-5">
<label for="file_name">Document Name<span class="text-danger">${required_star}</span></label>
<input type="text" class="form-control" id="docs_name" name="doc_name[]" placeholder="Enter file name" ${required}>
</div>
<div class="form-group col-md-5">
<label for="file">Upload File<span class="text-danger">${required_star}</span></label>
<input type="file" class="form-control" id="file_name" name="file[]" ${required} accept=".pdf,.jpg,.jpeg,.png">
</div>
<div class="form-group col-md-2" style="position: relative;top: 28px;">
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInput(this, '${container_id}')">x</a>
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="addHTMLInput(null, '${container_id}')">+</a>
</div>
`;
container.appendChild(newRow);
if (data !== null && data.db_column_name !== undefined) {
const selectElement = newRow.querySelector('.db-column-name-select');
selectElement.value = data.db_column_name;
}
}
function removeHTMLInput(element, container_id)
{
const container = document.getElementById(container_id);
const rows = container.querySelectorAll('.dynamic-form-row');
if (rows.length > 1) {
const row = element.closest('.dynamic-form-row');
row.remove();
}
}
function appendFileTableBody(data)
{
console.log(data);
$('#table_bd').empty();
$.each(data, function(index, item) {
var row = $('<tr>');
row.append($('<td>').text(index+1));
row.append($('<td>').text(item.doc_name));
row.append($('<td>').text(item.file_name));
// var url = "<?= base_url('/downloadGdriveFile'); ?>" +
// "?client_id=" + item.client_id +
// "&file_type=policy" +
// "&file_name=" + item.file_name +
// "&client_policy_id=" + item.client_policy_id;
var url = '<?= base_url('download-kyc-docs/') ?>' + item.file_name;
var link = $('<a>')
.attr('href', url)
.attr('target', '_blank') // Open in a new tab
.attr('style', 'font-size:18px;')
.attr('data-id', item.id)
.addClass('mdi mdi-download')
// Append the <a> tag inside the <td>
row.append($('<td>').append(link));
$('#table_bd').append(row);
});
}
</script>

View File

@ -2384,6 +2384,9 @@
$('#table_tr_37').hide();
}
$('#client_id').addClass('readonly-select ').select2('destroy');
$('#client_branch_id').addClass('readonly-select ').select2('destroy');
}, 4000)
// Set additional fields
@ -2485,7 +2488,7 @@
// } else {
// $('#bro_payable_by').prop('checked', false);
// }
$('#bro_payable_by').val(res.data.bro_payable_by);
$('#bro_payable_by').val(res.data.bro_payable_by ?? 1);
// Policy transaction status handling
if (res.data.status == "completed") {

View File

@ -316,7 +316,7 @@ table.dataTable tbody td {
<?php foreach($inception_data_list as $index => $row){ ?>
<tr>
<td class="text-center"><?php echo $index+1; ?></td>
<td><?php echo $issuer[$row['issuer']]; ?></td>
<td><?php echo $issuer[$row['issuer']] ?? 'Nhance'; ?></td>
<td><?php echo $issuing_type[$row['issue_type']] ?? 'N/A'; ?></td>
<td><?php echo $client_type[$row['client_type']] ?? 'N/A'; ?></td>
<td><?php echo $row['client_type'] == 2 ? $row['client_name'] . " - " . (!empty($row['pan']) ? $row['pan'] : 'N/A') : $row['client_short_name'] . ' - ' . $row['client_branch_name']; ?></td>

View File

@ -0,0 +1,34 @@
<div class="row" id="pt_onboarding" style="position: relative; bottom: 25px; display:none;">
<div class="col-xl-12">
<div class="card-body">
<div class="tab-wrapper position-relative">
<ul class="nav nav-pills navtab-bg" id="myTab">
<li class="nav-item d-flex justify-content-center align-items-center">
<button class="scroll-btn left-btn" type="button">&#9664;</button>
</li>
<li class="nav-item">
<a href="#form" data-toggle="tab" aria-expanded="false" class="nav-link px-3 py-2 active-tab active" id="general_tab">
<span class="mr-1"><i class="mdi mdi-contacts"></i></span>
<span class="d-none d-sm-inline-block">Policy</span>
</a>
</li>
<li class="nav-item" id="hide_file_upload" style="display: none;">
<a href="#fileupload" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-2" id="kyc_tab">
<span class="mr-1"><i class="mdi mdi-file"></i></span>
<span class="d-none d-sm-inline-block">Policy Docs</span>
</a>
</li>
<li class="nav-item d-flex justify-content-center align-items-center">
<!-- Right Arrow -->
<button class="scroll-btn right-btn" type="button">&#9654;</button>
</li>
</ul>
</div>
<div class="tab-content">
<?php include('policy_transaction_endorsement_form.php'); ?>
<?php include('drive_file_upload.php'); ?>
</div>
</div>
</div>
</div>

View File

@ -184,9 +184,9 @@ table.dataTable tbody td {
<!-- <td style="display: none;"><?php echo $row['insurer_name'] ?: 'N/A'; ?> </td> -->
<td><?php echo $row['insurer_branch_name'] ?: 'N/A'; ?></td>
<!-- <td style="display: none;"><?php echo $row['tpa_name']; ?></td> -->
<td style="display: none;"><?php echo empty($row['endorse_eff_date']) ? 'N/A' : date('d/m/Y', strtotime($row['endorse_eff_date'])) ?></td>
<td style="display: none;"><?php echo empty($row['policy_start_date']) ? 'N/A' : date('d/m/Y', strtotime($row['policy_start_date'])); ?></td>
<td style="display: none;"><?php echo empty($row['policy_end_date']) ? 'N/A' : date('d/m/Y', strtotime($row['policy_end_date'])); ?></td>
<td style="display: none;"><?php echo empty($row['endorse_eff_date']) ? 'N/A' : change_date_format($row['endorse_eff_date'], 'Y-m-d', 'd/m/Y') ?></td>
<td style="display: none;"><?php echo empty($row['policy_start_date']) ? 'N/A' : change_date_format($row['policy_start_date'], 'Y-m-d', 'd/m/Y'); ?></td>
<td style="display: none;"><?php echo empty($row['policy_end_date']) ? 'N/A' : change_date_format($row['policy_end_date'], 'Y-m-d', 'd/m/Y'); ?></td>
<td style="display: none;"><?php echo $row['ref'] ?: 'N/A'; ?></td>
<td style="display: none;"><?php echo $row['remarks'] ?: 'N/A'; ?></td>
@ -241,8 +241,8 @@ table.dataTable tbody td {
<td style="display: none;"><?php echo $row['service_person_name'] ?: 'N/A'; ?></td>
<td style="display: none;"><?php echo $row['nhance_branch'] ?: 'N/A'; ?></td>
<td style="display: none;"><?php echo $row['installment'] ?: 'N/A'; ?></td>
<td style="display: none;"><?php echo empty($row['data_received_date']) ? 'N/A' : date('d/m/Y', strtotime($row['data_received_date'])) ?></td>
<td style="display: none;"><?php echo empty($row['renewal_date']) ? 'N/A' : date('d/m/Y', strtotime($row['renewal_date'])) ?></td>
<td style="display: none;"><?php echo empty($row['data_received_date']) ? 'N/A' : change_date_format($row['data_received_date'], 'Y-m-d', 'd/m/Y') ?></td>
<td style="display: none;"><?php echo empty($row['renewal_date']) ? 'N/A' : change_date_format($row['renewal_date'], 'Y-m-d', 'd/m/Y') ?></td>
<td style="display:none;"><?php echo $row['co_share'] ?? 'No'; ?></td>
<td style="display:none;"><?php echo $row['bro_payable_by'] ?? 'No'; ?></td>

View File

@ -131,22 +131,28 @@
<div class="form-row">
<div class="form-group col-md-4">
<label for="incept_emp_count" class="emp_title"> No of Employees at Inception <span
class="text-danger"></span></label>
<label for="incept_emp_count" class="emp_title">
<span class="emp_title_text"> No of Employees at Inception </span>
<span class="text-danger">*</span>
</label>
<input value="<?= isset($lead_edit_data['incept_emp_count']) ? $lead_edit_data['incept_emp_count'] : '' ?>" type="text" class="form-control" id="incept_emp_count" name="incept_emp_count[]"
placeholder="Enter Lives" required oninput="calculateTotalLives(this)">
</div>
<div class="form-group col-md-4">
<label for="incept_dept_count" class="depnd_title"> No of Dependents at Inception <span
class="text-danger"></span></label>
<label for="incept_dept_count" class="depnd_title">
<span class="depnd_title_text"> No of Dependents at Inception </span>
<span class="text-danger">*</span>
</label>
<input value="<?= isset($lead_edit_data['incept_dept_count']) ? $lead_edit_data['incept_dept_count'] : '' ?>" type="text" class="form-control" id="incept_dept_count" name="incept_dept_count[]"
placeholder="Enter Lives" required oninput="calculateTotalLives(this)">
</div>
<div class="form-group col-md-4">
<label for="incept_no_of_lives" class="total_title"> Total Lives at Inception <span
class="text-danger"></span></label>
<label for="incept_no_of_lives" class="total_title">
<span class="total_title_text">Total Lives at Inception</span>
<span class="text-danger">*</span>
</label>
<input value="<?= isset($lead_edit_data['incept_no_of_lives']) ? $lead_edit_data['incept_no_of_lives'] : '' ?>" type="text" class="form-control" id="incept_no_of_lives" name="incept_no_of_lives[]"
placeholder="Enter Lives" required>
</div>

View File

@ -3,12 +3,16 @@
<div class="form-row" >
<div class="form-group col-md-4">
<label for="incept_emp_count" class="emp_title"> No of Employees at Inception <span class="text-danger">*</span></label>
<label for="incept_emp_count" class="emp_title">
<span class="emp_title_text"> No of Employees at Inception </span>
<span class="text-danger">*</span>
</label>
<input value="<?= isset($lead_edit_data['incept_emp_count']) ? $lead_edit_data['incept_emp_count'] : '' ?>" type="text" class="form-control" id="incept_emp_count" name="incept_emp_count[]" placeholder="Enter Lives" required>
</div>
<div class="form-group col-md-4">
<label for="total_lives_at_incept" class="total_title"> Total Lives at Inception <span class="text-danger"></span></label>
<label for="total_lives_at_incept" class="total_title">
<span class="total_title_text"> Total Lives at Inception </span> <span class="text-danger"></span></label>
<input value="<?= isset($lead_edit_data['total_lives_at_incept']) ? $lead_edit_data['total_lives_at_incept'] : '' ?>" type="text" class="form-control" id="total_lives_at_incept" name="total_lives_at_incept[]" placeholder="Enter Lives" disabled>
</div>