GWM : API rate filter added

This commit is contained in:
Gowtham M 2026-02-07 11:49:12 +05:30
commit f96f180e37
45 changed files with 2979 additions and 1583 deletions

View File

@ -120,3 +120,4 @@ FHPL_USER_NAME =
FHPL_PASSWORD =
FHPL_GRANT_TYPE =
METABASE_SECRET_KEY=

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');
});
@ -556,6 +559,10 @@ $routes->group("/api", ["filter" => [ 'ratelimit' , 'authJWT']], function ($rout
$routes->get("getSSORedirectUrl", "ApiServiceController::getSSORedirectUrl");
$routes->get("getEmployeePolicy", "EmployeeRestController::getEmployeePolicy");
$routes->get("downloadCdSplitUpFile", "EmployeeRestController::downloadCdSplitUpFile");
$routes->get("downloadFileTableFile/(:any)", "EmployeeController::downloadFileList/$1");
$routes->group("employeeRest", ['filter' => ['ratelimit' , 'appSignature'] ], function ($routes) {
@ -600,7 +607,7 @@ $routes->group("employeeRest", ['filter' => ['ratelimit' , 'appSignature'] ], fu
});
$routes->group("employeeRest", ["filter" => [ 'ratelimit' , 'appSignature' , 'authJWT']], function ($routes) {
$routes->group("employeeRest", ["filter" => ['GlobalPostFileUploadGuard', 'ratelimit' , 'appSignature', 'authJWT']], function ($routes) {
$routes->post('logout', 'RestAuthenticationController::logout');
@ -652,6 +659,7 @@ $routes->group("employeeRest", ["filter" => [ 'ratelimit' , 'appSignature' , 'au
$routes->get("hrFileDownload", "EmployeeRestController::hrFileDownload");
$routes->post("hrFileUpload", "EmployeeRestController::hrFileUpload");
$routes->post("updateHrFileUploadData", "EmployeeRestController::updateHrFileUploadData");
$routes->post("getHrDashboad", "EmployeeRestController::getHrDashboad");
//thz_master's
@ -682,7 +690,10 @@ $routes->group("employeeRest", ["filter" => [ 'ratelimit' , 'appSignature' , 'au
// 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");

File diff suppressed because it is too large Load Diff

View File

@ -209,24 +209,23 @@ class EmpDataServiceController extends BaseController
//check CD amt insufficient only insurer, not tpa // DO NOT REMOVE THIS
if($export_data['insurer_or_tpa'] == 'insurer')
{
if (!empty($cash_balance)) {
clear_cd_balance_session();
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]);
$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', false);
$hr_data = $this->getHrdataForInsufficientMailSend($export_data['client_branch_id']);
$session_data = json_encode(['client_id' => $export_data['client_id'], 'hr_data' => $hr_data]);
session()->set('hr_data', $session_data);
}else{
session()->set('cd_balance', true);
}
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);
}
}
@ -735,17 +734,23 @@ class EmpDataServiceController extends BaseController
if($export_data['insurer_or_tpa'] == 'insurer')
{
if (!empty($cash_balance)) {
if ((int) $cash_balance['balance'] < (int) $rounded_totals) {
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.');
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount. CASH BALANCE : {balance} and TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]);
session()->set('cd_balance', false);
session()->set('cd_amount', $cash_balance['balance']);
session()->set('excel_file_amt', $rounded_totals);
if ((int) $cash_balance['balance'] < (int) $totals) {
clear_cd_balance_session(); // Clear old junk first
$cd_session_data = json_encode([
'cd_balance' => false,
'cd_amount' => $cash_balance['balance'],
'excel_file_amt' => $totals
]);
session()->set('cd_balance_info', $cd_session_data);
session()->set('cd_balance', 'insufficient'); // Use a string status for clarity
$hr_data = $this->getHrdataForInsufficientMailSend($export_data['client_branch_id']);
session()->set('hr_data', json_encode(['client_id' => $export_data['client_id'], 'hr_data' => $hr_data]));
}else{
session()->set('cd_balance', true);
session()->set('cd_amount', $cash_balance['balance']);
session()->set('excel_file_amt', $rounded_totals);
session()->set('cd_balance', 'sufficient'); // Use a string status for clarity
session()->set('cd_balance_info', null);
}
}
}
@ -1066,17 +1071,23 @@ class EmpDataServiceController extends BaseController
if($export_data['insurer_or_tpa'] != 'tpa')// check overal emp premium amt with cd balance only for insurer export, not tpa export
{
if (!empty($cash_balance)) {
if ((int) $cash_balance['balance'] < (int) $totals) {
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.');
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount. CASH BALANCE : {balance} and TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]);
session()->set('cd_balance', false);
session()->set('cd_amount', $cash_balance['balance']);
session()->set('excel_file_amt', $totals);
if ((int) $cash_balance['balance'] < (int) $totals) {
clear_cd_balance_session(); // Clear old junk first
$cd_session_data = json_encode([
'cd_balance' => false,
'cd_amount' => $cash_balance['balance'],
'excel_file_amt' => $totals
]);
session()->set('cd_balance_info', $cd_session_data);
session()->set('cd_balance', 'insufficient'); // Use a string status for clarity
$hr_data = $this->getHrdataForInsufficientMailSend($export_data['client_branch_id']);
session()->set('hr_data', json_encode(['client_id' => $export_data['client_id'], 'hr_data' => $hr_data]));
}else{
session()->set('cd_balance', true);
session()->set('cd_amount', $cash_balance['balance']);
session()->set('excel_file_amt', $totals);
session()->set('cd_balance', 'sufficient'); // Use a string status for clarity
session()->set('cd_balance_info', null);
}
}
}
@ -2195,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' => [
@ -2218,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]]);
@ -2634,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]]);
}
@ -3378,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' => [
@ -3889,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' => [
@ -4373,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']);
@ -4510,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']);
@ -4540,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']);
@ -4652,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']);
@ -5418,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]));
@ -5550,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();

View File

@ -31,6 +31,7 @@ use App\Models\UserModel;
use App\Models\PartnerEndorsementRequestModel;
use App\Models\TpaApiDataModel;
use App\Models\LevelContactModel;
use App\Models\NotificationModel;
use App\Controllers\Jobs;
@ -335,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);
}
@ -445,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')
@ -483,7 +485,35 @@ 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){
$string = $error['error_data'] ?? 'System error';
$errorMap = [
"Column order conflict" => "Invalid file format. Please use the sample file.",
];
$message = $string; // Default to the original error
foreach ($errorMap as $keyword => $friendlyMessage) {
if (strpos($string, $keyword) !== false) {
$message = $friendlyMessage;
break; // Stop looking once we find a match
}
}
return $this->respond(['status' => false, 'code' => 404, 'message' => $message, 'data' => []], 200);
}
}
// $file_id = $this->request->uri->getSegment(3);
$empServiceController = new EmployeeServiceController();
@ -4434,7 +4464,7 @@ class EmployeeController extends AdminController
* 4. SEQUENTIAL RE-QUEUE (SAFE)
* --------------------------------------------------------- */
if ($execution_mode === 'sequential' && $rowCount === $batch_size) {
$this->myLogger->logme('info', "$log_search_context"."Re-queueing next batch - " . json_encode([
$this->myLogger->logme('error', "$log_search_context"."Re-queueing next batch - " . json_encode([
'next_batch' => $batch_no + 1,
'last_emp_id' => $new_last_emp_id
]));
@ -4543,7 +4573,6 @@ class EmployeeController extends AdminController
}
}
public function insufficientCdBalanceHrMailSend()
{
$post_data = $this->request->getJson(true);
@ -4554,29 +4583,38 @@ class EmployeeController extends AdminController
$client_data = $this->clientModel->where('is_active', 1)->where('id', $post_data['client_id'])->first();
$common['mail_type'] = "insufficient_cd_balance_by_hr";
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 = 'Insufficient CD Balance Notification';
$mail_content = '
Dear {{HR_NAME}},
Greetings from Nhance.
We would like to inform you that the CD balance for {{CLIENT_NAME}} is currently low / insufficient, which may impact further processing of insurance-related activities.
Kindly request you to credit the required amount at the earliest to avoid any service disruption.
Please let us know once the amount is credited, or if you need any clarification from our end.
Thank you for your support and cooperation.
';
$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);
$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]);
}
@ -4584,6 +4622,217 @@ class EmployeeController extends AdminController
}
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);
}
public function bulkEcardDownloadAsZipFromS3($params)
{
try {
$limit = $params['limit'] ?? 100;
$batch_no = $params['batch_no'] ?? 1;
$last_id = $params['last_emp_policy_id'] ?? 0;
// Fetch batch data
$employee_data = $this->employeePolicyModel->getEmployeeDataWithPolicyUsingClientPolicyIdOrEmployeePolicyIds($params, $limit, $last_id);
if (empty($employee_data)) {
if(!empty($last_id)){
$this->myLogger->logme('error', "bulkEcardDownloadAsZipFromS3 - No more records after last_emp_policy_id: {$last_id}");
$this->myLogger->logme('error', "getEmployeeEcardFromTmpFolderAndZipToS3 - Queuing ZIP creation for folder: " . ($params['folder_name'] ?? 'N/A'));
$r = Jobs::addJob(['job_name' => 'getEmployeeEcardFromTmpFolderAndZipToS3', 'payload' => $params]);
}
return ['status' => true, 'message' => 'Proceeding to Zip'];
}
// Use a consistent folder name across batches (passed in params)
$folderName = $params['folder_name'] ?? 'bulk_ecards_' . $employee_data[0]['policy_no'] . '_' . date('Y-m-d_H-i-s');
$tempPath = FCPATH . 'tmp/' . $folderName . '/';
if (!is_dir($tempPath)) {
mkdir($tempPath, 0777, true);
}
$s3 = \Config\Services::getS3Service();
$pdf_count = 0;
$current_last_id = end($employee_data)['emp_policy_id'];
foreach ($employee_data as $emp_value) {
// Track the last ID in this batch
$current_last_id = $emp_value['emp_policy_id'];
$s3_key = 'ecard_' . $emp_value['name'] . '(' . $emp_value['emp_code'] . ')' . '_' . $emp_value['tpa_id'] . '.pdf';
$s3_key = $this->sanitizeFilePart($s3_key);
if ($s3->exists($s3_key)) {
$s3_url = $s3->getPresignedUrl($s3_key);
$pdf_content = file_get_contents($s3_url['url']);
if ($pdf_content !== false) {
file_put_contents($tempPath . $s3_key, $pdf_content);
$pdf_count++;
}
}
}
$hasMore = count($employee_data) == $limit;
$payload = [
'batch_no' => $batch_no + 1,
'last_emp_policy_id' => $current_last_id,
'folder_name' => $folderName,
'processed_in_this_batch_data_count' => count($employee_data),
'pdf_count' => $pdf_count,
'hr_id' => $params['hr_id'] ?? null
];
if ($hasMore) {
$this->myLogger->logme('error', "bulkEcardDownloadAsZipFromS3 - Queuing next batch: " . json_encode($payload));
$r = Jobs::addJob(['job_name' => 'bulkEcardDownloadAsZipFromS3', 'payload' => $payload]);
$message = "Queuing next batch";
} else {
$this->myLogger->logme('error', "bulkEcardDownloadAsZipFromS3 - No more records after this batch. Next proceeding with getEmployeeEcardFromTmpFolderAndZipToS3");
$r = Jobs::addJob(['job_name' => 'getEmployeeEcardFromTmpFolderAndZipToS3', 'payload' => $payload]);
$message = "All batch completed. Next proceeding with getEmployeeEcardFromTmpFolderAndZipToS3";
}
return ['status' => true, 'message' => $message];
} catch (\Throwable $e) {
$mail_response = $this->sendMailToHrWithZipAttachments($params);
$context = [
'error_message' => $e->getMessage(),
'exception_class' => get_class($e),
'file' => $e->getFile(),
'line' => $e->getLine(),
'trace' => $e->getTraceAsString(),
'mail_response' => $mail_response,
'params' => $params,
];
// Log detailed context for debugging
$this->myLogger->logme('error', 'bulkEcardDownloadAsZipFromS3 - Exception' . json_encode($context, JSON_PRETTY_PRINT));
// Return a detailed, structured error response
return [
'status' => false,
'message' => 'Exception occurred during bulk e-card download and ZIP creation.',
'error' => $context,
];
}
}
public function getEmployeeEcardFromTmpFolderAndZipToS3($params)
{
try {
$zipService = new \App\Libraries\ZipService();
$source = FCPATH . 'tmp/' . $params['folder_name'];
$destination = '/';
$zipName = $params['folder_name'] . '.zip' ?? '';
$result = $zipService->zipAndUploadS3($source, $destination, $zipName);
if($result['status'] === false){
$this->myLogger->logme('error', "getEmployeeEcardFromTmpFolderAndZipToS3 - ZIP creation/upload failed: " . json_encode($result));
$params['url'] = null; // Indicate failure
}else{
$params['url'] = $result['presigned_url']['url'] ?? null;
}
$mail_response = $this->sendMailToHrWithZipAttachments($params);
return ['zip_responce' => $result, 'mail_response' => $mail_response];
} catch (\Throwable $e) {
$mail_response = $this->sendMailToHrWithZipAttachments($params);
$context = [
'error_message' => $e->getMessage(),
'exception_class' => get_class($e),
'file' => $e->getFile(),
'line' => $e->getLine(),
'trace' => $e->getTraceAsString(),
'mail_response' => $mail_response,
'params' => $params,
];
// Log detailed context for debugging
$this->myLogger->logme('error', 'getEmployeeEcardFromTmpFolderAndZipToS3 - Exception' . json_encode($context, JSON_PRETTY_PRINT));
// Return a detailed, structured error response
return [
'status' => false,
'message' => 'Exception occurred during bulk e-card download and ZIP creation.',
'error' => $context,
];
}
}
public function sendMailToHrWithZipAttachments($params)
{
$hr_id = $params['hr_id'] ?? null;
$url = $params['url'] ?? null;
if (empty($hr_id)) {
$this->myLogger->logme('error', "sendMailToHrWithZipAttachments - No HR ID provided.");
return ['status' => false, 'message' => 'No HR ID provided.'];
}
$hr_data = $this->LevelContactModel->where('id', $hr_id)->where('is_active', 1)->first();
if (empty($hr_data) || empty($hr_data['email'])) {
$this->myLogger->logme('error', "sendMailToHrWithZipAttachments - No valid HR data found for ID: {$hr_id}");
return ['status' => false, 'message' => 'No valid HR data found for ID: ' . $hr_id];
}
if(empty($url)){
$subject = "Employee Bulk E-Card Download Failed";
$message = "Dear {$hr_data['name']},<br><br>We were unable to generate the bulk e-card ZIP file. Please re-initialize the process or contact support to retry.";
}else{
$subject = "Employee Bulk E-Cards Download";
$message = "Dear {$hr_data['name']},<br><br>Please find the employee e-cards attached below.<br><br>Download Link: <a href='{$url}'>Download E-Cards</a><br><br>Note : This link valid for 2 days only.";
}
$bbc = 'venkateshraman786@gmail.com';
$mail_response = MailHelper::send_email([
'mail' => $hr_data['email'],
'subject' => $subject,
'message' => $message,
'bcc' => $bbc,
'common' => [
'mail_type' => 'employee_bulk_ecard_download_by_hr',
]
]);
$this->myLogger->logme('error', "sendMailToHrWithZipAttachments - Email sent to HR ID: {$hr_id}, Email Response: " . json_encode($mail_response));
return $mail_response;
}
public function downloadZip(){
}
}

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;
@ -66,6 +69,8 @@ use Kreait\Firebase\Messaging\CloudMessage;
use Kreait\Firebase\Messaging\Notification;
use Kreait\Firebase\Exception\MessagingException;
use Firebase\JWT\JWT;
class EmployeeRestController extends AdminController
{
@ -100,6 +105,7 @@ class EmployeeRestController extends AdminController
protected $hrFileUploadModel;
protected $ticketMailTemplateModel;
protected $employeeRetailPolicy;
protected $batchFileModel;
public function __construct()
@ -134,6 +140,7 @@ class EmployeeRestController extends AdminController
$this->insurerModel = new InsurerModel();
$this->hrFileUploadModel = new HrFileUploadModel();
$this->ticketMailTemplateModel = new TicketMailTemplateModel();
$this->batchFileModel = new BatchFileModel();
}
@ -599,6 +606,7 @@ class EmployeeRestController extends AdminController
public function getEmployeeAndDependenceByClientId()
{
try {
$empData = $this->employeePolicyModel->getEmployeePolicy(client_id: $this->request->getGet('client_id'), policy_id: $this->request->getGet('client_policy_id'), status: 0, branch_id: $this->request->getGet('client_branch_id'));
if ($empData) {
@ -2369,6 +2377,8 @@ class EmployeeRestController extends AdminController
$value['totalMembersCount'] = count($employeeDetails);
$value['membersCountOfActive'] = $activeCount;
$value['membersCountOfInactive'] = $inactiveCount;
$value['is_ecard_bulk_download'] = 0;
$value['is_ecard_bulk_download_for_employee'] = 0;
array_push($result, $value);
@ -2494,11 +2504,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']);
$policy_number = isset($search_data['policy_no']) ? $search_data['policy_no'] : null;
$from_date = isset($search_data['from_date']) ? $search_data['from_date'] : null;
$to_date = isset($search_data['to_date']) ? $search_data['to_date'] : null;
$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']);
unset($search_data['from_date'], $search_data['to_date'], $search_data['claim_status_id'], $search_data['policy_no']);
$where = [];
@ -2618,6 +2629,10 @@ class EmployeeRestController extends AdminController
$builder->whereIn('claim_status_id', $claim_status_ids);
}
if (!empty($policy_number)) {
$builder->where('cp.policy_no', $policy_number);
}
$builder->orderBy('tm.id', 'DESC');
$data = $builder->get()->getResultArray();
@ -3622,6 +3637,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([
@ -3909,10 +3930,14 @@ class EmployeeRestController extends AdminController
log_message('error', 'Ticket validation | Ticket ID: ' . $ticket_id . ' | Matching active tickets with NULL TPA reference: ' . $count);
if ($count > 0 && $pdf_exist_in_the_file && $tpa_claim_push == true) {
// this call for TPA integration
$apiServiceController = new ApiServiceController();
$apiServiceController->pushClaims($ticket_id);
log_message('error', "pushClaims function called with Ticket ID: {$ticket_id}, In Employee Rest Controller");
try {
// this call for TPA integration
$apiServiceController = new ApiServiceController();
$apiServiceController->pushClaims($ticket_id);
log_message('error', "pushClaims function called with Ticket ID: {$ticket_id}, In Employee Rest Controller");
} catch (\Throwable $e) {
log_message('error', "Error in TPA Claim Push via Benifits or HR : ApiServiceController pushClaims function call for Ticket ID: {$ticket_id}. Error: " . $e->getMessage() . " Trace: " . $e->getTraceAsString());
}
} else {
if($tpa_claim_push == false){
log_message('error', 'Skip the TPA claim push for IR DOCUMENTS');
@ -4506,11 +4531,12 @@ class EmployeeRestController extends AdminController
$post_data = [
'client_id' => $this->request->getPost('client_id') ?? null,
'client_branch_id' => $this->request->getPost('client_branch_id'),
'policy_id' => $this->request->getPost('policy_id'),
'file_action' => $this->request->getPost('file_action'),
'created_by' => $this->request->getPost('created_by'),
'file_name' => $this->request->getFile('file_name')
'client_branch_id' => $this->request->getPost('client_branch_id') ?? null,
'policy_id' => $this->request->getPost('policy_id') ?? null,
'file_action' => $this->request->getPost('file_action') ?? null,
'created_by' => $this->request->getPost('created_by') ?? null,
'file_name' => $this->request->getFile('file_name') ?? null,
'policy_no' => $this->request->getPost('policy_no') ?? null,
];
// print_r($post_data); die;
@ -4521,6 +4547,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();
}
@ -4529,10 +4556,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){
@ -4578,15 +4601,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
@ -4609,14 +4632,16 @@ class EmployeeRestController extends AdminController
$responce = $employeeController->employeesUplodWithEvents($post_data);
// print_r($responce); die;
if($responce['status']){
$file_data = $this->getDataFromHrFilesTable(['file_id' => $responce['file_id']]);
$responce['data'] = $file_data;
return $responce;
}else{
$responce['data'] = [];
return $responce;
}
return $responce;
// if(isset($responce['file_id'])){
// $file_data = $this->getDataFromHrFilesTable(['hr_id' => $responce['created_by']]);
// $responce['data'] = $file_data;
// return $responce;
// }else{
// $responce['data'] = [];
// return $responce;
// }
}
private function giveNotificationToClientsAccountManager($data)
@ -4703,28 +4728,40 @@ class EmployeeRestController extends AdminController
try {
$file_id = $this->request->getGet('id') ?? $id;
$client_id = $this->request->getGet('cliend_id') ?? null;
$client_data = [];
if(!empty($client_id)){
if (is_string($client_id) && preg_match('/^[a-f0-9]{32}$/i', $client_id)) {
$client_data = $this->clientModel->where('MD5(id)', $client_id)->first();
} else {
$client_data = $this->clientModel->where('id', $client_id)->first();
}
}
// Find record
$record = $this->hrFileUploadModel->where('id', (int)$file_id)->find();
// print_rr( $record);die;
if($client_data && $client_data['hr_file_processed_by'] == 1){
$record = $this->fileModel->where('id', (int)$file_id)->find();
$uploadPath = WRITEPATH . 'uploads/excel/';
}else{
$record = $this->hrFileUploadModel->where('id', (int)$file_id)->find();
$uploadPath = WRITEPATH . 'uploads/hr_files/';
}
if (!$record) {
return $this->failNotFound("File record not found");
}
$uploadPath = WRITEPATH . 'uploads/hr_files/';
$filePath = $uploadPath . $record[0]['file_name'];
$filePath = $uploadPath . $record[0]['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);
return $this->failNotFound("File not found on server");
}
// Force file download
return $this->response->download($filePath, null)
->setFileName($record[0]['file_name']);
} catch (\Exception $e) {
return $this->failServerError($e->getMessage());
}
@ -4783,13 +4820,21 @@ 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();
if (is_string($search_data['client_id']) && preg_match('/^[a-f0-9]{32}$/i', $search_data['client_id'])) {
$client_data = $this->clientModel->where('MD5(id)', $search_data['client_id'])->first();
$search_data['client_id'] = $client_data['id'];
} else {
$client_data = $this->clientModel->where('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";
}
}
@ -4800,8 +4845,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());
}
}
@ -4835,7 +4892,8 @@ 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,
'' 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')
@ -4870,6 +4928,7 @@ class EmployeeRestController extends AdminController
}
// Execute query
$builder->orderBy('hr_file_upload.id', 'DESC');
$data = $builder->get()->getResultArray();
if(!empty($data)){
@ -4881,7 +4940,7 @@ class EmployeeRestController extends AdminController
public function getDataFromHrFilesTable($search_data)
{
$file_download_base = base_url('util/download-file-list/');
$file_download_base = base_url('downloadFileTableFile/');
$builder = $this->fileModel
->select("
files.id,
@ -4890,7 +4949,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,
@ -4924,7 +4983,11 @@ class EmployeeRestController extends AdminController
}
if (isset($search_data['client_id']) && !empty($search_data['client_id'])) {
$builder->where("files.client_id", $search_data['client_id']);
if (is_string($search_data['client_id']) && preg_match('/^[a-f0-9]{32}$/i', $search_data['client_id'])) {
$builder->where("MD5(files.client_id)", $search_data['client_id']);
} else {
$builder->where("files.client_id", $search_data['client_id']);
}
}
if (isset($search_data['file_id']) && !empty($search_data['file_id'])) {
@ -4933,6 +4996,7 @@ class EmployeeRestController extends AdminController
// Execute query
$builder->orderBy('files.id', 'DESC');
$data = $builder->get()->getResultArray();
if (!empty($data)) {
@ -5369,6 +5433,195 @@ class EmployeeRestController extends AdminController
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);
}
}
public function getHrDashboad()
{
// $dashboard_id = $this->request->getGet('dashboard_id') ?? null;
$client_id = $this->request->getPost('client_id') ?? null;
$client_policy_id = $this->request->getPost('client_policy_id') ?? null;
$received_data = $this->request->getJSON(true) ?? null;
// 🔐 Move this to .env in real projects
$METABASE_SECRET_KEY = getenv('METABASE_SECRET_KEY');
$payload = [
'resource' => [
// 'dashboard' => 1
'dashboard' => 2
],
'params' => (object)['client_policy' => $received_data['client_policy_id']], // 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',
]);
}
// 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();
$builder = $policyTransactionModel
->where('is_active', 1)
->where('policy_no', $client_policy_data['policy_no'])
->where('action_type', $cd_data['event_name']);
if (!empty($cd_data['endorsement_no']) && $cd_data['event_name'] != 'inception') {
$builder->where('endorsement_no', $cd_data['endorsement_no']);
}
$policy_transaction_data = $builder->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);
}
$received_data['folder_name'] = 'bulk_ecards_' . $employee_data[0]['policy_no'] . '_' . date('Y-m-d_H-i-s');
// Dispatch background job to process the bulk e-card download
$r = Jobs::addJob(['job_name' => 'bulkEcardDownloadAsZipFromS3', 'payload' => $received_data]);
$this->myLogger->logme('error', 'bulkEcardDownloadAsZip: Job dispatched with result = ' . json_encode($r ?? []));
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

@ -213,6 +213,14 @@ class JobWorker extends AdminController
'bulkGenerateEcardAndStoreinS3' => [
'type' => 'CC', // Handler Category
'handler' => 'App\Controllers\EmployeeController',
],
'bulkEcardDownloadAsZipFromS3' => [
'type' => 'CC', // Handler Category
'handler' => 'App\Controllers\EmployeeController',
],
'getEmployeeEcardFromTmpFolderAndZipToS3' => [
'type' => 'CC', // Handler Category
'handler' => 'App\Controllers\EmployeeController',
]
];

View File

@ -497,6 +497,9 @@ class MasterController extends AdminController
{
$this->myLogger->logme('error','Edit Insurer general info function called');
$postData = $this->request->getPost();
$logoFile = $this->request->getFile('insurer_logo');
$rules = [
'name' => [
'rules' => 'required',
@ -513,22 +516,30 @@ class MasterController extends AdminController
]
],
'insurer_logo' => [
'rules' => 'if_exist|is_image[insurer_logo]|max_size[insurer_logo,200]|ext_in[insurer_logo,jpg,jpeg,png]',
'rules' => 'permit_empty|is_image[insurer_logo]|max_size[insurer_logo,200]|ext_in[insurer_logo,jpg,jpeg,png]',
'errors' => [
'is_image' => 'The uploaded file must be an image',
'max_size' => 'File size should not exceed 200 KB',
'ext_in' => 'Allowed file types: jpg, jpeg, png',
'ext_in' => 'Only JPG, JPEG, and PNG files are allowed.',
]
],
];
if (!$this->validate($rules)) {
return $this->response->setStatusCode(400)->setJSON([
'status' => false,
'message' => 'Input validation failed',
'code' => 400,
'errors' => $this->validator->getErrors()
]);
if (!$this->validateData($postData, $rules)) {
$errors = $this->validator->getErrors();
$mainMessage = 'Input validation failed';
if (isset($errors['insurer_logo']) && (strpos($errors['insurer_logo'], 'Security') !== false || strpos($errors['insurer_logo'], 'Forbidden') !== false)) {
$mainMessage = 'File upload rejected: Security policy violation.';
}
return $this->response->setStatusCode(400)->setJSON([
'status' => false,
'message' => $mainMessage, // This will change based on the error
'code' => 400,
'errors' => $this->validator->getErrors()
]);
}
$uploadFilePath = ROOTPATH . 'public/uploads/logo/';
@ -2967,6 +2978,7 @@ class MasterController extends AdminController
'files' => WRITEPATH . 'uploads/commission/files',
'rules' => WRITEPATH . 'uploads/commission/rules',
'claim_sample_forms' => ROOTPATH . 'public/claim_sample_forms/',
'tmp' => ROOTPATH . 'public/tmp/',
'bds_dump_excel' => WRITEPATH . 'uploads/bds_dump_excel/',
'claims_mis' => WRITEPATH . 'uploads/claims_mis/',
];

View File

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

@ -776,7 +776,7 @@ class RestAuthenticationController extends AdminController
}else {
return $this->respond(['status' => 'failed','code' => 404,'data' => "" , 'message' => 'User not found' ],200);
return $this->respond(['status' => 'failed','code' => 404,'data' => "" , 'message' => 'Invalid OTP' ],200);
}
@ -786,7 +786,7 @@ class RestAuthenticationController extends AdminController
} else {
return $this->respond(['status' => 'failed','code' => 404,'data' => "" , 'message' => 'User not found' ],200);
return $this->respond(['status' => 'failed','code' => 404,'data' => "" , 'message' => 'Invalid OTP' ],200);
}
} catch (\Exception $e) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()],500);

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,46 @@ class TestingController extends BaseController
}
public function metaDashboardDemo()
{
// 🔐 Move this to .env in real projects
$METABASE_SECRET_KEY = getenv('METABASE_SECRET_KEY');
$policy_id = $this->request->getGet('client_policy');
$policy_id = $policy_id ? $policy_id : 4687;
$payload = [
'resource' => [
// 'dashboard' => 1
'dashboard' => 2
],
'params' => (object)['client_policy' => $policy_id], // MUST be object for Metabase
'exp' => time() + (10 * 60) // 10 minutes
];
// dd($payload);
$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'];
}
$file_id = $params['file_id'] ?? null;
$fileData = $this->claimDumpFileModel->where('id', $file_id)->first();
if (!$fileData) {
return ['status' => false, 'message' => 'Invalid file ID No file data found to import'];
return ['status' => false, 'message' => 'Invalid file ID. No file data found to import'];
}
$handler = TpaClaimsImportFactory::make($fileData['tpa_id'] ?? 0);
$result = $handler->runTicketMasterInsert($params);
if (!empty($result['status']) && $result['status'] === true) {
// Success: Update the status to success
$this->claimDumpFileModel->update($file_id, [
'status' => 'success',
'reason' => null
]);
} else {
// Logic failure: The runTicketMasterInsert returned status false
$this->markAsFailed(
$file_id,
$result['message'] ?? 'System error contact admin',
$fileData['created_by'] ?? null
);
}
return $result;
} catch (\Throwable $th) {
// Log the full error
$this->myLogger->logme("error", 'TICKET_MASTER_CLAIM_IMPORTER_JOB :' . $th->getMessage() . ' at line ' . $th->getLine());
$this->myLogger->logme("error", 'TICKET_MASTER_CLAIM_IMPORTER_JOB :' .($th->getMessage() . ' --- ' . $th->getLine() . '----' . $th->getTraceAsString()));
$errorData = [
'message' => $th->getMessage(),
'file' => $th->getFile(),
'line' => $th->getLine(),
'code' => $th->getCode(),
'trace' => $th->getTraceAsString(),
'trace_array' => $th->getTrace(), // full array version (optional)
'function' => $th->getTrace()[0]['function'] ?? null,
'class' => $th->getTrace()[0]['class'] ?? null,
];
// CRITICAL: Even if the code crashes, try to mark the file as failed
if ($file_id) {
$this->markAsFailed($file_id, 'Fatal Crash: ' . $th->getMessage(), $fileData['created_by'] ?? null);
}
return [
'status' => false,
'message' => $th->getMessage(),
'error_data' => json_encode($errorData, JSON_PRETTY_PRINT)
'error_data' => [
'line' => $th->getLine(),
'file' => $th->getFile()
]
];
}
}

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

@ -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'] ?? null,
];
// Insert data and get the insert ID

View File

@ -947,21 +947,37 @@ if (!function_exists('validateExcelFile')) {
function validateExcelFile($file)
{
$allowed = [
// 1. Check if the file was uploaded without errors
if (! $file->isValid() || $file->hasMoved()) {
return false;
}
// 2. Size check (16MB)
if ($file->getSizeByUnit('mb') > 16) {
return false;
}
// 3. Define allowed types
$allowedMimes = [
'application/vnd.ms-excel',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.oasis.opendocument.spreadsheet'
'application/vnd.oasis.opendocument.spreadsheet',
'application/zip',
'application/octet-stream'
];
// if ($file->getError() !== UPLOAD_ERR_OK) return 'Upload error';
// if ($file->getSize() > (16 * 1024 * 1024)) return 'File too large';
// if (!in_array($file->getClientMimeType(), $allowed, true)) return 'Invalid file type';
if ($file->getError() !== UPLOAD_ERR_OK) return false;
if ($file->getSize() > (16 * 1024 * 1024)) return false;
if (!in_array($file->getClientMimeType(), $allowed, true)) return false;
$allowedExtensions = ['xls', 'xlsx', 'ods', 'xlsm'];
return true;
// Get the actual values using CI4 methods
$mime = $file->getClientMimeType();
$extension = $file->getExtension(); // This is the CI4 method
// 4. Validate
if (in_array($mime, $allowedMimes) || in_array($extension, $allowedExtensions)) {
return true;
}
return false;
}
}
@ -1108,6 +1124,7 @@ if (!function_exists('get_cd_balance')) {
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') ?? [],
];

View File

@ -86,10 +86,6 @@ class AbhiClaimImportService extends BaseTpaClaimImportService
// Employee / Member details
'member_code' => 'emp_code',
'relation' => 'relationship',
// Policy / Claim identifiers
'policy_number' => 'policy_no',
'abhi_claim_no' => 'claim_number',
// Dates
@ -114,6 +110,8 @@ class AbhiClaimImportService extends BaseTpaClaimImportService
// Misc
'diagnosis' => 'claim_description',
'healthcard_id' => 'tpa_no',
'claim_type' => 'tpa_claim_type',
];
protected $statusMapping = [
@ -174,9 +172,7 @@ class AbhiClaimImportService extends BaseTpaClaimImportService
}
$ticketMasterModel = new TicketMasterModel();
$ticketMasterModel->insertBatch($data);
return true;
return $ticketMasterModel->insertBatch($data);
}
@ -187,9 +183,7 @@ class AbhiClaimImportService extends BaseTpaClaimImportService
}
$builder = $this->db->table('claims_dump_abhi');
$builder->insertBatch($data);
return true;
return $builder->updateBatch($data, 'id');
}
@ -200,9 +194,7 @@ class AbhiClaimImportService extends BaseTpaClaimImportService
}
$builder = $this->db->table('claims_dump_abhi');
$builder->insertBatch($data);
return true;
return $builder->updateBatch($data, 'id');
}
@ -307,7 +299,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 +318,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;
}
@ -440,41 +424,31 @@ class AbhiClaimImportService extends BaseTpaClaimImportService
return null;
}
$relation = strtolower($relation);
// trim removes whitespace, strtolower handles case sensitivity
$relation = strtolower(trim($relation));
if (str_contains($relation, 'self')) {
return 'self';
// Mapping specific keywords to standardized outputs
// ORDER MATTERS: Specific phrases (in-law) must come before general ones (father)
$map = [
'father-in-law' => ['father in law', 'father-in-law', 'fil'],
'mother-in-law' => ['mother in law', 'mother-in-law', 'mil'],
'father' => ['father', 'papa', 'dad'],
'mother' => ['mother', 'mom', 'mummy'],
'spouse' => ['spouse', 'wife', 'husband', 'hubby'],
'daughter' => ['daughter', 'daug'],
'son' => ['son'],
'self' => ['self', 'employee', 'main'],
];
foreach ($map as $standard => $keywords) {
foreach ($keywords as $keyword) {
if (str_contains($relation, $keyword)) {
return $standard;
}
}
}
if (str_contains($relation, 'spouse') || str_contains($relation, 'wife') || str_contains($relation, 'husband')) {
return 'spouse';
}
if (str_contains($relation, 'daughter')) {
return 'daughter';
}
if (str_contains($relation, 'son')) {
return 'son';
}
if (str_contains($relation, 'father in law') || str_contains($relation, 'father-in-law')) {
return 'father-in-law';
}
if (str_contains($relation, 'mother in law') || str_contains($relation, 'mother-in-law')) {
return 'mother-in-law';
}
if (str_contains($relation, 'father')) {
return 'father';
}
if (str_contains($relation, 'mother')) {
return 'mother';
}
return null; // unmatched case
return null;
}
}

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();
$fileData = $this->claimDumpFileModel->where('id', $fileId)->first();
try {
$fileData = $this->claimDumpFileModel->where('id', $fileId)->first();
if (env('FHPL_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
$rows = $this->readExcelBySheetName($filePath, 'Claims&Preauth');
} else if (env('R_CARE_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
$rows = $this->readExcelBySheetName($filePath, 'CL');
// $AL = $this->readExcelBySheetName($filePath, 'AL');
// $rows = array_merge($CL, $AL);
} else {
$rows = $this->readExcel($filePath);
}
// dd($rows);
// Determine sheet name logic...
if (env('FHPL_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
$rows = $this->readExcelBySheetName($filePath, 'Claims&Preauth');
} else if (env('R_CARE_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
$rows = $this->readExcelBySheetName($filePath, 'CL');
} else {
$rows = $this->readExcel($filePath);
}
if (empty($rows)) {
return ['status' => false, 'message' => 'Excel file contains no data or wrong file upload'];
}
if (empty($rows)) {
$this->db->transRollback(); // ROLLBACK BEFORE RETURN
return ['status' => false, 'message' => 'Excel file contains no data or wrong file upload'];
}
$tpaInsertData = $this->mapTPAData($rows, $fileId);
// dd($tpaInsertData);
$tpaInsertData = $this->mapTPAData($rows, $fileId);
if (empty($tpaInsertData)) {
return ['status' => false, 'message' => 'These records already exist in the system.'];
}
if (empty($tpaInsertData)) {
$this->db->transRollback(); // ROLLBACK BEFORE RETURN
return ['status' => false, 'message' => 'These records already exist in the system.'];
}
if (env('FHPL_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
$ClaimsDumpFhplModel = $this->db->table('claims_dump_fhpl');
$return_res = $ClaimsDumpFhplModel->insertBatch($tpaInsertData);
} else if (env('R_CARE_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
$ClaimsDumpIciciModel = $this->db->table('claims_dump_reliance');
$return_res = $ClaimsDumpIciciModel->insertBatch($tpaInsertData);
} else if (env('ICICI_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
$ClaimsDumpIciciModel = $this->db->table('claims_dump_icici');
$return_res = $ClaimsDumpIciciModel->insertBatch($tpaInsertData);
} else if (env('ABHI_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
// $ClaimsDumpAbhiModel = $this->db->table('claims_dump_abhi');
// $return_res = $ClaimsDumpAbhiModel->insertBatch($tpaInsertData);
$return_res = $this->bulkInsertTPATable($tpaInsertData);
} else if (env('VIDAL_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
$ClaimsDumpVidalModel = $this->db->table('claims_dump_vidal');
$return_res = $ClaimsDumpVidalModel->insertBatch($tpaInsertData);
} else if (env('MEDI_ASSIST_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
$ClaimsDumpMediAssistModel = $this->db->table('claims_dump_medi_assist');
$return_res = $ClaimsDumpMediAssistModel->insertBatch($tpaInsertData);
} else{
if ($return_res !== true) {
$this->db->transRollback(); // ROLLBACK BEFORE RETURN
return ['status' => false, 'message' => 'TPA Import bulk insert failed'];
}
// 2. Commit if everything is fine
$this->db->transCommit();
return ['status' => true, 'message' => 'File uploaded successfully', 'record_count' => count($tpaInsertData)];
} catch (\Throwable $e) {
// 3. Rollback on any crash/exception
$this->db->transRollback();
return ['status' => false, 'message' => 'System error : ' . $e->getMessage()];
}
// $return_res = $this->bulkInsertTPATable($tpaInsertData);
if (!$return_res) {
return ['status' => false, 'message' => 'TPA Import bulk insert failed'];
}
$this->db->transComplete();
if ($this->db->transStatus() === false) {
$error = $this->db->error();
$error_data = [
'message' => $error['message'] ?: 'Unknown DB error',
'code' => $error['code'] ?? null,
'last_query' => (string) $this->db->getLastQuery()
];
// dd($error_data);
// unset($error_data['last_query']);
return ['status' => false, 'message' => 'TPA Import transaction failed', 'error_data' => $error_data];
}
return ['status' => true, 'message' => 'File uploaded successfully', 'record_count' => count($tpaInsertData ?? [])];
}
/**
@ -107,34 +77,65 @@ abstract class BaseTpaClaimImportService
*/
public function runTicketMasterInsert(array $params): array
{
$this->db->transStart();
// 1. Start manual transaction
$this->db->transBegin();
$file_id = $params['file_id'];
try {
$file_id = $params['file_id'];
$ticketMasterData = $this->mapClaimMasterData($file_id);
$ticketMasterData = $this->mapClaimMasterData($file_id);
// Check if mapping failed
if (!$ticketMasterData['status']) {
$this->db->transRollback(); // ALWAYS rollback before early return
return $ticketMasterData;
}
if (!$ticketMasterData['status']) {
return $ticketMasterData;
$message = '';
$hasExecutedTask = false;
// Process Mapped Data
if (!empty($ticketMasterData['mapped_array'])) {
$insert_res = $this->importClaimMaster($ticketMasterData['mapped_array']);
if (!$insert_res) {
$this->db->transRollback();
return ['status' => false, 'message' => 'Ticket Master Claim bulk insert failed'];
}
$message .= 'Ticket Master Claim bulk insert success. ';
$hasExecutedTask = true;
}
// Process Rejected Reasons
if (!empty($ticketMasterData['rejected_reason_array'])) {
$update_res = $this->updateTicketMasterRejectedReasonInTPATable($ticketMasterData['rejected_reason_array']);
if (!$update_res) {
$this->db->transRollback();
return ['status' => false, 'message' => 'Updating rejected reasons failed'];
}
$message .= empty($ticketMasterData['mapped_array'])
? 'Those employees not in our system. '
: 'Ticket Master Claim rejected reason updated successfully. ';
$hasExecutedTask = true;
}
// If nothing was processed but no error occurred
if (!$hasExecutedTask) {
$this->db->transRollback();
return ['status' => false, 'message' => 'No data found to process.'];
}
// 2. Commit the transaction
$this->db->transCommit();
return ['status' => true, 'message' => trim($message)];
} catch (\Throwable $th) {
// 3. Rollback on crash
$this->db->transRollback();
return [
'status' => false,
'message' => 'System error during Ticket Master Insert: ' . $th->getMessage()
];
}
$return_res = $this->importClaimMaster($ticketMasterData['mapped_array']);
if(!$return_res){
return ['status' => false, 'message' => 'Ticket Master Claim bulk insert failed'];
}
$this->updateTicketMasterRejectedReasonInTPATable($ticketMasterData['rejected_reason_array']);
$this->db->transComplete();
if ($this->db->transStatus() === false) {
return ['status' => false, 'message' => 'Ticket Master Claim bulk insert failed'];
}
return ['status' => true, 'message' => 'Ticket Master Claim inserted successfully'];
}
/**
@ -273,27 +274,14 @@ abstract class BaseTpaClaimImportService
*/
protected function getTpaClaimDumpData(string $table, array $params): array
{
$tpaClaimDumpDataCount = $this->db
->table($table)
->where('is_active', 1)
->where('file_id', $params['file_id'])
->where('ticket_id IS NULL')
->countAllResults();
$batch_size = 100;
$total_batch = (int) ceil($tpaClaimDumpDataCount / $batch_size);
$batch_no = isset($params['batch_no']) ? (int) $params['batch_no'] : null;
$last_emp_id = (int) ($params['last_emp_id'] ?? 0);
return $this->db
->table($table)
->where('is_active', 1)
->where('file_id', $params['file_id'])
->where('ticket_id IS NULL')
->where('master_reject_reason IS NULL')
->get()
->getResultArray();
}
/**
@ -304,10 +292,11 @@ abstract class BaseTpaClaimImportService
$EmployeeModel = new EmployeeModel();
$employeeData = $EmployeeModel
->select([
'employees.id AS emp_id',
'employees.id AS id',
'employees.email_corporate AS emp_mail',
'employees.mobile AS emp_mobile',
'employees.name AS emp_name',
'employees.name AS name',
'employees.emp_code AS emp_code',
// insured employee
'insured.id AS insured_emp_id',

View File

@ -141,12 +141,8 @@ class FhplClaimImportService extends BaseTpaClaimImportService
// Claim / Reference
'claim_id' => 'claim_number',
// Policy
'policy_no' => 'policy_no',
// Employee / Member
'employee_id' => 'emp_code',
'relationship' => 'relationship',
// Claim Dates
'admission_date' => 'doa',
@ -177,10 +173,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 +232,7 @@ class FhplClaimImportService extends BaseTpaClaimImportService
}
$ticketMasterModel = new TicketMasterModel();
$ticketMasterModel->insertBatch($data);
return true;
return $ticketMasterModel->insertBatch($data);
}
@ -252,9 +243,7 @@ class FhplClaimImportService extends BaseTpaClaimImportService
}
$builder = $this->db->table('claims_dump_fhpl');
$builder->insertBatch($data);
return true;
return $builder->updateBatch($data, 'id');
}
@ -265,9 +254,7 @@ class FhplClaimImportService extends BaseTpaClaimImportService
}
$builder = $this->db->table('claims_dump_fhpl');
$builder->insertBatch($data);
return true;
return $builder->updateBatch($data, 'id');
}
@ -372,7 +359,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 +378,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

@ -81,7 +81,6 @@ class IciciClaimImportService extends BaseTpaClaimImportService
// Employee / Member
'employee_member_id' => 'emp_code',
'relation_group' => 'relationship',
// Claim
'claim_number' => 'claim_number',
@ -100,7 +99,8 @@ class IciciClaimImportService extends BaseTpaClaimImportService
'cheque_number' => 'utr_details',
'uhid' => 'tpa_no',
'rejected_query_desc' => 'claim_description',
'rejected_query_desc' => 'claim_description',
'type_of_claim' => 'tpa_claim_type',
];
protected $statusMapping = [
@ -168,9 +168,7 @@ class IciciClaimImportService extends BaseTpaClaimImportService
}
$ticketMasterModel = new TicketMasterModel();
$ticketMasterModel->insertBatch($data);
return true;
return $ticketMasterModel->insertBatch($data);
}
@ -181,9 +179,7 @@ class IciciClaimImportService extends BaseTpaClaimImportService
}
$builder = $this->db->table('claims_dump_icici');
$builder->insertBatch($data);
return true;
return $builder->upsertBatch($data, 'id');
}
@ -194,9 +190,7 @@ class IciciClaimImportService extends BaseTpaClaimImportService
}
$builder = $this->db->table('claims_dump_icici');
$builder->insertBatch($data);
return true;
return $builder->updateBatch($data, 'id');
}
@ -301,7 +295,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 +314,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"],
@ -116,10 +116,8 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService
// Employee / Beneficiary details
'pribenef_employee_code' => 'emp_code',
'benef_relation' => 'relationship',
// Policy / Claim identifiers
'policy_no' => 'policy_no',
'claim_id' => 'claim_number',
'event_id' => 'tpa_no',
'claim_pre_auths' => 'tpa_claim_push_reference_no',
@ -153,6 +151,7 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService
// Payment
'utr_no' => 'utr_details',
'claim_type' => 'tpa_claim_type',
];
protected $statusMapping = [
@ -166,7 +165,6 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService
'Cashless Document Awaited' => 3,
];
/**
* ABSTRACT FUNCTIONs
*/
@ -177,9 +175,8 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService
}
$builder = $this->db->table('claims_dump_medi_assist');
$builder->insertBatch($data);
return $builder->insertBatch($data);
return true;
}
@ -190,9 +187,7 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService
}
$ticketMasterModel = new TicketMasterModel();
$ticketMasterModel->insertBatch($data);
return true;
return $ticketMasterModel->insertBatch($data);
}
@ -216,9 +211,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 +312,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 +331,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

@ -60,10 +60,8 @@ class RcareClaimImportService extends BaseTpaClaimImportService
// Employee / Member
'employee_member_id' => 'emp_code',
'relation' => 'relationship',
// Policy
'policy_number' => 'policy_no',
'policy_start_date' => 'date_of_incep',
// Claim Dates
@ -159,9 +157,7 @@ class RcareClaimImportService extends BaseTpaClaimImportService
}
$ticketMasterModel = new TicketMasterModel();
$ticketMasterModel->insertBatch($data);
return true;
return $ticketMasterModel->insertBatch($data);
}
@ -172,9 +168,7 @@ class RcareClaimImportService extends BaseTpaClaimImportService
}
$builder = $this->db->table('claims_dump_reliance');
$builder->insertBatch($data);
return true;
return $builder->updateBatch($data, 'id');
}
@ -185,9 +179,7 @@ class RcareClaimImportService extends BaseTpaClaimImportService
}
$builder = $this->db->table('claims_dump_reliance');
$builder->insertBatch($data);
return true;
return $builder->updateBatch($data, 'id');
}
@ -291,7 +283,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 +302,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,11 +311,9 @@ 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
'insurer_policy_number' => 'policy_no',
'insurer_claim_number' => 'claim_number',
'tpa_claim_number' => 'tpa_claim_id',
@ -346,9 +343,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 +377,7 @@ class VidalClaimImportService extends BaseTpaClaimImportService
}
$ticketMasterModel = new TicketMasterModel();
$ticketMasterModel->insertBatch($data);
return true;
return $ticketMasterModel->insertBatch($data);
}
@ -393,9 +388,7 @@ class VidalClaimImportService extends BaseTpaClaimImportService
}
$builder = $this->db->table('claims_dump_vidal');
$builder->insertBatch($data);
return true;
return $builder->updateBatch($data, 'id');
}
@ -406,9 +399,7 @@ class VidalClaimImportService extends BaseTpaClaimImportService
}
$builder = $this->db->table('claims_dump_vidal');
$builder->insertBatch($data);
return true;
return $builder->updateBatch($data, 'id');
}
@ -514,7 +505,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 +525,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

@ -0,0 +1,179 @@
<?php
namespace App\Libraries;
use ZipArchive;
class ZipService
{
protected $s3Service;
public function __construct()
{
$this->s3Service = new S3Service();
}
/**
* Zips a local folder and uploads it to S3
*/
public function zipAndUploadS3(string $localFolderPath, string $s3Folder = '', string $zipName = ''): array
{
// dd($localFolderPath, $s3Folder, $zipName);
if (!is_dir($localFolderPath)) {
return ['status' => false, 'message' => 'Local directory does not exist'];
}
// 1. Prepare naming
$folderName = basename($localFolderPath);
$zipName = $zipName ?: $folderName . '_' . time() . '.zip';
$tempZipPath = FCPATH . 'tmp/' . $zipName;
// 2. Create the Local Zip
$zipResult = $this->createLocalZip($localFolderPath, $tempZipPath);
if (!$zipResult['status']) {
return $zipResult;
}
try {
// 3. Upload to S3
$uploadResult = $this->s3Service->upload($tempZipPath, $s3Folder, $zipName);
// dd($uploadResult);
// 4. Cleanup
if (file_exists($tempZipPath)) {
unlink($tempZipPath);
}
$get_presinged_url = $this->s3Service->getPresignedUrl($uploadResult['key'], 2,880);
// To delete the original temprory folder after zipping and uploading
// $this->deleteDirectory($localFolderPath);
return ['status' => true, 'data' => $uploadResult, 'presigned_url' => $get_presinged_url];
} catch (\Exception $e) {
log_message('error', 'Zip/Upload Error: ' . $e->getMessage());
return ['status' => false, 'message' => $e->getMessage()];
}
}
/**
* Zips a local folder using native ZipArchive
*/
public function createLocalZip(string $localFolderPath, string $destinationPath): array
{
// 1. Validate Source Directory
if (!is_dir($localFolderPath)) {
return ['status' => false, 'message' => 'Source directory does not exist'];
}
// 2. Check if folder is empty (ignoring hidden files)
$filesInFolder = array_diff(scandir($localFolderPath), array('.', '..'));
if (empty($filesInFolder)) {
return ['status' => false, 'message' => 'No records found to compress'];
}
// 3. Ensure the destination directory exists and is writable
$destDir = dirname($destinationPath);
if (!is_dir($destDir)) {
mkdir($destDir, 0777, true);
}
$zip = new ZipArchive();
// 4. Open the zip file
$openZip = $zip->open($destinationPath, ZipArchive::CREATE | ZipArchive::OVERWRITE);
if ($openZip !== true) {
return ['status' => false, 'message' => "Could not open Zip. Error code: " . $openZip];
}
try {
$files = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($localFolderPath, \RecursiveDirectoryIterator::SKIP_DOTS),
\RecursiveIteratorIterator::LEAVES_ONLY
);
$fileCount = 0;
$sourcePath = realpath($localFolderPath);
foreach ($files as $file) {
if (!$file->isDir()) {
$filePath = $file->getRealPath();
// Calculate relative path correctly
$relativePath = ltrim(substr($filePath, strlen($sourcePath)), DIRECTORY_SEPARATOR);
// Add to zip
if ($zip->addFile($filePath, $relativePath)) {
$fileCount++;
}
}
}
// 5. Finalize
if ($fileCount > 0) {
if (!$zip->close()) {
return ['status' => false, 'message' => 'Failed to write ZIP file to disk (Check permissions/space)'];
}
} else {
$zip->close();
return ['status' => false, 'message' => 'No files were added to the archive'];
}
return [
'status' => true,
'path' => $destinationPath,
'count' => $fileCount,
'message' => 'Zip created successfully'
];
} catch (\Exception $e) {
// Only attempt to close if the zip object was successfully opened
if (isset($zip->status) && $zip->status !== ZipArchive::ER_OK) {
@$zip->close();
}
log_message('error', 'Local Zip Error: ' . $e->getMessage());
return ['status' => false, 'message' => 'from catch Exception: ' . $e->getMessage()];
}
}
private function deleteDirectory($dir)
{
if (!file_exists($dir)) {
return true;
}
if (!is_dir($dir)) {
// Use @ to suppress warnings if the file is already gone or locked
// return @unlink($dir);
return unlink($dir);
}
// scandir can return false if the directory isn't readable
$items = scandir($dir);
if ($items === false) {
return false;
}
foreach ($items as $item) {
if ($item == '.' || $item == '..') {
continue;
}
// Recursively call the function
if (!$this->deleteDirectory($dir . DIRECTORY_SEPARATOR . $item)) {
// If a child cannot be deleted, attempt to change its permissions and try once more
@chmod($dir . DIRECTORY_SEPARATOR . $item, 0777);
if (!$this->deleteDirectory($dir . DIRECTORY_SEPARATOR . $item)) {
return false;
}
}
}
// Finally, remove the empty directory
return @rmdir($dir);
}
}

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')
@ -391,8 +399,8 @@ class EmployeePolicyModel extends Model
->where('is_active',1)
->find();
}
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
public function getInceptionEmployeeDataForExportExcel($ref_data, $return_type = 0)
{
@ -2218,5 +2226,70 @@ class EmployeePolicyModel extends Model
// return $result;
}
// for this function using bulk e-card download as a zip
public function getEmployeeDataWithPolicyUsingClientPolicyIdOrEmployeePolicyIds($params, $limit = 100, $last_id = 0)
{
$client_policy_id = $params['client_policy_id'] ?? null;
$emp_policy_ids = $params['emp_policy_ids'] ?? null;
if (empty($client_policy_id) && empty($emp_policy_ids)) {
return [];
}
$builder = $this->db->table('employee_polices');
$builder->select('
employee_polices.id as emp_policy_id,
employee_polices.client_policy_id,
employees.name,
employees.emp_code,
employees.id as emp_id,
tpa.short_name,
employee_polices.tpa_id,
client_policy.policy_no
')
->join('client_policy', 'client_policy.id = employee_polices.client_policy_id')
->join('employees', 'employees.id = employee_polices.employee_id')
->join('tpa', 'tpa.id = client_policy.tpa_id')
->where([
'employees.emp_status' => 'active',
'employees.is_active' => '1',
'employee_polices.status' => 'active',
'employee_polices.is_active' => '1',
])
->where("employee_polices.tpa_id IS NOT NULL AND employee_polices.tpa_id <> ''");
// BATCHING LOGIC: Only get records greater than the last processed ID
if ($last_id > 0) {
$builder->where('employee_polices.id >', $last_id);
}
if ($client_policy_id) $builder->where('employee_polices.client_policy_id', $client_policy_id);
if ($emp_policy_ids) $builder->whereIn('employee_polices.id', $emp_policy_ids);
$builder->orderBy('employee_polices.id', 'ASC'); // Critical for keyset pagination
$builder->limit($limit);
return $builder->get()->getResultArray();
}
public function getClientPolicyDetailsByClientPolicyIdOrEmployeePolicyId($params)
{
$client_policy_id = $params['client_policy_id'] ?? null;
$emp_policy_id = $params['emp_policy_id'] ?? null;
if (empty($client_policy_id) && empty($emp_policy_id)) {
return [];
}
$builder = $this->db->table('client_policy');
$builder->select('client_policy.*')
->join('employee_polices ep', 'ep.client_policy_id = client_policy.id', 'left');
if ($client_policy_id) $builder->where('employee_polices.client_policy_id', $client_policy_id);
if ($emp_policy_id) $builder->where('employee_polices.id', $emp_policy_id);
return $builder->get()->getResultArray();
}
}

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

@ -93,6 +93,9 @@ class TicketMasterModel extends Model
'required_docs',
'policy_transaction_id',
'tpa_claim_type',
'tpa_ailments',
'claim_dump_ref_id',
];

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 () {
@ -1899,19 +1912,36 @@ table.dataTable tbody td {
</script>
<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');
$(document).on('click', '#btnAdd', function() {
// 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');?>');
let myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
myModal.show(); // open modal
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">
<!-- Single zip upload -->
<div>
<label for="zip_file">Zip File</label>
<input type="file" name="zip_file" id="zip_file" required>
</div>
<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 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">
<option value="web/">web/</option>
<!-- <option value="dist/">dist/</option> -->
</select>
</div>
<!-- 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">
<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 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>
<div>
<label for="s3_prefix">S3 Prefix</label>
<input type="text" name="s3_prefix" id="s3_prefix" value="/*">
</div>
<!-- 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>
<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">
<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>
<!-- 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>
<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>
<!-- 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>
<button type="submit">Deploy</button>
</form>
<script>
document.addEventListener('DOMContentLoaded', function () {
const bucketToDistributionMap = {

View File

@ -70,7 +70,7 @@ input:checked + .slider:before {
<div class="card-body">
<div class="custom-form">
<form role="form" class="parsley-examples" method="post" id="insurer_general_form" enctype="multipart/form-data">
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
<input type="hidden" name="PrimaryKey" id="insurer_General_PrimaryKey" value="<?= isset($insurer['id']) ? $insurer['id'] : '' ?>" />
<input type="hidden" name="insurer_id" id="insurer_id" />
@ -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

@ -1163,68 +1163,50 @@
<?php endif; ?>
}
function checkCDBalance() {
async function checkCDBalance() {
try {
// 1. Fetch the LATEST session data from the server
const response = await fetch('checkSessionStatus');
const cdData = await response.json();
const cdData = <?= json_encode(get_cd_balance()) ?>;
console.log(cdData, typeof cdData);
console.log('Current Session Data:', cdData);
// cdData itself null / undefined safety
if (!cdData || typeof cdData !== 'object') {
console.log('CD data not available');
return;
}
// 2. Check if cd_balance_info exists and isn't empty
if (cdData.has_cd_balance && cdData.cd_balance_info) {
let cd_balance_info = cdData.cd_balance_info
console.log('cd_balance_info', cd_balance_info);
cd_balance_info = JSON.parse(cd_balance_info);
console.log('cd_balance_info', 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;
let hr_data = cdData.hr_data
console.log('hr_data', hr_data);
hr_data = JSON.parse(hr_data);
console.log('hr_data', hr_data);
// 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 }
);
let cd_balance = cd_balance_info.cd_balance;
let cd_amount = cd_balance_info.cd_amount;
let excel_file_amt = cd_balance_info.excel_file_amt;
if(hr_info) {
$('#client_id_for_hr_mail_send').val(hr_info.client_id);
window.hr_data = hr_info.hr_data;
}
console.log(cd_balance ,cd_amount ,excel_file_amt);
openModal();
window.hr_data = hr_data.hr_data;
$('#client_id_for_hr_mail_send').val(hr_data.client_id)
console.log(cd_balance, typeof cd_balance);
if (cd_balance === false && messageShown === false) {
const message1 =
'Insufficient CD Balance deducted. Please wait the file will be downloaded<br>' +
'<strong>CD Amount:</strong> ₹' + cd_amount + '<br>' +
'<strong>Total Amount:</strong> ₹' + excel_file_amt;
toastr.warning(message1, 'WARNING', {
allowHtml: true,
timeOut: 10000,
extendedTimeOut: 3000
});
messageShown = true;
stopInterval();
openModal();
<?php clear_cd_balance_session(); ?>
}
else if (cd_balance === true) {
console.log('CD Balance is sufficient');
stopInterval();
}
else {
console.log('CD balance info not available');
// 3. Clear the session now that we've handled it
fetch('clearCdSession');
}
}
} catch (error) {
console.error('Error checking CD balance:', error);
}
}
@ -1234,7 +1216,7 @@
messageShown = false; // Reset message flag
submitInterval = setInterval(function() {
checkCDBalance();
}, 10000);
}, 2000);
console.log("Checking CD balance started...");
}
}

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">
@ -1841,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)) {
@ -2347,6 +2464,61 @@
});
});
$('#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');
$('.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);
}
});
});
});
function hideBranding() {
$('iframe').on('load', function() {
console.log('Iframe loaded.');
@ -2445,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,427 +151,450 @@
</style>
<div class="row" id="endorsement_form" style="display: none;">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="row" style="margin-bottom:1rem;">
<div class="col-6" style="align-self: center;">
<h4 style="position: relative;">Add Endorsement</h4>
</div>
<div class="col-6" style="text-align: right;">
<a href="<?= base_url('policy_tranction/endorsement/list') ?>" id="btnAdd" class="btn btn-primary waves-effect waves-light"
>Back</a>
</div>
</div>
<form role="form" class="parsley-examples" method="post" id="endorsement_form_id" enctype="multipart/form-data">
<input type="hidden" name="id" id="policy_tranction_primarykey">
<input type="hidden" name="client_id" id="client_id_for_edit">
<input type="hidden" name="insurer_id" id="insurer_id">
<input type="hidden" name="cd_ac_no" id="cd_ac_no">
<input type="hidden" name="cd_ac_pk" id="cd_ac_pk">
<input type="hidden" name="ct_type" id="ct_type">
<input type="hidden" name="bro_payable_by" id="bro_payable_by">
<input type="hidden" name="cop_yes" id="cop_yes">
<input type="hidden" name="base_cd_amount" id="base_cd_amount">
<input type="hidden" name="cd_amt_changed" id="cd_amt_changed" disabled>
<!-- Client Row -->
<div class="row">
<!-- Section 1 -->
<div class="col-md-12">
<div id="accordion_0" class="mb-0">
<label id="policyAccordion" class="m-1 d-flex justify-content-between align-items-center">
<span class="font-color-black">Client Details</span>
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseOne"
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="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_0">
<div class="card-body">
<div class="row">
<div class="form-group col-md-3">
<label for="client_type">Client Type<span class="text-danger"></span></label>
<select class="form-control" id="client_type" name="client_type" >
<option value="">Select Client type</option>
<option value="1">Group</option>
<option value="2">Individual</option>
</select>
</div>
<div class="form-group col-md-3">
<label for="client_branch">Client<span class="text-danger">*</span></label>
<select class="form-control" id="client_id" name="client_id" required>
<option value="">Select Client</option>
<!-- <option value="add_client"> + Add Client</option> -->
</select>
</div>
<div class="form-group col-md-3 branchdiv">
<label for="client_branch">Branch<span class="text-danger"></span></label>
<select class="form-control" id="client_branch_id" name="client_branch_id">
<option value="">Select Branch</option>
</select>
</div>
<div class="form-group col-md-3">
<label for="email"> Policy <span class="text-danger">*</span></label>
<select class="form-control" id="client_policy_id" name="client_policy_id" required>
<option value="">Select Policy</option>
</select>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<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">
<div class="row" style="margin-bottom:1rem;">
<div class="col-6" style="align-self: center;">
<h4 style="position: relative;">Add Endorsement</h4>
</div>
<div class="col-6" style="text-align: right;">
<a href="<?= base_url('policy_tranction/endorsement/list') ?>" id="btnAdd" class="btn btn-primary waves-effect waves-light"
>Back</a>
</div>
</div>
<form role="form" class="parsley-examples" method="post" id="endorsement_form_id" enctype="multipart/form-data">
<input type="hidden" name="id" id="policy_tranction_primarykey">
<input type="hidden" name="client_id" id="client_id_for_edit">
<input type="hidden" name="insurer_id" id="insurer_id">
<input type="hidden" name="cd_ac_no" id="cd_ac_no">
<input type="hidden" name="cd_ac_pk" id="cd_ac_pk">
<input type="hidden" name="ct_type" id="ct_type">
<input type="hidden" name="bro_payable_by" id="bro_payable_by">
<input type="hidden" name="cop_yes" id="cop_yes">
<input type="hidden" name="base_cd_amount" id="base_cd_amount">
<input type="hidden" name="cd_amt_changed" id="cd_amt_changed" disabled>
<!-- Endorsement details -->
<div class="row">
<div class="col-md-12">
<div id="accordion_2" class="mb-0">
<!-- Client Row -->
<div class="row">
<!-- Section 1 -->
<div class="col-md-12">
<div id="accordion_0" class="mb-0">
<label id="policyAccordion" class="m-1 d-flex justify-content-between align-items-center">
<span class="font-color-black">Endorsement</span>
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseThree"
<span class="font-color-black">Client Details</span>
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseOne"
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="collapseThree" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_2">
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_0">
<div class="card-body">
<div class="row">
<!-- <div class="form-group col-md-3" id="tpa_endorse_div">
<label for="tpa"> TPA <span id="tpa_danger"class="text-danger"></span></label>
<select class="form-control readonly-select" id="tpa" name="tpa" >
<option value="" selected>Select TPA</option>
<?php foreach ($tpa as $value) { ?>
<option value="<?= $value['id'] . '-' . $value['tpa_id'] ?>">
<?= $value['tpa_short_name'] . '-' . $value['branch_code'] ?>
</option>
<?php } ?>
</select>
</div> -->
<div class="form-group col-md-3">
<label for="addon_policy">Policy No<span id="base_danger"class="text-danger"></span></label>
<input type="text" class="form-control" id="policy_no" name="policy_no"placeholder="Enter Policy No" readonly>
</div>
<div class="row">
<div class="form-group col-md-3">
<label for="bp_cgst">D.O.C <span id="base_danger" class="text-danger"></span></label>
<input id="policy_start_date" type="text" class="form-control" placeholder="DD/MM/YYYY" readonly>
</div>
<div class="form-group col-md-3">
<label for="bp_igst">D.O.E <span id="base_danger" class="text-danger"></span></label>
<input id="policy_end_date" type="text" class="form-control" placeholder="DD/MM/YYYY" readonly>
</div>
<div class="form-group col-md-3">
<label for="addon_policy"> Endorsement Type <span id="base_danger" class="text-danger">*</span></label>
<select class="form-control" id="action_type" name="action_type" required>
<option value="" selected>Select Endorsement Type</option>
<?php
if (isset($action_type) && count($action_type)) {
foreach ($action_type as $key => $value) {
echo "<option value=" . $key . ">" . $value . "</option>";
}
}
?>
</select>
</div>
<div class="form-group col-md-3">
<label for="addon_policy">Endorsement No<span id="base_danger" class="text-danger"></span></label>
<input type="text" class="form-control" id="endorsement_no" name="endorsement_no" placeholder="Enter Endorsement No" onchange="validateInput(this, 'policy_transaction', 'endorsement_no')">
</div>
<div class="form-group col-md-3">
<label for="addon_policy">Data Received Date<span id="base_danger" class="text-danger">*</span></label>
<input type="text" class="form-control" id="data_received_date" name="data_received_date" placeholder="DD/MM/YYYY" required>
</div>
<div class="form-group col-md-3">
<label for="policy_issue_date">Endorsement Issue Date<span id="base_danger" class="text-danger">*</span></label>
<input type="text" class="form-control" id="policy_issue_date" name="policy_issue_date" placeholder="DD/MM/YYYY" required>
</div>
<div class="form-group col-md-3">
<label for="month">Endorsement Issue Month<span id="base_danger" class="text-danger">*</span></label>
<input type="text" class="form-control readonly-select" id="month" name="month" placeholder="MM/YYYY" required>
</div>
<div class="form-group col-md-3">
<label for="endorse_eff_date">Endorsement Effective Date<span id="base_danger" class="text-danger"></span></label>
<input type="text" class="form-control" id="endorse_eff_date" name="endorse_eff_date" placeholder="DD/MM/YYYY" >
</div>
<div class="form-group col-md-3" id="no_of_insured_endorse_div">
<label for="addon_policy">No of Insured<span id="base_danger"class="text-danger"></span></label>
<input type="text" class="form-control" id="emp_count" name="emp_count" placeholder="Enter Employeee" onkeypress="return onlyNumbers(event)">
</div>
<div class="form-group col-md-3" id="no_of_dependents_endorse_div">
<label for="addon_policy">No of Dependents<span id="base_danger" class="text-danger"></span></label>
<input type="text" class="form-control" id="dependent_count" name="dependent_count" placeholder="Enter Dependent" onkeypress="return onlyNumbers(event)">
</div>
<div class="form-group col-md-3">
<label for="client_type">Client Type<span class="text-danger"></span></label>
<select class="form-control" id="client_type" name="client_type" >
<option value="">Select Client type</option>
<option value="1">Group</option>
<option value="2">Individual</option>
</select>
</div>
<hr>
<div class="form-group col-md-3">
<label for="client_branch">Client<span class="text-danger">*</span></label>
<select class="form-control" id="client_id" name="client_id" required>
<option value="">Select Client</option>
<!-- <option value="add_client"> + Add Client</option> -->
</select>
</div>
<div class="row">
<!-- <div class="form-group col-md-3">
<label for="addon_policy"> Status <span id="base_danger"class="text-danger">*</span></label>
<select class="form-control" id="policy_status" name="status" required>
<option value="" selected>Select Status</option>
<?php
if (isset($policy_status) && count($policy_status)) {
foreach ($policy_status as $key => $value) {
if($key == 'pending'){
echo "<option value=" . $key . " selected>" . $value . "</option>";
}else{
echo "<option value=" . $key . ">" . $value . "</option>";
}
}
}
?>
</select>
</div> -->
<div class="form-group col-md-3">
<label for="last_action_date">Latest Action Date</label>
<input id="last_action_date" type="text" class="form-control" name="last_action_date" placeholder="DD/MM/YYYY">
</div>
<div class="form-group col-md-3 install_due_date_div" style="display: none;">
<label for="install_due_date">Installment due Date</label>
<input id="install_due_date" type="text" class="form-control" name="install_due_date" placeholder="DD/MM/YYYY">
</div>
<!-- <div class="form-group col-md-3">
<label class="switch" style="position: relative;top: 32px;left: 20px;">
<input id="policy_with_corr" type="checkbox" name="policy_with_corr">
<span class="slider round" style="height: 27px;"></span>
</label>
<label for="policy_with_corr" style="position: relative;top: 33px;left: 25px;"> Policy with Correction</label>
</div> -->
<!-- <div class="form-group col-md-3">
<label class="switch" style="position: relative;top: 32px;left: 20px;">
<input id="is_cd_reduce_from_bds" type="checkbox" name="is_cd_reduce_from_bds">
<span class="slider round" style="height: 27px;"></span>
</label>
<label for="is_cd_reduce_from_bds" style="position: relative;top: 33px;left: 25px;">Make Entry in CD &nbsp;&nbsp; <i class="mdi mdi-information-outline" data-toggle="tooltip" title="Enabling this will affect ( Credit/Debit ) the CD transaction. ( GMC, GPA, EDLI and GTLI, CD transaction from CRM )"></i></label>
</div> -->
<div class="form-group col-md-3 branchdiv">
<label for="client_branch">Branch<span class="text-danger"></span></label>
<select class="form-control" id="client_branch_id" name="client_branch_id">
<option value="">Select Branch</option>
</select>
</div>
<div class="form-group col-md-3">
<label for="email"> Policy <span class="text-danger">*</span></label>
<select class="form-control" id="client_policy_id" name="client_policy_id" required>
<option value="">Select Policy</option>
</select>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Premium Details -->
<div class="row">
<div class="col-md-12">
<div id="accordion_3" class="mb-0">
<label id="policyAccordion" class="m-1 d-flex justify-content-between align-items-center">
<span class="font-color-black">Premium Details</span>
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseTwo"
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-0">
<div id="collapseTwo" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_3">
<div class="card-body">
<div class="row d-none" id="add_more_row">
<div class="col-md-2">
<input type="number" id="setInsurerCount" class="form-control" placeholder="Enter count">
</div>
<!-- <div class="col-md-2">
<a id="addInsurer" class="btn btn-primary mb-3">Add Insurer</a>
</div> -->
<!-- <div class="col-md-1">
<a id="submitForm" class="btn btn-success mb-3">Submit</a>
</div> -->
</div>
<div id="insurerTableContainer" style="overflow: auto;">
<table data-custom-table-css="table" class="table co_share_table" id="insurerTable">
<thead>
<tr>
<th><span class="font-color-black">Premium Details</span></th>
</tr>
</thead>
<tbody>
<tr id="table_tr_1">
<td>Insurer</td>
</tr>
<tr id="table_tr_2" style="display: none;">
<td>Is Leader?</td>
</tr>
<tr id="table_tr_34">
<td>CD Acc No</td>
</tr>
<tr id="table_tr_37">
<td>CD Amount</td>
</tr>
<tr id="table_tr_35" style="display: none;">
<td>Follower Policy No</td>
</tr>
<tr id="table_tr_40" >
<td>Endorsement Issue Date</td>
</tr>
<tr id="table_tr_3" style="display: none;">
<td>Co-Share %</td>
</tr>
<tr id="table_tr_36">
<td>Non-Commissionable<br> Premium Amount</td>
</tr>
<tr id="table_tr_4">
<td>Base Premium</td>
</tr>
<tr class="hidetp" id="table_tr_5">
<td id="tp_premium_td">TP Premium</td>
</tr>
<tr class="hideter" id="table_tr_6" style="display: none;">
<td>TEP Premium</td>
</tr>
<tr class="hidecop" id="table_tr_7" style="display: none;">
<td>Co-Premium</td>
</tr>
<tr class="hidecotp" id="table_tr_38" style="display: none;">
<td>Co-TP Premium</td>
</tr>
<tr class="hidecoter" id="table_tr_39" style="display: none;">
<td>Co-TEP Premium</td>
</tr>
<tr id="table_tr_8">
<td>CGST</td>
</tr>
<tr id="table_tr_9">
<td>SGST</td>
</tr>
<tr id="table_tr_10">
<td>IGST</td>
</tr>
<tr id="table_tr_11">
<td>GST Amount</td>
</tr>
<tr id="table_tr_12">
<td>Stamp Duty</td>
</tr>
<tr id="table_tr_13">
<td>Total</td>
</tr>
<tr id="table_tr_14">
<td>Agreed BP %</td>
</tr>
<tr class="hidetp" id="table_tr_15">
<td id="agree_tp_td">Agreed TP %</td>
</tr>
<tr class="hideter" id="table_tr_16" style="display: none;">
<td id="agree_tp_td">Agreed TEP %</td>
</tr>
<?php if (in_array(get_role_id(), [1,5]) || in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team())) { ?>
<tr id="table_tr_17">
<td>Agreed Amount</td>
</tr>
<?php } ?>
<tr id="table_tr_18">
<td>Standard BP %</td>
</tr>
<tr class="hidetp" id="table_tr_19">
<td>Standard TP %</td>
</tr>
<tr class="hideter" id="table_tr_20" style="display: none;">
<td>Standard TEP %</td>
</tr>
<?php if (in_array(in_array(get_role_id(), [1,5]) || FINANCE_TEAM_ID, user_team()) || in_array(MANAGEMENT_TEAM_ID, user_team())) { ?>
<tr id="table_tr_21">
<td>Actual BP Amount</td>
</tr>
<tr class="hidetp" id="table_tr_22">
<td>Actual TP Amount</td>
</tr>
<tr class="hideter" id="table_tr_23" style="display: none;">
<td>Actual TEP Amount</td>
</tr>
<tr id="table_tr_24">
<td>Actual BP %</td>
</tr>
<tr class="hidetp" id="table_tr_25">
<td>Actual TP %</td>
</tr>
<tr class="hideter" id="table_tr_26" style="display: none;">
<td>Actual TEP %</td>
</tr>
<tr id="table_tr_27">
<td>Actual BP <br> Remuneration Amount</td>
</tr>
<tr class="hidetp" id="table_tr_28">
<td>Actual TP <br> Remuneration Amount</td>
</tr>
<tr class="hideter" id="table_tr_29" style="display: none;">
<td>Actual TEP <br> Remuneration Amount</td>
</tr>
<tr id="table_tr_30">
<td>Expected Amount</td>
</tr>
<!-- <tr id="table_tr_31">
<td>Variance</td>
</tr> -->
<!-- <tr id="table_tr_32">
<td>Reward</td>
</tr> -->
<?php } ?>
<tr id="table_tr_33" style="display: none;">
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="form-group text-right mt-3 m-b-0" id="submitButton">
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="btnSubmit">Submit</button>
</div>
</form>
<!-- Endorsement details -->
<div class="row">
<div class="col-md-12">
<div id="accordion_2" class="mb-0">
<label id="policyAccordion" class="m-1 d-flex justify-content-between align-items-center">
<span class="font-color-black">Endorsement</span>
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseThree"
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="collapseThree" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_2">
<div class="card-body">
<div class="row">
<!-- <div class="form-group col-md-3" id="tpa_endorse_div">
<label for="tpa"> TPA <span id="tpa_danger"class="text-danger"></span></label>
<select class="form-control readonly-select" id="tpa" name="tpa" >
<option value="" selected>Select TPA</option>
<?php foreach ($tpa as $value) { ?>
<option value="<?= $value['id'] . '-' . $value['tpa_id'] ?>">
<?= $value['tpa_short_name'] . '-' . $value['branch_code'] ?>
</option>
<?php } ?>
</select>
</div> -->
<div class="form-group col-md-3">
<label for="addon_policy">Policy No<span id="base_danger"class="text-danger"></span></label>
<input type="text" class="form-control" id="policy_no" name="policy_no"placeholder="Enter Policy No" readonly>
</div>
<div class="form-group col-md-3">
<label for="bp_cgst">D.O.C <span id="base_danger" class="text-danger"></span></label>
<input id="policy_start_date" type="text" class="form-control" placeholder="DD/MM/YYYY" readonly>
</div>
<div class="form-group col-md-3">
<label for="bp_igst">D.O.E <span id="base_danger" class="text-danger"></span></label>
<input id="policy_end_date" type="text" class="form-control" placeholder="DD/MM/YYYY" readonly>
</div>
<div class="form-group col-md-3">
<label for="addon_policy"> Endorsement Type <span id="base_danger" class="text-danger">*</span></label>
<select class="form-control" id="action_type" name="action_type" required>
<option value="" selected>Select Endorsement Type</option>
<?php
if (isset($action_type) && count($action_type)) {
foreach ($action_type as $key => $value) {
echo "<option value=" . $key . ">" . $value . "</option>";
}
}
?>
</select>
</div>
<div class="form-group col-md-3">
<label for="addon_policy">Endorsement No<span id="base_danger" class="text-danger"></span></label>
<input type="text" class="form-control" id="endorsement_no" name="endorsement_no" placeholder="Enter Endorsement No" onchange="validateInput(this, 'policy_transaction', 'endorsement_no')">
</div>
<div class="form-group col-md-3">
<label for="addon_policy">Data Received Date<span id="base_danger" class="text-danger">*</span></label>
<input type="text" class="form-control" id="data_received_date" name="data_received_date" placeholder="DD/MM/YYYY" required>
</div>
<div class="form-group col-md-3">
<label for="policy_issue_date">Endorsement Issue Date<span id="base_danger" class="text-danger">*</span></label>
<input type="text" class="form-control" id="policy_issue_date" name="policy_issue_date" placeholder="DD/MM/YYYY" required>
</div>
<div class="form-group col-md-3">
<label for="month">Endorsement Issue Month<span id="base_danger" class="text-danger">*</span></label>
<input type="text" class="form-control readonly-select" id="month" name="month" placeholder="MM/YYYY" required>
</div>
<div class="form-group col-md-3">
<label for="endorse_eff_date">Endorsement Effective Date<span id="base_danger" class="text-danger"></span></label>
<input type="text" class="form-control" id="endorse_eff_date" name="endorse_eff_date" placeholder="DD/MM/YYYY" >
</div>
<div class="form-group col-md-3" id="no_of_insured_endorse_div">
<label for="addon_policy">No of Insured<span id="base_danger"class="text-danger"></span></label>
<input type="text" class="form-control" id="emp_count" name="emp_count" placeholder="Enter Employeee" onkeypress="return onlyNumbers(event)">
</div>
<div class="form-group col-md-3" id="no_of_dependents_endorse_div">
<label for="addon_policy">No of Dependents<span id="base_danger" class="text-danger"></span></label>
<input type="text" class="form-control" id="dependent_count" name="dependent_count" placeholder="Enter Dependent" onkeypress="return onlyNumbers(event)">
</div>
</div>
<hr>
<div class="row">
<!-- <div class="form-group col-md-3">
<label for="addon_policy"> Status <span id="base_danger"class="text-danger">*</span></label>
<select class="form-control" id="policy_status" name="status" required>
<option value="" selected>Select Status</option>
<?php
if (isset($policy_status) && count($policy_status)) {
foreach ($policy_status as $key => $value) {
if($key == 'pending'){
echo "<option value=" . $key . " selected>" . $value . "</option>";
}else{
echo "<option value=" . $key . ">" . $value . "</option>";
}
}
}
?>
</select>
</div> -->
<div class="form-group col-md-3">
<label for="last_action_date">Latest Action Date</label>
<input id="last_action_date" type="text" class="form-control" name="last_action_date" placeholder="DD/MM/YYYY">
</div>
<div class="form-group col-md-3 install_due_date_div" style="display: none;">
<label for="install_due_date">Installment due Date</label>
<input id="install_due_date" type="text" class="form-control" name="install_due_date" placeholder="DD/MM/YYYY">
</div>
<!-- <div class="form-group col-md-3">
<label class="switch" style="position: relative;top: 32px;left: 20px;">
<input id="policy_with_corr" type="checkbox" name="policy_with_corr">
<span class="slider round" style="height: 27px;"></span>
</label>
<label for="policy_with_corr" style="position: relative;top: 33px;left: 25px;"> Policy with Correction</label>
</div> -->
<!-- <div class="form-group col-md-3">
<label class="switch" style="position: relative;top: 32px;left: 20px;">
<input id="is_cd_reduce_from_bds" type="checkbox" name="is_cd_reduce_from_bds">
<span class="slider round" style="height: 27px;"></span>
</label>
<label for="is_cd_reduce_from_bds" style="position: relative;top: 33px;left: 25px;">Make Entry in CD &nbsp;&nbsp; <i class="mdi mdi-information-outline" data-toggle="tooltip" title="Enabling this will affect ( Credit/Debit ) the CD transaction. ( GMC, GPA, EDLI and GTLI, CD transaction from CRM )"></i></label>
</div> -->
</div>
</div>
</div>
</div>
</div>
</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">
<div id="accordion_3" class="mb-0">
<label id="policyAccordion" class="m-1 d-flex justify-content-between align-items-center">
<span class="font-color-black">Premium Details</span>
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseTwo"
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-0">
<div id="collapseTwo" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_3">
<div class="card-body">
<div class="row d-none" id="add_more_row">
<div class="col-md-2">
<input type="number" id="setInsurerCount" class="form-control" placeholder="Enter count">
</div>
<!-- <div class="col-md-2">
<a id="addInsurer" class="btn btn-primary mb-3">Add Insurer</a>
</div> -->
<!-- <div class="col-md-1">
<a id="submitForm" class="btn btn-success mb-3">Submit</a>
</div> -->
</div>
<div id="insurerTableContainer" style="overflow: auto;">
<table data-custom-table-css="table" class="table co_share_table" id="insurerTable">
<thead>
<tr>
<th><span class="font-color-black">Premium Details</span></th>
</tr>
</thead>
<tbody>
<tr id="table_tr_1">
<td>Insurer</td>
</tr>
<tr id="table_tr_2" style="display: none;">
<td>Is Leader?</td>
</tr>
<tr id="table_tr_34">
<td>CD Acc No</td>
</tr>
<tr id="table_tr_37">
<td>CD Amount</td>
</tr>
<tr id="table_tr_35" style="display: none;">
<td>Follower Policy No</td>
</tr>
<tr id="table_tr_40" >
<td>Endorsement Issue Date</td>
</tr>
<tr id="table_tr_3" style="display: none;">
<td>Co-Share %</td>
</tr>
<tr id="table_tr_36">
<td>Non-Commissionable<br> Premium Amount</td>
</tr>
<tr id="table_tr_4">
<td>Base Premium</td>
</tr>
<tr class="hidetp" id="table_tr_5">
<td id="tp_premium_td">TP Premium</td>
</tr>
<tr class="hideter" id="table_tr_6" style="display: none;">
<td>TEP Premium</td>
</tr>
<tr class="hidecop" id="table_tr_7" style="display: none;">
<td>Co-Premium</td>
</tr>
<tr class="hidecotp" id="table_tr_38" style="display: none;">
<td>Co-TP Premium</td>
</tr>
<tr class="hidecoter" id="table_tr_39" style="display: none;">
<td>Co-TEP Premium</td>
</tr>
<tr id="table_tr_8">
<td>CGST</td>
</tr>
<tr id="table_tr_9">
<td>SGST</td>
</tr>
<tr id="table_tr_10">
<td>IGST</td>
</tr>
<tr id="table_tr_11">
<td>GST Amount</td>
</tr>
<tr id="table_tr_12">
<td>Stamp Duty</td>
</tr>
<tr id="table_tr_13">
<td>Total</td>
</tr>
<tr id="table_tr_14">
<td>Agreed BP %</td>
</tr>
<tr class="hidetp" id="table_tr_15">
<td id="agree_tp_td">Agreed TP %</td>
</tr>
<tr class="hideter" id="table_tr_16" style="display: none;">
<td id="agree_tp_td">Agreed TEP %</td>
</tr>
<?php if (in_array(get_role_id(), [1,5]) || in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team())) { ?>
<tr id="table_tr_17">
<td>Agreed Amount</td>
</tr>
<?php } ?>
<tr id="table_tr_18">
<td>Standard BP %</td>
</tr>
<tr class="hidetp" id="table_tr_19">
<td>Standard TP %</td>
</tr>
<tr class="hideter" id="table_tr_20" style="display: none;">
<td>Standard TEP %</td>
</tr>
<?php if (in_array(in_array(get_role_id(), [1,5]) || FINANCE_TEAM_ID, user_team()) || in_array(MANAGEMENT_TEAM_ID, user_team())) { ?>
<tr id="table_tr_21">
<td>Actual BP Amount</td>
</tr>
<tr class="hidetp" id="table_tr_22">
<td>Actual TP Amount</td>
</tr>
<tr class="hideter" id="table_tr_23" style="display: none;">
<td>Actual TEP Amount</td>
</tr>
<tr id="table_tr_24">
<td>Actual BP %</td>
</tr>
<tr class="hidetp" id="table_tr_25">
<td>Actual TP %</td>
</tr>
<tr class="hideter" id="table_tr_26" style="display: none;">
<td>Actual TEP %</td>
</tr>
<tr id="table_tr_27">
<td>Actual BP <br> Remuneration Amount</td>
</tr>
<tr class="hidetp" id="table_tr_28">
<td>Actual TP <br> Remuneration Amount</td>
</tr>
<tr class="hideter" id="table_tr_29" style="display: none;">
<td>Actual TEP <br> Remuneration Amount</td>
</tr>
<tr id="table_tr_30">
<td>Expected Amount</td>
</tr>
<!-- <tr id="table_tr_31">
<td>Variance</td>
</tr> -->
<!-- <tr id="table_tr_32">
<td>Reward</td>
</tr> -->
<?php } ?>
<tr id="table_tr_33" style="display: none;">
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="form-group text-right mt-3 m-b-0" id="submitButton">
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="btnSubmit">Submit</button>
</div>
</form>
</div>
</div>
</div>
</div>
@ -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

@ -2255,7 +2255,7 @@
var page_title = 'Edit Policy' + (res.data.client_short_name || res.data.policy_type || res.data.policy_no ?
' - ' + [res.data.client_short_name, res.data.policy_type, res.data.policy_no]
.filter(Boolean).join('-') : '');
$('#page_title').text(page_title);
$('#client_id_kyc').val(res.data.client_id);
$('#policy_tranction_primarykey_for_file_upload').val(res.data.id);
@ -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>