Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev

This commit is contained in:
Gowtham M 2025-01-07 11:02:03 +05:30
commit 5bee08b595
75 changed files with 11294 additions and 1795 deletions

View File

@ -8,4 +8,4 @@ From command propmt run the following cmds
Run speeific method
`>php vendor/bin/phpunit tests\unit\PremiumCalculationTest.php --filter testPremiumCalculationWithPrimaryRackRateAndAdditionalRackRate`
`php vendor/bin/phpunit tests\unit\PremiumCalculationTest.php --filter testPremiumCalculationWithPrimaryRackRateAndAdditionalRackRate`

View File

@ -99,5 +99,5 @@ class Autoload extends AutoloadConfig
* @var string[]
* @phpstan-var list<string>
*/
public $helpers = ['uuid','session','utility', 'form', 'url', 'oauth', 'fileupload', 'excel_import_export', 'file', 'drive'];
public $helpers = ['uuid','session','utility', 'form', 'url', 'oauth', 'fileupload', 'excel_import_export', 'file', 'drive','ExcelSanitizeHelper'];
}

View File

@ -155,6 +155,7 @@ $routes->group("/employee", ["filter" => "authMVC"], function ($routes) {
$routes->get("truncate/(:any)", "EmployeeController::truncateFileData/$1");
$routes->get("test-rack-rate", "EmployeeController::testRackRate");
$routes->post("test-rack-rate", "EmployeeController::testRackRate");
$routes->get('test_members_list', 'EmployeeController::test_members_list');
});
$routes->group("/master", ["filter" => "authMVC"], function ($routes) {
@ -327,6 +328,13 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->get('view_log/(:any)', 'EmployeeController::viewLog/$1');
$routes->get('download_log/(:any)', 'EmployeeController::downloadLog/$1');
$routes->post('checkDuplicateTableFieldValue', 'ClientController::checkDuplicateTableFieldValue');
$routes->get('getCoShareStatementDetails/(:any)', 'PolicyTransactionController::getCoShareStatementDetails/$1');
$routes->get('getClientPolicyDataBasedOnClientAndInsuer', 'PolicyTransactionController::getClientPolicyDataBasedOnClientAndInsuer');
$routes->get('checkCDAmountForBasePremium', 'PolicyTransactionController::checkCDAmountForBasePremium');
$routes->post('map_employees', 'EmployeeController::mapEmployees');
$routes->post('get_data_for_mapping', 'EmployeeController::getDataForMapping');
$routes->post('unmap_employees/(:num)', 'EmployeeController::unmapEmployees/$1');
$routes->get('transformMailContent', 'LeadsController::transformMailContent');
});
$routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
@ -362,6 +370,8 @@ $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
$routes->get("deletePaymentEntry/(:any)", "PolicyTransactionController::deletePaymentEntry/$1");
$routes->get("downloadSampleInsurerStatement", "PolicyTransactionController::downloadSampleInsurerStatement");
$routes->get("getFileErr/(:any)", "PolicyTransactionController::getFileErr/$1");
$routes->get("getInsurerStatementMonth", "PolicyTransactionController::getInsurerStatementMonth");
$routes->get("deleteStatement/(:any)", "PolicyTransactionController::deleteStatement/$1");
});
});
@ -372,9 +382,11 @@ $routes->group("leads", ["filter" => "authMVC"], function ($routes) {
$routes->post("create", "LeadsController::createLead");
$routes->get("list/(:any)", "LeadsController::getLeadDataForEdit/$1");
$routes->get("sendMail", "LeadsController::sendMailWithAttachement");
$routes->post("sendMail", "LeadsController::sendMailWithAttachement");
$routes->get("exportQCRandRFQ/(:any)", "LeadsController::exportQCRandRFQ/$1");
$routes->get("featchLeadDataAndInsertClient/(:any)", "LeadsController::featchLeadDataAndInsertClient/$1");
$routes->get("featchClientPolicyFromLead/(:any)", "LeadsController::featchClientPolicyFromLead/$1");
});
$routes->group("rfq", ["filter" => "authMVC"], function ($routes) {
@ -388,6 +400,7 @@ $routes->get("driveListFiles", "GoogleDriveController::listFiles");
$routes->post('dmsSearch', 'PolicyTransactionController::dmsSearch', ['filter' => 'authMVC']);
$routes->get('dmsSearch', 'PolicyTransactionController::dmsSearch', ['filter' => 'authMVC']);
$routes->get('downloadGdriveFile', 'GoogleDriveController::downloadGdriveFile', ['filter' => 'authMVC']);
$routes->get('cli/sendZeptoMail', 'MasterController::testZeptoSMTP');
$routes->cli('cli/processjob', 'JobWorker::processJob');
$routes->cli('cli/processjobs', 'JobWorker::processJobs');
@ -395,6 +408,7 @@ $routes->cli('cli/processjobs', 'JobWorker::processJobs');
$routes->get("processjob", "JobWorker::processJob");
$routes->cli('cli/new_gmail_token', 'MasterController::generateNewGmailAPIToken');
$routes->cli('cli/send_mail_cli', 'MasterController::testGmailAPIViaCLI');
$routes->cli('cli/sendZeptoMail', 'MasterController::testZeptoSMTP');
$routes->cli('cli/check_bounce_mail_cli', 'MasterController::testCheckBounceMails');
$routes->cli('cli/app_check_list', 'MasterController::appCheckList');
$routes->cli('cli/new_gdrive_token', 'GoogleDriveController::generateNewGoogleDriveAccessToken');

View File

@ -484,7 +484,7 @@ class ClientController extends AdminController
// Fetch associated insurer names and balances
$balances = $this->clientPolicyModel->getBalances($id);
$data['balances'] = $balances;
// dd($data);
echo view('layout/header', $headerData);
echo view('client_deposit_list', $data);
echo view('layout/footer');
@ -521,7 +521,7 @@ class ClientController extends AdminController
$data['clientData'] = $this->clientPolicyModel->getClientById($clientId);
$data['deposiamount'] = $this->clientPolicyModel->getDepositSummary($clientId, $insurerId);
// dd($data['depositdata']);
// dd($data['insurerName']);
// print_r($data['depositdata'] );die;
// Load the view for the new list page;
@ -1051,7 +1051,7 @@ class ClientController extends AdminController
$data['policy_status'] = 1;
$data['inception_type'] = $this->request->getPost('inception_type') ? 2 : 1;
$data['client_branch_id'] = $this->request->getPost('client_branch_id');
$data['cd_ac_no'] = $this->request->getPost('cd_ac_no');
$data['cd_ac_pk'] = $this->request->getPost('cd_ac_no');
$data['gst'] = $this->request->getPost('gst');
$data['disclaimer'] = $this->request->getPost('disclaimer');
$data['is_member_modify_allowed'] = $this->request->getPost('is_member_modify_allowed') ? 1 : 0;
@ -1091,7 +1091,7 @@ class ClientController extends AdminController
$data['reminder_date'] = null;
}
$data['created_by'] = get_session_userid();
$data['created_by'] = get_session_userid();
$policy_tranction_data = [
@ -1102,7 +1102,7 @@ class ClientController extends AdminController
'insurer_branch_id' => $insurerBranchId,
'issue_type' => 1,
'policy_no' => $this->request->getPost('policy_no'),
'cd_ac_no' => $this->request->getPost('cd_ac_no'),
'cd_ac_pk' => $this->request->getPost('cd_ac_no'),
'policy_issue_date' => date('Y-m-d'),
'policy_start_date' => change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d'),
'policy_end_date' => change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d'),
@ -1112,7 +1112,6 @@ class ClientController extends AdminController
];
$insert = $this->clientPolicyModel->insert($data);
if ($insert) {
@ -1139,6 +1138,7 @@ class ClientController extends AdminController
public function editClientPolicy()
{
// print_r('test'); die;
$this->myLogger->logme('error', 'Client policy function called');
@ -1182,13 +1182,12 @@ class ClientController extends AdminController
$data['inception_type'] = $this->request->getPost('inception_type') ? 2 : 1;
$data['enrolment_visibility'] = $this->request->getPost('enrolment_visibility') ? 1 : 0;
$data['client_branch_id'] = $this->request->getPost('client_branch_id');
$data['cd_ac_no'] = $this->request->getPost('cd_ac_no');
$data['cd_ac_pk'] = $this->request->getPost('cd_ac_no');
$data['gst'] = $this->request->getPost('gst');
$data['disclaimer'] = $this->request->getPost('disclaimer');
$data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd-m-Y', 'Y-m-d');
$data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd-m-Y', 'Y-m-d');
$data['is_member_modify_allowed'] = $this->request->getPost('is_member_modify_allowed') ? 1 : 0;
if ($data['inception_type'] == 2) {
$data['open_date'] = change_date_format($this->request->getPost('open_date'), 'd-m-Y', 'Y-m-d');
$data['close_date'] = change_date_format($this->request->getPost('close_date'), 'd-m-Y', 'Y-m-d');
@ -3298,11 +3297,10 @@ class ClientController extends AdminController
public function getClientAndBranchAndPolicy()
{
// ---------for client-----------------------------------------------------------------------------
$clients = $this->clientModel->where('is_active', 1)->findAll();
$vehicles = $this->vehicleModel
->select('vehicle.*, clients.client_type')
->join('clients', 'clients.id=vehicle.owner')
->where('vehicle.is_active', 1)->findAll();
$clientIds = array_column($clients, 'id');
// Fetch branches in a single query
@ -3311,6 +3309,29 @@ class ClientController extends AdminController
->where('is_active', 1)
->findAll();
// -----------for vehicle ---------------------------------------------------------------------------
$vehicles = $this->vehicleModel
->select('vehicle.*, clients.client_type')
->join('clients', 'clients.id=vehicle.owner')
->where('vehicle.is_active', 1)->findAll();
// -----------for Insurer ---------------------------------------------------------------------------
//fetch all insurer data
$insurers = $this->insurerModel->where('is_active', 1)->findAll();
//map the insurer primary key to column
$insurersIds = array_column($insurers, 'id');
// Fetch insurer branches in a single query
$insurerBranches = $this->insurerBranchModel
->whereIn('insurer_id', $insurersIds)
->where('is_active', 1)
->findAll();
// -----------for Policy ---------------------------------------------------------------------------
// Fetch policies in a single query
$policies = $this->clientPolicyModel
->select("
@ -3329,16 +3350,26 @@ class ClientController extends AdminController
->where('client_policy.is_active', 1)
->findAll();
// --------------------------------------------------------------------------------------
$branchList = [];
$policyList = [];
$policyListByClient = [];
$unitList = [];
$insurerBranchList = [];
//for client branch mapping to the client
foreach ($branches as $branch) {
$branchList[$branch['client_id']][] = $branch;
$unitList[$branch['id']][] = json_decode($branch['units']);
}
//for insurer branch mapping to the insurer
foreach ($insurerBranches as $branch) {
$insurerBranchList[$branch['insurer_id']][] = $branch;
}
//for client policy mapping to the branch and client
foreach ($policies as $policy) {
$policyList[$policy['client_branch_id']][] = $policy;
$policyListByClient[$policy['client_id']][] = $policy;
@ -3349,6 +3380,7 @@ class ClientController extends AdminController
}
}
//get policy count
foreach ($clients as &$client) {
$client['client_policy_count'] = $policyCount[$client['id']] ?? 0;
}
@ -3361,6 +3393,8 @@ class ClientController extends AdminController
'branch_data' => $branchList,
'policy_data' => $policyList,
'policyListByClient' => $policyListByClient,
'insurer_data' => $insurers,
'insurer_branch_data' => $insurerBranchList,
'unit_data' => $unitList,
], 200);
} else {
@ -3807,7 +3841,7 @@ class ClientController extends AdminController
// dd($this->request);
// $employeeRestController = new EmployeeServiceController();
// $employeeRestController->employeesEnrollmentInsert(['file_id' => 721]);
// $employeeRestController->employeesOnboardPreprocess(['file_id' => 721]);
// $r = Jobs::addJob(['job_name' => 'employeesEnrollmentInsert','payload' => ['file_id' => 721]]);
@ -3832,6 +3866,37 @@ class ClientController extends AdminController
// $PolicyTransactionController = new PolicyTransactionController();
// $res = $PolicyTransactionController->validateInsurerStatement(['file_id' => '36']);
// $empServiceController = new EmployeeServiceController();
// $res = $empServiceController->excelFileDataValidation(['file_id' => '319']);
// dd($res);
// $EmpDataServiceController = new EmpDataServiceController();
// $EmpDataServiceController->importInceptionFileValidation(['file_id' => 160]);
$EmpDataServiceController = new EmpDataServiceController();
// $EmpDataServiceController->importInceptionUpdateTPAandUHID(['file_id' => 162]);
// $EmpDataServiceController->importInceptionFileValidation(['file_id' => 162]);
// $EmpDataServiceController->importDeletionValidation(['file_id' => 171]);
// $EmpDataServiceController->importDeletionUpdateEndorsementID(['file_id' => 171]);
$array = [
"employeeIds" => ["12800", "12798", "12797", "12799"],
"client_id" => "159",
"client_policy_id" => "336",
"client_branch_id" => "126",
"cd_ac_no" => "Apple_123",
"endorsement_no" => "ENDORSEMENT_ID",
"count" => 4,
"event_name" => "deletion",
"policy_name" => "GMC",
"user_id" => "1"
];
$EmpDataServiceController->cashDepositCalculationForDeletion($array);
// $employeeRestController = new EmployeeServiceController();
// $employeeRestController->employeesOnboardPreprocess(['file_id' => 757]);
}
// -------------------------------------------------------------------------------------------------------

View File

@ -459,7 +459,7 @@ class DashboardController extends AdminController
$mail_result = sendMailNotification::sendMailNotification('member_reminder_mail', $params);
// dd($mail_result);
// $this->myLogger->logme('error', 'Mail sent result: ' . json_encode($mail_result));
$reminder_whole_mail[] = $mail_result[0];
$reminder_whole_mail[] = $mail_result;
}
}
@ -550,7 +550,7 @@ class DashboardController extends AdminController
// Send the mail notification
$mail_result = sendMailNotification::sendMailNotification('member_reminder_mail', $params);
// $this->myLogger->logme('error', 'Mail sent result: ' . json_encode($mail_result));
$reminder_whole_mail[] = $mail_result[0];
$reminder_whole_mail[] = $mail_result;
}
}

View File

@ -169,13 +169,13 @@ class EmpDataServiceController extends BaseController
$cash_balance['balance'] = $balance['opening_bal'];
}
// Calculate the total amount from the objects
$totals = 0;
foreach ($objects as $item) {
$totals = $totals + $item->total;
}
$totals = round($totals, 2);
// Calculate the total amount from the objects
$totals = 0;
foreach ($objects as $item) {
$totals = $totals + $item->total;
}
$totals = round($totals, 2);
if($export_data['insurer_or_tpa'] == 'insurer') //check CD amt related issue for only insurer, not tpa
{
@ -205,9 +205,6 @@ class EmpDataServiceController extends BaseController
// Log the export file name
$this->myLogger->logme('error', 'Inception export file name : {data}', ['data' => $export_data['file_name']]);
// remove existing batch file anf batch list data every time export
$this->removeOldExportInfoFromBatchFile($export_data);
// default excel header information
$excel_header_columns = [
[
@ -258,7 +255,7 @@ class EmpDataServiceController extends BaseController
[
'column_index' => 7,
'column_name' => 'DATE OF COVERAGE',
'db_column_name' => 'date_coverage'
'db_column_name' => 'date_of_coverage'
],
[
'column_index' => 8,
@ -368,7 +365,7 @@ class EmpDataServiceController extends BaseController
[
'column_index' => 7,
'column_name' => 'DATE OF COVERAGE',
'db_column_name' => 'date_coverage'
'db_column_name' => 'date_of_coverage'
],
[
'column_index' => 8,
@ -426,16 +423,48 @@ class EmpDataServiceController extends BaseController
'db_column_name' => 'total'
]
];
//for addition and dependent addition adding a ENDORSEMENT NO column
if(in_array($export_data['event_type'], ['addition', 'dependent_addition'])){
$excel_header_columns[] = [
'column_index' => 18,
'column_name' => 'ENDORSEMENT NO',
'db_column_name' => ''
];
}
}else{
// get excel export format structure array
$template_json = $this->clientPolicyModel
->select('insurer_excel_export_template.jsoncolumns')
->join('insurer_excel_export_template', 'insurer_excel_export_template.insurer_id = client_policy.insurer_id and insurer_excel_export_template.policy_type_id = client_policy.policy_type_id')
->where('client_policy.id', $export_data['client_policy_id'])
->where('insurer_excel_export_template.event_name', $export_data['event_type'])
->where('insurer_excel_export_template.is_active', 1) //Live issue changes 17-10-2024
->where('insurer_excel_export_template.type_name', $export_data['actions'])
->first();
// $template_json = $this->clientPolicyModel
// ->select('insurer_excel_export_template.jsoncolumns')
// ->join('insurer_excel_export_template', 'insurer_excel_export_template.insurer_id = client_policy.insurer_id and insurer_excel_export_template.policy_type_id = client_policy.policy_type_id')
// ->where('client_policy.id', $export_data['client_policy_id'])
// ->where('insurer_excel_export_template.event_name', $export_data['event_type'])
// ->where('insurer_excel_export_template.is_active', 1) //Live issue changes 17-10-2024
// ->where('insurer_excel_export_template.type_name', $export_data['actions'])
// ->first();
$sql = "
SELECT `insurer_excel_export_template`.`jsoncolumns`
FROM `client_policy`
JOIN `insurer_excel_export_template`
ON `insurer_excel_export_template`.`insurer_id` = `client_policy`.`insurer_id`
AND `insurer_excel_export_template`.`policy_type_id` =
CASE
WHEN `client_policy`.`policy_type_id` IN (2, 3, 4, 5) THEN 2
ELSE `client_policy`.`policy_type_id`
END
WHERE `client_policy`.`id` = '".$export_data['client_policy_id']."'
AND `insurer_excel_export_template`.`event_name` = '".$export_data['event_type']."'
AND `insurer_excel_export_template`.`is_active` = 1
AND `insurer_excel_export_template`.`type_name` = '".$export_data['actions']."'
LIMIT 1";
$query = db_connect()->query($sql);
$template_json = $query->getRowArray();
// dd(db_connect()->getLastQuery());
if(!empty($template_json) && $template_json != null){
$excel_header_columns = json_decode($template_json['jsoncolumns'], true);
@ -444,6 +473,10 @@ class EmpDataServiceController extends BaseController
}
}
// remove existing batch file anf batch list data every time export
$this->removeOldExportInfoFromBatchFile($export_data);
//convert the excel data based on the insurer
$excel_data_info = generate_insurer_based_excel($excel_header_columns, $objects);
// Generate Excel file
@ -1256,6 +1289,7 @@ class EmpDataServiceController extends BaseController
$this->myLogger->logme('info', 'Inception File Validation -- Function called');
$file_id = $params['file_id'];
// dd($file_id);
$this->myLogger->logme('error', 'Inception File Validation -- Batch File Table Primary ID : {data}', ['data' => $file_id]);
@ -1288,30 +1322,36 @@ class EmpDataServiceController extends BaseController
// array_pop($excel_data);
$inceptionHeader = [
'S.No',
'NAME OF EMP/DEP',
'EMP ID',
// 'EMP/DEP TYPE',
// 'RELATIONSHIP CODE',
'DOB',
'GENDER',
'PRE EXISTING AILMENTS',
'BASIC COVER SI',
'DATE OF COVERAGE',
'AGE',
'RELATIONSHIP',
'REMARKS',
'POLICY END DATE',
'NO OF DAYS',
'TPA ID',
'UHID',
// 'PREMIUM',
'PRO RATA PREMIUM',
'GST',
'TOTAL AMOUNT'
];
'S.No',
'NAME OF EMP/DEP',
'EMP ID',
// 'EMP/DEP TYPE',
// 'RELATIONSHIP CODE',
'DOB',
'GENDER',
'PRE EXISTING AILMENTS',
'BASIC COVER SI',
'DATE OF COVERAGE',
'AGE',
'RELATIONSHIP',
'REMARKS',
'POLICY END DATE',
'NO OF DAYS',
'TPA ID',
'UHID',
// 'PREMIUM',
'PRO RATA PREMIUM',
'GST',
'TOTAL AMOUNT',
];
if(in_array($file['event_type'], ['addition', 'dependent_addition'])){
$inceptionHeader[] = 'ENDORSEMENT NO';
}
// dd($inceptionHeader);
foreach ($inceptionHeader as $key => $value) {
if($excel_header[$key] != $value){
$data = [
'status' => 'failed-5',
@ -1330,46 +1370,9 @@ class EmpDataServiceController extends BaseController
$emp_count = count($excel_data);
//get the employee data for excel file validation
$employee_data = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($ref_data, 1);
// ->select('
// employee_polices.id as emp_policy_id,
// employees.name AS emp_name,
// employees.emp_code AS emp_code,
// "Has Define" as emp_type,
// employees.relationship_code AS emp_relationship_code,
// employees.dob AS emp_dob,
// employees.gender AS emp_gender,
// employee_polices.pre_existing_alignments,
// employee_polices.basic_cover_si,
// employee_polices.date_coverage,
// TIMESTAMPDIFF(YEAR, employees.dob, CURDATE()) AS emp_age,
// employees.relationship AS emp_relationship,
// employees.change_event AS change_event,
// employee_polices.policy_end_date,
// employee_polices.days,
// employee_polices.tpa_id,
// employee_polices.uhid,
// employee_polices.premium,
// employee_polices.rata_premimum,
// employee_polices.gst,
// (employee_polices.rata_premimum + employee_polices.gst) AS total
// ')
// ->join('employees', 'employees.id = employee_polices.employee_id')
// ->where('employee_polices.client_policy_id', $client_policy_id)
// ->where('employees.client_id', $client_id)
// ->where('employees.client_branch_id', $client_branch_id)
// ->where("employee_polices.{$id} IS NULL OR employee_polices.{$id} = ''")
// ->where('employee_polices.is_active', 1)
// ->where('employee_polices.status', 'active')
// ->where('employees.is_active', 1)
// ->where('employees.emp_status', 'active')
// ->findAll();
if ($employee_data == null || empty($employee_data)) {
if ($insurer_or_tpa == 'tpa') {
@ -1402,7 +1405,6 @@ class EmpDataServiceController extends BaseController
}
$this->myLogger->logme('error', 'Inception File Validation -- UHID or TPAID already updated or the uploadedfile is not correct');
}
$excel_data_count = count($excel_data);
@ -1423,7 +1425,6 @@ class EmpDataServiceController extends BaseController
$this->myLogger->logme('error', 'Inception File Validation -- excel file count partially : {data}', ['data' => $partially_updated_data]);
}
if ($emp_data_count < $excel_data_count) {
$data = [
@ -1453,17 +1454,22 @@ class EmpDataServiceController extends BaseController
}
if ($insurer_or_tpa == 'tpa') {
if ($excel_data[$key][13] === null) {
$missing_id[$key][] = [
'row' => $key,
'column' => 15,
'column' => 13,
'db_data' => "TPA ID is Must",
'excel_data' => $excel_data[$key][13]
];
}
} else if ($insurer_or_tpa == 'insurer') {
if ($excel_data[$key][14] === null) {
$missing_id[$key][] = [
'row' => $key,
'column' => 16,
'column' => 14,
'db_data' => "UHID or Risk ID is Must",
'excel_data' => $excel_data[$key][14]
];
}
}
@ -1569,6 +1575,7 @@ class EmpDataServiceController extends BaseController
}
if ($emp_value['gst'] != $excel_data[$key][16]) {
$errors[$key][] = [
'row' => $key,
'column' => 16,
@ -1610,7 +1617,7 @@ class EmpDataServiceController extends BaseController
$missing_id_count = count($missing_id);
$json_missing_id = json_encode($missing_id);
// dd($error_count, $missing_id_count, $json_errors, $json_missing_id);
// dd($error_count, $missing_id_count, $json_errors, $json_missing_id, $employee_data, $excel_data);
if ($missing_id_count > 0) {
@ -1695,6 +1702,7 @@ class EmpDataServiceController extends BaseController
$file_id = $params['file_id'];
$file = $this->batchFileModel->find($file_id);
// dd($file);
if (!$file) {
@ -1727,22 +1735,20 @@ class EmpDataServiceController extends BaseController
->first();
$get_policy_type = $this->clientPolicyModel
->select('policy_type.policy_type, policies.policy_type_id as policy_type_id')
->join('policies', 'policies.id = client_policy.policy_id')
->join('policy_type', 'policy_type.id = policies.policy_type_id')
->select('client_policy.*, policy_type.policy_type')
->join('policy_type', 'policy_type.id = client_policy.policy_type_id', 'left')
->where('client_policy.id', $client_policy_id)
->first();
// dd($get_policy_type);
$status_val = 'success';
if ($status == 'in-progress-partially') {
$status_val = 'partially success';
}
$this->myLogger->logme('error', 'Inception Update TPA and UHID -- file name : {data}', ['data' => $file['file_name']]);
$file_name_with_path = WRITEPATH . "/uploads/import_excel/" . $file['file_name'];
$excel_data = $this->readExcelFileToArray($file_name_with_path);
unset($excel_data[0]); // Remove header row
@ -1753,10 +1759,15 @@ class EmpDataServiceController extends BaseController
$emp_details = [];
$tpa_id = [];
$uhid = [];
$emp_endorsement_table_data = [];
$enrollment_file_id = null;
$endorsement_id = null;
$emp_count = count($excel_data);
$db = \Config\Database::connect();
// print_rr($excel_data); die;
foreach ($excel_data as $key => $value) {
$name = $value[1];
@ -1796,11 +1807,54 @@ class EmpDataServiceController extends BaseController
$emp_details[] = array('id' => $result['id'], 'tpa_id' => $value[13], 'uhid' => $value[14]);
}
//for addition and dependent_addition endorsement , endorsement_id update functionality
if(in_array($file['event_type'], ['addition', 'dependent_addition']) && isset($value[18])){
$action = 'a';
if($file['event_type'] == "dependent_addition"){
$action = 'da';
}
$endorsement_id = $value[18];
$result_for_endorsement = $this->empEndorsementModel
->select('emp_endorsement.*, employees.id as emp_id, employee_polices.id as emp_policy_id')
->join('employee_polices', 'employee_polices.id = emp_endorsement.pk')
->join('employees', 'employees.emp_code = emp_endorsement.emp_code')
->where('employees.emp_code', $emp_code)
->where('employees.name', $name)
->where('employees.client_id', $client_id)
->where('employees.client_branch_id', $client_branch_id)
->where('emp_endorsement.actions', $action)
->where('employee_polices.client_policy_id', $client_policy_id)
->where('employee_polices.is_active', 1)
->where('employee_polices.status', 'active')
->where('employees.is_active', 1)
->where('employees.emp_status', 'active')
->where('(emp_endorsement.endorsement_id IS NULL OR emp_endorsement.endorsement_id = "")')
->groupBy('emp_endorsement.group_key')
->first();
if (!empty($result_for_endorsement) && count($result_for_endorsement)) {
$enrollment_file_id = $result_for_endorsement['file_id']; //files table primary key
$emp_endorsement_table_data[] = array('id' => $result_for_endorsement['id'], 'group_key' => $result_for_endorsement['group_key'], 'endorsement_id' => $value[18], 'status' => 'complete');
}
}
}
}
// dd($emp_endorsement_table_data, $enrollment_file_id);
//update the employee policy data (TPAID or UHID)
$return = $this->employeePolicyModel->bulkUpdate($emp_details);
if(in_array($file['event_type'], ['addition', 'dependent_addition']) && !empty($emp_endorsement_table_data)){
$this->employeePolicyModel->updateEmpEndorsementAddition($emp_endorsement_table_data);
$this->storeEndorsementNumber($file_id, $endorsement_id, $enrollment_file_id);
}
// Update batch file status and amount
$this->batchFileModel->update($file_id, [
'count' => $emp_count,
@ -1836,7 +1890,7 @@ class EmpDataServiceController extends BaseController
'client_id' => $client_id,
'client_policy_id' => $client_policy_id,
'cd_ac_no' => $CD_Account_Number['cd_ac_no'] ?? null,
'endorsement_no' => null,
'endorsement_no' => $endorsement_id,
'client_branch_id' => $client_branch_id,
'count' => $emp_count,
'event_name' => $file['event_type'],
@ -1954,12 +2008,14 @@ class EmpDataServiceController extends BaseController
->where("employees.is_active", 1)
->where("employees.emp_status", "active")
->where("emp_endorsement.actions", "c")
->where("emp_endorsement.is_active", 1)
->where("emp_endorsement.status !=", "truncated")
->where("(emp_endorsement.endorsement_id IS NULL OR emp_endorsement.endorsement_id = '')")
->findAll();
// dd($endorsement_data, $excel_data);
dd($endorsement_data, $excel_data);
if ($endorsement_data == null || empty($endorsement_data)) {
@ -2225,6 +2281,7 @@ class EmpDataServiceController extends BaseController
$emp_details = [];
$endorsement_id = [];
$endorsement_details = [];
$enrollment_file_id = null;
$emp_count = count($excel_data);
$db = \Config\Database::connect();
@ -2237,7 +2294,6 @@ class EmpDataServiceController extends BaseController
$endorsement_id[] = $value[10];
$uhid = $value[1];
$result = $this->empEndorsementModel
->select('emp_endorsement.*, employees.id as emp_id')
->join('employees', 'employees.id = emp_endorsement.pk')
@ -2253,11 +2309,13 @@ class EmpDataServiceController extends BaseController
->where('employee_polices.status', 'active')
->where('employees.is_active', 1)
->where('employees.emp_status', 'active')
->where("emp_endorsement.is_active", 1)
->where("emp_endorsement.status !=", "truncated")
->first();
if (isset($result['id']) && $result['id'] !== null) {
// return $result;
$enrollment_file_id = $result['file_id'];
$emp_details[] = array('id' => $result['emp_id'], $result['field_name'] => $value[8]);
$endorsement_details[] = array('group_key' => $result['group_key'], 'id' => $result['id'], 'endorsement_id' => $value[10], 'status' => 'complete');
}
@ -2268,7 +2326,7 @@ class EmpDataServiceController extends BaseController
$this->empEndorsementModel->updateBatch($endorsement_details, 'group_key');
$this->employeePolicyModel->bulkUpdateForCorrection($emp_details);
$this->storeEndorsementNumber($file_id, $endorsement_id[0]);
$this->storeEndorsementNumber($file_id, $endorsement_id[0], $enrollment_file_id);
// Update batch file status and amount
@ -2782,6 +2840,7 @@ class EmpDataServiceController extends BaseController
$employeeIds = [];
$emp_details = [];
$endorsement_id = '';
$enrollment_file_id = '';
$endorsement_details = [];
$totals = 0;
@ -2813,6 +2872,8 @@ class EmpDataServiceController extends BaseController
->first();
if (isset($result['id']) && $result['id'] !== null) {
$enrollment_file_id = $result['file_id'];
$emp_policy_ids[] = array('id' => $result['emp_policy_id'], 'is_active' => 0);
$employeeIds[] = $result['emp_policy_id'];
$endorsement_details[] = array('id' => $result['id'], 'group_key' => $result['group_key'], 'endorsement_id' => $value[19], 'status' => 'complete');
@ -2872,7 +2933,7 @@ class EmpDataServiceController extends BaseController
// }
$this->employeePolicyModel->bulkUpdateForEndorsement($endorsement_details);
$this->storeEndorsementNumber($file_id, $endorsement_id);
$this->storeEndorsementNumber($file_id, $endorsement_id, $enrollment_file_id);
// Update batch file status and amount
@ -2957,7 +3018,7 @@ class EmpDataServiceController extends BaseController
// array_pop($excel_data);
$headers = ['S.No','EMP ID','EMP NAME','DOB','GENDER','RELATIONSHIP','SUM INSURED','Date of Leaving','Policy End Date','No Of Days','Premium','Pro Rata Premium','GST','Total','Claim Status','ENDORSEMENT_ID'];
// dd($headers, $excel_header);
foreach ($headers as $key => $value) {
if($excel_header[$key] != $value){
@ -3289,6 +3350,7 @@ class EmpDataServiceController extends BaseController
$employee_policy_table_data = [];
$employee_policy_table_primaryKey = [];
$endorsement_id = '';
$enrollment_file_id = null; //files table primary key
$totals = 0;
@ -3309,13 +3371,16 @@ class EmpDataServiceController extends BaseController
'emp_name' => $emp_name,
'emp_code' => $emp_code
];
$result = $this->employeePolicyModel->fetchEmpEndorsementData($fetch_data);
// dd($result, db_connect()->getLastQuery());
if (isset($result['emp_endorsement_primarykey']) && $result['emp_endorsement_primarykey'] !== null) {
$enrollment_file_id = $result['file_id']; //files table primary key
$employee_policy_table_primaryKey[] = $result['emp_policy_primarykey']; //for cash deposite
$employee_policy_table_data[] = array('id' => $result['emp_policy_primarykey'], 'date_of_exit' => $result['date_of_exit'], 'reason_for_exit' => $result['reason_for_exit'], 'status' => $result['status']);
$employees_table_data[] = array('id' => $result['employees_id'], 'emp_status' => $result['status']);
$employee_policy_table_data[] = array('id' => $result['emp_policy_primarykey'], 'date_of_exit' => $result['date_of_exit'], 'reason_for_exit' => $result['reason_for_exit'], 'claim_status' => $result['claim_status'], 'status' => $result['status']);
// $employees_table_data[] = array('id' => $result['employees_id'], 'emp_status' => $result['status']);
$emp_endorsement_table_data[] = array('id' => $result['emp_endorsement_primarykey'], 'group_key' => $result['group_key'], 'endorsement_id' => $value[15], 'status' => 'complete');
}
@ -3327,11 +3392,10 @@ class EmpDataServiceController extends BaseController
// dd($employees_table_data, $emp_endorsement_table_data, $employee_policy_table_data, $employee_policy_table_primaryKey, $totals, $emp_count);
// Check if $employees_table_data is null or empty
if (empty($employees_table_data)) {
return ['status' => 'error', 'message' => 'Employees table data is empty or null.'];
}
// if (empty($employees_table_data)) {
// return ['status' => 'error', 'message' => 'Employees table data is empty or null.'];
// }
// Check if $employee_policy_table_data is null or empty
if (empty($employee_policy_table_data)) {
@ -3343,10 +3407,10 @@ class EmpDataServiceController extends BaseController
return ['status' => 'error', 'message' => 'Employee endorsement table data is empty or null.'];
}
$this->employeeModel->updateBatch($employees_table_data, 'id');
// $this->employeeModel->updateBatch($employees_table_data, 'id');
$this->employeePolicyModel->updateBatch($employee_policy_table_data, 'id');
$this->employeePolicyModel->bulkUpdateForEndorsement($emp_endorsement_table_data);
$this->storeEndorsementNumber($file_id, $endorsement_id);
$this->storeEndorsementNumber($file_id, $endorsement_id, $enrollment_file_id);
// Update batch file status and amount
$this->batchFileModel->update($file_id, [
@ -3355,12 +3419,12 @@ class EmpDataServiceController extends BaseController
'amount' => $rounded_totals,
]);
$this->myLogger->logme('error', 'Deletion Update Endorsement ID -- Employee count : {data}', ['data' => $emp_count]);
$this->myLogger->logme('error', 'Deletion Update Endorsement ID -- Batch File status : {data}', ['data' => $status_val]);
//call the cash deposite function
if ($file['insurer_or_tpa'] == 'insurer') {
$policy_name = $this->getPolicyNameUsingClientPolicyId($client_policy_id);
$job_details = new Jobs();
$r = Jobs::addJob(['job_name' => 'cashDepositCalculationForDeletion', 'payload' => [
@ -3816,7 +3880,8 @@ class EmpDataServiceController extends BaseController
foreach($units as $unit)
{
$client_policy_id = $arrayData['client_policy_id'];
$cd_ac_pk = $this->clientPolicyModel->select('cd_ac_pk')->where('id',$client_policy_id)->first();
$amount = $this->employeePolicyModel->query("
SELECT SUM(rata_premimum + gst) AS total_sum
FROM employee_polices
@ -3844,6 +3909,7 @@ 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']
];
$response = DepositHelper::saveDeposit($data, $arrayData['user_id']);
@ -3900,6 +3966,7 @@ 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']
];
$response = DepositHelper::saveDeposit($data, $arrayData['user_id']);
@ -3935,7 +4002,7 @@ class EmpDataServiceController extends BaseController
// dd($client_branch_data, $units);
$get_insurer_id_from_client_policy = db_connect()->table('client_policy')
->select('insurer_id')
->select('insurer_id,cd_ac_pk')
->where('id', $arrayData['client_policy_id'])
->get()
->getRowArray();
@ -3988,10 +4055,11 @@ class EmpDataServiceController extends BaseController
WHERE
employee_polices.id IN (" . implode(',', $arrayData['employeeIds']) . ")
AND emp_endorsement.pk IN (" . implode(',', $arrayData['employeeIds']) . ")
AND employee_polices.claim_status = 0
AND emp_endorsement.field_name = 'date_of_exit'
")->getRow();
// dd(db_connect()->getLastQuery(), $amount);
dd(db_connect()->getLastQuery(), $amount);
if($amount){
@ -4012,6 +4080,7 @@ 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']
];
$response = DepositHelper::saveDeposit($data, $arrayData['user_id']);
@ -4485,7 +4554,7 @@ class EmpDataServiceController extends BaseController
$this->messageModel->insert($msg_data);
}
public function storeEndorsementNumber($file_id, $endorsement_no)
public function storeEndorsementNumber($file_id, $endorsement_no, $enrollment_file_id)
{
// Log the function entry with input parameters
$this->myLogger->logme('error', "storeEndorsementNumber --- Starting function with file_id: $file_id and endorsement_no: $endorsement_no");
@ -4521,6 +4590,7 @@ class EmpDataServiceController extends BaseController
'insurer_id' => $filedata['insurer_id'],
'tpa_id' => $filedata['tpa_id'],
'endorsement_no' => $endorsement_no,
'file_id' => $enrollment_file_id,
'endorsement_type' => $filedata['event_type'],
'created_by' => $filedata['created_by'],
]);

View File

@ -24,6 +24,7 @@ use App\Models\TPAModel;
use App\Models\InsurerExcelExportTemplateModel;
use App\Models\InsurerModel;
use App\Models\ClientDepositModel;
use App\Models\PolicyPremium2Model;
use App\Controllers\Jobs;
@ -40,7 +41,7 @@ use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use Dompdf\Dompdf;
use Dompdf\Options;
use Kint;
class EmployeeController extends AdminController
{
@ -62,6 +63,7 @@ class EmployeeController extends AdminController
protected $excelExportTemplateModel;
protected $insurerModel;
protected $cashDepositModel;
protected $PolicyPremium2Model;
public function __construct()
{
@ -81,6 +83,7 @@ class EmployeeController extends AdminController
$this->policiesModel = new PolicesModel();
$this->insurerModel = new InsurerModel();
$this->cashDepositModel = new ClientDepositModel();
$this->PolicyPremium2Model = new PolicyPremium2Model();
}
public function list()
@ -108,7 +111,7 @@ class EmployeeController extends AdminController
emp_name : $filterData['emp_name'] ?? null,
status : $filterData['status'] ?? [],
);
log_message('error',json_encode($data['employees']));
// log_message('error',json_encode($data['employees']));
// Set getData in $data array with the processed $filterData
$data['getData'] = $filterData;
}
@ -207,7 +210,9 @@ class EmployeeController extends AdminController
// $this->fileModel->where('id', '12')->set(['status' => 'failed','reason' => $failure_reason])->update();
// dd($failure_reason);
// }
// $this->truncateFileData(747, 5) ;
// print_rr($this->cloneWorksheet());
// die();
if ($this->request->getMethod() == 'post') {
//validate uploaded file
@ -1224,24 +1229,26 @@ class EmployeeController extends AdminController
public function truncateFileData($file_id, $role_id = null)
{
$file_id = $this->request->uri->getSegment(3);
// $file_id = 112;
// $file_id = 747;
$file = $this->fileModel->find($file_id);
$client_id = $file['client_id'];
$client_policy_id = $file['policy_id'];
$loggedInUserID = get_session_userid();
$policy_data = $this->clientPolicyModel->where('id', $client_policy_id)->first();
$cd_tranction = $this->cashDepositModel
->where('client_id', $client_id)
->where('insurer_id', $policy_data['insurer_id'])
->where('event_name',$file['action'])
->where('client_policy_id', $client_policy_id)
->where('client_id', $client_id) //client
->where('insurer_id', $policy_data['insurer_id']) //insurer
->where('event_name',$file['action']) //event
->where('client_policy_id', $client_policy_id)//policy
->orderBy('id', 'desc')
->first();
// $file['action'] = 'si_enhancement';
// $result = [];
// !dd($file);
// dd($file);
if ($file['action'] == 'inception' || $file['action'] == 'dependent_addition' || $file['action'] == 'addition' || $file['action'] == 'enrollment' || $file['action'] == 'missed_inception') {
@ -1251,6 +1258,7 @@ class EmployeeController extends AdminController
$result = $this->employeeModel->getEmpListByFileId(file_id: $file_id, emp_status: ['active'], policy_status: ['active']);
}
$result = [];
// ~dd($result);
if (count($result) && $role_id == null) {
if(get_role_id() == 1 || get_role_id() == 5){
@ -1260,21 +1268,116 @@ class EmployeeController extends AdminController
}
} else {
//update emp and emp plocies
$db = db_connect();
$query = "UPDATE employees JOIN employee_polices ON employees.id = employee_polices.employee_id and employees.file_id = $file_id SET employees.emp_status = 'truncated', employee_polices.status = 'truncated', employees.is_active = 0,employee_polices.is_active = 0 WHERE employees.file_id = $file_id";
$db->query($query);
$affectedRows = $db->affectedRows();
// print_r($db->getLastQuery()); die;
// $affectedRows = 10;
$this->myLogger->logme('error', 'TRUNCATED STARTED WITH ADMIN OR HEAD PERMISSION');
$this->myLogger->logme('error', 'Event Type : -- {data} --', ['data' => $file['action']]);
//update file status
$this->fileModel->where('id', $file_id)->set(['status' => 'truncated'])->update();
// GET THE CD AMOUND
//get cd amount for the particular file id to reverse entry to the cash deposite
$cd_amount = $cd_tranction['amount'];
if(in_array($file['action'], ['addition', 'dependent_addition'])){
$cd_amount_total = $this->employeePolicyModel->getAdditionDataForTruncated($file_id, $file['action']);
// dd($cd_amount_total);
$cd_amount = $cd_amount_total['total'];
$this->myLogger->logme('error', 'Addition or Dependent Addition CD Amount : {data}', ['data' => $cd_amount]);
}
$this->myLogger->logme('error', 'CD Amount : {data}', ['data' => $cd_amount]);
if($file['action'] != 'enrollment')
{
//STEP: 1 - Update employee policy table
//update emp and emp plocies
$db = db_connect();
$query = "
UPDATE employee_polices
JOIN employees ON employees.id = employee_polices.employee_id
SET employee_polices.status = 'truncated', employee_polices.is_active = 0
WHERE employees.file_id = $file_id
";
$db->query($query);
$affectedRows = $db->affectedRows();
$this->myLogger->logme('error', 'employee_polices table update query : {data}', ['data' => $query]);
$this->myLogger->logme('error', 'employee_polices table updated - Affected Rows : {data}', ['data' => $affectedRows]);
// print_r($db->getLastQuery()); die;
// $affectedRows = 10;
//STEP:2 - Update emp_endorsement Table
//update truncated status and is_active 0 to the Emp_endorsement table
if(in_array($file['action'], ['addition', 'dependent_addition'])){
$this->empEndorsementModel->where('file_id', $file_id)
->set(['status' => 'truncated','is_active' => 0])
->update();
$this->myLogger->logme('error', 'emp_endorsement table updated');
}
//STEP:3 - Update files table
//update file status
$this->fileModel->where('id', $file_id)->set(['status' => 'truncated'])->update();
$this->myLogger->logme('error', 'files table updated');
}
else
{
// echo 'came here...1';
//check all dependents added by self and other dependent policies
$emp_codes = $this->employeeModel->select('emp_code')
->where('file_id', $file_id)
->findAll();
$emp_codes = array_column($emp_codes,'emp_code');
// Kint::dump($emp_codes);//die;
$dependent_policies = $this->clientPolicyModel->select('id')
->where('base_policy', $client_policy_id)
->findAll();
// $dependent_policies = [ [10],[25],[35] ];
// Kint::dump($dependent_policies);
// Kint::dump(array_column($dependent_policies,'id'));
if(count($dependent_policies))
{
$dependent_policies = array_column($dependent_policies,'id');
// Kint::dump($dependent_policies);
$second_level_dependent_policies = $this->clientPolicyModel->select('id')
->whereIn('base_policy', $dependent_policies)
->findAll();
// dd($second_level_dependent_policies);
if(count($second_level_dependent_policies))
{
$second_level_dependent_policies = array_column($second_level_dependent_policies,'id');
}
$dependent_policies = array_merge($dependent_policies,$second_level_dependent_policies);
}
$dependent_policies = array_merge($dependent_policies,[$client_policy_id]);
// Kint::dump($dependent_policies);
//update emp and emp plocies
$db = db_connect();
$emp_codes = '(' . implode(',', array_map(fn($code) => "'$code'", $emp_codes)) . ')';
$dependent_policies = '(' . implode(',', $dependent_policies) . ')';
$query = "
UPDATE employee_polices
JOIN employees ON employees.id = employee_polices.employee_id and employees.emp_code in $emp_codes
SET employee_polices.status = 'truncated', employee_polices.is_active = 0
WHERE employee_polices.client_policy_id in $dependent_policies
";
$db->query($query);
$affectedRows = $db->affectedRows();
// dd($affectedRows);
$affectedRows = $affectedRows * 2;
$this->fileModel->where('id', $file_id)->set(['status' => 'truncated'])->update();
}
//FINAL STEP - Update reverse entry in cash_deposite table
if($cd_tranction){
$cd_data = [
'amount' => $cd_tranction['amount'],
'amount' => $cd_amount,
'sub_type_id' => 8,
'endorsement_no' => null,
'insurer_id' =>$policy_data['insurer_id'],
@ -1284,12 +1387,17 @@ class EmployeeController extends AdminController
'client_id' => $client_id,
'client_policy_id' => $client_policy_id,
'cd_ac_no' => $policy_data['cd_ac_no'] ?? null,
'cd_ac_pk' => $policy_data['cd_ac_pk'] ?? null,
'event_name' => $file['action'],
];
$response = DepositHelper::saveDeposit($cd_data, $loggedInUserID);
$this->myLogger->logme('error', 'cash_deposite table updated -- cd transaction');
}
$this->myLogger->logme('error', 'SUCCESSFULLY TRUNCATED');
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => round($affectedRows / 2)], 200);
}
@ -1306,23 +1414,57 @@ class EmployeeController extends AdminController
// print_r($this->empEndorsementModel->getLastQuery());
// echo $res[0]->count;die();
if ($res[0]->count == 0 || $role_id == 5 || $role_id == 1) {
//update truncated status to db
$this->myLogger->logme('error', 'TRUNCATED STARTED WITH ADMIN OR HEAD PERMISSION');
$this->myLogger->logme('error', 'Event Type : -- {data} --', ['data' => $file['action']]);
$transaction_type = 'Credit';
$cd_amount = $cd_tranction['amount'];
if($file['action'] == 'deletion'){
$transaction_type = 'Debit';
//get cd amount for the particular file id to reverse entry to the cash deposite for only deletion
$cd_amount_total = $this->employeePolicyModel->getDeletionDataForTruncated($file['id']);
$totalSum = array_sum(array_column($cd_amount_total, 'total'));
$cd_amount = $totalSum;
$this->myLogger->logme('error', 'Deletion CD Amount : {data}', ['data' => $cd_amount]);
}
$this->myLogger->logme('error', 'Endorsemnt CD Amount : {data}', ['data' => $cd_amount]);
//STEP 1:
//update truncated status to the Emp_endorsement table
$this->empEndorsementModel->where('file_id', $file_id)
->set(['status' => 'truncated'])
->set(['status' => 'truncated','is_active' => 0])
->update();
//update file status
$this->myLogger->logme('error', 'emp_endorsement table updated');
//STEP 2:
if($file['action'] == 'deletion') {
//update the employee policy table reverse the data
$this->employeePolicyModel->updateEmployeePolicyTruncateReverse($file_id);
$this->myLogger->logme('error', 'employee_polices table updated for deletion');
}
if($file['action'] == 'correction'){
}
// STEP 3:
//update files table status to "truncated"
$this->fileModel->where('id', $file_id)->set(['status' => 'truncated'])->update();
$this->myLogger->logme('error', 'files table updated');
if($cd_tranction && $file['action'] != 'correction'){
$transaction_type = 'Credit';
if($file['action'] == 'deletion'){
$transaction_type = 'Debit';
}
$cd_data = [
'amount' => $cd_tranction['amount'],
'amount' => $cd_amount,
'sub_type_id' => 8,
'endorsement_no' => null,
'insurer_id' =>$policy_data['insurer_id'],
@ -1332,13 +1474,19 @@ class EmployeeController extends AdminController
'client_id' => $client_id,
'client_policy_id' => $client_policy_id,
'cd_ac_no' => $policy_data['cd_ac_no'] ?? null,
'cd_ac_pk' => $policy_data['cd_ac_pk'] ?? null,
'event_name' => $file['action'],
];
$response = DepositHelper::saveDeposit($cd_data, $loggedInUserID);
$this->myLogger->logme('error', 'cash_deposite table updated -- cd transaction');
}
$this->myLogger->logme('error', 'SUCCESSFULLY TRUNCATED');
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => 'success'], 200);
} else {
if(get_role_id() == 1 || get_role_id() == 5){
return $this->respond(['role' => get_role_id(), 'dataStatus' => false, 'code' => 404, 'message' => 'File data already processed. Do you want to truncate data from uploaded file?'], 200);
@ -1642,14 +1790,18 @@ class EmployeeController extends AdminController
$existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $client_id,client_branch_id: $branch_id);
//get familiy details in inception file format array from post method
$data = calculate_premium_new(family_data: $family_details,policy_terms:$policy_details,slab_details:$slab_details,fileArr: $file,existing_units: $existing_units);
// print_rr($data);die();
foreach($data as $key => $member )
{
// ~dd($member);
if(is_array($member))
if(is_array($member) && isset($member['policy_details']['date_coverage']) && isset($member['policy_details']['policy_end_date']) )
{
$data[$key]['policy_details']['no_of_days'] = $member['policy_details']['date_coverage'] ? (calculate_days_bw_dates($member['policy_details']['date_coverage'],$member['policy_details']['policy_end_date'])->days + 1) : '';
}
else
{
$data[$key]['policy_details']['no_of_days'] = '0';
}
}
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => ['new' => $data,'old' => $existing_famility_details], 200]);
@ -1762,7 +1914,7 @@ class EmployeeController extends AdminController
public function update_emp_data()
{
$data = $this->request->getPost();
// print_rr($data);
// print_rr($data);die();
// $data['dob'] = date('Y-m-d', strtotime($data['dob']));
$data['dob'] = change_date_format($data['dob'], 'd/m/Y', 'Y-m-d');
// print_rr($data); die;
@ -2021,4 +2173,163 @@ class EmployeeController extends AdminController
exit;
}
public function test_members_list(){
// $model = new EmployeeModel();
// $list = [
// ['relationship' => 'spouse','emp_code' => 'TEST002', 'name' => 'Lakshmi','email_personal' => 'lakshmi@gmail.com','mobile'=>'6382156701','gender'=>'female','dob'=>'1996-05-19','doj'=>'2022-02-01','basic_pay'=>'100000','emp_status'=>'enrolled'],
// ['relationship' => 'Daughter','emp_code' => 'TEST002', 'name' => 'Jayalakshmi','email_personal' => 'jayalakshmi@gmail.com','mobile'=>'6382156701','gender'=>'female','dob'=>'2018-05-19','doj'=>'2022-02-01','basic_pay'=>'100000','emp_status'=>'enrolled'],
// ['relationship' => 'Son','emp_code' => 'TEST002', 'name' => 'Jayam Ravi','email_personal' => 'jayamravi@gmail.com','mobile'=>'6382156701','gender'=>'male','dob'=>'1994-05-19','doj'=>'2019-02-01','basic_pay'=>'100000','emp_status'=>'enrolled'],
// // ['relationship' => 'self','emp_code' => 'TEST003', 'name' => 'Ravi Shankar','email_personal' => 'srinivassaravanan2002@gmail.com','email_corporate'=>'srinivas.saravanan@venbainfotech.com','mobile'=>'6382156701','gender'=>'male','dob'=>'1994-05-19','doj'=>'2022-02-01','basic_pay'=>'100000','emp_status'=>'enrolled']
// ['relationship' => 'spouse','emp_code' => 'TEST001', 'name' => 'Lakshmi','email_personal' => 'lakshmi@gmail.com','mobile'=>'6382156701','gender'=>'female','dob'=>'1996-05-19','doj'=>'2022-02-01','basic_pay'=>'100000','emp_status'=>'enrolled'],
// ];
// foreach($list as $listitem){
// $model->insert($listitem);
// }
// die();
$employee_data = $this->employeeModel->getTestEmployeeData();
$data['employees'] = $employee_data;
$data['clients'] = $this->clientModel->findAll();
// dd($data);
return $this->loadLayout('test_members_list',$data);
}
public function mapEmployees(){
$client_id = $this->request->getPost('client_id');
$branch_id = $this->request->getPost('branch_id');
$policy_id = $this->request->getPost('client_policy_id');
$selected_employees = (array)$this->request->getPost('selected');
$si_amt = $this->request->getPost('si_amt');
$policy_start_date_unformatted = $this->request->getPost('policy_start_date');
$policy_start_date = change_date_format($policy_start_date_unformatted, 'd/M/Y', 'Y-m-d');
$data1 = [
'client_id' => $client_id,
'client_branch_id' => $branch_id,
];
$data2 = [
'client_policy_id' => $policy_id,
'status' => 'draft',
'date_coverage' => $policy_start_date,
'basic_cover_si' => $si_amt,
];
for($i = 0; $i < count($selected_employees); $i++){
$data2['employee_id'] = $selected_employees[$i];
$result1 = $this->employeeModel->set($data1)->where('id',$selected_employees[$i])->update();
$result2 = $this->employeePolicyModel->insert($data2);
}
if ($result1 && $result2) {
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Employees mapped successfully'], 200);
} else {
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to map employees.'], 404);
}
}
public function getDataForMapping(){
$policy_id = $this->request->getPost('policy_id');log_message('error',$policy_id);
$data['policy_start_date'] = $this->clientPolicyModel->select('policy_start_date')->where('id',$policy_id)->first()['policy_start_date'];
$data['si_amt'] = $this->PolicyPremium2Model->select('si')->where('client_policy_id', $policy_id)->groupBy('si')->findAll();
log_message('error',json_encode($data).'policy id '.$policy_id);
return $this->respond(['status' => true, 'code' => 200, 'data' => $data], 200);
}
public function unmapEmployees($actionType){
$selected_employees = (array)$this->request->getPost('selected');
if($actionType == 0){
for($i = 0;$i<count($selected_employees);$i++){log_message('error',$selected_employees[$i]);
$result1 = $this->employeeModel->set(['client_id' => null, 'client_branch_id' => null])->where('id',$selected_employees[$i])->update();log_message('error',$result1);
$result2 = $this->employeePolicyModel->where('employee_id',$selected_employees[$i])->delete();log_message('error',$result2);
}
}
else if ($actionType == 1){
for($i = 0;$i<count($selected_employees);$i++){
log_message('error','Emp id is '.$selected_employees[$i]);
$result1 = $this->employeeModel->set(['client_id' => null, 'client_branch_id' => null])->where('id',$selected_employees[$i])->update();log_message('error','result 1 is '.$result1);
$result2 = $this->employeePolicyModel->where('employee_id',$selected_employees[$i])->delete();log_message('error', 'result 2 is '.$result2);
$emp_code = $this->employeeModel->select('emp_code')->where('id',$selected_employees[$i])->first()['emp_code'];log_message('error','emp_code is '.$emp_code);
$result3 = $this->employeeModel->where('emp_code',$emp_code)->whereNotIn('relationship',['self'])->delete();log_message('error','result 3 is '.$result3);
}
}
else{
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Invalid action type.'], 404);
}
if($actionType == 1){
if($result1 && $result2 && $result3){
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Employees unmapped successfully and Dependencies are Deleted'], 200);
}
else{
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to unmap employees.'], 404);
}
}else{
if($result1 && $result2 ){
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Employees unmapped successfully'], 200);
}
else{
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to unmap employees.'], 404);
}
}
}
public function cloneWorksheet()
{
// Define file paths
$inputFilePath = 'C:\Users\Venba\Downloads/merge1.xlsx'; // Path to the existing file
$outputFilePath = WRITEPATH . '/tmp/cloned_file.xlsx'; // Path to save the new file
try {
// Load the existing spreadsheet
$spreadsheet = IOFactory::load($inputFilePath);
// Get the first worksheet (or specify the index of the sheet to clone)
$originalWorksheet = $spreadsheet->getSheet(0);
// Clone the worksheet
$clonedWorksheet = clone $originalWorksheet;
// Generate a unique name for the cloned worksheet
$baseName = "Cloned Sheet";
$sheetIndex = 1;
$uniqueName = $baseName;
// Check for duplicate names and generate a unique one
while ($spreadsheet->sheetNameExists($uniqueName)) {
$uniqueName = $baseName . " " . $sheetIndex;
$sheetIndex++;
}
// Set the unique name for the cloned worksheet
$clonedWorksheet->setTitle($uniqueName);
// Add the cloned worksheet to the spreadsheet
$spreadsheet->addSheet($clonedWorksheet);
// Modify the cloned sheet (optional)
$clonedWorksheet->setCellValue('A1', 'Hello, Cloned Sheet!');
// Save the modified spreadsheet to a new file
$writer = new Xlsx($spreadsheet);
$writer->save($outputFilePath);
return $this->response->setJSON([
'status' => 'success',
'message' => 'Spreadsheet with cloned sheet created successfully!',
'file_path' => $outputFilePath,
]);
} catch (\Exception $e) {
// Handle exceptions
return $this->response->setJSON([
'status' => 'error',
'message' => $e->getMessage(),
]);
}
}
}

View File

@ -745,6 +745,7 @@ class EmployeeRestController extends AdminController
//make an entry in DB
$file_id = $this->fileModel->insert(['file_name' => $filename, 'client_id' => $client_id, 'policy_id' => $policy_id, 'created_by' => $employee_id, 'status' => 'inprogress', 'action' => 'enrollment', 'client_branch_id' => $client_branch_id]); //here field policy_id have client_policy_id and not policy id from policy master
$this->myLogger->logme("error", '{file_id} - client uploaded success', ['file_id' => $file_id]);
$empServiceController = new EmployeeServiceController();
@ -965,6 +966,7 @@ class EmployeeRestController extends AdminController
}
}
}
$employee_policy = $this->employeePolicyModel->checkExistingEmpPolicy(['employee_id' => $emp_id,'client_policy_id' => $policy_id]);
$emp_policy_data =[
'employee_id'=>$emp_id,
@ -972,10 +974,10 @@ class EmployeeRestController extends AdminController
'status'=> 'draft',
'date_coverage' => $date_coverage,
'payable_employee' => check_pay_by_employee_or_company($client_policy['policy_terms'], $dataToInsert[$a]['relationship']),
'basic_cover_si'=>isset($basic_cover_si[$a]) ? $basic_cover_si[$a] : null
'basic_cover_si'=>isset($basic_cover_si[$a]) ? $basic_cover_si[$a] : null,
'file_id' => isset($employee_policy['file_id']) && $employee_policy['file_id'] != '' ? $employee_policy['file_id'] : $file_id,
];
$employee_policy = $this->employeePolicyModel->checkExistingEmpPolicy(['employee_id' => $emp_id,'client_policy_id' => $policy_id]);
// print_r($employee_policy); die;
if ($employee_policy) {
foreach ($employee_policy as $existing_policy) {

View File

@ -132,7 +132,7 @@ class EmployeeServiceController extends AdminController
'format' => 'd-M-Y',
'allowed_values' => null,
'custom' => 'check_dob_diff',
'params' => ['row', 'relationship', 'default_age_ratio']
'params' => ['row', 'relationship', 'default_age_ratio','policy_details']
],
'gender' => [
'col_idx' => 4,
@ -344,6 +344,15 @@ class EmployeeServiceController extends AdminController
'data_type' => 'str',
'format' => null,
'allowed_values' => null
],
'claim_status' => [
'col_idx' => 6,
'col_cell_name' => 'G',
'col_name' => 'Claim status',
'is_mandatory' => ['D'],
'data_type' => 'str',
'format' => null,
'allowed_values' => [0,1]
]
];
@ -767,10 +776,9 @@ class EmployeeServiceController extends AdminController
$relationship = $this->general_relationships;
//get exisiting mobilr nos
$existing_mobilenos = $this->employeePolicyModel->getExisitingMobileNos(client_policy_id: $file['policy_id']);
//get existing units in the current branch
$existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'],client_branch_id: $file['client_branch_id']);
// dd($existing_units);
// dd($excel_data);
foreach ($excel_data as $row_key => $row)
{
//define row wise action/event in temporary variable
@ -1234,7 +1242,6 @@ class EmployeeServiceController extends AdminController
// Kint::dump($family);die();
$data = calculate_premium_new(family_data:$family,policy_terms: $policy_terms,slab_details : $slab_details,fileArr: $file, existing_units:$existing_units);
// dd($data);
$employee_data_group_by_family[$emp_id] = $data;
$this->employeesOnboardProcess(['familiy_data' => $data,'file' => $file]);
}
@ -1328,7 +1335,7 @@ class EmployeeServiceController extends AdminController
// }
// dd($row[4]);
//for emp table
$this->empEndorsementModel->save(['pk' => (int)$data['emp_id'],'emp_code' => $data['emp_code'],'table_name' => 'employees','actions' => 'd','name' => $data['name'],'field_name' => 'emp_status','old_value' => $data['emp_status'],'new_value' => 'deactivate','created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']);
// $this->empEndorsementModel->save(['pk' => (int)$data['emp_id'],'emp_code' => $data['emp_code'],'table_name' => 'employees','actions' => 'd','name' => $data['name'],'field_name' => 'emp_status','old_value' => $data['emp_status'],'new_value' => 'deactivate','created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']);
// dd( $this->empEndorsementModel->getLastQuery());
// $this->empEndorsementModel->save(['pk' => (int)$data['emp_id'],'emp_code' => $data['emp_code'],'table_name' => 'employees','actions' => 'd','name' => $data['name'],'field_name' => 'change_event','old_value' => $data['change_event'],'new_value' => 'deletion','created_by' => $file['created_by'],'remarks' => 'general deletion']);
@ -1336,6 +1343,7 @@ class EmployeeServiceController extends AdminController
$this->empEndorsementModel->save(['pk' => (int)$data['emp_policy_id'],'emp_code' => $data['emp_code'],'table_name' => 'employee_polices','actions' => 'd','name' => $data['name'],'field_name' => 'date_of_exit','old_value' => $data['date_of_exit'],'new_value' => $row[4],'created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']);
$this->empEndorsementModel->save(['pk' => (int)$data['emp_policy_id'],'emp_code' => $data['emp_code'],'table_name' => 'employee_polices','actions' => 'd','name' => $data['name'],'field_name' => 'reason_for_exit','old_value' => $data['reason_for_exit'],'new_value' => $row[5],'created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']);
$this->empEndorsementModel->save(['pk' => (int)$data['emp_policy_id'],'emp_code' => $data['emp_code'],'table_name' => 'employee_polices','actions' => 'd','name' => $data['name'],'field_name' => 'status','old_value' => $data['status'],'new_value' => 'inactive','created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']);
$this->empEndorsementModel->save(['pk' => (int)$data['emp_policy_id'],'emp_code' => $data['emp_code'],'table_name' => 'employee_polices','actions' => 'd','name' => $data['name'],'field_name' => 'claim_status','old_value' => $data['claim_status'],'new_value' => $row[6],'created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']);
};
//iterate each row
foreach ($excel_data as $col_key => $row)
@ -1370,7 +1378,7 @@ class EmployeeServiceController extends AdminController
if(!in_array($employee['id'],$endorsement_data))//make entry in endorsement firsttime only with checking that PK of emp exisintg in variable $endorsement_data
{
$employee_policy = $this->employeePolicyModel->where('employee_id',$employee['id'])->where('client_policy_id',$file['policy_id'])->first();
$data = ['emp_id' => $employee['id'],'name' => $employee['name'],'emp_status' => $employee['emp_status'],'emp_policy_id' => $employee_policy['id'],'emp_code' => $employee['emp_code'],'change_event' => $employee['change_event'],'date_of_exit' => $employee_policy['date_of_exit'],'reason_for_exit' => $employee_policy['reason_for_exit'],'status' => $employee_policy['status']];
$data = ['emp_id' => $employee['id'],'name' => $employee['name'],'emp_status' => $employee['emp_status'],'emp_policy_id' => $employee_policy['id'],'emp_code' => $employee['emp_code'],'change_event' => $employee['change_event'],'date_of_exit' => $employee_policy['date_of_exit'],'reason_for_exit' => $employee_policy['reason_for_exit'],'status' => $employee_policy['status'],'claim_status' => $employee_policy['claim_status']];
$endorsement($data,$file,$row);
$endorsement_data[] = $employee['id'];
}
@ -1461,6 +1469,8 @@ class EmployeeServiceController extends AdminController
->where('emp_code',$employee['emp_code'])
->where('name',$employee['name'])
->where('field_name',$field_name)
->where('is_active',1)
->where('status !=','truncated')
->findAll();
// dd($existing_endorsements);
//make entry in endorsement table
@ -1611,7 +1621,7 @@ class EmployeeServiceController extends AdminController
// echo '---------------------------------------';
//start implemet of si enhancement of grid type 10,11
if(count($employee) && $file['action'] == 'dependent_addition' && $temp['source'] == 'db' && in_array($value['temp']['grid_id'],[10,11]) && ( ($value['temp']['premium_type'] == 1 && (strtolower($value['relationship']) == 'self' || $temp['acting_self'])) || ($value['temp']['premium_type'] == 2 || $value['temp']['premium_type'] == null)))
if(count($employee) && $file['action'] == 'dependent_addition' && $temp['source'] == 'db' && in_array($temp['grid_id'],[10,11]) && ( ($temp['premium_type'] == 1 && (strtolower($value['relationship']) == 'self' || $temp['acting_self'])) || ($temp['premium_type'] == 2 || $temp['premium_type'] == null)))
{
$log_message = 'Employee record from DB,Checking SI for - '.$employee[0]['name'].'('.$employee[0]['emp_code'].')';
$this->myLogger->logme('error',$log_message);
@ -1620,7 +1630,6 @@ class EmployeeServiceController extends AdminController
break;//skip db employee
}
//end implemet of si enhancement of grid type
//save employee table
$value['relationship'] = ucfirst(trim($value['relationship']));
if(count($employee))
@ -1629,6 +1638,7 @@ class EmployeeServiceController extends AdminController
$value['id'] = $employee[0]['id'];
$value['emp_status'] = 'active';
$value['client_branch_id'] = $file['client_branch_id'];
$value['file_id'] = isset($employee[0]['file_id']) && $employee[0]['file_id'] != '' ? $employee[0]['file_id'] : $file['id'] ;
$log_message = 'Update Employee - '.$employee[0]['name'].'('.$employee[0]['emp_code'].') with PK '.$employee[0]['id'];
// $this->myLogger->logme('error',('Update - ' . $employee[0]['id'].' - '. $employee[0]['emp_code'] .' - '.$employee[0]['name']));
// echo 'insert emp';
@ -1639,11 +1649,11 @@ class EmployeeServiceController extends AdminController
$value['created_by'] = $file['created_by'];
$value['client_branch_id'] = $file['client_branch_id'];
$value['family_floater_key'] = generate_family_floater_key($value['relationship']);
$value['file_id'] = isset($employee[0]['file_id']) && $employee[0]['file_id'] != '' ? $employee[0]['file_id'] : $file['id'] ;
$log_message = 'Insert Employee- '.$value['name'] .'('.$value['emp_code'] .') with PK ';
// $this->myLogger->logme('error',('Insert - ' . $value['emp_code'] .' - '. $value['name']));
// echo 'update emp';
}
$this->employeeModel->save($value);
if (isset($value['id'])) {
$emp_id = $value['id'];
@ -1667,7 +1677,7 @@ class EmployeeServiceController extends AdminController
$policy_data['id'] = $employee_policy[0]['id'];
$policy_data['status'] = 'active';
$policy_data['payable_employee'] = check_pay_by_employee_or_company($policy_details['policy_terms'], $value['relationship']);
$policy_data['file_id'] = isset($employee_policy[0]['file_id']) && $employee_policy[0]['file_id'] != '' ? $employee_policy[0]['file_id'] : $file['id'] ;
$log_message = 'Update Employee Policy for '. $value['name'].'('. $value['emp_code'].') with PK- ' . $employee_policy[0]['id'] .' client policy ID '.$employee_policy[0]['client_policy_id'].' with SI '.$policy_data['basic_cover_si'];
// echo 'insert policy';
}
@ -1678,12 +1688,14 @@ class EmployeeServiceController extends AdminController
$policy_data['created_by'] = $file['created_by'];
$policy_data['status'] = 'active';
$policy_data['payable_employee'] = check_pay_by_employee_or_company($policy_details['policy_terms'], $value['relationship']);
$policy_data['file_id'] = $file['id'];
$log_message = 'Insert Employee Policy for '. $value['name'].'('. $value['emp_code'].') - client policy id -'. $file['policy_id'].' - with SI '.$policy_data['basic_cover_si'];
// echo 'update policy';
}
$this->employeePolicyModel->save($policy_data);
// log_message('error',json_encode($policy_data));
// dd($this->employeePolicyModel->save($policy_data));
$res = $this->employeePolicyModel->save($policy_data);
// if($res){log_message('error','ths the resul'.$res);}
if(isset($policy_data['id']))
{
$emp_policy_id = $policy_data['id'];
@ -1702,7 +1714,7 @@ class EmployeeServiceController extends AdminController
$log_message = $file['action'].' - endorsement'. $value['emp_code'].' - '.$value['name'].' - with policy id'.$emp_policy_id;
$this->myLogger->logme('error',$log_message);
$actions = ($file['action'] == 'dependent_addition' ? 'da' : ($file['action'] == 'addition' ? 'a' : 'a'));
$addition_endorse_data = ['pk' => $emp_policy_id,'group_key' => rand(100000, 999999),'emp_code' => $value['emp_code'],'table_name' => 'employee_polices','actions' => $actions,'name' => $value['name'],'field_name' => 'basic_cover_si','old_value' => NULL,'new_value' => $policy_data['basic_cover_si'],'remarks' => 'addition endorsement','file_id' => $file['id'],'created_by' => $file['created_by']];
$addition_endorse_data = ['pk' => $emp_policy_id,'group_key' => rand(100000, 999999),'emp_code' => $value['emp_code'],'table_name' => 'employee_polices','actions' => $actions,'name' => $value['name'],'field_name' => 'basic_cover_si','old_value' => NULL,'new_value' => $policy_data['basic_cover_si'],'remarks' => 'addition endorsement','file_id' => $file['id'],'created_by' => $file['created_by'],'status' => 'pending'];
$this->employeeEndorsementforAddtionAndDependentAddition($addition_endorse_data);
}
@ -2012,10 +2024,10 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
$value['emp_code'] = $row[1];
$value['name'] = $row[2];
$value['doj'] = (!empty($row[3]) ? convert_string_to_date($row[3],'Y-m-d'): null);
$value['doj'] = (!empty($row[3]) ? change_date_format($row[3],'d-M-Y','Y-m-d') : null );
$value['gender'] = $row[4];
$value['relationship'] = ucfirst(trim($row[5]));
$value['dob'] = convert_string_to_date($row[6],'Y-m-d');
$value['dob'] = change_date_format($row[6],'d-M-Y','Y-m-d');
$value['email_corporate'] = $row[7];
$value['mobile'] = $row[8];
$value['band'] = $row[10];
@ -2042,7 +2054,7 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
$value['family_floater_key'] = $relation;
$policy_data['basic_cover_si'] = $row[9];
$policy_data['date_coverage'] = $row[13] != "" && $row[13] != null ? change_date_format($row[13],null,'Y-m-d') : null;
$policy_data['date_coverage'] = $row[13] != "" && $row[13] != null ? change_date_format($row[13],'d-M-Y','Y-m-d') : null;
$policy_data['client_policy_id'] = $file['policy_id'];
$employee = $this->employeeModel->checkExistingEmployee($value,$file['client_branch_id']);
@ -2085,7 +2097,7 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
$policy_data['id'] = $employee_policy[0]['id'];
$policy_data['status'] = 'draft';
$policy_data['payable_employee'] = check_pay_by_employee_or_company($policy_details['policy_terms'], $value['relationship']);
$policy_data['file_id'] = isset($employee_policy[0]['file_id']) && $employee_policy[0]['file_id'] != '' ? $employee_policy[0]['file_id'] : $file_id ;
$log_message = 'Update Employee Policy for '. $value['name'].'('. $value['emp_code'].') with PK- ' . $employee_policy[0]['id'] .' client policy ID '.$employee_policy[0]['client_policy_id'].' with SI '.$policy_data['basic_cover_si'];
// echo 'insert policy';
}
@ -2096,11 +2108,13 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
$policy_data['created_by'] = $file['created_by'];
$policy_data['status'] = 'draft';
$policy_data['payable_employee'] = check_pay_by_employee_or_company($policy_details['policy_terms'], $value['relationship']);
$policy_data['file_id'] = $file_id;
$log_message = 'Insert Employee Policy for '. $value['name'].'('. $value['emp_code'].') - client policy id -'. $file['policy_id'].' - with SI '.$policy_data['basic_cover_si'];
// echo 'update policy';
}
log_message('error',json_encode($policy_data));
// dd($policy_data);
$this->employeePolicyModel->save($policy_data);
$emp_policy_id = $this->employeePolicyModel->getInsertID();
$this->myLogger->logme('error',$log_message);

View File

@ -126,6 +126,10 @@ class JobWorker extends AdminController
'employeesEnrollmentInsert' => [
'type' => 'CC', // Handler Category
'handler' => 'App\Controllers\EmployeeServiceController',
],
'calculateMembersDemography' => [
'type' => 'CC', // Handler Category
'handler' => 'App\Controllers\LeadsController',
]
];

File diff suppressed because it is too large Load Diff

View File

@ -1224,7 +1224,7 @@ class MasterController extends AdminController
$data = $this->request->getPost();
$date = (string) $this->request->getPost('opening_date');
$data['opening_date'] = date('Y-m-d', strtotime($date));
// print_rr($data);die();
// Prepare the array with data
$cd_tranction_data = [
'amount' => $data['opening_bal'],
@ -1247,7 +1247,7 @@ class MasterController extends AdminController
$insert = $this->CDMasterModel->insert($data);
if ($insert) {
$cd_tranction_data['cd_ac_pk'] = $this->CDMasterModel->insertID();
$response = DepositHelper::saveDeposit($cd_tranction_data, $loggedInUserID);
session()->setFlashdata('success', "Cash Deposite Master Added Successfully");
@ -1313,12 +1313,31 @@ class MasterController extends AdminController
->where('id', $id)
->where('is_active', 1)
->first();
$db = db_connect();
$builder = $db->table('cd_master');
$builder->select('cd_master.cd_ac_no, cd_master.id, COUNT(cash_deposit.cd_ac_no) AS cd_ac_no_count_cd_tranction');
$builder->join('cash_deposit', 'cash_deposit.cd_ac_pk = cd_master.id');
$builder->where('cash_deposit.is_active', 1);
$builder->where('cd_master.is_active', 1);
$builder->where('cd_master.id', $id);
$builder->groupBy('cd_master.id');
// convert the date formate 2000-01-01 to 01-01-2000
$query = $builder->get();
$result = $query->getResultArray();
// print_r($result); die;
$count = 0;
if(isset($result[0])){
$count = $result[0]['cd_ac_no_count_cd_tranction'];
}
// convert the date formate 2000-01-01 to 01-01-2000
$cd_data['opening_date'] = date('d-m-Y', strtotime($cd_data['opening_date']));
if ($cd_data) {
return $this->respond(['status' => true, 'code' => 200, 'data' => $cd_data], 200);
return $this->respond(['status' => true, 'code' => 200, 'data' => $cd_data, 'cd_transaction_count' => $count], 200);
} else {
return $this->respond(['status' => false, 'code' => 404], 200);
}
@ -1502,25 +1521,34 @@ class MasterController extends AdminController
}
public function duplicateTemplate($template_id, $event_name)
// Duplicate the insuer same policy type other events template
public function duplicateTemplate($template_id, $event_name, $insurer_id)
{
// Fetch the template data based on the provided ID and ensure it is active
$insurer_template_data = $this->insurerTemplateModel->where('id', $template_id)
->where('is_active', 1)
->first();
->where('is_active', 1)
->first();
// Check if the event name matches the existing template's event name
$insurer_template_data_check_duplicate = $this->insurerTemplateModel
->where('insurer_id', $insurer_id)
->where('event_name', $event_name)
->where('policy_type_id', $insurer_template_data['policy_type_id'])
->where('is_active', 1)
->findAll();
//if the template already exist than return the message
if (!empty($insurer_template_data_check_duplicate) && count($insurer_template_data_check_duplicate) > 0) {
return $this->respond([
'status' => false,
'message' => 'Template with the same event already exists.',
'data' => $insurer_template_data_check_duplicate
]);
}
if ($insurer_template_data) {
// Check if the event name matches the existing template's event name
if ($insurer_template_data['event_name'] == $event_name) {
return $this->respond([
'status' => false,
'message' => 'Template with the same event already exists.',
'data' => $insurer_template_data
]);
}
// Prepare data for insertion as a duplicate
$data_to_insert = [
"insurer_id" => $insurer_template_data['insurer_id'],
@ -1531,28 +1559,28 @@ class MasterController extends AdminController
"created_by" => get_session_user(),
"is_active" => 1,
];
// Insert the duplicate template data
$insert_result = $this->insurerTemplateModel->insert($data_to_insert);
if ($insert_result) {
return $this->respond([
'status' => true,
'message' => 'Template duplicated successfully.',
'status' => true,
'message' => 'Template duplicated successfully.',
'data' => $insurer_template_data
]);
} else {
return $this->respond([
'status' => false,
'message' => 'Failed to duplicate template.',
'status' => false,
'message' => 'Failed to duplicate template.',
'data' => $insurer_template_data
]);
}
} else {
// No matching active template found
return $this->respond([
'status' => false,
'message' => 'No active template data found.',
'status' => false,
'message' => 'No active template data found.',
'data' => null
]);
}
@ -1632,7 +1660,35 @@ class MasterController extends AdminController
print_r($res);
}
public function testZeptoSMTP() {
$message = '<style>body{font-family:Arial,sans-serif;color:#333;line-height:1.6;margin:0;padding:0}.email-container{width:100%;max-width:600px;margin:0 auto;padding:20px;border:1px solid #e0e0e0;background-color:#f9f9f9}.header{background-color:#4a90e2;color:#fff;padding:15px;text-align:center}.header h1{margin:0;font-size:24px}.content{padding:20px;background-color:#fff}.content h2{color:#4a90e2;font-size:20px;margin-top:0}.content p{margin:10px 0}.details-table{width:100%;border-collapse:collapse;margin-top:20px}.details-table td,.details-table th{border:1px solid #ddd;padding:10px;text-align:left}.details-table th{background-color:#f2f2f2}.footer{margin-top:20px;font-size:12px;color:#777;text-align:center}.attachment-note{margin-top:20px;padding:10px;background-color:#f7f7f7;border-left:4px solid #4a90e2;font-style:italic}</style><div class=email-container><div class=header><h1>Request for Quotation (RFQ)</h1></div><div class=content><h2>Dear {{RECIPIENT_NAME}},</h2><p>We are reaching out to request a quotation for the following insurance coverage. Please review the details below and provide your quote at your earliest convenience.<h2>RFQ Details</h2><table class=details-table><tr><th>Client name<td>{{CLIENT_NAME}}<tr><th>Coverage Type<td>{{POLICY_LONG_NAME}}<tr><th>Policy Start Date<td>{{POLICY_START_DATE}}<tr><th>Policy Duration<td>{{DURATION}}</table><div class=attachment-note>Please note: Additional terms and details are included in the attachment for your reference.</div><p>Please feel free to reach out if you require any further information to prepare the quote. We look forward to receiving your proposal.<p>Best regards,<p><strong>Nhance India Pvt Ltd</strong><br></div><div class=footer><p>© Nhance India Pvt Ltd. All rights reserved.</div></div>';
$attachments = [
["filePath" => ROOTPATH."public/sample_excel/sample_addition.xls","fileName" => "sample_addition.xls"],
["filePath" => ROOTPATH."public/sample_excel/sample_inception.xls","fileName" => "sample_inception.xls"],
["filePath" => ROOTPATH."public/assets/images/login_bg.jpg","fileName" => "login_bg.jpg"]
];
$email_id = 'srinivas.saravanan@venbainfotech.com';
$common = ['mail_type'=>'test_mail_cli'];
// Send email and get response
$result = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => $message,'attachments' => $attachments,'common'=>$common]);
log_message('error',json_encode($result));
// Format the response for display/debugging
$response = [
'success' => $result['success'] ?? false,
'smtp_data' => [
'last_reply' => $result['smtp_data']['last_reply'] ?? '',
'error_info' => $result['smtp_data']['error_info'] ?? ''
],
'message_id' => $result['message_id'] ?? '',
'timestamp' => $result['timestamp'] ?? ''
];
// Return JSON response
return $this->response->setJSON($result);
}
public function testCheckBounceMails()
{
$gmailapi = \Config\Services::gmailapi();
@ -1674,6 +1730,7 @@ class MasterController extends AdminController
'template_bg' => ROOTPATH . 'public/uploads/template_bg/',
'attachments' => WRITEPATH . 'uploads/attachments/',
'sample_import_excel' => ROOTPATH . 'public/sample_import_excel',
'lead_files' => WRITEPATH . 'uploads/lead_files/',
];
foreach ($folders as $folderName => $folderPath) {

View File

@ -31,6 +31,7 @@ use App\Models\InsurerStatements;
use App\Models\InvPaymentDetailsModel;
use App\Models\BatchFileModel;
use App\Models\FileModel;
use App\Models\COShareStmtDetailsModel;
use Kint;
class PolicyTransactionController extends BaseController
@ -62,6 +63,7 @@ class PolicyTransactionController extends BaseController
protected $invPaymentDetailsModel;
protected $batchFileModel;
protected $filesModel;
protected $coShareStmtDetailsModel;
public function __construct()
{
@ -91,11 +93,12 @@ class PolicyTransactionController extends BaseController
$this->invPaymentDetailsModel = new InvPaymentDetailsModel();
$this->batchFileModel = new BatchFileModel();
$this->filesModel = new FileModel();
$this->coShareStmtDetailsModel = new COShareStmtDetailsModel();
$this->invoiceStatus = [
'pending' => 'Pending',
'generated' => 'Generated',
'sent' => 'Sent',
'payment_received' => 'Payment Received',
'payment_received' => 'Payment<br> Received',
];
}
@ -179,6 +182,7 @@ class PolicyTransactionController extends BaseController
// Fetch additional data
$data['client'] = $this->clientModel->where('is_active', 1)->findAll();
$data['client_branch'] = $this->clientBranchModel->where('is_active', 1)->findAll();
$data['policy_type'] = $this->policyTypeModel->where('is_active', 1)->findAll();
$data['insurer'] = $this->insurerModel->where('is_active', 1)->findAll();
$data['entity'] = $this->kycEntityTypeModel->where('is_active', 1)->findAll();
@ -221,6 +225,7 @@ class PolicyTransactionController extends BaseController
// print_r($this->request->getPost()); die;
$id = $this->request->getPost('id');
$data = $this->preparePolicyData();
$data['cd_ac_pk'] = $this->request->getPost('cd_ac_no');
// print_r($this->request->getPost()); die;
@ -430,7 +435,7 @@ class PolicyTransactionController extends BaseController
if(isset($data['follow_insurer_id'])){
foreach ($data['follow_insurer_id'] as $index => $insurer) {
// Separate the insurer and insurer branch
list($insurer_branch_id, $insurer_id) = explode('-', $insurer);
@ -473,6 +478,7 @@ class PolicyTransactionController extends BaseController
'created_by' => get_session_userid() ?? null,
'updated_by' => get_session_userid() ?? null,
'id' => $data['co_share_id'][$index] ?? null, // Assuming this is the ID to identify existing records
'follower_policy_no' => $data['follower_policy_no'][$index] ?? null, // Assuming this is the ID to identify existing records
];
}
@ -529,7 +535,7 @@ class PolicyTransactionController extends BaseController
'created_by' => get_session_userid(),
'policy_no' => $data['policy_no'] ?? null,
'client_branch_id' => $data['client_branch_id'] ?? 0,
'cd_ac_no' => $data['cd_ac_no'] ?? null,
'cd_ac_pk' => $data['cd_ac_no'] ?? null,
'gst' => 18,
];
}
@ -786,10 +792,24 @@ class PolicyTransactionController extends BaseController
->findAll();
$data['pt_co_share_details'] = $this->PTCOShareDetailsModel
->where('pt_id', $id)
->where('is_active', 1)
->orderBy('id', 'asc')
->findAll();
->select("
pt_co_share_details.*,
(
SELECT
COUNT(*)
FROM
co_share_stmt_details
WHERE
co_share_stmt_details.co_share_id = pt_co_share_details.id
AND co_share_stmt_details.is_active = 1
) AS record_count
")
->where('pt_id', $id)
->where('is_active', 1)
->orderBy('id', 'asc')
->findAll();
$data['emp_data'] = $this->employeeModel
->select('employees.*, employee_polices.id as emp_policy_id')
->join('employee_polices', 'employees.id = employee_polices.employee_id', 'left')
@ -1329,8 +1349,8 @@ class PolicyTransactionController extends BaseController
//---------------------------------------------------------------------------------------------------
//get BDS Reports data
public function reportBDS()
//get BDS Reports data old function
public function reportBDSOld()
{
$data['page_name'] = 'BDS Report';
@ -1390,6 +1410,81 @@ class PolicyTransactionController extends BaseController
$this->loadLayout('report_bds_filter', $data);
}
//get BDS Reports data New Function
public function reportBDS()
{
$data['page_name'] = 'BDS Report';
$data['issuer'] = [1 => 'JIBS', 2 => 'Nhance'];
$data['client_type'] = [1 => 'Group', 2 => 'Individual'];
$data['issuing_type'] = [1 => 'Fresh', 2 => 'Renewal', 3 => 'Roll Over'];
$data['policy_status'] = [
'pending' => 'Pending',
'exported_to_insurer' => 'Exported to Insurer',
'imported_from_insurer' => 'Imported from Insurer',
'exported_to_tpa' => 'Exported to TPA',
'imported_from_tpa' => 'Imported from TPA',
'completed' => 'Completed'
];
$data['invoice_status_array'] = [
'yet_to_generate' => 'Yet to Generate',
'generated' => 'Generated',
'send' => 'Send',
'recived' => 'Recived',
];
$data['date_type'] = [
'policy_issue_date' => 'Policy Issue Date',
'policy_start_date' => 'Policy Start Date',
'policy_end_date' => 'Policy End Date',
'data_received_date' => 'Data Received Date',
'closure_date' => 'Closure Date',
'statement_month' => 'Statement Month',
];
$data['insurer'] = $this->insurerModel->where('is_active', 1)->findAll();
$data['policy_types'] = $this->policyTypeModel->where('is_active', 1)->findAll();
$data['clients'] = $this->clientModel->where('is_active', 1)->findAll();
//filter datas
$start_date = $this->request->getGet('start_date');
$end_date = $this->request->getGet('end_date');
$client_id = $this->request->getGet('client_id');
$insurer_id = $this->request->getGet('insurer_id');
$policy_type_id = $this->request->getGet('policy_type_id');
$date_type = $this->request->getGet('date_type');
$issuer = $this->request->getGet('issuer');
$client_branch_id = $this->request->getGet('client_branch_id');
$insurer_branch_id = $this->request->getGet('insurer_branch_id');
$client_policy_id = $this->request->getGet('client_policy_id');
if($date_type == 'statement_month'){
$start_date = (string)date('Y-m-01', strtotime($start_date));
$end_date = (string)date('Y-m-31', strtotime($end_date));
}
// dd($start_date, $end_date, $date_type);
$start_date = (!isset($start_date) || $start_date === '' || $start_date === null) ? 0 : $start_date;
$end_date = (!isset($end_date) || $end_date === '' || $end_date === null) ? 0 : $end_date;
$client_id = (!isset($client_id) || $client_id === '' || $client_id === null) ? 0 : $client_id;
$insurer_id = (!isset($insurer_id) || $insurer_id === '' || $insurer_id === null) ? 0 : $insurer_id;
$policy_type_id = (!isset($policy_type_id) || $policy_type_id === '' || $policy_type_id === null) ? 0 : $policy_type_id;
$date_type = (!isset($date_type) || $date_type === '' || $date_type === null) ? 0 : $date_type;
$issuer = (!isset($issuer) || $issuer === '' || $issuer === null) ? 0 : $issuer;
$client_branch_id = (!isset($client_branch_id) || $client_branch_id === '' || $client_branch_id === null) ? 0 : $client_branch_id;
$insurer_branch_id = (!isset($insurer_branch_id) || $insurer_branch_id === '' || $insurer_branch_id === null) ? 0 : $insurer_branch_id;
$client_policy_id = (!isset($client_policy_id) || $client_policy_id === '' || $client_policy_id === null) ? 0 : $client_policy_id;
//Actual data for the list
$data['report_list'] = $this->policyTransactionModel->getBDSReportList($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $client_branch_id, $insurer_branch_id, $client_policy_id);
// dd($data['report_list']);
$this->loadLayout('report_bds_filter', $data);
}
public function reportVarience()
{
$data['page_name'] = 'Variance Report';
@ -1414,6 +1509,10 @@ class PolicyTransactionController extends BaseController
$policy_type_id = $this->request->getGet('policy_type_id');
$date_type = $this->request->getGet('date_type');
$issuer = $this->request->getGet('issuer');
$client_branch_id = $this->request->getGet('client_branch_id');
$insurer_branch_id = $this->request->getGet('insurer_branch_id');
$client_policy_id = $this->request->getGet('client_policy_id');
$start_date = (!isset($start_date) || $start_date === '' || $start_date === null) ? 0 : $start_date;
$end_date = (!isset($end_date) || $end_date === '' || $end_date === null) ? 0 : $end_date;
@ -1424,7 +1523,12 @@ class PolicyTransactionController extends BaseController
$date_type = (!isset($date_type) || $date_type === '' || $date_type === null) ? 0 : $date_type;
$issuer = (!isset($issuer) || $issuer === '' || $issuer === null) ? 0 : $issuer;
$data['varience_list'] = $this->policyTransactionModel->getVarienceReportLIst($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer);
$client_branch_id = (!isset($client_branch_id) || $client_branch_id === '' || $client_branch_id === null) ? 0 : $client_branch_id;
$insurer_branch_id = (!isset($insurer_branch_id) || $insurer_branch_id === '' || $insurer_branch_id === null) ? 0 : $insurer_branch_id;
$client_policy_id = (!isset($client_policy_id) || $client_policy_id === '' || $client_policy_id === null) ? 0 : $client_policy_id;
$data['varience_list'] = $this->policyTransactionModel->getVarienceReportLIst($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $client_branch_id, $insurer_branch_id, $client_policy_id);
$this->loadLayout('variance_report_list', $data);
}
@ -1531,20 +1635,17 @@ class PolicyTransactionController extends BaseController
$end_date = $this->request->getGet('end_date');
$client_id = $this->request->getGet('client_id');
$insurer_id = $this->request->getGet('insurer_id');
$policy_type_id = $this->request->getGet('policy_type_id');
$date_type = $this->request->getGet('date_type');
$issuer = $this->request->getGet('issuer');
$insurer_branch_id = $this->request->getGet('insurer_branch_id');
$start_date = (!isset($start_date) || $start_date === '' || $start_date === null) ? 0 : change_date_format($start_date,'d-m-Y','Y-m-01');
$end_date = (!isset($end_date) || $end_date === '' || $end_date === null) ? 0 : change_date_format($end_date,'d-m-Y','Y-m-31');
// dd([$start_date,$end_date]);
$start_date = (!isset($start_date) || $start_date === '' || $start_date === null) ? 0 : $start_date;
$end_date = (!isset($end_date) || $end_date === '' || $end_date === null) ? 0 : $end_date;
$client_id = (!isset($client_id) || $client_id === '' || $client_id === null) ? 0 : $client_id;
$insurer_id = (!isset($insurer_id) || $insurer_id === '' || $insurer_id === null) ? 0 : $insurer_id;
$policy_type_id = (!isset($policy_type_id) || $policy_type_id === '' || $policy_type_id === null) ? 0 : $policy_type_id;
$date_type = (!isset($date_type) || $date_type === '' || $date_type === null) ? 0 : $date_type;
$issuer = (!isset($issuer) || $issuer === '' || $issuer === null) ? 0 : $issuer;
$insurer_branch_id = (!isset($insurer_branch_id) || $insurer_branch_id === '' || $insurer_branch_id === null) ? 0 : $insurer_branch_id;
$data['outstanting_list'] = $this->policyTransactionModel->getOutstandingReportLIst($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer);
$data['outstanting_list'] = $this->policyTransactionModel->getOutstandingReportLIst($start_date, $end_date,$insurer_id, $insurer_branch_id);
// dd($this->policyTransactionModel->getLastQuery());
// dd($data);
$this->loadLayout('outstanding_report_list', $data);
@ -1576,7 +1677,7 @@ class PolicyTransactionController extends BaseController
WHERE pt_co_share_details.is_active = 1
AND pt_co_share_details.statement_id = insurer_statements.id
) AS exp_inv_amt,
(SELECT SUM(inv_payment_details.inv_amt) + SUM(inv_payment_details.tds)
(SELECT SUM(inv_payment_details.inv_amt) + SUM(inv_payment_details.tds) + SUM(inv_payment_details.gst)
FROM inv_payment_details
WHERE inv_payment_details.is_active = 1
AND inv_payment_details.statement_id = insurer_statements.id
@ -1649,9 +1750,10 @@ class PolicyTransactionController extends BaseController
$month = $month.'-01';
// print_r($month);die;
$month = change_date_format($month,'Y-M-d','Y-m-d');
$stmt_sno = $this->request->getPost('statement_no');
// print_r($month);die;
$file_id = $this->insurerStatements->insert(['insurer_id' => $insurer_id, 'branch_id' => $branch_id, 'file_name' => $filename,'month' => $month, 'created_by' => $loggedInUserID]); //here field policy_id have client_policy_id and not policy id from policy master
$file_id = $this->insurerStatements->insert(['insurer_id' => $insurer_id, 'branch_id' => $branch_id, 'file_name' => $filename,'month' => $month, 'created_by' => $loggedInUserID,'stmt_sno' => $stmt_sno]); //here field policy_id have client_policy_id and not policy id from policy master
$this->myLogger->logme("error", '{file_id} statement uploaded success', ['file_id' => $file_id]);
//validate file
@ -1739,9 +1841,9 @@ class PolicyTransactionController extends BaseController
unset($excel_data[0]);
// Kint::dump($excel_data);
//get no of line items and update in DB
$line_items = count($excel_data);
$line_items = 0;
// get uploaded month transactions data
$source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(month:$month,year:$year,insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']);
$source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']);
// var_dump($source_data);die();
// Kint::dump($source_data);//die();
@ -1766,6 +1868,7 @@ class PolicyTransactionController extends BaseController
if( ($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no && change_date_format($policy_start_date,'d-m-Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date,'d-m-Y','Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name'])
{
$is_source_found = 1;
$line_items = $line_items + 1;
unset($source_data[$source_key]);
continue 2;
}
@ -1842,7 +1945,7 @@ class PolicyTransactionController extends BaseController
//get no of line items and update in DB
$line_items = count($excel_data);
// get uploaded month transactions data
$source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(month:$month,year:$year,insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']);
$source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']);
// Kint::dump($source_data);die;
// Kint::dump($excel_data);
@ -1934,7 +2037,7 @@ class PolicyTransactionController extends BaseController
//find variance
$variance_amt = $source_row['exp_amt'] - $total_amt;
$data_to_update[] = ['id' => $source_row['id'],'actual_bp_amt' => $actual_bp_amt,'actual_tp_amt' => $actual_tp_amt,'actual_tep_amt' => $actual_tep_amt,'actual_bp_per' => $actual_bp_per,'actual_tp_per' => $actual_tp_per,'actual_tep_per' => $actual_tep_per,'variance' => $variance_amt,'actual_tep_brokerage_amt' => $actual_tep_brokerage,'actual_tp_brokerage_amt' => $actual_tp_brokerage,'actual_bp_brokerage_amt' => $actual_bp_brokerage,'reward' => trim($excel_row[15]),'statement_id' => $file_id];
$data_to_update[] = ['co_share_id' => $source_row['id'],'actual_bp_amt' => $actual_bp_amt,'actual_tp_amt' => $actual_tp_amt,'actual_tep_amt' => $actual_tep_amt,'actual_bp_per' => $actual_bp_per,'actual_tp_per' => $actual_tp_per,'actual_tep_per' => $actual_tep_per,'variance' => $variance_amt,'actual_tep_brokerage_amt' => $actual_tep_brokerage,'actual_tp_brokerage_amt' => $actual_tp_brokerage,'actual_bp_brokerage_amt' => $actual_bp_brokerage,'reward' => trim($excel_row[15]),'statement_id' => $file_id];
unset($source_data[$source_key]);
continue 2;
@ -1944,7 +2047,7 @@ class PolicyTransactionController extends BaseController
}
}
// dd($data_to_update);
$this->PTCOShareDetailsModel->updateBatch($data_to_update, 'id');
$this->coShareStmtDetailsModel->insertBatch($data_to_update, 'id');
// dd($data_to_update);
// if($error_data['error_code'])
// {
@ -1966,8 +2069,24 @@ class PolicyTransactionController extends BaseController
->where('is_active',1)
->get()
->getResultArray();
if(!$inv_details['invoice_value'])
{
$stmt_level_value = $this->coShareStmtDetailsModel->select('sum(actual_tep_brokerage_amt) + sum(actual_tp_brokerage_amt) + sum(actual_bp_brokerage_amt) + sum(reward) as invoice_value')
->where('statement_id',$statement_id)
->groupBy('statement_id')
->get()
->getResultArray();
// print_r($stmt_level_value);
if($stmt_level_value && count($stmt_level_value) && isset($stmt_level_value[0]))
{
$inv_details['invoice_value'] = $stmt_level_value[0]['invoice_value'];
}
}
// ~dd($inv_details);
$data = [ 'invoice_status' => $inv_details['invoice_status'],
'gst_per' => isset($inv_details['gst_per']) ? $inv_details['gst_per'] : 18 ,
'invoice_value' => $inv_details['invoice_value'],
'gst_value' => $inv_details['gst_value'],
'invoice_no' => $inv_details['invoice_no'],
'invoice_amount' => $inv_details['invoice_amount'],
'invoice_date' => isset($inv_details['invoice_date']) ? change_date_format($inv_details['invoice_date'],'Y-m-d','d/m/Y') : null ];
@ -1989,6 +2108,9 @@ class PolicyTransactionController extends BaseController
$invoiceNo = $jsonData['invoice_no'];
$invoiceDate = change_date_format($jsonData['invoice_date'],'d/m/Y','Y-m-d');
$invoice_amount = $jsonData['invoice_amount'];
$invoice_value = $jsonData['invoice_value'];
$gst_per = $jsonData['invoice_gst_per'];
$gst_value = $jsonData['invoice_gst'];
//Update statement table
$parentData = [
@ -1996,6 +2118,9 @@ class PolicyTransactionController extends BaseController
'invoice_no' => $invoiceNo,
'invoice_date' => $invoiceDate,
'invoice_amount' => $invoice_amount,
'gst_per' => $gst_per,
'gst_value' => $gst_value,
'invoice_value' => $invoice_value,
'updated_by' => get_session_userid()
];
@ -2007,6 +2132,7 @@ class PolicyTransactionController extends BaseController
$receivedAmounts = $jsonData['received_amount'];
$utrNos = $jsonData['utr_no'];
$tdsTotal = $jsonData['tds'];
$gstTotal = $jsonData['gst_amount'];
$paymentDates = $jsonData['payment_date'];
$pks = $jsonData['pk'];
@ -2014,6 +2140,7 @@ class PolicyTransactionController extends BaseController
$pk = $pks[$index]; // Get the pk for the current record
$utrNo = $utrNos[$index];
$tds = $tdsTotal[$index];
$gst = $gstTotal[$index];
$paymentDate = $paymentDates[$index];
// Prepare data for insert/update
@ -2021,6 +2148,7 @@ class PolicyTransactionController extends BaseController
'inv_amt' => $receivedAmount,
'utr_no' => $utrNo,
'tds' => $tds,
'gst' => $gst,
'received_date' => change_date_format($paymentDate,'d/m/Y','Y-m-d'),
'statement_id' => $hiddenStatementId
];
@ -2120,5 +2248,182 @@ class PolicyTransactionController extends BaseController
}
//---------------------------------------------------------------------------------------------------
public function getCoShareStatementDetails($pt_id)
{
if (!$pt_id) {
return $this->respond([
'status' => false,
'code' => 400,
'message' => 'No data found'
], 200);
}
// Fetch data from the database
$data = db_connect()->table("co_share_stmt_details")
->select("
co_share_stmt_details.*,
insurer_statements.month,
insurer_statements.invoice_status,
insurer_statements.invoice_date,
insurer_statements.invoice_no,
insurer_statements.invoice_amount,
insurer_statements.stmt_sno,
(co_share_stmt_details.actual_bp_amt + co_share_stmt_details.actual_tp_amt + co_share_stmt_details.actual_tep_amt) AS sum_of_actual_amt
")
->join('insurer_statements', 'co_share_stmt_details.statement_id = insurer_statements.id')
->where([
'co_share_stmt_details.is_active' => 1,
'insurer_statements.is_active' => 1,
'co_share_stmt_details.co_share_id' => $pt_id
])
->get()
->getResultArray();
// Check if data exists before formatting
if ($data) {
foreach ($data as &$row) {
// Check if invoice_date is not null before formatting
$row['invoice_date'] = $row['invoice_date'] ? change_date_format($row['invoice_date'], 'Y-m-d', 'd/m/Y') : null;
// Check if month is not null before formatting
$row['month'] = $row['month'] ? change_date_format($row['month'], 'Y-m-d', 'M-Y') : null;
}
return $this->respond([
'status' => true,
'code' => 200,
'data' => $data
], 200);
} else {
return $this->respond([
'status' => false,
'code' => 400,
'message' => 'No data found'
], 200);
}
}
public function getClientPolicyDataBasedOnClientAndInsuer()
{
$client_id = $this->request->getGet('client_id') ?? 0;
$client_branch_id = $this->request->getGet('client_branch_id') ?? 0;
$insurer_id = $this->request->getGet('insurer_id') ?? 0;
$insurer_branch_id = $this->request->getGet('insurer_branch_id') ?? 0;
$policy_type_id = $this->request->getGet('policy_type_id') ?? 0;
$builder = db_connect()->table("client_policy")
->select("
client_policy.*,
policy_type.policy_type,
")
->join('policy_type', 'client_policy.policy_type_id = policy_type.id')
->where([
'client_policy.is_active' => 1,
]);
if (!empty($client_id)) {
$builder->where('client_policy.client_id', $client_id);
}
if (!empty($client_branch_id)) {
$builder->where('client_policy.client_branch_id', $client_branch_id);
}
if (!empty($insurer_id)) {
$builder->where('client_policy.insurer_id', $insurer_id);
}
if (!empty($insurer_branch_id)) {
$builder->where('client_policy.insurer_branch_id', $insurer_branch_id);
}
if (!empty($policy_type_id)) {
$builder->where('client_policy.policy_type_id', $policy_type_id);
}
$result = $builder->get()->getResultArray();
if ($result) {
return $this->respond(['status' => true,'code' => 200,'data' => $result, 'getData' => $this->request->getGet()], 200);
} else {
return $this->respond(['status' => false,'code' => 400,'message' => 'No data found'], 200);
}
}
public function checkCDAmountForBasePremium()
{
$base_premium = $this->request->getGet('base_premium') ?? 0;
$cd_ac_no = $this->request->getGet('cd_ac_no') ?? 0;
// Validate inputs
if (empty($cd_ac_no)) {
return $this->respond(['status' => false, 'code' => 400, 'message' => 'CD Account Number is required'], 200);
}
// Build query
$db = db_connect();
$builder = $db->table("cash_deposit")
->where('cd_ac_no', $cd_ac_no)
->where('is_active', 1)
->orderBy('id', 'desc')
->limit(1);
$result = $builder->get()->getRowArray();
if ($result) {
// Check if base premium exceeds balance
$base_premium_greater_than_balance = $base_premium > $result['balance'];
return $this->respond([
'status' => true,
'code' => 200,
'data' => $result,
'base_premium_greater_than_balance' => $base_premium_greater_than_balance,
], 200);
}
return $this->respond(['status' => false, 'code' => 400, 'message' => 'No data found for this CD'], 200);
}
public function getInsurerStatementMonth()
{
$insurer_id = $this->request->getGet('insurer_id');
$month = $this->request->getGet('month');
// echo $month;
$insurer_branch_id = explode('-',$insurer_id)[1];
$insurer_id = explode('-',$insurer_id)[0];
$month = $month.'-01';
$month = change_date_format($month,'Y-M-d','Y-m-d');
// echo $month;
$res_data = $this->insurerStatements
->where('insurer_id',$insurer_id)
->where('branch_id',$insurer_branch_id)
->where('month', $month)
->where('is_active', 1)
->where('file_status', 'success')
->findAll();
return $this->respond(['dataStatus' => true, 'code' => 200,'data' => $res_data], 200);
}
public function deleteStatement($id)
{
// echo $id;die();
$this->coShareStmtDetailsModel->where('statement_id',$id)
->set(['is_active' => 0])
->update();
$this->invPaymentDetailsModel->where('statement_id',$id)
->set(['is_active' => 0])
->update();
$this->insurerStatements->where('id',$id)
->set(['is_active' => 0])
->update();
return $this->respond(['dataStatus' => true, 'code' => 200], 200);
}
}

View File

@ -40,7 +40,7 @@ class UserController extends AdminController
$data['UserList'] = $this->userModel->getUserList();
// echo '<pre>';
// print_r($data); die;
$data['roleData'] = $this->roleModel->select('id, role')->findAll();
$data['roleData'] = $this->roleModel->select('id, role')->findAll();
$data['teamData'] = $this->teamModel->select('id, name')->findAll();
$this->loadLayout('UserList', $data);
}

View File

@ -62,6 +62,7 @@ class DepositHelper
'created_by' => $loggedInUserID,
'updated_by' => $data['updated_by'],
'balance' => $newBalance, // Include the new balance in the data array
'cd_ac_pk'=> isset($data['cd_ac_pk'])?$data['cd_ac_pk']:null,
];
// Insert data and get the insert ID

View File

@ -0,0 +1,150 @@
<?php
namespace App\Helpers;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use Exception;
class ExcelMergeHelper {
/**
* Main merge function with auto-retry
*
* @param array $filePaths Array of file paths with optional sheets to merge.
* @param string $outputPath Path to save the merged Excel file.
* @return string|null Returns output path on success, null on failure.
*/
public static function mergeExcelFiles(array $filePaths, string $outputPath): ?string
{
try {
log_message('debug', 'Attempting merge with original file order');
return self::processFiles($filePaths, $outputPath);
} catch (Exception $e) {
log_message('error', 'First attempt failed: ' . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine());
log_message('debug', 'Retrying with reversed file order');
// Reverse the file order and try again
$reversedFiles = array_reverse($filePaths);
try {
return self::processFiles($reversedFiles, $outputPath);
} catch (Exception $e2) {
log_message('error', 'Both attempts failed. Last error: ' . $e2->getMessage() . ' in ' . $e2->getFile() . ' on line ' . $e2->getLine());
return null;
}
}
}
/**
* Process files to merge spreadsheets
*
* @param array $filePaths
* @param string $outputPath
* @return string
* @throws Exception
*/
private static function processFiles(array $filePaths, string $outputPath): string
{
log_message('debug', 'Starting Excel merge process');
log_message('debug', 'Files to process: ' . json_encode($filePaths));
if (empty($filePaths)) {
throw new Exception("No files provided to merge");
}
// Initialize an empty merged spreadsheet
$mergedSpreadsheet = new Spreadsheet();
$mergedSpreadsheet->removeSheetByIndex(0); // Remove the default empty sheet
// Process the base file
$firstFile = array_shift($filePaths);
self::processSingleFile($firstFile, $mergedSpreadsheet);
// Process remaining files
foreach ($filePaths as $index => $fileInfo) {
self::processSingleFile($fileInfo, $mergedSpreadsheet, $index);
}
// Save the merged file
log_message('debug', "Saving merged file to: {$outputPath}");
$writer = IOFactory::createWriter($mergedSpreadsheet, 'Xlsx');
$writer->setPreCalculateFormulas(false);
$writer->save($outputPath);
// Clean up
$mergedSpreadsheet->disconnectWorksheets();
unset($mergedSpreadsheet);
gc_collect_cycles();
log_message('debug', 'Excel merge process completed successfully');
return $outputPath;
}
/**
* Process a single file to merge its sheets into the merged spreadsheet
*
* @param array $fileInfo
* @param Spreadsheet $mergedSpreadsheet
* @param int|null $index
* @throws Exception
*/
private static function processSingleFile(array $fileInfo, Spreadsheet $mergedSpreadsheet, int $index = null)
{
if (!isset($fileInfo['file_path']) || !file_exists($fileInfo['file_path'])) {
$path = $fileInfo['file_path'] ?? 'undefined';
log_message('error', "File " . ($index ?? 'base') . ": Invalid or missing file path: {$path}");
return;
}
log_message('debug', "Processing file " . ($index ?? 'base') . ": " . $fileInfo['file_path']);
try {
// Load the source spreadsheet
$sourceSpreadsheet = IOFactory::load($fileInfo['file_path']);
// Get all worksheets
$worksheets = $sourceSpreadsheet->getAllSheets();
$totalSheets = count($worksheets);
log_message('debug', "Total sheets in file: " . $totalSheets);
$sheetsToMerge = $fileInfo['sheets'] ?? [];
// Process each worksheet
foreach ($worksheets as $sheetIndex => $worksheet) {
if (empty($sheetsToMerge) || in_array($sheetIndex, $sheetsToMerge)) {
try {
$sheetName = $worksheet->getTitle();
log_message('debug', "Processing sheet: {$sheetName}");
// Generate unique sheet name before cloning
$newName = $sheetName;
$counter = 1;
while (in_array($newName, $mergedSpreadsheet->getSheetNames())) {
$newName = $sheetName . "_" . $counter++;
log_message('debug', "Sheet name already exists. Trying new name: {$newName}");
}
// Clone the worksheet and set the new name
$clonedSheet = clone $worksheet;
$clonedSheet->setTitle($newName);
// Add as external sheet
$mergedSpreadsheet->addExternalSheet($clonedSheet);
log_message('debug', "Successfully added sheet: {$newName}");
} catch (Exception $e) {
log_message('error', "Error processing sheet {$sheetName} as new name {$newName}: " . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine());
}
}
}
// Clean up source spreadsheet
$sourceSpreadsheet->disconnectWorksheets();
unset($sourceSpreadsheet);
gc_collect_cycles();
} catch (Exception $e) {
log_message('error', "Error processing file {$fileInfo['file_path']}: " . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine());
}
}
}

View File

@ -0,0 +1,51 @@
<?php
namespace App\Helpers;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
class ExcelSanitizeHelper
{
/**
* Array of non-printable characters to be removed from strings.
*
* You can modify this array to include any characters you want to remove.
*/
private static $nonPrintableChars = [
"\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\x09",
"\x0A", "\x0B", "\x0C", "\x0D", "\x0E", "\x0F", "\x10", "\x11", "\x12", "\x13",
"\x14", "\x15", "\x16", "\x17", "\x18", "\x19", "\x1A", "\x1B", "\x1C", "\x1D",
"\x1E", "\x1F", "\x7F", "_x000D_", "_x000A_", "_x0009_", "_x0008_", "_x0007_",
"_x0006_", "_x0005_", "_x0004_", "_x0003_", "_x0002_", "_x0001_"
];
/**
* Sanitizes array data by removing non-printable characters and trimming whitespace from strings.
*
* @param array $data Input array containing data to sanitize
* @return array Sanitized array with non-printable characters removed and leading/trailing whitespace trimmed
*/
public static function sanitizeArrayData(array $data): array
{
try {
$cleanData = [];
foreach ($data as $key => $value) {
if (is_array($value)) {
$cleanData[$key] = self::sanitizeArrayData($value); // Recursive call for nested arrays
} elseif (is_string($value)) {
// Remove non-printable characters and trim whitespace from strings
$cleanData[$key] = trim(str_replace(self::$nonPrintableChars, '', $value));
} else {
$cleanData[$key] = $value; // Keep non-string/non-array data as is
}
}
return $cleanData;
} catch (\Exception $e) {
// Log the error and the problematic data for debugging
log_message('error', 'Error sanitizing array data: ' . $e->getMessage());
log_message('error', 'Problematic data: ' . json_encode($data));
return $data; // Return the original data in case of error
}
}
}

View File

@ -77,17 +77,16 @@ class GmailResponseHandler{
}
}
}
if(isset($params['gmail_api']['status']) && $params['gmail_api']['status'] == 1 ){
$data['gmail_api_status'] = isset($params['gmail_api']['status']) ? $params['gmail_api']['status'] : null;
$data['gmail_api_id'] = isset($params['gmail_api']['data']['id']) ? $params['gmail_api']['data']['id'] : null;
$data['received_message'] = isset($params['gmail_api']['data']['labelIds']) ? json_encode($params['gmail_api']['data']['labelIds']) : null;
if(isset($params['zepto_api']['data']) && $params['zepto_api']['message'] == 'OK' ){
$data['gmail_api_status'] = isset($params['zepto_api']['data']) ? $params['zepto_api']['data'][0]['code'] : null;
$data['gmail_api_id'] = isset($params['zepto_api']['request_id']) ? $params['zepto_api']['request_id'] : null;
$data['received_message'] = isset($params['zepto_api']['data'][0]['message']) ? json_encode($params['zepto_api']['data'][0]['message']) : null;
}
elseif(isset($params['gmail_api']['status']) && $params['gmail_api']['status'] == false ){
$data['gmail_api_status'] = $params['gmail_api']['status'];
if(isset($params['gmail_api']['data'])){
$data['received_message'] = json_encode($params['gmail_api']['data']);
}
elseif(isset($params['zepto_api']['error'])){
$data['gmail_api_status'] = isset($params['zepto_api']['error']['code'])?$params['zepto_api']['error']['code']:null;
$data['received_message'] = json_encode($params['zepto_api']);
$data['gmail_api_id'] = isset($params['zepto_api']['error']['request_id']) ? $params['zepto_api']['error']['request_id'] : null;
}
$gmailModel = new GmailSentHistoryModel();
@ -96,7 +95,9 @@ class GmailResponseHandler{
public function gmail_response_logger($params)
{
$this->myLogger->logme('error',json_encode($params));
if(isset($params['zepto_api']['error'])){
$this->myLogger->logme('error',json_encode($params));
}
}
public function client_id_flag_setter($params)
@ -119,7 +120,6 @@ class GmailResponseHandler{
$error = $e->getMessage();
$this->myLogger->logme('error','An Error Occured - '.$error);
}
}
}
}

View File

@ -1,175 +1,422 @@
<?php
// namespace App\Helpers;
// use Psr\Log\LoggerInterface;
// use App\Controllers\BaseController;
// use PHPMailer\PHPMailer\PHPMailer;
// use PHPMailer\PHPMailer\SMTP;
// use PHPMailer\PHPMailer\Exception;
// use App\Models\JobModel;
// class MailHelper
// {
// public static function send_email_smtp($params)
// {
// // print_r($params);die;
// $myLogger = \Config\Services::mylogger();
// $emaill = $params['mail'];
// $subject = $params['subject'];
// $message = $params['message'];
// if (isset($params['bcc'])) {
// $bcc = $params['bcc'];
// }else{
// $bcc= '';
// }
// try {
// $email = \Config\Services::email();
// $email->setMailType('html');
// $email->setFrom('bbone@venbait.in', 'Nhance');
// $email->setTo($emaill);
// if (!empty($bcc)) {
// // Convert the comma-separated string into an array
// $bccList = explode(',', $bcc);
// // Trim whitespace from each email ID
// $bccList = array_map('trim', $bccList);
// // Set BCC recipients
// $email->setBCC($bccList);
// }
// $email->setSubject($subject);
// $email->setMessage($message);
// if ($email->send()) {
// return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...','data' => $emaill,],200);
// } else {
// $myLogger->logme('error', "mail sent failed - $emaill");
// return json_encode(['status' => 'failed','code' => 404,'message'=>'Email Sent Failed...','data' => $emaill ],404);
// }
// } catch (Exception $e) {
// $msg = $e->getMessage();
// $myLogger->logme('error', "mail sent failed - $msg");
// return json_encode(['status' => 'failed','code' => 500,'data' => $emaill],500);
// }
// }
// public static function bulk_mail_smtp(array $mails = [])
// {
// // print_r();die;
// $model = new JobModel();
// $start = microtime(true);
// $runtime= 0;
// try {
// foreach ( $mails as $index=>$mail) {
// $runtime = microtime(true) - $start;
// $send_mail = self::send_email($mail);
// }
// return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...'],200);
// } catch (\Throwable $th) {
// return json_encode(['status' => 'failed','code' => 500],500);
// }
// }
// //using GmailAPI
// public static function send_email($params)
// {
// // print_r($params);die;
// $myLogger = \Config\Services::mylogger();
// $gmailapi = \Config\Services::gmailapi();
// $emaill = $params['mail'];
// $subject = $params['subject'];
// $message = $params['message'];
// $attachments = isset($params['attachments']) && count($params['attachments']) ? $params['attachments'] : [];
// $common = isset($params['common'])?$params['common']:'';
// //check BCC mail
// if (isset($params['bcc'])) {
// $bcc = $params['bcc'];
// if(!is_array($bcc)){
// $bcc = explode(',', $bcc);
// }
// }else{
// $bcc = [];
// }
// //check CC mail
// if (isset($params['cc'])) {
// $cc = $params['cc'];
// if(!is_array($cc)){
// $cc = explode(',', $cc);
// }
// }else{
// $cc = [];
// }
// //check REPLY TO mail
// $reply_to = "";
// if(isset($params['reply_to']) && !empty($params['reply_to'])){
// $reply_to = $params['reply_to'];
// }
// $MailDataHelper = new GmailResponseHandler();
// $res['params'] = $params;
// try {
// $res['gmail_api'] = $gmailapi->sendMessage($emaill, $subject, $message, 'no-reply@nhanceindia.in', $reply_to, $cc, $bcc,$attachments);
// if($res['gmail_api']['status'])
// {
// $response = $res;
// $MailDataHelper->receive_and_distribute_param_to_functions($response);
// return json_encode(['status' => 'success','code' => 200, 'message'=>('Email Sent Successfully...'.$emaill),'data' => $res,],200);
// }
// else
// {
// $myLogger->logme('error', "mail sent failed - $emaill");
// $response = $res;
// $MailDataHelper->receive_and_distribute_param_to_functions($response);
// return json_encode(['status' => 'failed','code' => 404,'message'=>( 'Email Sent Failed...' . $emaill ),'data' => $res ],404);
// }
// } catch (Exception $e) {
// $msg['error'] = $e->getMessage();
// $msg['params'] = $params;
// $myLogger->logme('error', "mail sent failed - $msg");
// $response = $msg;
// $MailDataHelper->receive_and_distribute_param_to_functions($response);
// return json_encode(['status' => 'failed','code' => 500,'data' => $msg],500);
// }
// }
// public static function bulk_mail(array $mails = [])
// {
// // print_r($mails);die;
// $model = new JobModel();
// $start = microtime(true);
// $runtime= 0;
// try {
// foreach ( $mails as $index=>$mail) {
// $runtime = microtime(true) - $start;
// $send_mail = self::send_email($mail);
// }
// return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...'],200);
// } catch (\Throwable $th) {
// $error = $th->getMessage();
// log_message('error',$error);
// return json_encode(['status' => 'failed','code' => 500,'error'=>$error],500);
// }
// }
// }
namespace App\Helpers;
use Psr\Log\LoggerInterface;
use App\Controllers\BaseController;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
use App\Models\JobModel;
class MailHelper
{
public static function send_email_smtp($params)
{
// print_r($params);die;
$myLogger = \Config\Services::mylogger();
$emaill = $params['mail'];
$subject = $params['subject'];
$message = $params['message'];
if (isset($params['bcc'])) {
$bcc = $params['bcc'];
}else{
$bcc= '';
} else {
$bcc = '';
}
$from_address = getenv('email.fromEmail');
try {
$email = \Config\Services::email();
$email->setMailType('html');
$email->setFrom('bbone@venbait.in', 'Nhance');
$email->setTo($emaill);
$curl = curl_init();
$postData = [
'from' => [
'address' => $from_address
],
'to' => [
[
'email_address' => [
'address' => $emaill
]
]
],
'subject' => $subject,
'htmlbody' => $message
];
// Add BCC if present
if (!empty($bcc)) {
// Convert the comma-separated string into an array
$bccList = explode(',', $bcc);
// Trim whitespace from each email ID
$bccList = array_map('trim', $bccList);
// Set BCC recipients
$email->setBCC($bccList);
$postData['bcc'] = array_map(function($email) {
return [
'email_address' => [
'address' => $email
]
];
}, $bccList);
}
$email->setSubject($subject);
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.zeptomail.in/v1.1/email",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($postData),
CURLOPT_HTTPHEADER => [
"accept: application/json",
"authorization: Zoho-enczapikey " . getenv('ZEPTO_API_KEY'),
"cache-control: no-cache",
"content-type: application/json",
],
]);
$email->setMessage($message);
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$err = curl_error($curl);
if ($email->send()) {
curl_close($curl);
if ($err) {
$myLogger->logme('error', "mail sent failed - $emaill");
return json_encode(['status' => 'failed', 'code' => 404, 'message' => 'Email Sent Failed...', 'data' => $emaill], 404);
}
return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...','data' => $emaill,],200);
$apiResponse = json_decode($response, true);
if ($httpCode === 200) {
return json_encode(['status' => 'success', 'code' => 200, 'message' => 'Email Sent Successfully...', 'data' => $emaill], 200);
} else {
$myLogger->logme('error', "mail sent failed - $emaill");
return json_encode(['status' => 'failed','code' => 404,'message'=>'Email Sent Failed...','data' => $emaill ],404);
return json_encode(['status' => 'failed', 'code' => 404, 'message' => 'Email Sent Failed...', 'data' => $emaill], 404);
}
} catch (Exception $e) {
} catch (\Exception $e) {
$msg = $e->getMessage();
$myLogger->logme('error', "mail sent failed - $msg");
return json_encode(['status' => 'failed','code' => 500,'data' => $emaill],500);
}
return json_encode(['status' => 'failed', 'code' => 500, 'data' => $emaill], 500);
}
}
public static function bulk_mail_smtp(array $mails = [])
{
// print_r();die;
$model = new JobModel();
$start = microtime(true);
$runtime= 0;
try {
foreach ( $mails as $index=>$mail) {
$runtime = 0;
try {
foreach ($mails as $index => $mail) {
$runtime = microtime(true) - $start;
$send_mail = self::send_email($mail);
}
return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...'],200);
}
return json_encode(['status' => 'success', 'code' => 200, 'message' => 'Email Sent Successfully...'], 200);
} catch (\Throwable $th) {
return json_encode(['status' => 'failed','code' => 500],500);
}
} catch (\Throwable $th) {
return json_encode(['status' => 'failed', 'code' => 500], 500);
}
}
//using GmailAPI
public static function send_email($params)
public static function send_email($params)
{
// print_r($params);die;
$myLogger = \Config\Services::mylogger();
$gmailapi = \Config\Services::gmailapi();
$emaill = $params['mail'];
$subject = $params['subject'];
$message = $params['message'];
$attachments = isset($params['attachments']) && count($params['attachments']) ? $params['attachments'] : [];
$common = isset($params['common'])?$params['common']:'';
//check BCC mail
if (isset($params['bcc'])) {
$bcc = $params['bcc'];
$bcc = explode(',', $bcc);
}else{
$bcc = [];
}
$attachments = isset($params['attachments']) ? $params['attachments'] : [];
$common = isset($params['common']) ? $params['common'] : '';
//check CC mail
if (isset($params['cc'])) {
$cc = $params['cc'];
if(!is_array($cc)){
$cc = explode(',', $cc);
}
}else{
$cc = [];
}
//check REPLY TO mail
$reply_to = "";
if(isset($params['reply_to']) && !empty($params['reply_to'])){
$reply_to = $params['reply_to'];
}
$MailDataHelper = new GmailResponseHandler();
$res['params'] = $params;
$from_address = getenv('email.fromEmail');
try {
$res['gmail_api'] = $gmailapi->sendMessage($emaill, $subject, $message, 'no-reply@nhanceindia.in', $reply_to, $cc, $bcc,$attachments);
if($res['gmail_api']['status'])
{
$response = $res;
$MailDataHelper->receive_and_distribute_param_to_functions($response);
return json_encode(['status' => 'success','code' => 200, 'message'=>('Email Sent Successfully...'.$emaill),'data' => $res,],200);
}
else
{
$myLogger->logme('error', "mail sent failed - $emaill");
$response = $res;
$MailDataHelper->receive_and_distribute_param_to_functions($response);
return json_encode(['status' => 'failed','code' => 404,'message'=>( 'Email Sent Failed...' . $emaill ),'data' => $res ],404);
}
} catch (Exception $e) {
$curl = curl_init();
$postData = [
'from' => [
'address' => $from_address
],
'to' => [
[
'email_address' => [
'address' => $emaill
]
]
],
'subject' => $subject,
'htmlbody' => $message
];
// Handle attachments
if (!empty($attachments)) {
$postData['attachments'] = [];
foreach ($attachments as $attachment) {
if (isset($attachment['filePath']) && file_exists($attachment['filePath'])) {
// Determine MIME type dynamically
$fileMimeType = mime_content_type($attachment['filePath']);
$postData['attachments'][] = [
'content' => base64_encode(file_get_contents($attachment['filePath'])),
'name' => $attachment['fileName'],
'mime_type' => $fileMimeType, // Add mime_type field
];
}
}
}
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.zeptomail.in/v1.1/email",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($postData),
CURLOPT_HTTPHEADER => [
"accept: application/json",
"authorization: Zoho-enczapikey " . getenv('ZEPTO_API_KEY'),
"cache-control: no-cache",
"content-type: application/json",
],
]);
$mail_result = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
// log_message('error','inside mail helper');
// log_message('error', $response.' error->'.$err);die();
$res['params'] = $params;
$MailDataHelper = new GmailResponseHandler();
$apiResponse = json_decode($mail_result, true);
$res['zepto_api'] = $apiResponse;
if (isset($apiResponse['error'])) {
$response = $res;
$MailDataHelper->receive_and_distribute_param_to_functions($response);
return json_encode([
'status' => 'failed',
'code' => 404,
'message' => 'Email Sent Failed...' . $emaill,
'data' => $res
], 404);
}
// $apiResponse = json_decode($response, true);
// Check if request_id exists in response (indicates success)
if (isset($apiResponse['data'])) {
$response = $res;
$MailDataHelper->receive_and_distribute_param_to_functions($response);
return json_encode([
'status' => 'success',
'code' => 200,
'message' => 'Email Sent Successfully...' . $emaill,
'data' => $res
], 200);
}
} catch (\Exception $e) {
$msg['error'] = $e->getMessage();
$msg['params'] = $params;
$myLogger->logme('error', "mail sent failed - $msg");
$response = $msg;
$response = $res;
$MailDataHelper->receive_and_distribute_param_to_functions($response);
return json_encode(['status' => 'failed','code' => 500,'data' => $msg],500);
return json_encode([
'status' => 'failed',
'code' => 500,
'data' => $msg
], 500);
}
}
public static function bulk_mail(array $mails = [])
{
// print_r($mails);die;
$model = new JobModel();
$start = microtime(true);
$runtime= 0;
try {
foreach ( $mails as $index=>$mail) {
$runtime = 0;
try {
foreach ($mails as $index => $mail) {
$runtime = microtime(true) - $start;
$send_mail = self::send_email($mail);
}
return json_encode(['status' => 'success', 'code' => 200, 'message' => 'Email Sent Successfully...'], 200);
} catch (\Throwable $th) {
$error = $th->getMessage();
log_message('error', $error);
return json_encode(['status' => 'failed', 'code' => 500, 'error' => $error], 500);
}
return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...'],200);
} catch (\Throwable $th) {
$error = $th->getMessage();
log_message('error',$error);
return json_encode(['status' => 'failed','code' => 500,'error'=>$error],500);
}
}
}
?>

View File

@ -128,7 +128,7 @@ if (! function_exists('transform_objects_to_array_for_inception')) {
$obj->emp_gender, // Employee Gender
$obj->pre_existing_alignments, // Pre-existing Alignments
$obj->basic_cover_si, // Basic Cover SI
$obj->date_coverage, // Date Coverage
$obj->date_of_coverage, // Date Coverage
$obj->emp_age, // Employee Age
$obj->emp_relationship, // Employee Relationship
$obj->change_event, // Change Event
@ -260,7 +260,6 @@ if (! function_exists('transform_objects_to_array_for_deletion')) {
$obj->total,
$claim_status,
$endorsement_id
];
// Append the row data to the main data array
@ -487,7 +486,7 @@ if (!function_exists('format_Excel_BasedOn_Client'))
$rowData[] = $obj->basic_cover_si; // Employee BASIC COVER SI
break;
case 'dateofcoverage':
$rowData[] = $obj->date_coverage; // DATE OF COVERAGE
$rowData[] = $obj->date_of_coverage; // DATE OF COVERAGE
break;
case 'age':
$rowData[] = $obj->emp_age; // Employee AGE

View File

@ -345,8 +345,7 @@ if(!function_exists('check_basic_pay'))
if (!function_exists('check_dob_diff'))
{
function check_dob_diff($row,$relationships,$default_age_ratio) {
// echo 'called';
function check_dob_diff($row,$relationships,$default_age_ratio,$policy_details) {
if($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I','A','DA','MI']))// check rule only of action column data available
{
if($row[3] != null && $row[5] != null)
@ -358,13 +357,11 @@ if (!function_exists('check_dob_diff'))
}
// return array('status' => true);
$dob = $dateString;
// echo $row[3].' - '.$dob;echo '<br>';
$currentDateTime = new DateTime();//die();
// print_r($currentDateTime);
//$currentDateTime = new DateTime();//previously dob calculated from current date time
$temp_date = ($row[7] != null && $row[7] != "") ? convert_string_to_date($row[7]) : $policy_details[0]->policy_start_date; //pick date of coverage from row if not then use policy start date as from to calculate DOB
$currentDateTime = new DateTime($temp_date);//later DOB calculated from date of coverage or policy_start_date
// die();
$passedDateTime = new DateTime($dob);
// print_r($passedDateTime);
$interval = $currentDateTime->diff($passedDateTime);
//remap default age ratio data into relationship array
if(count($default_age_ratio))
@ -375,7 +372,6 @@ if (!function_exists('check_dob_diff'))
$relationship = $slug->slugify($row[5]);
$age_min = isset($relationships[$relationship]['age_min']) ? $relationships[$relationship]['age_min'] : NULL;
$age_max = isset($relationships[$relationship]['age_max']) ? $relationships[$relationship]['age_max'] : NULL;
// echo $relationship.','.$age_min.'-'.$age_max;
if($age_min !== null && $age_min > $interval->y)
{
return array('status' => false,'error' => "Age conflict : minimum $age_min yrs allowed, received $interval->y");
@ -965,7 +961,6 @@ if (!function_exists('calculate_premium_new'))
if(empty($member[18])){ $member[18] = $existing_units[0]; }
//transform as db row column
$transformed_familiy_member_data = transform_excel_data_to_db($member,$fileArr);
// kint::dump($transformed_familiy_member_data);
//generate relationship code
if($transformed_familiy_member_data['temp']['action'] != 'D' && $transformed_familiy_member_data['temp']['action'] != 'C' && $transformed_familiy_member_data['temp']['action'] != 'SI')
{
@ -979,7 +974,7 @@ if (!function_exists('calculate_premium_new'))
'isEmployeeSourceEnrollment' => $fileArr['id'] == null,
'isEmployeeSourceExcelFile' => $transformed_familiy_member_data['temp']['source'] == 'excel',
'isCurrentActionDependentAddition' => $fileArr['action'] == 'dependent_addition',
// 'isPrimaryGridPremiumTypeSingle' => $transformed_familiy_member_data['temp']['premium_type'] == 1,
'isPrimaryGridPremiumTypeSingle' => isset($transformed_familiy_member_data['temp']['premium_type']) ? $transformed_familiy_member_data['temp']['premium_type'] == 1 : 0,
'isCurrentRelationshipSelf' => (strtolower($transformed_familiy_member_data['relationship']) == 'self' || (isset($transformed_familiy_member_data['temp']['acting_self']) && $transformed_familiy_member_data['temp']['acting_self'] === true)),
'isBasicCoverCalculatedToCurrentEmployee' => ($transformed_familiy_member_data['policy_details']['basic_cover_si'] != null && $transformed_familiy_member_data['policy_details']['basic_cover_si'] != 0)
];
@ -1049,7 +1044,7 @@ if (!function_exists('transform_excel_data_to_db'))
$result['designation'] = $memArr[11];
$result['mobile'] = $memArr[12];
$result['email_corporate'] = $memArr[13];
$result['file_id'] = $actionArr['id'];
$result['file_id'] = isset($memArr['temp']['source']) && $memArr['temp']['source'] == 'db' && isset($memArr['temp']['file_id']) ? $memArr['temp']['file_id'] : $actionArr['id'];
$result['client_id'] = $actionArr['client_id'];
$result['change_event'] = $memArr[15];
$result['unit'] = $memArr[18];
@ -1078,8 +1073,6 @@ if (!function_exists('premium_calculation_manager'))
{
function premium_calculation_manager($emp_data,$policy_terms,$slab_details,$default_si = null)
{
// Kint::dump($emp_data);die();
$myLogger = \Config\Services::mylogger();
// grid type
// 1 = premium => si
@ -1167,7 +1160,7 @@ if (!function_exists('premium_calculation_manager'))
{
if($temp_slab_rates[0]['si_or_bp'] == 2)
{
$temp_si = $emp_data['basic_pay'] * $temp_slab_rates[0]['si_or_bp'];
$temp_si = $emp_data['basic_pay'] * $temp_slab_rates[0]['basic_multiplier'];
$temp_premium = ($temp_si * $temp_slab_rates[0]['multiplier']) / 1000;
$emp_data['policy_details']['basic_cover_si'] = $temp_si;
@ -1229,9 +1222,12 @@ if (!function_exists('premium_calculation_manager'))
//GMC - Employees Age band
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
// dd($employee_received_si);
$temp_date = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$age = calculate_days_bw_dates(from_date: $emp_data['dob'],to_date: $temp_date)->y;
foreach ($temp_slab_rates as $skey => $slab_value)
{
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) ))
{
// dd($slab_value);
@ -1250,9 +1246,12 @@ if (!function_exists('premium_calculation_manager'))
case "5":
//GMC - Employees Age + SI
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
$temp_date = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$age = calculate_days_bw_dates(from_date: $emp_data['dob'],to_date: $temp_date)->y;
foreach ($temp_slab_rates as $skey => $slab_value)
{
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3 ) ))
{
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
@ -1270,9 +1269,11 @@ if (!function_exists('premium_calculation_manager'))
case "6":
//GMC - Employees + Dependent Age band
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
$temp_date = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$age = calculate_days_bw_dates(from_date: $emp_data['dob'],to_date: $temp_date)->y;
foreach ($temp_slab_rates as $skey => $slab_value)
{
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) ))
{
// echo $emp_data['name'];
@ -1292,9 +1293,11 @@ if (!function_exists('premium_calculation_manager'))
case "7":
//GMC - Employees + Dependent Age + SI
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
$temp_date = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$age = calculate_days_bw_dates(from_date: $emp_data['dob'],to_date: $temp_date)->y;
foreach ($temp_slab_rates as $skey => $slab_value)
{
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) ))
{
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
@ -1442,7 +1445,8 @@ if (!function_exists('premium_calculation_manager'))
$employee_relationship = $slug->slugify($emp_data['relationship']);
$employee_relationship = ($employee_relationship == 'daughter' || $employee_relationship == 'son' ? $employee_relationship = 'child' : $employee_relationship);
$emp_data['policy_details']['basic_cover_si'] = null;
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
$temp_date = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$age = calculate_days_bw_dates(from_date: $emp_data['dob'],to_date: $temp_date)->y;
foreach ($temp_slab_rates as $skey => $slab_value)
{
if( $slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && ((($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) && $slab_value['relationship'] == $employee_relationship) || ($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) )) )
@ -1475,7 +1479,8 @@ if (!function_exists('premium_calculation_manager'))
}
if(!$is_match_found)
{
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
$temp_date = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$age = calculate_days_bw_dates(from_date: $emp_data['dob'],to_date: $temp_date)->y;
$log_message = '[ client_policy_id : ' .$emp_data['policy_details']['client_policy_id'].' - '. $emp_data['emp_code'].' - '.$emp_data['name'] .' - '. $emp_data['policy_details']['basic_cover_si'] . ', Age : '. $age.' ]';
if($temp_slab_rates[0]['premium_type'] == 1)
{
@ -1560,6 +1565,7 @@ if (!function_exists('transform_db_data_to_excel'))
$row['temp']['emp_status'] = $value['emp_status'];
$row['temp']['policy_status'] = $value['status'];
$row['temp']['rata_premimum'] = $value['rata_premimum'];
$row['temp']['file_id'] = $value['file_id'];
array_push($return_data, ($row));
}

View File

@ -327,7 +327,7 @@ class sendMailNotification
// dd($payable_employee_array);
// dd(count($payable_employee_array['emp_data']));
if(count($payable_employee_array['emp_data']) > 0){
if(isset($payable_employee_array['emp_data']) && count($payable_employee_array['emp_data']) > 0){
$table_content .= '<div style="text-align: left; font-size: 12px;"><div style="text-align:left;"><h4>Policy Type :';
$temp_data = '';

View File

@ -21,7 +21,7 @@ class MyLogger extends Logger
$message = '{context} - {uuid} -' . $message;
// /echo $message;//die();
$context = array_merge($context,['uuid' => get_session_uuid()]);
$context = array_merge($context,['uuid' => (null !== get_session_uuid()) ? get_session_uuid() : 'CLI']);
// print_r($context);die();
// echo isset($context['context']) ? $context['context'] : $this->context;die();
$context['context'] = isset($context['context']) ? $context['context'] : get_session_context();

View File

@ -65,28 +65,37 @@ class CDMasterModel extends Model
{
$query = $this->db->table('cd_master')
->select('cd_master.*, clients.client_name, clients.short_name, insurers.name AS insurer_name, user_profiles.first_name AS user_name, IFNULL(cd_ac_counts.cd_ac_no_count, 0) AS cd_ac_no_count, IFNULL(cd_ac_counts_for_cdt.cd_ac_no_count_cd_tranction, 0) AS cd_ac_no_count_cd_tranction')
->join('clients', 'clients.id = cd_master.client_id')
->join('insurers', 'insurers.id = cd_master.insurer_id')
->join('user_profiles', 'user_profiles.id = cd_master.created_by')
->join(
'(SELECT cd_master.cd_ac_no, COUNT(client_policy.cd_ac_no) AS cd_ac_no_count
FROM cd_master
JOIN client_policy ON client_policy.cd_ac_no = cd_master.cd_ac_no
WHERE client_policy.is_active = 1
AND cd_master.is_active = 1
GROUP BY cd_master.cd_ac_no) AS cd_ac_counts',
'cd_ac_counts.cd_ac_no = cd_master.cd_ac_no',
'(SELECT cd_master.cd_ac_no, cd_master.id, COUNT(client_policy.cd_ac_no) AS cd_ac_no_count
FROM cd_master
JOIN client_policy ON client_policy.cd_ac_pk = cd_master.id
WHERE client_policy.is_active = 1
AND cd_master.is_active = 1
GROUP BY cd_master.id
) AS cd_ac_counts',
'cd_ac_counts.id = cd_master.id',
'left'
)
->join(
'(SELECT cd_master.cd_ac_no, COUNT(cash_deposit.cd_ac_no) AS cd_ac_no_count_cd_tranction
FROM cd_master
JOIN cash_deposit ON cash_deposit.cd_ac_no = cd_master.cd_ac_no
WHERE cash_deposit.is_active = 1
AND cd_master.is_active = 1
GROUP BY cd_master.cd_ac_no) AS cd_ac_counts_for_cdt',
'cd_ac_counts_for_cdt.cd_ac_no = cd_master.cd_ac_no',
'(SELECT cd_master.cd_ac_no, cd_master.id, COUNT(cash_deposit.cd_ac_no) AS cd_ac_no_count_cd_tranction
FROM cd_master
JOIN cash_deposit ON cash_deposit.cd_ac_pk = cd_master.id
WHERE cash_deposit.is_active = 1
AND cd_master.is_active = 1
GROUP BY cd_master.id
) AS cd_ac_counts_for_cdt',
'cd_ac_counts_for_cdt.id = cd_master.id',
'left'
)
->where('cd_master.is_active', 1)

View File

@ -0,0 +1,38 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class COShareStmtDetailsModel extends Model
{
protected $table = 'co_share_stmt_details';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = [
'id',
'co_share_id',
'statement_id',
'actual_bp_amt',
'actual_tp_amt',
'actual_tep_amt',
'actual_bp_per',
'actual_tp_per',
'actual_tep_per',
'actual_bp_brokerage_amt',
'actual_tp_brokerage_amt',
'actual_tep_brokerage_amt',
'reward',
'exp_amt',
'variance',
'created_by',
'updated_by',
'is_active'
];
}

View File

@ -27,6 +27,7 @@ class ClientDepositModel extends Model
"endorsement_no",
"event_name",
"unit",
"cd_ac_pk"
];

View File

@ -52,6 +52,7 @@ class ClientPolicyModel extends Model
"disclaimer",
"is_active",
"is_member_modify_allowed",
"cd_ac_pk"
];
// Callbacks
@ -169,13 +170,14 @@ class ClientPolicyModel extends Model
public function getinsurerswithclientid($id){
return $this->db->table('client_policy')
->select('client_policy.*, cd_master.cd_ac_no')
->select('client_policy.*, cd_master.cd_ac_no as cd_master_account_no')
->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
->select('clients.client_name as client_name')
->join('clients','clients.id=client_policy.client_id')
->join('insurers', 'insurers.id = client_policy.insurer_id')
->join('cd_master', 'cd_master.insurer_id = insurers.id AND cd_master.client_id = client_policy.client_id')
->where('client_policy.client_id', $id)
->where('cd_master.id = client_policy.cd_ac_pk')
->groupBy('client_policy.insurer_id')
->groupBy('client_policy.client_id', $id) // Group by insurer_id
->get()
@ -225,6 +227,7 @@ class ClientPolicyModel extends Model
->select('cash_deposit.*')
->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
->select('clients.client_name as clientname, clients.short_name as clientshort, client_policy.policy_no')
->select('cd_master.cd_ac_no as cd_master_account_no')
// ->select('policies.name as policy_name')
->select('policy_type.policy_type')
->select('user_profiles.first_name as username')
@ -232,11 +235,13 @@ class ClientPolicyModel extends Model
->join('insurers', 'insurers.id = cash_deposit.insurer_id', 'left')
->join('clients', 'clients.id = cash_deposit.client_id', 'left')
->join('client_policy', 'client_policy.id = cash_deposit.client_policy_id', 'left')
->join('cd_master', 'cd_master.id = cash_deposit.cd_ac_pk', 'left')
// ->join('policies', 'policies.id = client_policy.policy_id', 'left')
->join('policy_type', 'policy_type.id = client_policy.policy_type_id', 'left')
->where('cash_deposit.client_id', $clientId)
->where('cash_deposit.insurer_id', $insurerId)
->where('cash_deposit.is_active', 1)
// ->where('cash_deposit.cd_ac_pk = cd_master.id')
->orderBy('cash_deposit.id', 'DESC')
->get()
->getResult();

View File

@ -106,7 +106,7 @@ class EmployeeModel extends Model
public function getEmpFamilybyEmpCode(string $client_policy_id = null,string $emp_code = null,string $client_id = null,array $emp_status = [],array $policy_status = [],array $relationship = [],array $client_branch_id = [])
{
$result = $this->select(['employees.id as emp_id', 'employees.client_id','employees.client_branch_id', 'employees.relationship', 'employees.relationship_code', 'employees.change_event', 'employees.emp_code', 'employees.name', 'employees.email_personal', 'employees.email_corporate', 'employees.mobile', 'employees.gender', 'employees.dob', 'employees.doj', 'employees.basic_pay', 'employees.band', 'employees.designation', 'employees.emp_status','employees.unit','employee_polices.id as emp_policy_id', 'employee_polices.employee_id', 'employee_polices.client_policy_id', 'employee_polices.tpa_id', 'employee_polices.uhid', 'employee_polices.batch_code', 'employee_polices.status', 'employee_polices.pre_existing_alignments', 'employee_polices.basic_cover_si', 'employee_polices.date_coverage', 'employee_polices.policy_end_date', 'employee_polices.days', 'employee_polices.premium', 'employee_polices.rata_premimum', 'employee_polices.gst', 'employee_polices.date_of_exit', 'employee_polices.reason_for_exit','policy_type.long_name as policy_name','client_policy.is_addon', 'employee_polices.payable_employee'])
$result = $this->select(['employees.id as emp_id', 'employees.client_id','employees.client_branch_id', 'employees.relationship', 'employees.relationship_code', 'employees.change_event', 'employees.emp_code', 'employees.name', 'employees.email_personal', 'employees.email_corporate', 'employees.mobile', 'employees.gender', 'employees.dob', 'employees.doj', 'employees.basic_pay', 'employees.band', 'employees.designation', 'employees.emp_status','employees.unit','employees.file_id','employee_polices.id as emp_policy_id', 'employee_polices.employee_id', 'employee_polices.client_policy_id', 'employee_polices.tpa_id', 'employee_polices.uhid', 'employee_polices.batch_code', 'employee_polices.status', 'employee_polices.pre_existing_alignments', 'employee_polices.basic_cover_si', 'employee_polices.date_coverage', 'employee_polices.policy_end_date', 'employee_polices.days', 'employee_polices.premium', 'employee_polices.rata_premimum', 'employee_polices.gst', 'employee_polices.date_of_exit', 'employee_polices.reason_for_exit','policy_type.long_name as policy_name','client_policy.is_addon', 'employee_polices.payable_employee'])
->join('employee_polices', 'employee_polices.employee_id = employees.id')
->join('client_policy', 'client_policy.id = employee_polices.client_policy_id')
->join('policy_type', 'policy_type.id = client_policy.policy_type_id','left')
@ -212,4 +212,32 @@ class EmployeeModel extends Model
return $results;
}
public function getTestEmployeeData(){
$query = "
SELECT
e.*,
(
SELECT
COUNT(ep.client_policy_id)
FROM
employee_polices ep
WHERE
ep.employee_id = e.id
) AS policy_count
FROM
employees e
WHERE
e.emp_code LIKE 'TEST%'
ORDER BY
e.emp_code,
CASE
WHEN e.relationship = 'self' THEN 1
WHEN e.relationship = 'spouse' THEN 2
ELSE 3
END;
";
$results = $this->db->query($query)->getResultArray();
return $results;
}
}

View File

@ -35,6 +35,7 @@ class EmployeePolicyModel extends Model
"claim_status",
'ecard_sent_status',
'payable_employee',
'file_id'
];
// Callbacks
@ -179,7 +180,11 @@ class EmployeePolicyModel extends Model
$result->where('employee_polices.is_active', 1)
->where('emp.is_active', 1);
return $result->findAll();
$res = $result->findAll();
// dd($this->db->getLastQuery());
return $res;
}
public function getEmployeePolicyForEcard($policy_id = 0)
@ -275,7 +280,7 @@ class EmployeePolicyModel extends Model
employee_polices.uhid,
employee_polices.pre_existing_alignments,
employee_polices.basic_cover_si,
employee_polices.date_coverage,
employee_polices.date_coverage as date_of_coverage,
employee_polices.policy_end_date,
employee_polices.days as no_of_days,
employee_polices.premium,
@ -322,6 +327,9 @@ class EmployeePolicyModel extends Model
}else{
$results = $query->getResult();
}
// dd($this->db->getLastQuery());
return $results;
}
@ -556,6 +564,175 @@ class EmployeePolicyModel extends Model
}
// DO NOT DELETE this DELETION QUERY FUNCTION
// public function getDeletionEmployeeDataForExportExcel($ref_data, $return_type = 0)
// {
// $client_id = $ref_data['client_id'];
// $client_policy_id = $ref_data['client_policy_id'];
// $client_branch_id = $ref_data['client_branch_id'];
// $insurer_or_tpa = $ref_data['insurer_or_tpa'];
// $get_insurer_id_from_client_policy = $this->db->table('client_policy')
// ->select('insurer_id')
// ->where('id', $client_policy_id)
// ->get()
// ->getRowArray();
// $add_one_day = 0;
// if (!empty($get_insurer_id_from_client_policy)) {
// $get_the_insurer_add_one_for_delete = $this->db->table('insurers')
// ->select('deletion_add_day')
// ->where('id', $get_insurer_id_from_client_policy['insurer_id'])
// ->get()
// ->getRowArray();
// if (!empty($get_the_insurer_add_one_for_delete) && $get_the_insurer_add_one_for_delete['deletion_add_day'] == 1) {
// $add_one_day = 1;
// }
// }
// $status_condition = "{$insurer_or_tpa}" === 'tpa'
// ? "employee_polices.status = 'inactive' AND employees.emp_status = 'inactive'"
// : "employee_polices.status = 'active' AND employees.emp_status = 'active'";
// $endorsement_condition = "{$insurer_or_tpa}" === 'tpa' ? "AND (a.endorsement_id IS NOT NULL OR a.endorsement_id != '')" : "AND (a.endorsement_id IS NULL OR a.endorsement_id = '')";
// $query = $this->db->query("
// SELECT DISTINCT
// a.id as endorsement_primarykey,
// a.group_key,
// employee_polices.id as primaryKey,
// employees.name AS emp_name,
// employees.emp_code AS emp_code,
// employees.dob AS emp_dob,
// employees.gender AS emp_gender,
// employees.relationship AS emp_relationship,
// employees.relationship_code AS emp_relationship_code,
// employees.emp_type as emp_type,
// 'D' as event_type_data,
// TIMESTAMPDIFF(YEAR, employees.dob, CURDATE()) AS emp_age,
// employees.doj AS emp_doj,
// employees.mobile AS emp_mobile,
// employees.email_corporate AS emp_email_c,
// employees.email_personal AS emp_email_p,
// employees.band AS emp_grade,
// employees.designation AS emp_designation,
// employees.basic_pay AS emp_basic_pay,
// employee_polices.basic_cover_si,
// employee_polices.uhid as uhid,
// employee_polices.policy_end_date,
// employee_polices.rata_premimum as premium,
// employee_polices.claim_status,
// batch_data.emp_policy_id AS emp_policy_id,
// batch_data.bl AS batch_list_batch_code,
// batch_data.bf AS batch_files_batch_code,
// deletiondata.empstatus,
// deletiondata.changeevent,
// deletiondata.dateofexit,
// deletiondata.reasonforexit,
// deletiondata.status,
// DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + '$add_one_day' AS no_of_days,
// CASE
// WHEN employee_polices.claim_status = 0 THEN
// ROUND((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365, 2)
// ELSE
// 0
// END AS pro_rata_premium,
// CASE
// WHEN employee_polices.claim_status = 0 THEN
// ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18, 2)
// ELSE
// 0
// END AS gst,
// CASE
// WHEN employee_polices.claim_status = 0 THEN
// ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) +
// (((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18), 2)
// ELSE
// 0
// END AS total,
// CASE
// WHEN employee_polices.claim_status = 0 THEN
// 'No claim'
// ELSE
// 'Claim'
// END AS claim_status
// FROM
// emp_endorsement a
// LEFT JOIN
// employees ON a.emp_code = employees.emp_code
// LEFT JOIN
// employee_polices ON employees.id = employee_polices.employee_id
// LEFT JOIN(
// select aa.emp_code, aa.new_value as 'empstatus', bb.new_value as 'changeevent', cc.new_value as 'dateofexit', dd.new_value as 'reasonforexit', ee.new_value as 'status' from
// ( SELECT a1.emp_code, a1.field_name, a1.new_value from emp_endorsement as a1 where a1.field_name = 'emp_status' and a1.status != 'truncated') aa
// left join
// ( SELECT b1.emp_code, b1.field_name, b1.new_value from emp_endorsement as b1 where b1.field_name = 'change_event' and b1.status != 'truncated') bb on aa.emp_code = bb.emp_code
// left join
// ( SELECT c1.emp_code, c1.field_name, c1.new_value from emp_endorsement as c1 where c1.field_name = 'date_of_exit' and c1.status != 'truncated') cc on aa.emp_code = cc.emp_code
// left join
// ( SELECT d1.emp_code, d1.field_name, d1.new_value from emp_endorsement as d1 where d1.field_name = 'reason_for_exit' and d1.status != 'truncated') dd on aa.emp_code = dd.emp_code
// left JOIN
// ( SELECT e1.emp_code, e1.field_name, e1.new_value from emp_endorsement as e1 where e1.field_name = 'status' and e1.status != 'truncated') ee on aa.emp_code = ee.emp_code
// ) as deletiondata on a.emp_code = deletiondata.emp_code and a.status != 'truncated'
// LEFT JOIN
// (
// SELECT
// batch_list.emp_policy_id,
// batch_list.batch_code AS bl,
// batch_files.batch_code AS bf
// FROM
// batch_files
// LEFT JOIN
// batch_list ON batch_files.batch_code = batch_list.batch_code
// WHERE
// batch_files.event_type = 'deletion'
// AND batch_files.actions = 'export'
// AND batch_files.insurer_or_tpa = '{$insurer_or_tpa}'
// ) AS batch_data ON employee_polices.id = batch_data.emp_policy_id
// WHERE employee_polices.client_policy_id = {$client_policy_id}
// AND employees.client_branch_id = {$client_branch_id}
// $endorsement_condition
// AND a.actions = 'd'
// AND a.status != 'truncated'
// AND employee_polices.is_active = 1
// AND employees.is_active = 1
// AND $status_condition
// group by group_key
// ");
// if($return_type == 1){
// $result = $query->getResultArray();
// }else{
// $result = $query->getResult();
// }
// // dd($this->db->getLastQuery(), $result);
// return $result;
// }
public function getDeletionEmployeeDataForExportExcel($ref_data, $return_type = 0)
{
@ -630,26 +807,26 @@ class EmployeePolicyModel extends Model
deletiondata.dateofexit,
deletiondata.reasonforexit,
deletiondata.status,
deletiondata.claimstatus,
DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + '$add_one_day' AS no_of_days,
CASE
WHEN employee_polices.claim_status = 0 THEN
WHEN deletiondata.claimstatus = 0 THEN
ROUND((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365, 2)
ELSE
0
END AS pro_rata_premium,
CASE
WHEN employee_polices.claim_status = 0 THEN
WHEN deletiondata.claimstatus = 0 THEN
ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18, 2)
ELSE
0
END AS gst,
CASE
WHEN employee_polices.claim_status = 0 THEN
WHEN deletiondata.claimstatus = 0 THEN
ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) +
(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18), 2)
ELSE
@ -657,7 +834,7 @@ class EmployeePolicyModel extends Model
END AS total,
CASE
WHEN employee_polices.claim_status = 0 THEN
WHEN deletiondata.claimstatus = 0 THEN
'No claim'
ELSE
'Claim'
@ -666,28 +843,32 @@ class EmployeePolicyModel extends Model
FROM
emp_endorsement a
LEFT JOIN
employees ON a.emp_code = employees.emp_code and a.pk = employees.id
employee_polices ON a.pk = employee_polices.id
LEFT JOIN
employee_polices ON employees.id = employee_polices.employee_id
LEFT JOIN(
select aa.emp_code, aa.new_value as 'empstatus', bb.new_value as 'changeevent', cc.new_value as 'dateofexit', dd.new_value as 'reasonforexit', ee.new_value as 'status' from
( SELECT a1.emp_code, a1.field_name, a1.new_value from emp_endorsement as a1 where a1.field_name = 'emp_status' and a1.status != 'truncated') aa
left join
( SELECT b1.emp_code, b1.field_name, b1.new_value from emp_endorsement as b1 where b1.field_name = 'change_event' and b1.status != 'truncated') bb on aa.emp_code = bb.emp_code
left join
( SELECT c1.emp_code, c1.field_name, c1.new_value from emp_endorsement as c1 where c1.field_name = 'date_of_exit' and c1.status != 'truncated') cc on aa.emp_code = cc.emp_code
left join
( SELECT d1.emp_code, d1.field_name, d1.new_value from emp_endorsement as d1 where d1.field_name = 'reason_for_exit' and d1.status != 'truncated') dd on aa.emp_code = dd.emp_code
left JOIN
( SELECT e1.emp_code, e1.field_name, e1.new_value from emp_endorsement as e1 where e1.field_name = 'status' and e1.status != 'truncated') ee on aa.emp_code = ee.emp_code
) as deletiondata on a.emp_code = deletiondata.emp_code and a.status != 'truncated'
employees ON employee_polices.employee_id = employees.id
LEFT JOIN (
SELECT
emp_code,
group_key,
MAX(CASE WHEN field_name = 'emp_status' THEN new_value END) AS empstatus,
MAX(CASE WHEN field_name = 'change_event' THEN new_value END) AS changeevent,
MAX(CASE WHEN field_name = 'date_of_exit' THEN new_value END) AS dateofexit,
MAX(CASE WHEN field_name = 'reason_for_exit' THEN new_value END) AS reasonforexit,
MAX(CASE WHEN field_name = 'status' THEN new_value END) AS status,
MAX(CASE WHEN field_name = 'claim_status' THEN new_value END) AS claimstatus
FROM
emp_endorsement
WHERE
status != 'truncated'
GROUP BY
group_key
) AS deletiondata
ON a.emp_code = deletiondata.emp_code AND a.status != 'truncated'
LEFT JOIN
(
(
SELECT
batch_list.emp_policy_id,
batch_list.batch_code AS bl,
@ -700,7 +881,7 @@ class EmployeePolicyModel extends Model
batch_files.event_type = 'deletion'
AND batch_files.actions = 'export'
AND batch_files.insurer_or_tpa = '{$insurer_or_tpa}'
) AS batch_data ON employee_polices.id = batch_data.emp_policy_id
) AS batch_data ON employee_polices.id = batch_data.emp_policy_id
WHERE employee_polices.client_policy_id = {$client_policy_id}
AND employees.client_branch_id = {$client_branch_id}
@ -720,6 +901,7 @@ class EmployeePolicyModel extends Model
}
// dd($this->db->getLastQuery(), $result);
// dd($result);
return $result;
@ -742,6 +924,7 @@ class EmployeePolicyModel extends Model
ee.id as emp_endorsement_primarykey,
ep.id as emp_policy_primarykey,
e.id as employees_primarykey,
ee.file_id,
ee.group_key,
(
SELECT employees.id
@ -769,7 +952,12 @@ class EmployeePolicyModel extends Model
CASE
WHEN ee.field_name = 'status' THEN ee.new_value
END
) AS status
) AS status,
MAX(
CASE
WHEN ee.field_name = 'claim_status' THEN ee.new_value
END
) AS claim_status
FROM
emp_endorsement AS ee
JOIN employee_polices AS ep ON ep.id = ee.pk
@ -779,7 +967,7 @@ class EmployeePolicyModel extends Model
AND ep.client_policy_id = '$client_policy_id'
AND e.client_branch_id = '$client_branch_id'
AND ee.name = '$emp_name'
AND ee.field_name IN ('date_of_exit', 'reason_for_exit', 'status')
AND ee.field_name IN ('date_of_exit', 'reason_for_exit', 'status', 'claim_status')
AND ep.is_active = 1
AND ep.status = 'active'
AND e.is_active = 1
@ -837,7 +1025,6 @@ class EmployeePolicyModel extends Model
e.remarks,
e.endorsement_id,
ep.client_policy_id,
policies.name as policy_name,
insurers.short_name as insurer_short_name,
client_policy.policy_no,
policy_type.policy_type
@ -847,9 +1034,9 @@ class EmployeePolicyModel extends Model
$query1->join('employees', 'employees.id = ep.employee_id');
$query1->join('client_policy', 'client_policy.id = ep.client_policy_id');
$query1->join('client_branch', 'client_branch.id = employees.client_branch_id');
$query1->join('policies', 'policies.id = client_policy.policy_id');
$query1->join('policy_type', 'policy_type.id = policies.policy_type_id');
$query1->join('insurers', 'insurers.id = policies.insurer_id');
// $query1->join('policies', 'policies.id = client_policy.policy_id');
$query1->join('policy_type', 'policy_type.id = client_policy.policy_type_id');
$query1->join('insurers', 'insurers.id = client_policy.insurer_id');
$query1->whereIn('e.actions', ['c']);
$query1->where('ep.client_policy_id', $policy_id);
$query1->where('employees.client_id', $client_id);
@ -874,7 +1061,6 @@ class EmployeePolicyModel extends Model
e.endorsement_id,
e.remarks,
ep.client_policy_id,
policies.name as policy_name,
insurers.short_name as insurer_short_name,
client_policy.policy_no,
policy_type.policy_type
@ -883,10 +1069,10 @@ class EmployeePolicyModel extends Model
$query2->join('employees', 'employees.id = ep.employee_id');
$query2->join('client_policy', 'client_policy.id = ep.client_policy_id');
$query2->join('client_branch', 'client_branch.id = employees.client_branch_id');
$query2->join('policies', 'policies.id = client_policy.policy_id');
$query2->join('policy_type', 'policy_type.id = policies.policy_type_id');
$query2->join('insurers', 'insurers.id = policies.insurer_id');
$query2->whereIn('e.actions', ['si', 'd']);
// $query2->join('policies', 'policies.id = client_policy.policy_id');
$query2->join('policy_type', 'policy_type.id = client_policy.policy_type_id');
$query2->join('insurers', 'insurers.id = client_policy.insurer_id');
$query2->whereIn('e.actions', ['si', 'd', 'a']);
$query2->where('ep.client_policy_id', $policy_id);
$query2->where('employees.client_id', $client_id);
$query2->where('employees.client_branch_id', $branch_id);
@ -900,6 +1086,8 @@ class EmployeePolicyModel extends Model
$results2 = $query2->get()->getResultArray();
$results = array_merge($results1, $results2);
// dd($this->db->getLastQuery());
return $results;
@ -1180,13 +1368,13 @@ class EmployeePolicyModel extends Model
return "WHEN group_key = $id THEN $endorsement_id";
}, $escapedIds, $escapedEndorsementIds);
$caseStatus = array_map(function ($id, $status) {
return "WHEN status = $id THEN $status";
}, $escapedIds, $escapedStatuses);
// $caseStatus = array_map(function ($id, $status) {
// return "WHEN status = $id THEN $status";
// }, $escapedIds, $escapedStatuses);
// Convert cases to a string
$caseEndorsementIdString = implode(' ', $caseEndorsementId);
$caseStatusString = implode(' ', $caseStatus);
// $caseStatusString = implode(' ', $caseStatus);
// Convert ids to a string
$idsString = implode(', ', $escapedIds);
@ -1196,10 +1384,12 @@ class EmployeePolicyModel extends Model
UPDATE emp_endorsement
SET
endorsement_id = CASE {$caseEndorsementIdString} END,
status = CASE {$caseStatusString} END
status = 'complete'
WHERE group_key IN ({$idsString})
";
// dd($sql);
// Begin a transaction
$this->db->transBegin();
@ -1216,6 +1406,7 @@ class EmployeePolicyModel extends Model
// Otherwise, commit
$this->db->transCommit();
}
// $this->storeEndorsementNumber($file_id, $endorsement_id, $enrollment_file_id);
return $this->db->getLastQuery();
} catch (\Exception $e) {
@ -1287,5 +1478,209 @@ class EmployeePolicyModel extends Model
}
//for truncate get deletion data
public function getDeletionDataForTruncated($file_id)
{
// Fetch the necessary details in a single query using JOINs
$result = $this->db->table('files f')
->select('i.deletion_add_day')
->join('client_policy cp', 'cp.id = f.policy_id', 'left')
->join('insurers i', 'i.id = cp.insurer_id', 'left')
->where('f.id', $file_id)
->get()
->getRowArray();
// Determine if one day should be added for deletion
$add_one_day = (!empty($result) && $result['deletion_add_day'] == 1) ? 1 : 0;
$query = $this->db->query("
SELECT DISTINCT
a.id as endorsement_primarykey,
a.group_key,
employee_polices.id as primaryKey,
employees.name AS emp_name,
employees.emp_code AS emp_code,
employees.dob AS emp_dob,
employees.gender AS emp_gender,
employees.relationship AS emp_relationship,
employees.relationship_code AS emp_relationship_code,
employees.emp_type as emp_type,
'D' as event_type_data,
TIMESTAMPDIFF(YEAR, employees.dob, CURDATE()) AS emp_age,
employees.doj AS emp_doj,
employees.mobile AS emp_mobile,
employees.email_corporate AS emp_email_c,
employees.email_personal AS emp_email_p,
employees.band AS emp_grade,
employees.designation AS emp_designation,
employees.basic_pay AS emp_basic_pay,
employee_polices.basic_cover_si,
employee_polices.uhid as uhid,
employee_polices.policy_end_date,
employee_polices.rata_premimum as premium,
employee_polices.claim_status,
deletiondata.empstatus,
deletiondata.changeevent,
deletiondata.dateofexit,
deletiondata.reasonforexit,
deletiondata.status,
deletiondata.claimstatus,
DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + '$add_one_day' AS no_of_days,
CASE
WHEN deletiondata.claimstatus = 0 THEN
ROUND((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365, 2)
ELSE
0
END AS pro_rata_premium,
CASE
WHEN deletiondata.claimstatus = 0 THEN
ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18, 2)
ELSE
0
END AS gst,
CASE
WHEN deletiondata.claimstatus = 0 THEN
ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) +
(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18), 2)
ELSE
0
END AS total,
CASE
WHEN deletiondata.claimstatus = 0 THEN
'No claim'
ELSE
'Claim'
END AS claim_status
FROM
emp_endorsement a
LEFT JOIN
employee_polices ON a.pk = employee_polices.id
LEFT JOIN
employees ON employee_polices.employee_id = employees.id
LEFT JOIN (
SELECT
emp_code,
group_key,
MAX(CASE WHEN field_name = 'emp_status' THEN new_value END) AS empstatus,
MAX(CASE WHEN field_name = 'change_event' THEN new_value END) AS changeevent,
MAX(CASE WHEN field_name = 'date_of_exit' THEN new_value END) AS dateofexit,
MAX(CASE WHEN field_name = 'reason_for_exit' THEN new_value END) AS reasonforexit,
MAX(CASE WHEN field_name = 'status' THEN new_value END) AS status,
MAX(CASE WHEN field_name = 'claim_status' THEN new_value END) AS claimstatus
FROM
emp_endorsement
WHERE
status != 'truncated'
GROUP BY
group_key
) AS deletiondata
ON a.emp_code = deletiondata.emp_code AND a.status != 'truncated'
WHERE a.file_id = {$file_id}
AND a.actions = 'd'
AND a.status != 'truncated'
AND employee_polices.is_active = 1
AND employees.is_active = 1
group by group_key
");
$result = $query->getResultArray();
// dd($this->db->getLastQuery(), $result);
// dd($result);
return $result;
}
//for truncate get addition data
public function getAdditionDataForTruncated($file_id, $event_type)
{
$action = "a";
if($event_type == "dependent_addition"){
$action = "da";
}
$query = $this->db->query("
SELECT
ROUND(SUM(ep.rata_premimum + ep.gst), 2) AS total
FROM
emp_endorsement ee
JOIN
employee_polices ep ON ee.pk = ep.id
WHERE
ee.file_id = $file_id
AND ee.actions = '$action'
AND ep.status != 'truncated'
AND ee.status != 'truncated'
AND ee.is_active = 1
AND ep.is_active = 1;
");
$result = $query->getResultArray();
// dd($this->db->getLastQuery(), $result);
// dd($result);
return $result[0];
}
// reverse the employee policy table data for the truncated the deletion file
public function updateEmployeePolicyTruncateReverse($file_id)
{
$this->db->query("
UPDATE employee_polices
SET
is_active = 1,
status = 'active',
date_of_exit = NULL,
reason_for_exit = NULL,
claim_status = 0,
WHERE
id IN (
SELECT pk
FROM emp_endorsement
WHERE file_id = $file_id
GROUP BY group_key
)
AND status = 'inactive'
");
}
//update employee policy table status truncated and is_active 0 for truncated to the addition file
public function updateEmpEndorsementAddition($array)
{
$caseStatus = "CASE ";
$caseEndorsementId = "CASE ";
$ids = [];
foreach ($array as $item) {
$caseStatus .= "WHEN id = {$item['id']} THEN '{$item['status']}' ";
$caseEndorsementId .= "WHEN id = {$item['id']} THEN '{$item['endorsement_id']}' ";
$ids[] = $item['id'];
}
$caseStatus .= "END";
$caseEndorsementId .= "END";
$ids = implode(',', $ids);
$query = "UPDATE emp_endorsement SET status = $caseStatus, endorsement_id = $caseEndorsementId WHERE id IN ($ids);"; // Execute the query
$this->db->query($query);
}
}

View File

@ -41,11 +41,12 @@ class InsurerModel extends Model
{
// Fetch the insurer name based on the insurer ID
$query = $this->db->table('client_policy')
->select('insurers.id, insurers.name, cd_master.cd_ac_no')
->select('insurers.id, insurers.name, cd_master.cd_ac_no as cd_master_account_no')
->join('insurers', 'insurers.id = client_policy.insurer_id')
->join('cd_master', 'cd_master.insurer_id = insurers.id AND cd_master.client_id = client_policy.client_id')
->where('client_policy.insurer_id', $insurerId)
->where('client_policy.client_id', $client_id)
->where('cd_master.id = client_policy.cd_ac_pk')
->get();
if ($query->resultID->num_rows > 0) {
@ -60,7 +61,7 @@ class InsurerModel extends Model
{
$insurer_data = $this->db->table('insurer_excel_export_template')
->select('insurer_excel_export_template.*, insurers.name as insurer_name, insurers.is_multi_event')
->select('CASE WHEN insurers.is_multi_event = 1 THEN "All" ELSE insurer_excel_export_template.event_name END as event_name', false)
// ->select('CASE WHEN insurers.is_multi_event = 1 THEN "All" ELSE insurer_excel_export_template.event_name END as event_name', false)
->select('insurer_excel_export_template.type_name, insurer_excel_export_template.jsoncolumns, policy_type.policy_type')
->join('insurers', 'insurers.id = insurer_excel_export_template.insurer_id')
->join('policy_type', 'policy_type.id = insurer_excel_export_template.policy_type_id')

View File

@ -23,7 +23,11 @@ class InsurerStatements extends Model
"invoice_no",
"invoice_amount",
"invoice_date",
"updated_by"
"updated_by",
"stmt_sno",
"gst_per",
"gst_value",
"invoice_value"
];

View File

@ -16,6 +16,7 @@ class InvPaymentDetailsModel extends Model
'inv_amt',
'utr_no',
'tds',
'gst',
'received_date',
'created_by',
'is_active',

View File

@ -37,7 +37,7 @@ class LeadsModel extends Model
'policy_start_date',
'policy_end_date',
'no_of_lives',
'claims',
'incurred_claims',
'location',
'proposed_insurer_id',
'proposed_insurer_branch_id',
@ -52,6 +52,38 @@ class LeadsModel extends Model
'updated_by',
'is_active',
'is_client_created',
'renewal_emp_count',
'renewal_dept_count',
'renewal_no_of_lives',
'incept_emp_count',
'incept_dept_count',
'incept_no_of_lives',
'exp_emp_count',
'exp_dept_count',
'exp_no_of_lives',
'file_name',
'incurred_claims_date',
'paid_claims',
'outstanding_claims',
'policy_run_days',
'premium_at_inception',
'premium_date',
'earned_premium',
'annualised_claims',
'incurred_claims_ratio',
'earned_claims_ratio',
'placement_date',
'utr_no',
'premium_amount',
'total_amount',
'cd_amount',
'total_si_at_incept',
'total_si_at_renewal',
'fin_years_claims',
];

View File

@ -63,11 +63,15 @@ class PTCOShareDetailsModel extends Model
'amount',
'stamp_duty',
'cop_amt',
'statement_id'
'statement_id',
'follower_policy_no',
];
public function getNonReconcileredPolicyTransactions(string $month,string $year,string $insurer_id,string $insurer_branch_id)
public function getNonReconcileredPolicyTransactions(string $insurer_id,string $insurer_branch_id)
{
$currentDate = date('Y-m-d');
$sixMonthsAgo = date('Y-m-01', strtotime('-6 months'));
return $this->db->table('pt_co_share_details pt_co')
->select('
pt_co.id,
@ -93,12 +97,15 @@ class PTCOShareDetailsModel extends Model
->join('policy_transaction pt', 'pt_co.pt_id = pt.id')
->join('clients c', 'pt.client_id = c.id')
->where('pt_co.is_active', 1)
->where('MONTH(pt.month)', $month)
->where('YEAR(pt.month)', $year)
->where('pt.is_active', 1)
// ->where('MONTH(pt.month)', $month)
// ->where('YEAR(pt.month)', $year)
->where('pt_co.insurer_id', $insurer_id)
->where('pt_co.insurer_branch_id', $insurer_branch_id)
->where('pt_co.statement_id is null')
// ->where('pt_co.statement_id is null')
->where('pt.status','completed')
->where('DATE(pt.created_at) >=', $sixMonthsAgo)
->where('DATE(pt.created_at) <=', $currentDate)
// ->where('pt_co.exp_amt', 0.00)
// ->orWhere('pt_co.exp_amt is null')
->get()

View File

@ -76,6 +76,7 @@ class PolicyTransactionModel extends Model
'ct_tran_id',
'remarks',
'month',
'cd_ac_pk'
];
@ -113,8 +114,9 @@ class PolicyTransactionModel extends Model
return $data;
}
// BDS Report OLD Functin for QUERY
// public function getBDSReportList($client_id, $policy_id, $branch_id, $issuer)
public function getBDSReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0)
public function getBDSReportListOld($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0)
{
$builder = $this->db->table('policy_transaction')
->select("
@ -311,6 +313,257 @@ class PolicyTransactionModel extends Model
return $builder->get()->getResultArray();
}
// BDS Report NEW Functin for QUERY
// public function getBDSReportList($client_id, $policy_id, $branch_id, $issuer)
public function getBDSReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $client_branch_id = 0, $insurer_branch_id = 0, $client_policy_id = 0)
{
$date_condition = '';
if($date_type == 'statement_month' && $start_date != 0 && $end_date != 0) {
$date_condition = "
AND insurer_statements.month >= '".$start_date ."'
AND insurer_statements.month <= '".$end_date ."'
";
}
$builder = $this->db->table('policy_transaction')
->select("
policy_transaction.*,
DATE_FORMAT(policy_transaction.policy_issue_date, '%d %b %Y') AS policy_issue_date,
DATE_FORMAT(
IF(policy_transaction.month IS NULL,
policy_transaction.policy_issue_date,
policy_transaction.month),
'%b %Y') AS policy_issue_month,
CASE
WHEN clients.client_type = 1 THEN 'Group'
WHEN clients.client_type = 2 THEN 'Retail'
ELSE '-'
END AS client_type,
CASE
WHEN policy_transaction.revenue_type = 'NA' THEN 'Fresh'
ELSE 'Renewal'
END AS revenue_type,
CASE
WHEN policy_transaction.action_type = 'inception' THEN 'Policy'
ELSE 'Endorsement'
END AS action_type,
clients.client_name AS client_name,
clients.short_name AS client_short_name,
client_branch.branch_name AS client_branch_name,
client_branch.address1 AS client_address,
policy_type.policy_type,
policy_type.bap,
insurers.name AS insurer_name,
insurers.short_name AS insurer_short_name,
insurer_branch.branch_name AS insurer_branch_name,
insurer_branch.branch_code AS insurer_branch_code,
user_profiles.first_name as user_name,
vehicle.vehicle_no,
tpa.name as tpa_name,
pt_co_share_details.remark as remarks,
pt_co_share_details.reward,
pt_co_share_details.bp_amt,
pt_co_share_details.exp_amt,
pt_co_share_details.id as pt_id,
sales_user.first_name as salse_person_name,
service_user.first_name as service_person_name,
ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) AS premium_wo_gst,
ROUND((ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) * 18 / 100), 2) AS gst_amount,
ROUND((ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) + ROUND((ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) * 18 / 100), 2)), 2) AS total_premium,
ROUND((pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) AS tp_or_ter,
DATEDIFF(policy_transaction.policy_end_date, CURDATE()) AS days,
(pt_co_share_details.agreed_tp_per + pt_co_share_details.agreed_tep_per) AS agreed_tp_or_ter_per,
pt_co_share_details.agreed_bp_per,
ROUND(
(
SELECT
(
SUM(co_share_stmt_details.actual_bp_brokerage_amt) +
SUM(co_share_stmt_details.actual_tp_brokerage_amt) +
SUM(co_share_stmt_details.actual_tep_brokerage_amt) +
SUM(co_share_stmt_details.reward)
) AS total_irda_amt
FROM
co_share_stmt_details
JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
WHERE
co_share_stmt_details.co_share_id = pt_co_share_details.id
AND co_share_stmt_details.is_active = 1
AND insurer_statements.is_active = 1
$date_condition
),
2
) AS total_irda_amt,
ROUND(
(
SELECT
SUM(
COALESCE(co_share_stmt_details.actual_bp_brokerage_amt, 0) +
COALESCE(co_share_stmt_details.actual_tp_brokerage_amt, 0) +
COALESCE(co_share_stmt_details.actual_tep_brokerage_amt, 0) +
COALESCE(co_share_stmt_details.reward, 0)
) AS total_irda_amt
FROM
co_share_stmt_details
JOIN pt_co_share_details AS pt_table ON co_share_stmt_details.co_share_id = pt_table.id
JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
WHERE
co_share_stmt_details.co_share_id = pt_co_share_details.id
AND co_share_stmt_details.is_active = 1
AND pt_table.is_active = 1
AND insurer_statements.is_active = 1
AND insurer_statements.invoice_no IS NOT NULL
$date_condition
),
2
) AS billed_amt,
ROUND(
(
(
SELECT
SUM(
COALESCE(co_share_stmt_details.actual_bp_brokerage_amt, 0)
+ COALESCE(co_share_stmt_details.actual_tp_brokerage_amt, 0)
+ COALESCE(co_share_stmt_details.actual_tep_brokerage_amt, 0)
+ COALESCE(co_share_stmt_details.reward, 0)
)
FROM
co_share_stmt_details
JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
WHERE
co_share_stmt_details.co_share_id = pt_co_share_details.id
AND co_share_stmt_details.is_active = 1
$date_condition
)
-
(
SELECT
SUM(
COALESCE(co_share_stmt_details.actual_bp_brokerage_amt, 0)
+ COALESCE(co_share_stmt_details.actual_tp_brokerage_amt, 0)
+ COALESCE(co_share_stmt_details.actual_tep_brokerage_amt, 0)
+ COALESCE(co_share_stmt_details.reward, 0)
)
FROM
co_share_stmt_details
JOIN pt_co_share_details AS pt_table ON co_share_stmt_details.co_share_id = pt_table.id
JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
WHERE
co_share_stmt_details.co_share_id = pt_co_share_details.id
AND co_share_stmt_details.is_active = 1
AND pt_table.is_active = 1
AND insurer_statements.is_active = 1
AND insurer_statements.invoice_no IS NULL
$date_condition
)
),
2
) AS unbilled_amt
")
->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
->join('insurer_statements', 'pt_co_share_details.statement_id = insurer_statements.id', 'left')
->join('clients', 'clients.id = policy_transaction.client_id')
->join('client_branch', 'policy_transaction.client_branch_id = client_branch.id', 'left')
->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
->join('user_profiles', 'policy_transaction.created_by = user_profiles.id', 'left')
->join('vehicle', 'policy_transaction.vehicle_id = vehicle.id', 'left')
->join('policy_type', 'policy_transaction.policy_type_id = policy_type.id', 'left')
->join('insurers', 'policy_transaction.insurer_id = insurers.id', 'left')
->join('insurer_branch', 'policy_transaction.insurer_branch_id = insurer_branch.id', 'left')
->join('tpa', 'policy_transaction.tpa_id = tpa.id', 'left')
->join('tpa_branch', 'policy_transaction.tpa_branch_id = tpa_branch.id', 'left')
->join('user_profiles AS sales_user', 'policy_transaction.sales_generated_by = sales_user.id', 'left')
->join('user_profiles AS service_user', 'policy_transaction.serviced_by = service_user.id', 'left')
->where('policy_transaction.is_active', 1)
->where('pt_co_share_details.is_active', 1);
// Check if the start date and end date are provided
if ($start_date != 0 && $end_date != 0 && $date_type != 0 && $date_type != 'statement_month') {
$startDate = date('Y-m-d 00:00:00', strtotime($start_date));
$endDate = date('Y-m-d 23:59:59', strtotime($end_date));
$builder->where('policy_transaction.'.$date_type.'>=', $startDate)
->where('policy_transaction.'.$date_type.'<=', $endDate);
}else{
// $fromDate = date('Y-m-d', strtotime('-30 days'));
// $toDate = date('Y-m-d 23:59:59');
// $builder->where('policy_transaction.created_at >=', $fromDate)
// ->where('policy_transaction.created_at <=', $toDate);
}
if($date_type == 'statement_month' && $start_date != 0 && $end_date != 0){
$builder->where('policy_transaction.month >=', $startDate)
->where('policy_transaction.month <=', $endDate);
}
if ($client_id != 0) {
$builder->where('policy_transaction.client_id', $client_id);
}
if ($insurer_id != 0) {
$builder->where('policy_transaction.insurer_id', $insurer_id);
}
if ($client_branch_id != 0) {
$builder->where('policy_transaction.client_branch_id', $client_branch_id);
}
if ($insurer_branch_id != 0) {
$builder->where('policy_transaction.insurer_branch_id', $insurer_branch_id);
}
if ($client_policy_id != 0) {
$builder->where('policy_transaction.client_policy_id', $client_policy_id);
}
if ($policy_type_id != 0) {
$builder->where('client_policy.policy_type_id', $policy_type_id);
}
if ($issuer != 0) {
$builder->where('policy_transaction.issuer', $issuer);
}
if($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0){
$fromDate = date('Y-m-d', strtotime('-30 days'));
$toDate = date('Y-m-d 23:59:59');
$builder->where('policy_transaction.created_at >=', $fromDate)
->where('policy_transaction.created_at <=', $toDate);
}
$builder->orderBy('policy_transaction.id', 'desc');
$result = $builder->get()->getResultArray();
// dd($this->db->getLastQuery());
return $result;
}
public function getInceptionTranctionListData($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
{
@ -466,50 +719,74 @@ class PolicyTransactionModel extends Model
return $builder->get()->getResultArray();
}
public function getVarienceReportLIst($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
public function getVarienceReportLIst($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $client_branch_id = 0, $insurer_branch_id = 0, $client_policy_id = 0)
{
$builder = $this->db->table('policy_transaction')
->select("
policy_transaction.id,
clients.client_name,
client_branch.branch_name as client_branch_name,
insurers.name AS insurer_name,
insurer_branch.branch_name AS insurer_branch_name,
policy_type.policy_type,
policy_transaction.policy_no,
policy_transaction.endorsement_no,
CASE
WHEN policy_transaction.action_type = 'inception' THEN 'I'
ELSE 'E'
END AS action_type,
pt_co_share_details.exp_amt,
pt_co_share_details.variance,
insurer_statements.invoice_amount,
insurer_statements.invoice_status,
ROUND((pt_co_share_details.actual_bp_brokerage_amt + pt_co_share_details.actual_tp_brokerage_amt + pt_co_share_details.actual_tep_brokerage_amt), 2) AS realization_amount2,
ROUND(
(
SELECT
(SUM(inv_payment_details.inv_amt) + SUM(inv_payment_details.tds)) AS realization_amount
(
SUM(co_share_stmt_details.actual_bp_brokerage_amt) + SUM(co_share_stmt_details.actual_tp_brokerage_amt) + SUM(co_share_stmt_details.actual_tep_brokerage_amt)
) AS total_irda_amt
FROM
inv_payment_details
co_share_stmt_details
JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
WHERE
inv_payment_details.statement_id = insurer_statements.id
AND inv_payment_details.is_active = 1
) AS realization_amount,
co_share_stmt_details.co_share_id = pt_co_share_details.id
AND co_share_stmt_details.is_active = 1
),
2
) AS statement_amount,
ROUND(
pt_co_share_details.exp_amt -
(
SELECT
(
SUM(co_share_stmt_details.actual_bp_brokerage_amt) +
SUM(co_share_stmt_details.actual_tp_brokerage_amt) +
SUM(co_share_stmt_details.actual_tep_brokerage_amt)
)
FROM co_share_stmt_details
JOIN insurer_statements
ON co_share_stmt_details.statement_id = insurer_statements.id
WHERE
co_share_stmt_details.co_share_id = pt_co_share_details.id
AND co_share_stmt_details.is_active = 1
),
2
) AS variance_amt
")
->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
->join('insurer_statements', 'pt_co_share_details.statement_id = insurer_statements.id', 'left')
->join('inv_payment_details', 'insurer_statements.id = inv_payment_details.statement_id', 'left')
->join('clients', 'clients.id = policy_transaction.client_id', 'left')
->join('client_branch', 'client_branch.id = policy_transaction.client_branch_id', 'left')
->join('insurers', 'pt_co_share_details.insurer_id = insurers.id', 'left')
->join('insurer_branch', 'pt_co_share_details.insurer_branch_id = insurer_branch.id', 'left')
->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
->join('policy_type', 'policy_transaction.policy_type_id = policy_type.id', 'left')
->where('policy_transaction.is_active', 1)
->where('pt_co_share_details.actual_bp_brokerage_amt IS NOT NULL AND pt_co_share_details.actual_bp_brokerage_amt != 0')
->where('pt_co_share_details.variance IS NOT NULL')
->where('pt_co_share_details.variance !=', 0);
->where('pt_co_share_details.is_active', 1)
->having('variance_amt IS NOT NULL');
// ->where('pt_co_share_details.actual_bp_brokerage_amt IS NOT NULL AND pt_co_share_details.actual_bp_brokerage_amt != 0');
// ->where('pt_co_share_details.variance IS NOT NULL')
// ->where('pt_co_share_details.variance !=', 0);
if ($start_date != 0 && $end_date != 0 && $date_type != 0) {
@ -543,9 +820,18 @@ class PolicyTransactionModel extends Model
$builder->where('policy_transaction.issuer', $issuer);
}
if ($status != 0) {
$builder->where('policy_transaction.status', $status);
if ($client_branch_id != 0) {
$builder->where('policy_transaction.client_branch_id', $client_branch_id);
}
if ($insurer_branch_id != 0) {
$builder->where('policy_transaction.insurer_branch_id', $insurer_branch_id);
}
if ($client_policy_id != 0) {
$builder->where('policy_transaction.client_policy_id', $client_policy_id);
}
$builder->orderBy('policy_transaction.id', 'desc');
@ -694,7 +980,7 @@ class PolicyTransactionModel extends Model
return $builder->get()->getResultArray();
}
public function getOutstandingReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
public function getOutstandingReportList_OLD($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
{
$builder = $this->db->table('policy_transaction')
->select("
@ -791,5 +1077,53 @@ class PolicyTransactionModel extends Model
return $builder->get()->getResultArray();
}
public function getOutstandingReportList($start_date = 0, $end_date = 0, $insurer_id = 0,$insurer_branch_id = 0)
{
$builder = $this->db->table('insurer_statements s')
->select('
s.id,
s.insurer_id,
s.branch_id,
ins.short_name,
ib.branch_name,
s.month,
s.line_items,
s.stmt_sno,
s.invoice_status,
s.invoice_date,
s.invoice_no,
s.invoice_amount,
COALESCE(SUM(p.inv_amt) + SUM(p.tds) + SUM(p.gst), 0) AS total_paid,
(s.invoice_amount - COALESCE(SUM(p.inv_amt) + SUM(p.tds) + SUM(p.gst), 0)) AS outstanding_amount
')
->join('inv_payment_details p', 's.id = p.statement_id', 'left')
->join('insurers ins', 's.insurer_id = ins.id')
->join('insurer_branch ib', 's.branch_id = ib.id')
->where('s.is_active', 1)
->where('p.is_active', 1)
->groupBy('s.id, s.invoice_no, s.invoice_date, s.invoice_amount')
->having('outstanding_amount >', 0);
// ->get();
// Date range filtering
if ($start_date != 0 && $end_date != 0) {
$builder->where('s.month >=', $start_date)
->where('s.month <=', $end_date);
}
if ($insurer_id != 0) {
$builder->where('s.insurer_id', $insurer_id);
}
if ($insurer_branch_id != 0) {
$builder->where('s.branch_id', $insurer_branch_id);
}
$builder->orderBy('s.id', 'desc');
return $builder->get()->getResultArray();
}
}

View File

@ -60,14 +60,13 @@ class RFQModel extends Model
public function getRFQTableDataWithLeadIDAndType($lead_id, $type){
return $this->select('
leads.client_name,
leads.client_short_name,
leads.*,
insurers.name as insurer_name,
insurer_branch.branch_name as insurer_branch_name,
tpa.name as tpa_name,
tpa_branch.branch_name as tpa_branch_name,
policy_type.policy_type,
rfq.json
rfq.json,
')
->join('leads', 'rfq.lead_id = leads.id')
->join('policy_type', 'leads.policy_type_id = policy_type.id')
@ -76,7 +75,7 @@ class RFQModel extends Model
->join('tpa', 'leads.tpa_id = tpa.id', 'left')
->join('tpa_branch', 'leads.tpa_branch_id = tpa_branch.id', 'left')
->where('rfq.lead_id', $lead_id)
->where('rfq.type', $type)
// ->where('rfq.type', $type)
->where('rfq.is_active', 1)
->first();

View File

@ -182,7 +182,9 @@ $(document).ready(function () {
$('#tickets-table').DataTable({
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" ,
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" + // Keep your original alignment for the search and buttons
"<'row'<'col-sm-12'tr>>" + // Table rows
"<'row'<'col-sm-6'i><'col-sm-6'p>>",
buttons: [
{
extend: 'csv',

View File

@ -16,6 +16,32 @@ table.dataTable tbody td {
.dataTables_filter {
position: absolute;
}
.custom-dropdown-menu {
display: none;
position: absolute;
background-color: #ffffff !important;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
color: #212529 !important;
text-decoration: none !important;
background-color: transparent !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
</style>
<div class="row">
@ -209,6 +235,97 @@ table.dataTable tbody td {
</div>
</div>
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("scroll-horizontal-datatable");
// Create custom dropdown
function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
// Append the custom dropdown to the body
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
// Hide any active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
// Set as active dropdown
activeDropdown = customDropdown;
event.stopPropagation();
});
// Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
</script>
<script>
// Datatable document ready
$(document).ready(function() {

View File

@ -16,6 +16,32 @@ table.dataTable thead th {
max-width: 98% !important;
}
.custom-dropdown-menu {
display: none;
position: absolute;
background-color: #ffffff !important;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
color: #212529 !important;
text-decoration: none !important;
background-color: transparent !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
</style>
<div class="row" id="client_list">
@ -57,28 +83,18 @@ table.dataTable thead th {
<td><?php echo date('d-M-Y h:i A', strtotime($row['created_at'])) ?> by
<?php echo $row['user_name']; ?></td>
<td>
<?php if($row['cd_ac_no_count'] > 0 && $row['cd_ac_no_count_cd_tranction'] > 1) {?>
<div class="btn-group dropdown">
<!-- <a href="javascript: void(0);"class="dropdown-toggle arrow-none btn btn-light btn-sm"aria-expanded="false"></i></a> -->
<div class="btn-group dropdown">
<a href="javascript: void(0);"class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" data-toggle="modal" data-target="#con-close-modal"> <i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<?php if($row['cd_ac_no_count'] == 0) { ?>
<a class="dropdown-item" data-id="<?= $row['id'];?>" onclick="removeCDMaster(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
<?php } ?>
</div>
<?php } else { ?>
<div class="btn-group dropdown">
<a href="javascript: void(0);"class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<?php if($row['cd_ac_no_count_cd_tranction'] <= 1) { ?>
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" data-toggle="modal" data-target="#con-close-modal"> <i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<?php } ?>
<?php if($row['cd_ac_no_count'] == 0) { ?>
<a class="dropdown-item" data-id="<?= $row['id'];?>" onclick="removeCDMaster(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
<?php } ?>
</div>
</div>
<?php } ?>
</div>
</td>
<?php } ?>
</tr>
<?php } ?>
</tbody>
</table>
</div>
@ -168,9 +184,103 @@ table.dataTable thead th {
</div>
</div>
</div><!-- /.modal -->
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
// Create custom dropdown
function createCustomDropdown(row) {
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
customDropdown.innerHTML = originalDropdown.innerHTML;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
row.customDropdown = customDropdown;
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the last column (action column)
if (event.target.closest('td') === row.lastElementChild) {
return;
}
// Hide any active dropdown
if (activeDropdown && activeDropdown !== customDropdown) {
activeDropdown.style.display = 'none';
}
// Toggle the dropdown display
const isActive = customDropdown.style.display === 'block';
customDropdown.style.display = isActive ? 'none' : 'block';
// Set the position of the dropdown
const rect = event.target.closest('td').getBoundingClientRect();
customDropdown.style.position = 'absolute';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`;
// Set as active dropdown
activeDropdown = isActive ? null : customDropdown;
event.stopPropagation();
});
// Preserve click handlers for modal actions
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const isModalAction = this.hasAttribute('data-toggle') && this.getAttribute('data-toggle') === 'modal';
if (isModalAction) {
return; // Allow modal to function normally
}
// Close the dropdown if it's not related to modal
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
e.stopPropagation();
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
</script>
<script>
$(document).ready(function() {
$('#tickets-table').DataTable({
@ -195,7 +305,6 @@ table.dataTable thead th {
})
$(document).ready(function(){
<?php if (session()->has('error')) : ?>
@ -217,7 +326,6 @@ table.dataTable thead th {
})
$('#btnAdd').click(function(){
$('#client_id').val('');
$('#insurer_id').val('');
@ -231,7 +339,6 @@ table.dataTable thead th {
})
$('.close').click(function(){
$('#CD_Master_ID').val('');
$('#client_id').val('').change();
@ -244,10 +351,10 @@ table.dataTable thead th {
$('#client_id').prop("disabled", false);
$('#insurer_id').prop("disabled", false);
$('#cd_ac_no').prop("disabled", false);
$('#opening_bal').prop("disabled", false)
})
$('body').on('click', '.btnEdit', function () {
var cd_id = $(this).attr('data-id');
@ -270,8 +377,13 @@ table.dataTable thead th {
$('#insurer_id').prop("disabled", true);
$('#opening_date').val(res.data.opening_date);
$('#cd_ac_no').val(res.data.cd_ac_no);
$('#cd_ac_no').prop("disabled", true);
//$('#cd_ac_no').prop("disabled", true);
$('#opening_bal').val(res.data.opening_bal);
if(res.cd_transaction_count <= 1){
$('#opening_bal').prop("disabled", false)
}else{
$('#opening_bal').prop("disabled", true)
}
$('#btnSubmit').html('Update');
},
@ -282,7 +394,6 @@ table.dataTable thead th {
});
});
$('#cd_ac_no').change(function(){
var cd_ac_no = $(this).val();
@ -311,57 +422,55 @@ table.dataTable thead th {
})
function removeCDMaster(element) {
function removeCDMaster(element) {
Swal.fire({
title: "Are you sure?",
text: "You need to remove this CD.",
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes",
}).then((result) => {
Swal.fire({
title: "Are you sure?",
text: "You need to remove this CD.",
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes",
}).then((result) => {
if (result.isConfirmed) {
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("master/cash_deposite/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
// console.log(res.status == true);
if(res){
if (res.status == true) {
toastr.success('CD removed successfully.', 'success');
location.reload();
} else {
toastr.warning('Failed to remove CD.', 'warning');
if (result.isConfirmed) {
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("master/cash_deposite/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
// console.log(res.status == true);
if(res){
if (res.status == true) {
toastr.success('CD removed successfully.', 'success');
location.reload();
} else {
toastr.warning('Failed to remove CD.', 'warning');
}
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log('Something Wrong!', 'warning');
}
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log('Something Wrong!', 'warning');
}
});
}
});
}
});
});
}
}
function onlyNumbers(event) {
var charcode;
charcode = event.which || event.keyCode;
if (charcode >= 48 && charcode <= 57 || charcode == 46) return true;
return false;
}
function onlyNumbers(event) {
var charcode;
charcode = event.which || event.keyCode;
if (charcode >= 48 && charcode <= 57 || charcode == 46) return true;
return false;
}
</script>

View File

@ -33,7 +33,7 @@
<?php foreach ($clientData as $value): ?>
<td><?php echo $value->insurer_name;?></td>
<td><?php echo $value->cd_ac_no;?></td>
<td><?php echo $value->cd_master_account_no;?></td>
<td>
<?php

View File

@ -16,6 +16,33 @@ table.dataTable thead th {
max-width: 98% !important;
}
.custom-dropdown-menu {
display: none;
position: absolute;
background-color: #ffffff !important;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
color: #212529 !important;
text-decoration: none !important;
background-color: transparent !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
</style>
<div class="row" id="client_list">
@ -114,6 +141,123 @@ table.dataTable thead th {
</div>
</div><!-- /.modal -->
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
// Create custom dropdown
function createCustomDropdown(row) {
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
customDropdown.innerHTML = originalDropdown.innerHTML;
// Add 'Open Client Details' option in the dropdown
const clientId = row.querySelector('.client_info').dataset.id;
const openDetailsOption = document.createElement('a');
openDetailsOption.href = "javascript:void(0);";
openDetailsOption.className = 'dropdown-item';
openDetailsOption.innerHTML = `<i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>Open Client Details`;
openDetailsOption.addEventListener('click', function() {
openClientDetailsPage(clientId); // Open the client details page when clicked
});
customDropdown.appendChild(openDetailsOption);
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
// Show the action dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
const rect = event.target.getBoundingClientRect();
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // 5px gap
activeDropdown = customDropdown;
event.stopPropagation();
});
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
// Open client details page
function openClientDetailsPage(clientId) {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$.ajax({
url: "<?= base_url('util/get-client-details/') ?>" + clientId,
type: "GET",
dataType: 'json',
success: function(res) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
$('#append_client_info').empty().append(res.data);
$('#client_info').show();
$('#client_list').hide();
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}
});
}
});
</script>
<script>

View File

@ -533,7 +533,7 @@
var formData = new FormData($('#policy_form')[0]);
var policy_form_action = $('#policy_form_action').val();
console.log(formData+'form data');
$.ajax({
data: formData,
url: policy_form_action,
@ -702,8 +702,8 @@
$.get(url_for_cd, function(response){
//console.log(response)
//console.log(response.data)
// console.log(response)
// console.log(response.data)
if(response.status == false && response.insurer_id != 'undefined'){
toastr.warning('The CD Account Number not found.', 'Warning');
@ -894,14 +894,14 @@
if (res.data.is_addon == 2 || res.data.is_addon == 3) {
$("#insurer").next(".select2-container").css({
'pointer-events': 'none',
'pointer-events': 'auto',
});
$('#select2-insurer-container').css({
'background-color': '#ebebe0',
});
$("#tpa").next(".select2-container").css({
'pointer-events': 'none',
'pointer-events': 'auto',
});
$('#select2-tpa-container').css({
'background-color': '#ebebe0',
@ -1356,7 +1356,7 @@
if ($(this).val() == 4 || $(this).val() == 5) {
$("#insurer").next(".select2-container").css({
'pointer-events': 'none',
'pointer-events': 'auto',
});
$('#select2-insurer-container').css({
@ -1364,7 +1364,7 @@
});
$("#tpa").next(".select2-container").css({
'pointer-events': 'none',
'pointer-events': 'auto',
});
$('#select2-tpa-container').css({
@ -1649,7 +1649,7 @@
$.each(data, function(index, item) {
const option = $('<option>', {
value: item.cd_ac_no,
value: item.id,
text: item.cd_ac_no
});
@ -1927,14 +1927,14 @@
if (res.data.is_addon == 2 || res.data.is_addon == 3) {
$("#insurer").next(".select2-container").css({
'pointer-events': 'none',
'pointer-events': 'auto',
});
$('#select2-insurer-container').css({
'background-color': '#ebebe0',
});
$("#tpa").next(".select2-container").css({
'pointer-events': 'none',
'pointer-events': 'auto',
});
$('#select2-tpa-container').css({
'background-color': '#ebebe0',

View File

@ -18,6 +18,33 @@ table.dataTable tbody td {
color: white !important;
margin-right: 5px;
}
.custom-dropdown-menu {
display: none;
position: absolute;
background-color: #ffffff !important;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
color: #212529 !important;
text-decoration: none !important;
background-color: transparent !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
</style>
<div class="row">
@ -113,7 +140,94 @@ table.dataTable tbody td {
<!-- end row -->
<div id="loader" class="loader" style="display:none;">SPINNER</div>
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
// Create custom dropdown
function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
// Hide any active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
// Set as active dropdown
activeDropdown = customDropdown;
event.stopPropagation();
});
// Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
</script>
<script>
$(document).ready(function() {

View File

@ -7,6 +7,7 @@
.reload:hover {
cursor: pointer;
}
</style>
<div class="col-12">

View File

@ -16,6 +16,32 @@ table.dataTable tbody td {
.dataTables_filter {
position: absolute;
}
.custom-dropdown-menu {
display: none;
position: absolute;
background-color: #ffffff !important;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
color: #212529 !important;
text-decoration: none !important;
background-color: transparent !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
</style>
<div class="row" id="finance_filter">
@ -209,6 +235,98 @@ table.dataTable tbody td {
</div>
</div>
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("scroll-horizontal-datatable");
// Create custom dropdown
function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
// Append the custom dropdown to the body
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
// Hide any active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
// Set as active dropdown
activeDropdown = customDropdown;
event.stopPropagation();
});
// Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
</script>
<script>
// Datatable document ready
$(document).ready(function() {

View File

@ -91,7 +91,7 @@
<tr>
<td><?= $key+1; ?></td>
<td><?= $value['policy_type']; ?></td>
<td><?= $value['event_name']; ?></td>
<td><?= $events[$value['event_name']]; ?></td>
<td><?= $value['type_name']; ?></td>
<td style="overflow: hidden;" class="truncate" ><?= $value['jsoncolumns']; ?></td>
<td>
@ -209,6 +209,8 @@
</div>
<div class="modal-body">
<input type="hidden" id="insurer_id_for_dub_temp" value="<?= isset($insurer['id']) ? $insurer['id'] : '' ?>">
<div class="form-row">
<!-- <div class="form-group col-md-12">
@ -644,9 +646,11 @@
{
var template_id = $('#template_id_for_duplicate').attr('data-id');
var event_name = $('#event_name_for_duplicate').val();
var insurer_id = $('#insurer_id_for_dub_temp').val();
console.log('template_id_for_duplicate', template_id)
console.log('event_name_for_duplicate', event_name)
console.log('insurer_id', insurer_id)
if(event_name == ""){
@ -659,7 +663,7 @@
return false
}
var url = '<?= base_url('util/dublicate_template/') ?>' + template_id + '/' + event_name
var url = '<?= base_url('util/dublicate_template/') ?>' + template_id + '/' + event_name + '/' +insurer_id
$.ajax({
url: url,

View File

@ -1,3 +1,71 @@
<style>
custom-dropdown-menu {
display: none;
position: fixed;
background-color: #ffffff !important;
border: 1px solid rgba(0,0,0,.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
clear: both !important;
font-weight: 400 !important;
color: #212529 !important;
text-align: inherit !important;
white-space: nowrap !important;
background-color: transparent !important;
border: 0 !important;
text-decoration: none !important;
position: relative !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
.custom-dropdown-menu .dropdown-item i {
margin-right: 8px !important;
vertical-align: middle !important;
}
.table tbody tr {
cursor: pointer;
}
/* Ensure the dropdown menu has a solid background */
.custom-dropdown-menu::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #ffffff;
z-index: -1;
}
/* Add a subtle backdrop effect */
.custom-dropdown-menu::after {
content: '';
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.05);
z-index: -2;
pointer-events: none;
}
</style>
<div class="row" id="insurer_list">
<div class="col-12">
<div class="card">
@ -45,6 +113,97 @@
</div>
<!-- end row -->
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
// Create custom dropdown
function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
// Hide any active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
// Set as active dropdown
activeDropdown = customDropdown;
event.stopPropagation();
});
// Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
</script>
<script>
$(document).ready(function(){

View File

@ -103,6 +103,80 @@ table.dataTable tbody td {
.slider.round:before {
border-radius: 50%;
}
.disabled-option {
color: gray;
}
custom-dropdown-menu {
display: none;
position: fixed;
background-color: #ffffff !important;
border: 1px solid rgba(0,0,0,.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
clear: both !important;
font-weight: 400 !important;
color: #212529 !important;
text-align: inherit !important;
white-space: nowrap !important;
background-color: transparent !important;
border: 0 !important;
text-decoration: none !important;
position: relative !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
.custom-dropdown-menu .dropdown-item i {
margin-right: 8px !important;
vertical-align: middle !important;
}
.table tbody tr {
cursor: pointer;
}
/* Ensure the dropdown menu has a solid background */
.custom-dropdown-menu::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #ffffff;
z-index: -1;
}
/* Add a subtle backdrop effect */
.custom-dropdown-menu::after {
content: '';
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.05);
z-index: -2;
pointer-events: none;
}
</style>
<div class="row" id="inception_list">
@ -125,6 +199,7 @@ table.dataTable tbody td {
<th></th>
<th><div class="column-header">Insurer</div></th>
<th><div class="column-header">Month</div></th>
<th><div class="column-header">Statement<br>sno</div></th>
<th><div class="column-header">Filename</div></th>
<th><div class="column-header">Line<br>items</div></th>
<th><div class="column-header">File<br>status</div></th>
@ -140,6 +215,7 @@ table.dataTable tbody td {
<td><input type="hidden" class="row-select" data-id="<?= $row['id']; ?>"></td>
<td><?php echo $row['short_name'].'-'.$row['branch_code']; ?></td>
<td><?php echo change_date_format($row['month'],'Y-m-d','M-Y'); ?></td>
<td><?php echo $row['stmt_sno'] ?> </td>
<td><?php echo $row['file_name'] ?> </td>
<td><?php echo $row['line_items'] ?></td>
<td><?php echo $row['file_status'];
@ -172,6 +248,9 @@ table.dataTable tbody td {
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" data-exp-amt="<?= $row['exp_inv_amt'];?>" data-received-amt="<?= $row['received_inv_amt'];?>" onclick="showInvoiceStatusModal(event)">
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Invoice status
</a>
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>"onclick="deleteStatement(<?= $row['id'];?>)">
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
</a>
</div>
</div>
<?php } ?>
@ -218,8 +297,24 @@ table.dataTable tbody td {
</div>
<div class="form-group col-md-10">
<label for="statement_month">Statement month</label>
<input type="text" class="form-control" id="statement_month" name="statement_month" placeholder="" required readonly>
<input type="text" class="form-control" id="statement_month" name="statement_month" placeholder="" required readonly onchange="getStatementNo()">
</div>
<div class="form-group col-md-10">
<label for="statement_no">Statement no</label>
<select class="form-control" id="statement_no" name="statement_no" required >
<option value="" selected>Select statement no</option>
<?php
$stmt_no = [1,2,3,4,5,6,7];
if (isset($stmt_no) && count($stmt_no)) {
foreach ($stmt_no as $key => $value) {
echo "<option value=" . $value . ">" . $value . "</option>";
}
}
?>
</select>
</div>
<div class="form-group col-md-10" >
<label for="statment">Statement </label> <span><a href="downloadSampleInsurerStatement" id="download_sample_file" style="font-size: small;">Download sample file</a></span>
<input type="file" class="form-control" name="statement" required accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet">
@ -255,7 +350,7 @@ table.dataTable tbody td {
<!-- Invoice status content modal-->
<div class="modal fade" id="invoice_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-dialog modal-lg" style="max-width:1000px;">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="title">Update Invoice Status</h4>
@ -286,32 +381,65 @@ table.dataTable tbody td {
<label for="addon_policy">Exp Amount</label>
<input type="text" class="form-control" id="modal_exp_amt" placeholder="" disabled>
</div> -->
<div class="form-group col-md-4" id="modal_received_amt_div">
<label for="addon_policy">Total Received Amount</label>
<input type="text" class="form-control" id="modal_received_amt" placeholder="" disabled>
</div>
</div>
<!-- Invoice Number and Invoice Date in same row -->
<div class="row" id="invoice_no_div_modal" style="display: none;">
<div class="form-group col-md-4">
<label for="invoice_no">Invoice Number<span id="base_danger" class="text-danger"></span></label>
<input type="text" class="form-control" id="invoice_no_modal" name="invoice_no" placeholder="Enter Invoice Number" required>
<!-- <div id="invoice_no_div_modal" style="display: none;"> -->
<div class="row" id="invoice_no_div_modal" style="display: none;">
<div class="form-group col-md-4">
<label for="invoice_no">Invoice Number<span id="base_danger" class="text-danger"></span></label>
<input type="text" class="form-control" id="invoice_no_modal" name="invoice_no" placeholder="Enter Invoice Number" required>
</div>
<div class="form-group col-md-4">
<label for="invoice_date">Invoice Date</label>
<input type="text" class="form-control" id="invoice_date_modal" name="invoice_date" value="<?php echo date('Y-m-d'); ?>" readonly required>
</div>
<div class="form-group col-md-4">
<label for="invoice_value_modal">Invoice value<span id="base_danger" class="text-danger"></span></label>
<input type="number" class="form-control" id="invoice_value_modal" name="invoice_value" placeholder="Enter Invoice Value" readonly>
</div>
</div>
<div class="form-group col-md-4">
<label for="invoice_no">Invoice Amount<span id="base_danger" class="text-danger"></span></label>
<input type="number" class="form-control" id="invoice_amount_no_modal" name="invoice_amount" placeholder="Enter Invoice Amt" required>
<div class="row" id="invoice_no_div_modal2" style="display: none;">
<div class="form-group col-md-4">
<label for="gst_value_modal">GST %<span id="base_danger" class="text-danger"></span></label>
<input type="number" class="form-control" id="gst_per_modal" name="invoice_gst_per" placeholder="Enter GST %" required onchange="calcGSTValue()">
</div>
<div class="form-group col-md-4">
<label for="gst_value_modal">GST Value<span id="base_danger" class="text-danger"></span></label>
<input type="number" class="form-control" id="gst_value_modal" name="invoice_gst" placeholder="Enter Invoice Value" required readonly step="0.01">
</div>
<div class="form-group col-md-4">
<label for="invoice_no">Invoice Amount<span id="base_danger" class="text-danger"></span></label>
<input type="number" class="form-control" id="invoice_amount_no_modal" name="invoice_amount" placeholder="Enter Invoice Amt" required readonly step="0.01">
</div>
<!-- <div class="form-group col-md-3" id="modal_received_amt_div">
<label for="addon_policy">Total Received Amount</label>
<input type="text" class="form-control" id="modal_received_amt" placeholder="" disabled>
</div> -->
</div>
<div class="form-group col-md-4">
<label for="invoice_date">Invoice Date</label>
<input type="text" class="form-control" id="invoice_date_modal" name="invoice_date" value="<?php echo date('Y-m-d'); ?>" readonly required>
</div>
</div>
<div class="row" id="modal_received_amt_div">
<div class="form-group col-md-4" >
<label for="addon_policy">Total Received Amount</label>
<input type="number" class="form-control" id="modal_received_amt" placeholder="" disabled>
</div>
</div>
<!-- </div> -->
</div>
<!-- Payment Received Table -->
<div class="form-group col-md-12" style="display: none;" id="payment_table_div_modal">
<div class="form-group col-md-12" style="display: none;" id="payment_table_div_modal" style="max-width: 800px;">
<button type="button" id="add_row_btn" class="btn btn-secondary float-right"><i class="fa fa-plus"></i></button>
@ -319,7 +447,8 @@ table.dataTable tbody td {
<thead>
<tr>
<th style="display: none;">pk</th>
<th>Received Amount</th>
<th>Invoice value</th>
<th>GST</th>
<th>TDS</th>
<th>UTR Number</th>
<th>Date</th>
@ -330,6 +459,7 @@ table.dataTable tbody td {
<tr>
<td style="display: none;"><input type="hidden" class="form-control" name="pk[]" placeholder="Enter Amount"></td>
<td><input type="number" class="form-control" name="received_amount[]" placeholder="Enter Amount" required onchange="checkInvAmont(event)"></td>
<td><input type="number" class="form-control" name="gst_amount[]" placeholder="Enter GST" required step="0.01" onchange="checkInvAmont(event)"></td>
<td><input type="number" class="form-control" name="tds[]" placeholder="Enter TDS" onchange="checkInvAmont(event)" required></td>
<td><input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" required></td>
<td><input type="text" class="form-control payment_date" name="payment_date[]" value="<?php echo date('d/m/Y'); ?>" placeholder="dd/mm/yyyy" required readonly></td>
@ -351,19 +481,110 @@ table.dataTable tbody td {
</div>
</div>
</div>
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
// Create custom dropdown
function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
// Hide any active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
// Set as active dropdown
activeDropdown = customDropdown;
event.stopPropagation();
});
// Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
</script>
<script>
document.getElementById('invoice_status').addEventListener('change', function () {
const invoiceStatus = this.value;
console.log(invoiceStatus);
const invoiceNoDiv = document.getElementById('invoice_no_div_modal');
const invoiceNoDiv2 = document.getElementById('invoice_no_div_modal2');
// const invoiceDateDiv = document.getElementById('invoice_date_div_modal');
const paymentTableDiv = document.getElementById('payment_table_div_modal');
const totalReceivedAmtDiv = document.getElementById('modal_received_amt_div');
// Hide everything initially
invoiceNoDiv.style.display = 'none';
invoiceNoDiv2.style.display = 'none';
// invoiceDateDiv.style.display = 'none';
paymentTableDiv.style.display = 'none';
totalReceivedAmtDiv.style.display = 'none';
@ -371,6 +592,7 @@ table.dataTable tbody td {
// Show fields based on selected status
if (invoiceStatus === 'generated' || invoiceStatus === 'sent') {
invoiceNoDiv.style.display = 'flex';
invoiceNoDiv2.style.display = 'flex';
totalReceivedAmtDiv.style.display = 'none';
switchRequired('invoice_no_modal',true);
switchRequired('invoice_date_modal',true);
@ -378,12 +600,14 @@ table.dataTable tbody td {
switchRequired('received_amount',false,'name');
switchRequired('tds',false,'name');
switchRequired('gst_amount',false,'name');
switchRequired('utr_no',false,'name');
switchRequired('payment_date',false,'name');
switchRequired('pk',false,'name');
// invoiceDateDiv.style.display = 'block';
} else if (invoiceStatus === 'payment_received') {
invoiceNoDiv.style.display = 'flex';
invoiceNoDiv2.style.display = 'flex';
paymentTableDiv.style.display = 'block';
totalReceivedAmtDiv.style.display = 'block';
switchRequired('invoice_no_modal',true);
@ -394,11 +618,13 @@ table.dataTable tbody td {
switchRequired('received_amount',true,'name');
switchRequired('utr_no',true,'name');
switchRequired('tds',true,'name');
switchRequired('gst_amount',true,'name');
switchRequired('payment_date',true,'name');
switchRequired('pk',true,'name');
}else if(invoiceStatus === 'pending')
{
invoiceNoDiv.style.display = 'none';
invoiceNoDiv2.style.display = 'none';
paymentTableDiv.style.display = 'none';
totalReceivedAmtDiv.style.display = 'none';
// switchRequired('modal_received_amt_div',false);
@ -411,8 +637,11 @@ table.dataTable tbody td {
switchRequired('payment_date',false,'name');
switchRequired('pk',false,'name');
switchRequired('tds',false,'name');
switchRequired('gst_amount',false,'name');
}
calcGSTValue();
});
@ -435,6 +664,13 @@ table.dataTable tbody td {
$('#invoiceForm').on('submit', function (e) {
e.preventDefault(); // Prevent default form submission
var res = checkInvAmont();
if(!res)
{
return false;
}
var form = document.getElementById('invoiceForm');
// alert(form.checkValidity());
// alert($('#invoice_date_modal').val());
@ -487,7 +723,7 @@ table.dataTable tbody td {
$('.close').click()
// Reset the form data
$('#invoiceForm')[0].reset();
// $('#invoiceForm')[0].reset();
alert('Invoice updated successfully!');
location.reload();
@ -513,6 +749,7 @@ table.dataTable tbody td {
newRow.innerHTML = `
<td style="display: none;"><input type="hidden" class="form-control" name="pk[]" placeholder="Enter Amount"></td>
<td><input type="number" class="form-control" name="received_amount[]" placeholder="Enter Amount" onchange="checkInvAmont(event)" required></td>
<td><input type="number" class="form-control" name="gst_amount[]" placeholder="Enter GST" onchange="checkInvAmont(event)" required step="0.01"></td>
<td><input type="number" class="form-control" name="tds[]" placeholder="Enter TDS" onchange="checkInvAmont(event)" required></td>
<td><input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" required></td>
<td><input type="text" class="form-control payment_date" value="<?php echo date('d/m/Y'); ?>" name="payment_date[]" placeholder="dd/mm/yyyy" required readonly></td>
@ -627,6 +864,15 @@ function showInvoiceStatusModal(event)
document.getElementById('invoice_no_modal').value = response.data.invoice_no;
document.getElementById('invoice_date_modal').value = response.data.invoice_date === '' ? <?php echo date('d-m-Y')?> : response.data.invoice_date;
document.getElementById('invoice_amount_no_modal').value = response.data.invoice_amount;
document.getElementById('invoice_value_modal').value = response.data.invoice_value;
document.getElementById('gst_per_modal').value = response.data.gst_per;
document.getElementById('gst_value_modal').value = response.data.gst_value;
console.log('response.data.gst_value - ' + response.data.gst_value);
if(response.data.gst_value == 0 || response.data.gst_value == '' || response.data.gst_value == null)
{
calcGSTValue();
}
if (!$('#invoice_date_modal').val()) {
// alert('nope');
@ -646,6 +892,7 @@ function showInvoiceStatusModal(event)
row.innerHTML = `
<td style="display: none;"><input type="hidden" class="form-control" name="pk[]" value="${payment.id}"></td>
<td><input type="number" class="form-control" name="received_amount[]" placeholder="Enter Amount" value="${payment.inv_amt}" onchange="checkInvAmont(event)" required></td>
<td><input type="number" class="form-control" name="gst_amount[]" placeholder="Enter Amount" value="${payment.gst}" onchange="checkInvAmont(event)" required step="0.01"></td>
<td><input type="number" class="form-control" name="tds[]" placeholder="Enter Amount" value="${payment.tds}" onchange="checkInvAmont(event)" required></td>
<td><input type="text" class="form-control" name="utr_no[]" placeholder="Enter UTR No" value="${payment.utr_no}" required></td>
<td><input type="text" class="form-control payment_date" name="payment_date[]" value="${formatDateToDMY(payment.received_date)}" required readonly></td>
@ -720,14 +967,16 @@ maxDate.setDate(today.getDate() + 180);
$('#insurer_statement_upload_form').submit(function(event) {
event.preventDefault();
var isValid = $('#insurer_statement_upload_form').parsley().validate();
if (!isValid) {
console.log('Form is Empty', 'Warning');
alert('choose all fileds');
// alert('choose all fileds');
return;
}
$('#btnSubmit').prop('disabled', true).text('Submitting...');
// Create FormData object
var formData = new FormData($(this)[0]);
for (var pair of formData.entries()) {
@ -769,6 +1018,11 @@ maxDate.setDate(today.getDate() + 180);
toastr.error('Something went wrong! Try later', 'Error');
window.location.reload(true);
}
$('.close').click()
$('.loader').fadeOut();
$('.loader-mask').delay(10).fadeOut('slow');
$('#btnSubmit').prop('disabled', false).text('Submit');
},
error: function(xhr, status, error) {
@ -776,11 +1030,13 @@ maxDate.setDate(today.getDate() + 180);
console.error("Request failed:", status, error);
toastr.error('Something went wrong! Try later', 'Error');
$('#uploadForm')[0].reset();
$('.close').click()
$('.loader').fadeOut();
$('.loader-mask').delay(10).fadeOut('slow');
window.location.reload(true);
}
});
$('.loader').fadeOut();
$('.loader-mask').delay(10).fadeOut('slow');
});
function fetchFileError(file_id) {
@ -804,7 +1060,7 @@ maxDate.setDate(today.getDate() + 180);
var file_error_html = "";
if (file_error_data['error_code'] == 1) {
file_error_html += 'The following row no(s) from excel are <span style="font-weight:bold">either already mapped / not found with policy transactions / duplicates.</span>';
file_error_html += 'The following row no(s) from excel are <span style="font-weight:bold">not found with policy transactions / duplicates.</span>';
file_error_html += ' : ' + '<span style="font-weight:bolder">' + file_error_data['error_data'].join(',') + '</span>';
}
@ -829,19 +1085,21 @@ maxDate.setDate(today.getDate() + 180);
}
function checkInvAmont(event) {
function checkInvAmont(event = null) {
var total = 0;
var receivedAmounts = document.querySelectorAll('input[name="received_amount[]"]');
var receivedGST = document.querySelectorAll('input[name="gst_amount[]"]');
var tdsAmounts = document.querySelectorAll('input[name="tds[]"]');
// console.log();
receivedAmounts.forEach(function(el, index) {
// Get the received amount
let receivedVal = parseFloat(el.value) || 0;
// Get the corresponding tds amount (paired with the received amount)
let gstVal = parseFloat(receivedGST[index].value) || 0;
let tdsVal = parseFloat(tdsAmounts[index].value) || 0;
// Add received amount and tds amount
// console.log();
total += (receivedVal + tdsVal);
total += (receivedVal + tdsVal + gstVal);
});
// console.log(total);
// Get the expected invoice amount
@ -849,9 +1107,16 @@ function checkInvAmont(event) {
// Check if the total exceeds the expected amount
if (exp_amt < total) {
alert('Exceeds Invoice amount');
event.target.value = ''; // Reset the value of the element that triggered the event
alert('Exceeds Invoice amount...Plz adjust numbers');
if(event != null)
{
event.target.value = '';
}
return false; // Reset the value of the element that triggered the event
}
return true;
}
@ -883,5 +1148,200 @@ function switchRequired(elementId, isRequired, type = 'id') {
}
}
function getStatementNo()
{
var insurer_id = $('#insurer').val();
var statement_month = $('#statement_month').val();
console.log(insurer_id+' / '+statement_month);
if(insurer_id == "")
{
alert('Choose insurer...!');
$('#statement_month').val('');
}
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var apiURL = 'getInsurerStatementMonth?insurer_id=' +insurer_id+'&month='+statement_month ;
$.ajax({
url: apiURL,
type: "GET",
headers: {
// "Content-Type":"multipart/form-data",
"X-Requested-With": "XMLHttpRequest"
},
success: function(response) {
console.log(response);
// $('#insurer_statement_upload_form')[0].reset();
if (response.code === 200 && response.dataStatus === true && response
.data !== "") {
disableStatementNo(response.data)
$('.loader').fadeOut();
$('.loader-mask').delay(10).fadeOut('slow');
} else if (response.code === 404 && response.dataStatus === false) {
console.error('no data found', response);
// alert(response.message);
// toastr.error(response.message, 'Failed');
// window.location.reload(true);
$('.loader').fadeOut();
$('.loader-mask').delay(10).fadeOut('slow');
} else {
console.error('Something went wrong!');
// alert('Something went wrong! Try later');
toastr.error('Something went wrong! Try later', 'Error');
// window.location.reload(true);
$('.loader').fadeOut();
$('.loader-mask').delay(10).fadeOut('slow');
}
},
error: function(xhr, status, error) {
// Request failed, handle error
console.error("Request failed:", status, error);
toastr.error('Something went wrong! Try later', 'Error');
// $('#uploadForm')[0].reset();
// window.location.reload(true);
$('.loader').fadeOut();
$('.loader-mask').delay(10).fadeOut('slow');
}
});
// $('.loader').fadeOut();
// $('.loader-mask').delay(10).fadeOut('slow');
}
function calcGSTValue()
{
// alert('calcGSTValue');
console.log('calcGSTValue called');
var inv_status_element = document.getElementById('invoice_status');
if(inv_status_element.value == 'generated' || inv_status_element.value == 'send' || inv_status_element.value == 'payment_received')
{
var gst_per = document.getElementById('gst_per_modal').value;
console.log('gst_per - ' + gst_per);
var invoice_value_dom_obj = document.getElementById('invoice_value_modal');
var invoice_value = invoice_value_dom_obj.value;
console.log('invoice_value - ' + invoice_value);
var gst_value_dom_obj = document.getElementById('gst_value_modal');
var gst_value = gst_value_dom_obj.value;
console.log('gst_value - ' + gst_value);
var invoice_amount_dom_obj = document.getElementById('invoice_amount_no_modal');
// var invoice_amount = invoice_amount_dom_obj.value();
gst_value_dom_obj.value = Math.round((parseFloat(gst_per) / 100 ) * invoice_value);
// gst_value_dom_obj.value = ((parseFloat(gst_per) / 100 ) * invoice_value);
invoice_amount_dom_obj.value = parseFloat(invoice_value_dom_obj.value) + parseFloat(gst_value_dom_obj.value);
if(inv_status_element.value == 'payment_received')
{
checkInvAmont();
}
}
}
function disableStatementNo(arr)
{
// JavaScript array with values to disable
// const disableValues = arr;
const disableIds = arr.map(item => item.stmt_sno);
console.log(disableIds);
// Get the select element
const selectElement = document.getElementById("statement_no");
// Variable to track if the first enabled option is selected
let firstEnabledOptionSelected = false;
// Iterate over the options in the select element
Array.from(selectElement.options).forEach(option => {
// If the option value is in the disableIds array, disable it
console.log(option.value);
option.disabled = false;
option.style.backgroundColor = "";
if (disableIds.includes((option.value))) {
option.disabled = true;
option.style.backgroundColor = "lightgray";
}
else if (!firstEnabledOptionSelected && option.value !== "") {
// Automatically select the first enabled option
option.selected = true;
firstEnabledOptionSelected = true;
}
});
}
function deleteStatement(id)
{
//alert(id);
Swal.fire({
title: "Do you want to delete statement & it's invoice data if any?",
showCancelButton: true,
confirmButtonText: "Delete",
confirmButtonColor: "#ff3333",
}).then((result) => {
console.log(result);
if (result.isConfirmed) {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var apiURL = 'deleteStatement/' + id;
// console.log('Truncate API URL : ', apiURL);
$.ajax({
url: apiURL,
method: 'GET',
headers: {
"X-Requested-With": "XMLHttpRequest"
},
success: function(response) {
// console.log('Truncate Response', response)
$('.loader').fadeOut();
$('.loader-mask').delay(10).fadeOut('slow');
if (response.code === 200 && response.dataStatus === true) {
Swal.fire({
title: "Deleted!",
icon: "success"
});
window.location.reload(true);
} else {
Swal.fire({
title: "Failed!",
text: 'Something went wrong! Try later',
icon: "error"
});
window.location.reload(true);
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(10).fadeOut('slow');
console.error('Error fetching data from API:', error);
toastr.error('Something went wrong! Try later', 'Error');
window.location.reload(true);
}
});
}
});
}
</script>

View File

@ -1,3 +1,71 @@
<style>
custom-dropdown-menu {
display: none;
position: fixed;
background-color: #ffffff !important;
border: 1px solid rgba(0,0,0,.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
clear: both !important;
font-weight: 400 !important;
color: #212529 !important;
text-align: inherit !important;
white-space: nowrap !important;
background-color: transparent !important;
border: 0 !important;
text-decoration: none !important;
position: relative !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
.custom-dropdown-menu .dropdown-item i {
margin-right: 8px !important;
vertical-align: middle !important;
}
.table tbody tr {
cursor: pointer;
}
/* Ensure the dropdown menu has a solid background */
.custom-dropdown-menu::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #ffffff;
z-index: -1;
}
/* Add a subtle backdrop effect */
.custom-dropdown-menu::after {
content: '';
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.05);
z-index: -2;
pointer-events: none;
}
</style>
<div class="row" id="kyc_list">
<div class="col-12">
<div class="card">
@ -42,7 +110,94 @@
</div><!-- end col -->
</div>
<!-- end row -->
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
// Create custom dropdown
function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
// Hide any active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
// Set as active dropdown
activeDropdown = customDropdown;
event.stopPropagation();
});
// Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
</script>
<script>
$(document).ready(function(){

View File

@ -581,6 +581,9 @@
<li>
<a href="<?= base_url('/employee/enrollment-list') ?>">View Enrolment</a>
</li>
<li>
<a href="<?= base_url('/employee/test_members_list') ?>">Test Members List</a>
</li>
</ul>
</div>
</li>

View File

@ -32,6 +32,7 @@
color: white !important;
margin-right: 5px;
}
</style>
<div class="row" id="leads_form" style="display:none;">
@ -383,7 +384,7 @@ function getLeadsDataForEdit(input) {
$('#contact_person_name').val(res.data.contact_person_name);
$('#contact_person_mobile').val(res.data.contact_person_mobile);
$('#contact_person_email').val(res.data.contact_person_email);
$('#policy_type_id_1').val(res.data.policy_type_id).change();
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, 1000)
@ -396,7 +397,6 @@ function getLeadsDataForEdit(input) {
var proposed_insurer = res.data.proposed_insurer_branch_id + '-' + res.data.proposed_insurer_id;
var proposed_tpa = res.data.proposed_tpa_branch_id + '-' + res.data.proposed_tpa_id;
$('#policy_type_id_1').val(res.data.policy_type_id).change();
$('#insurer_1').val(insurer).select2();
$('#tpa_1').val(tpa).select2();
$('#proposed_insurer_1').val(proposed_insurer).select2();
@ -404,9 +404,37 @@ function getLeadsDataForEdit(input) {
$('#policy_start_date_1').val(res.data.policy_start_date);
$('#policy_end_date_1').val(res.data.policy_end_date);
$('#no_of_lives').val(res.data.no_of_lives);
$('#claims').val(res.data.claims);
$('#location').val(res.data.location);
let increment = 1;
// Other fields, set dynamically based on increment
$('#renewal_emp_count_' + increment).val(res.data.renewal_emp_count);
$('#renewal_dept_count_' + increment).val(res.data.renewal_dept_count);
$('#renewal_no_of_lives_' + increment).val(res.data.renewal_no_of_lives);
$('#incept_emp_count_' + increment).val(res.data.incept_emp_count);
$('#incept_dept_count_' + increment).val(res.data.incept_dept_count);
$('#incept_no_of_lives_' + increment).val(res.data.incept_no_of_lives);
$('#exp_emp_count_' + increment).val(res.data.exp_emp_count);
$('#exp_dept_count_' + increment).val(res.data.exp_dept_count);
$('#exp_no_of_lives_' + increment).val(res.data.exp_no_of_lives);
$('#incurred_claim_date_' + increment).val(res.data.incurred_claims_date);
$('#paid_claims_' + increment).val(res.data.paid_claims);
$('#outstanding_claims_' + increment).val(res.data.outstanding_claims);
$('#policy_run_days_' + increment).val(res.data.policy_run_days);
$('#premium_at_inception_' + increment).val(res.data.premium_at_inception);
$('#premium_date_' + increment).val(res.data.premium_date);
$('#earned_premium_' + increment).val(res.data.earned_premium);
$('#annualised_claims_' + increment).val(res.data.annualised_claims);
$('#incurred_claims_ratio_' + increment).val(res.data.incurred_claims_ratio);
$('#earned_claims_ratio_' + increment).val(res.data.earned_claims_ratio);
$('#incurred_claims_' + increment).val(res.data.incurred_claims);
$('#file_name_display').text('Upload File Name : ' + res.data.file_name);
// $('#file_name').val(res.data.file_name);
$('#total_si_at_incept_' + increment).val(res.data.total_si_at_incept);
$('#total_si_at_renewal_' + increment).val(res.data.total_si_at_renewal);
if (res.data.salse_person_id) {
selecSalsePerson(res.data.salse_person_id);
@ -419,12 +447,63 @@ function getLeadsDataForEdit(input) {
$('#freshDiv').hide();
$('.proposed_div').show().find('select, input').attr('required', 'required');
$('#policy_end_date, #policy_start_date, #claim').removeAttr('required');
$('.freashDiv').show()
$('.renewalDiv').hide()
$('.emp_title').text('No of Employees at Inception')
$('.depnd_title').text(' No of Dependents at Inception')
$('.total_title').text('Total Lives at Inception')
} else {
$('#renewalDiv').find('select, input').removeAttr('required');
$('#freshDiv').find('select, input').attr('required', 'required');
$('#renewalDiv').hide();
$('#freshDiv').show();
$('.proposed_div').hide().find('select, input').removeAttr('required');
if(res.data.lead_type == 1){
$('.freashDiv').hide()
$('.renewalDiv').show()
$('.emp_title').text('No of Employees')
$('.depnd_title').text('No of Dependents')
$('.total_title').text('Total Lives')
}else{
$('.freashDiv').show()
$('.renewalDiv').hide()
$('.emp_title').text('No of Employees at Inception')
$('.depnd_title').text(' No of Dependents at Inception')
$('.total_title').text('Total Lives at Inception')
}
}
if(res.data.policy_type_id != 2){
$('.gpa_hide_div_'+increment).hide();
$('.gpa_show_div_'+increment).show();
$('.gpa_div_elements_'+increment).show();
$('.emp_title').text('No of Employees at Inception');
let claimExperience = JSON.parse(res.data.fin_years_claims);
claimExperience[0].finyear.forEach((data, index) => {
const year = document.querySelector(`#${["first", "second", "third"][index]}_year_${increment}`);
const claimAmount = document.querySelector(`#${["first", "second", "third"][index]}_claim_amount_${increment}`);
const claimStatus = document.querySelector(`#${["first", "second", "third"][index]}_claim_status_${increment}`);
const causeOfDeath = document.querySelector(`#${["first", "second", "third"][index]}_casue_of_death_${increment}`);
const deathDate = document.querySelector(`#${["first", "second", "third"][index]}_death_date_${increment}`);
if (year) year.value = data.year;
if (claimAmount) claimAmount.value = data.claim_amount;
if (claimStatus) claimStatus.value = data.status;
if (causeOfDeath) causeOfDeath.value = data.cause_of_death;
if (deathDate) deathDate.value = data.death_date;
});
}else{
$('.gpa_hide_div_'+increment).show();
}
@ -575,8 +654,6 @@ function getPolicyData(client_policy_id, increment_count) {
}
}
// Salse team user list data
function selecSalsePerson(salse_person_ids) {
@ -604,16 +681,50 @@ function addHTMLInput(check) {
const newRow = document.createElement('div');
newRow.className = 'form-row dynamic-form-row';
const newRow2 = document.createElement('div');
newRow2.className = 'form-row dynamic-form-row freashDiv';
const newRow3 = document.createElement('div');
newRow3.className = 'form-row dynamic-form-row';
const newRow4 = document.createElement('div');
newRow4.className = 'form-row dynamic-form-row freashDiv';
const newRow5 = document.createElement('div');
newRow5.className = 'form-row dynamic-form-row';
const newRow7 = document.createElement('div');
newRow7.className = 'form-row dynamic-form-row';
const newRow8 = document.createElement('div');
newRow8.className = 'form-row dynamic-form-row';
const newRow6 = document.createElement('div');
newRow6.className = `form-row dynamic-form-row gpa_div_elements_${increment}`;
newRow6.style.display = 'none';
const newRow9 = document.createElement('div');
newRow9.className = `form-row dynamic-form-row gpa_div_elements_${increment}`;
newRow9.style.display = 'none';
const newRow10 = document.createElement('div');
newRow10.className = `form-row dynamic-form-row gpa_div_elements_${increment}`;
newRow10.style.display = 'none';
const newRow11 = document.createElement('div');
newRow11.className = `form-row dynamic-form-row gpa_div_elements_${increment}`;
newRow11.style.display = 'none';
// Add an <hr> element
const hrElement = document.createElement('hr');
container.appendChild(hrElement);
// Set inner HTML with necessary input fields
// Main div
newRow.innerHTML += `
<div class="form-group col-md-3">
<label for="policy_type_id">Policy Type <span class="text-danger">*</span></label>
<select class="form-control" id="policy_type_id_${increment}" name="policy_type_id[]" required>
<select class="form-control" id="policy_type_id_${increment}" name="policy_type_id[]" onchange="showGpaColumns(this)" required>
<option value="">Select Policy Type</option>
<?php
if (isset($policy_type) && count($policy_type)) {
@ -656,28 +767,77 @@ function addHTMLInput(check) {
</div>
<div class="form-group col-md-3">
<label for="no_of_lives">No of Lives <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="no_of_lives" name="no_of_lives[]" placeholder="Enter Lives" required>
</div>
<div class="form-group col-md-3 proposed_div">
<label for="policy_start_date_${increment}">Date of Commencement <span class="text-danger"></span></label>
<input type="text" class="form-control policy_start_date" id="policy_start_date_${increment}" name="policy_start_date[]" placeholder="Enter DOC">
</div>
<div class="form-group col-md-3 proposed_div">
<div class="form-group col-md-3">
<label for="policy_end_date_${increment}">Date of Expiry <span class="text-danger"></span></label>
<input type="text" class="form-control policy_end_date" id="policy_end_date_${increment}" name="policy_end_date[]" placeholder="Enter DOE">
</div>
`;
<div class="form-group col-md-3">
<label for="claims">Claims <span class="text-danger"></span></label>
<input type="text" class="form-control" id="claims" name="claims[]" placeholder="Enter Claims">
// Incured claim div
newRow8.innerHTML += `
<div class="form-group col-md-3 freashDiv" style="display: none;">
<label for="incurred_claim_date_${increment}">Incurred Claim Date<span class="text-danger"></span></label>
<input type="text" class="form-control incurred_claim" id="incurred_claim_date_${increment}" name="incurred_claim_date[]" placeholder="Enter DOE">
</div>
<div class="form-group col-md-3">
<div class="form-group col-md-3 freashDiv" style="display: none;">
<label for="paid_claims_${increment}">Paid Claims<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="paid_claims_${increment}" name="paid_claims[]" placeholder="Enter Paid Claims" oninput="incurredClaimSum(this)">
</div>
<div class="form-group col-md-3 freashDiv" style="display: none;">
<label for="outstanding_claims_${increment}">Outstanding Claims<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="outstanding_claims_${increment}" name="outstanding_claims[]" placeholder="Enter Outstanding Claims" oninput="incurredClaimSum(this)">
</div>
<div class="form-group col-md-3 freashDiv" style="display: none;">
<label for="incurred_claims_${increment}">Incurred Claim<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="incurred_claims_${increment}" name="incurred_claims[]" placeholder="Enter Incurred Claim" oninput="incurredClaimSum(this)">
</div>
<div class="form-group col-md-3 freashDiv" style="display: none;">
<label for="policy_run_days_${increment}">Policy Run Days<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="policy_run_days_${increment}" name="policy_run_days[]" placeholder="Enter Policy Run Days" oninput="earnedPremiumCalc(this)">
</div>
<div class="form-group col-md-3 freashDiv" style="display: none;">
<label for="premium_at_inception_${increment}">Premium Paid at Inception<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="premium_at_inception_${increment}" name="premium_at_inception[]" placeholder="Enter Premium Paid" oninput="earnedPremiumCalc(this)">
</div>
<div class="form-group col-md-3 freashDiv" style="display: none;">
<label for="premium_date_${increment}">Premium Date<span class="text-danger"></span></label>
<input type="text" class="form-control" id="premium_date_${increment}" name="premium_date[]" placeholder="Enter Premium Date">
</div>
<div class="form-group col-md-3 freashDiv" style="display: none;">
<label for="earned_premium_${increment}">Earned Premium<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="earned_premium_${increment}" name="earned_premium[]" placeholder="Enter Earned Premium" oninput="incurredClaimSum(this)">
</div>
<div class="form-group col-md-3 freashDiv" style="display: none;">
<label for="annualised_claims_${increment}">Annualised Claims<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="annualised_claims_${increment}" name="annualised_claims[]" placeholder="Enter Annualised Claims" >
</div>
<div class="form-group col-md-3 freashDiv" style="display: none;">
<label for="incurred_claims_ratio_${increment}">Incurred Claims Ratio<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="incurred_claims_ratio_${increment}" name="incurred_claims_ratio[]" placeholder="Enter Incurred Claims Ratio" >
</div>
<div class="form-group col-md-3 freashDiv" style="display: none;">
<label for="earned_claims_ratio_${increment}">Earned Claims Ratio<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="earned_claims_ratio_${increment}" name="earned_claims_ratio[]" placeholder="Enter Earned Claims Ratio" >
</div>
<div class="form-group col-md-3 freashDiv">
<label for="location">Location <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="location" name="location[]" placeholder="Enter Location" required>
<input type="text" class="form-control" id="location" name="location[]" placeholder="Enter Location" >
</div>
<div class="form-group col-md-3 proposed_div" style="display: none;">
@ -708,23 +868,241 @@ function addHTMLInput(check) {
</select>
</div>
`;
//renewal div
newRow2.innerHTML += `
<div class="form-group col-md-3">
<label for="renewal_emp_count_${increment}"> No of Employees at Renewal <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="renewal_emp_count_${increment}" name="renewal_emp_count[]" placeholder="Enter Lives" >
</div>
<div class="form-group col-md-3 gpa_hide_div_${increment}" style="display:none;">
<label for="renewal_dept_count_${increment}"> No of Dependents at Renewal <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="renewal_dept_count_${increment}" name="renewal_dept_count[]" placeholder="Enter Lives" >
</div>
<div class="form-group col-md-3 gpa_hide_div_${increment}" style="display:none;">
<label for="renewal_no_of_lives_${increment}"> Total Lives at Renewal <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="renewal_no_of_lives_${increment}" name="renewal_no_of_lives[]" placeholder="Enter Lives" >
</div>
<div class="form-group col-md-3 gpa_show_div_${increment}" style="display:none;">
<label for="total_si_at_renewal_${increment}"> Total Sum Insured at Renewal <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="total_si_at_renewal_${increment}" name="total_si_at_renewal[]" placeholder="Enter Lives" >
</div>
`;
//inception div
newRow3.innerHTML += `
<div class="form-group col-md-3">
<label for="incept_emp_count_${increment}" class="emp_title"> No of Employees at Inception <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="incept_emp_count_${increment}" name="incept_emp_count[]" placeholder="Enter Lives" >
</div>
<div class="form-group col-md-3 gpa_hide_div_${increment}" style="display:none;">
<label for="incept_dept_count_${increment}" class="depnd_title"> No of Dependents at Inception <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="incept_dept_count_${increment}" name="incept_dept_count[]" placeholder="Enter Lives" >
</div>
<div class="form-group col-md-3 gpa_hide_div_${increment}" style="display:none;">
<label for="incept_no_of_lives_${increment}" class="total_title"> Total Lives at Inception <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="incept_no_of_lives_${increment}" name="incept_no_of_lives[]" placeholder="Enter Lives" >
</div>
<div class="form-group col-md-3 gpa_show_div_${increment}" style="display:none;">
<label for="total_si_at_incept_${increment}" class="total_title"> Total Sum Insured at Inception <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="total_si_at_incept_${increment}" name="total_si_at_incept[]" placeholder="Enter Lives" >
</div>
`;
//expiry div
newRow4.innerHTML += `
<div class="form-group col-md-3">
<label for="exp_emp_count_${increment}"> No of Employees at Expiry <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="exp_emp_count_${increment}" name="exp_emp_count[]" placeholder="Enter Lives" >
</div>
<div class="form-group col-md-3">
<label for="exp_dept_count_${increment}"> No of Dependents at Expiry <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="exp_dept_count_${increment}" name="exp_dept_count[]" placeholder="Enter Lives" >
</div>
<div class="form-group col-md-3">
<label for="exp_no_of_lives_${increment}"> Total Lives at Expiry <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="exp_no_of_lives_${increment}" name="exp_no_of_lives[]" placeholder="Enter Lives" >
</div>
`;
//file upload div
newRow7.innerHTML += `
<div class="form-group col-md-3">
<label for="file_upload">File Upload<span class="text-danger">*</span></label>
<input type="file" class="form-control" id="file_name_${increment}" name="file_name[]" accept=".xls,.xlsx">
<span class="text-danger" id="file_name_display"></span>
</div>
`;
newRow9.innerHTML +=`<div class="form-group col-md-3"><h5>Claims Experience for last 3 Years </h5></div>`;
//Last 3 years claims expirence div
newRow6.innerHTML += `
<div class="form-group col-md-3">
<label for="first_year_${increment}">Year<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_year_${increment}" name="first_year[]">
</div>
<div class="form-group col-md-3">
<label for="first_claim_amount_${increment}">Claim Amount / Settled Amount<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_claim_amount_${increment}" name="first_claim_amount[]">
</div>
<div class="form-group col-md-3">
<label for="first_claim_status_${increment}">Claim Status<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_claim_status_${increment}" name="first_claim_status[]">
</div>
<div class="form-group col-md-3">
<label for="first_casue_of_death_${increment}">Nature / Casue Of Death <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_casue_of_death_${increment}" name="first_casue_of_death[]">
</div>
<div class="form-group col-md-3">
<label for="first_death_date_${increment}">Date of Death<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_death_date_${increment}" name="first_death_date[]">
</div>
`;
//Last 3 years claims expirence div
newRow10.innerHTML += `
<div class="form-group col-md-3">
<label for="second_year_${increment}">Year<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="second_year_${increment}" name="second_year[]">
</div>
<div class="form-group col-md-3">
<label for="second_claim_amount_${increment}">Claim Amount / Settled Amount<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="second_claim_amount_${increment}" name="second_claim_amount[]">
</div>
<div class="form-group col-md-3">
<label for="second_claim_status_${increment}">Claim Status<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="second_claim_status_${increment}" name="second_claim_status[]">
</div>
<div class="form-group col-md-3">
<label for="second_casue_of_death_${increment}">Nature / Casue Of Death <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="second_casue_of_death_${increment}" name="second_casue_of_death[]">
</div>
<div class="form-group col-md-3">
<label for="second_death_date_${increment}">Date of Death<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="second_death_date_${increment}" name="second_death_date[]">
</div>
`;
//Last 3 years claims expirence div
newRow11.innerHTML += `
<div class="form-group col-md-3">
<label for="third_year_${increment}">Year<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="third_year_${increment}" name="third_year[]">
</div>
<div class="form-group col-md-3">
<label for="third_claim_amount_${increment}">Claim Amount / Settled Amount<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="third_claim_amount_${increment}" name="third_claim_amount[]">
</div>
<div class="form-group col-md-3">
<label for="third_claim_status_${increment}">Claim Status<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="third_claim_status_${increment}" name="third_claim_status[]">
</div>
<div class="form-group col-md-3">
<label for="third_casue_of_death_${increment}">Nature / Casue Of Death <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="third_casue_of_death_${increment}" name="third_casue_of_death[]">
</div>
<div class="form-group col-md-3">
<label for="third_death_date_${increment}">Date of Death<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="third_death_date_${increment}" name="third_death_date[]">
</div>
`;
//button div
newRow5.innerHTML += `
<div class="form-group col-md-12 btnDiv" style="position: relative;top: 28px;float: right;text-align: end;">
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInput(this)">x</a>
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="addHTMLInput(1)">+</a>
</div>
`;
container.appendChild(newRow);
container.appendChild(newRow8);
const hrElement2 = document.createElement('hr');
container.appendChild(hrElement2);
//inception div
container.appendChild(newRow3);
//renewal div
container.appendChild(newRow2);
//expiry div
container.appendChild(newRow4);
const hrElement3 = document.createElement('hr');
hrElement3.className = "gpa_div_elements"; // Set class to hrElement3
container.appendChild(hrElement3); // Append hrElement3 to container
container.appendChild(newRow9);
//Last 3 years claims expirence div
container.appendChild(newRow6);
container.appendChild(newRow10);
container.appendChild(newRow11);
//file upload div
container.appendChild(newRow7);
//button div
container.appendChild(newRow5);
var lead_type = $('#lead_type').val();
if (lead_type == 2) {
// $('.proposed_div').show().find('select, input').attr('required', 'required');
$('.proposed_div').show();
$('.freashDiv').show()
$('.renewalDiv').hide()
$('.emp_title').text('No of Employees at Inception')
$('.depnd_title').text(' No of Dependents at Inception')
$('.total_title').text('Total Lives at Inception')
$('.gpa_div_elements').show();
} else {
// $('.proposed_div').hide().find('select, input').removeAttr('required');
$('.proposed_div').hide()
$('.gpa_div_elements').hide();
if(lead_type == 1){
$('.freashDiv').hide()
$('.renewalDiv').show()
$('.emp_title').text('No of Employees')
$('.depnd_title').text('No of Dependents')
$('.total_title').text('Total Lives')
}else{
$('.freashDiv').show()
$('.renewalDiv').hide()
$('.emp_title').text('No of Employees at Inception')
$('.depnd_title').text(' No of Dependents at Inception')
$('.total_title').text('Total Lives at Inception')
$('.gpa_div_elements').show();
}
}
// Scroll the newly added select into view and focus on it
@ -747,6 +1125,24 @@ function addHTMLInput(check) {
policy_end_date.setFullYear(policy_end_date.getFullYear() + 1);
policy_end_date.setDate(policy_end_date.getDate() - 1); // Set end date to last day of selected year
policy_end_datePicker.setDate(policy_end_date);
console.log('this object', this);
console.log('id of this element:', this.element);
console.log('id of this element:', this.element.id);
let increment = this.element.id.split('_').pop();
console.log(increment); // Outputs: 1
console.log('increment', increment);
console.log('policy_start_datePicker selectedDates', selectedDates);
console.log('policy_start_datePicker incurred_claim_date_', $("#incurred_claim_date_" + increment).val());
// Recalculate policy_run_days if incurred claim date is already selected
if ($("#incurred_claim_date_" + increment).val()) {
console.log('policy_start_datePicker selectedDates', selectedDates);
calculatePolicyRunDays(increment);
}
}
});
@ -755,6 +1151,32 @@ function addHTMLInput(check) {
allowInput: false
});
var incurred_claim_datepicker = flatpickr("#incurred_claim_date_" + increment, {
dateFormat: "d/m/Y",
allowInput: false,
onChange: function (selectedDates) {
console.log('Flatpickr instance:', this);
console.log('ID of this element:', this.input.id);
// Extract the increment value from the element's ID
let increment = this.input.id.split('_').pop();
console.log('Extracted increment:', increment);
console.log('Selected Dates:', selectedDates);
console.log('Policy Start Date:', $("#policy_start_date_" + increment).val());
// Recalculate policy_run_days if policy start date is already selected
if ($("#policy_start_date_" + increment).val()) {
calculatePolicyRunDays(increment);
}
}
});
var premium_date_datepicker = flatpickr("#premium_date_" + increment, {
dateFormat: "d/m/Y",
allowInput: false
});
$('#source_policy_id').on('change', function(){
let client_policy_id = $(this).val();
console.log('client_policy_id', client_policy_id)
@ -771,8 +1193,7 @@ function addHTMLInput(check) {
increment++; // Increment after adding the input
}
function removeHTMLInput(element)
{
function removeHTMLInput(element) {
const container = document.getElementById('dynamic-form-container');
const rows = container.querySelectorAll('.dynamic-form-row');
@ -790,6 +1211,96 @@ function removeHTMLInput(element)
}
}
function calculatePolicyRunDays(increment) {
console.log('calculatePolicyRunDays function called');
console.log('increment', increment);
var policyStartDate = flatpickr.parseDate($("#policy_start_date_" + increment).val(), "d/m/Y");
var incurredClaimDate = flatpickr.parseDate($("#incurred_claim_date_" + increment).val(), "d/m/Y");
console.log('policyStartDate', policyStartDate)
console.log('incurredClaimDate', incurredClaimDate)
if (policyStartDate && incurredClaimDate) {
var timeDiff = incurredClaimDate - policyStartDate; // Time difference in milliseconds
console.log('timeDiff', timeDiff);
var daysDiff = Math.ceil(timeDiff / (1000 * 60 * 60 * 24)); // Convert to days and add 1
console.log('daysDiff', daysDiff);
$("#policy_run_days_" + increment).val(daysDiff); // Set value in the policy_run_days_ input
}
}
function incurredClaimSum(input) {
let increment = input.id.split('_').pop(); // Extract the increment part
console.log('increment', increment);
// Retrieve and convert the values to numbers, fallback to 0 if empty or invalid
let paid_claims = Number($('#paid_claims_' + increment).val()) || 0;
console.log('paid_claims', paid_claims);
let outstanding_claims = Number($('#outstanding_claims_' + increment).val()) || 0;
console.log('outstanding_claims', outstanding_claims);
// Calculate the incurred claim
let incurred_claims = paid_claims + outstanding_claims;
console.log('incurred_claims', incurred_claims);
// Set the calculated value
$('#incurred_claims_' + increment).val(incurred_claims);
// ------------------------------------------------------------------------------------------
let policy_run_days = Number($('#policy_run_days_' + increment).val()) || 0;
console.log('policy_run_days', policy_run_days);
// Prevent division by zero in annualised claims calculation
let annualised_claims = policy_run_days > 0 ? incurred_claims / policy_run_days * 365 : 0;
console.log('annualised_claims', annualised_claims);
$('#annualised_claims_' + increment).val(annualised_claims);
// ------------------------------------------------------------------------------------------
// Prevent division by zero in incurred claim ratio calculation
let incurred_claim_ratio = annualised_claims > 0 ? incurred_claims / annualised_claims : 0;
console.log('incurred_claim_ratio', incurred_claim_ratio);
$('#incurred_claims_ratio_' + increment).val(incurred_claim_ratio);
// ------------------------------------------------------------------------------------------
let earned_premium = Number($('#earned_premium_' + increment).val()) || 0;
console.log('earned_premium', earned_premium);
// Prevent division by zero in earned claims ratio calculation
let earned_claims_ratio = earned_premium > 0 ? incurred_claims / earned_premium : 0;
console.log('earned_claims_ratio', earned_claims_ratio);
$('#earned_claims_ratio_' + increment).val(earned_claims_ratio);
}
function earnedPremiumCalc(input) {
let increment = input.id.split('_').pop(); // Extract the increment part
console.log('increment', increment);
// Retrieve and convert the values to numbers, fallback to 0 if empty or invalid
let premium_at_inception = Number($('#premium_at_inception_' + increment).val()) || 0;
console.log('premium_at_inception', premium_at_inception);
let policy_run_days = Number($('#policy_run_days_' + increment).val()) || 0;
console.log('policy_run_days', policy_run_days);
// Prevent division by zero and calculate earned premium
let earned_premium = policy_run_days > 0 ? premium_at_inception / policy_run_days : 0;
console.log('earned_premium', earned_premium);
// Set the calculated value with two decimal places
$('#earned_premium_' + increment).val(earned_premium.toFixed(2));
}
//---------------------------------------------------------------------------------------------------------
$("#leads_form_id").submit(function(event) {
@ -826,6 +1337,11 @@ $("#leads_form_id").submit(function(event) {
// Append the JSON string to the FormData object
formData.append('salse_person_id', jsonString);
// Convert the claim experience array to JSON
const finyearJsonString = gatherClaimExperienceData();
console.log('finyearJsonString', finyearJsonString);
formData.append('finyear', finyearJsonString);
$.ajax({
data: formData,
url: form_action,
@ -876,6 +1392,9 @@ $('#lead_type').change(function() {
$('#policy_start_date').removeAttr('required');
$('#claims').removeAttr('required');
$('#freshDiv').hide();
$('.freashDiv').show()
$('.renewalDiv').hide()
$('.gpa_div_elements').show();
$('#gst').val('');
$('#pan').val('');
@ -885,6 +1404,10 @@ $('#lead_type').change(function() {
$('#contact_person_mobile').val('');
$('#contact_person_email').val('');
$('.emp_title').text('No of Employees at Inception')
$('.depnd_title').text(' No of Dependents at Inception')
$('.total_title').text('Total Lives at Inception')
} else {
$('#renewalDiv').find('select, input').removeAttr('required');
@ -905,6 +1428,26 @@ $('#lead_type').change(function() {
$('#client_name').val('');
$('#client_short_name').val('');
$('#entity_type_id').val('');
if(value == 1){
$('.freashDiv').hide()
$('.renewalDiv').show()
$('.emp_title').text('No of Employees')
$('.depnd_title').text('No of Dependents')
$('.total_title').text('Total Lives')
$('.gpa_div_elements').show();
}else{
$('.freashDiv').show()
$('.renewalDiv').hide()
$('.emp_title').text('No of Employees at Inception')
$('.depnd_title').text(' No of Dependents at Inception')
$('.total_title').text('Total Lives at Inception')
$('.gpa_div_elements').show();
}
}
})
@ -929,6 +1472,85 @@ function tpaChange(input, unique_id) {
//-----------------------------------------------------------------------------------------------------------
function sumOfLives(input){
}
function gatherClaimExperienceData() {
// Initialize an empty array for the claim experience data
let claimExperience = [];
// Loop through the rows and extract data for each year
$('input[name="first_year[]"]').each(function(index) {
// Extract values for the first, second, and third year claims
const firstYear = $(this).val();
const firstClaimAmount = $(`input[name="first_claim_amount[]"]`).eq(index).val();
const firstClaimStatus = $(`input[name="first_claim_status[]"]`).eq(index).val();
const firstCauseOfDeath = $(`input[name="first_casue_of_death[]"]`).eq(index).val() || null;
const firstDeathDate = $(`input[name="first_death_date[]"]`).eq(index).val() || null;
const secondYear = $(`input[name="second_year[]"]`).eq(index).val();
const secondClaimAmount = $(`input[name="second_claim_amount[]"]`).eq(index).val();
const secondClaimStatus = $(`input[name="second_claim_status[]"]`).eq(index).val();
const secondCauseOfDeath = $(`input[name="second_casue_of_death[]"]`).eq(index).val() || null;
const secondDeathDate = $(`input[name="second_death_date[]"]`).eq(index).val() || null;
const thirdYear = $(`input[name="third_year[]"]`).eq(index).val();
const thirdClaimAmount = $(`input[name="third_claim_amount[]"]`).eq(index).val();
const thirdClaimStatus = $(`input[name="third_claim_status[]"]`).eq(index).val();
const thirdCauseOfDeath = $(`input[name="third_casue_of_death[]"]`).eq(index).val() || null;
const thirdDeathDate = $(`input[name="third_death_date[]"]`).eq(index).val() || null;
// Push each year's data into the array
claimExperience.push({
"finyear": [
{
"year": firstYear,
"claim_amount": firstClaimAmount,
"status": firstClaimStatus,
"cause_of_death": firstCauseOfDeath,
"death_date": firstDeathDate
},
{
"year": secondYear,
"claim_amount": secondClaimAmount,
"status": secondClaimStatus,
"cause_of_death": secondCauseOfDeath,
"death_date": secondDeathDate
},
{
"year": thirdYear,
"claim_amount": thirdClaimAmount,
"status": thirdClaimStatus,
"cause_of_death": thirdCauseOfDeath,
"death_date": thirdDeathDate
}
]
});
});
return JSON.stringify(claimExperience);
}
function showGpaColumns(input){
let policy_type_id = $(input).val()
let increment = input.id.split("_").pop();
if(policy_type_id != 2){
$('.gpa_hide_div_'+increment).hide();
$('.gpa_show_div_'+increment).show();
$('.gpa_div_elements_'+increment).show();
$('.emp_title').text('No of Employees at Inception')
$('.total_title').text('Total Sum Insured at Inception')
}else{
$('.gpa_hide_div_'+increment).show();
}
}
//-----------------------------------------------------------------------------------------------------------
function getURLParamsForReport() {
const params = new URLSearchParams(window.location.search);

View File

@ -36,6 +36,73 @@ table.dataTable tbody td {
padding: 10px;
margin-bottom: 10px;
}
custom-dropdown-menu {
display: none;
position: fixed;
background-color: #ffffff !important;
border: 1px solid rgba(0,0,0,.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
clear: both !important;
font-weight: 400 !important;
color: #212529 !important;
text-align: inherit !important;
white-space: nowrap !important;
background-color: transparent !important;
border: 0 !important;
text-decoration: none !important;
position: relative !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
.custom-dropdown-menu .dropdown-item i {
margin-right: 8px !important;
vertical-align: middle !important;
}
.table tbody tr {
cursor: pointer;
}
/* Ensure the dropdown menu has a solid background */
.custom-dropdown-menu::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #ffffff;
z-index: -1;
}
/* Add a subtle backdrop effect */
.custom-dropdown-menu::after {
content: '';
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.05);
z-index: -2;
pointer-events: none;
}
</style>
@ -102,11 +169,11 @@ table.dataTable tbody td {
<a href="<?= base_url('/rfq/list/').$row['id'] . '/' . 1; ?>" class="dropdown-item btnEdit" data-id="<?= $row['id']; ?>">
<i class="mdi mdi-note-text mr-2 text-muted font-18 vertical-middle"></i>RFQ
</a>
<?php if($row['qcr_count'] > 0) { ?>
<!-- <?php if($row['qcr_count'] > 0) { ?>
<a href="<?= base_url('/rfq/list/').$row['id'] . '/' . 2; ?>" class="dropdown-item btnEdit" data-id="<?= $row['id']; ?>">
<i class="mdi mdi-note-text mr-2 text-muted font-18 vertical-middle"></i>QCR
</a>
<?php } ?>
<?php } ?> -->
</div>
</div>
</td>
@ -132,6 +199,97 @@ table.dataTable tbody td {
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
// Create custom dropdown
function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
// Hide any active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
// Set as active dropdown
activeDropdown = customDropdown;
event.stopPropagation();
});
// Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
</script>
<script>
var client_list = ''; // local variable for storing the client branch list
var branch_list = ''; // local variable for storing the client branch list
var policy_list = ''; // local variable for storing the client policy list

View File

@ -41,7 +41,7 @@ table.dataTable tbody td {
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-3">
<!-- <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">
<option value="0">Select Client</option>
@ -53,7 +53,7 @@ table.dataTable tbody td {
}
?>
</select>
</div>
</div> -->
<div class="form-group col-md-3">
<label for="addon_policy"> Insurer <span id="base_danger"
@ -69,6 +69,19 @@ table.dataTable tbody td {
</div>
<div class="form-group col-md-3">
<label for="addon_policy"> Insurer Branch<span id="base_danger"
class="text-danger"></span></label>
<select class="form-control" id="insurer_id" name="insurer_id">
<option value="0" selected>Select Insurer</option>
<?php if(isset($insurer) && count($insurer)){ ?>
<?php foreach ($insurer as $value) { ?>
<option value="<?= $value['id']?>"><?= $value['name']?></option>
<?php } ?>
<?php } ?>
</select>
</div>
<!-- <div class="form-group col-md-3">
<label for="email"> Policy Type <span class="text-danger"></span></label>
<select class="form-control" id="policy_type_id" name="policy_type_id">
<option value="0">Select Policy Type</option>
@ -80,9 +93,9 @@ table.dataTable tbody td {
}
?>
</select>
</div>
</div> -->
<div class="form-group col-md-3">
<!-- <div class="form-group col-md-3">
<label for="client_branch">Issuer<span class="text-danger">*</span></label>
<select class="form-control" id="issuer" name="issuer" required>
<option value="0">Select Issure</option>
@ -94,13 +107,13 @@ table.dataTable tbody td {
}
?>
</select>
</div>
</div> -->
</div>
<!-- </div>
<div class="form-row">
<div class="form-row"> -->
<div class="form-group col-md-3">
<!-- <div class="form-group col-md-3">
<label>Date Type<span class="text-danger"></span></label>
<select class="form-control" id="date_type" name="date_type"
onchange="hideDateField()">
@ -113,10 +126,10 @@ table.dataTable tbody td {
}
?>
</select>
</div>
</div> -->
<div class="form-group col-md-3" style="display: none;" id="date_div">
<label>Date<span class="text-danger"></span></label>
<div class="form-group col-md-3" style="display: true;" id="date_div">
<label>Statement Month<span class="text-danger"></span></label>
<div id="reportrange" class="form-control"
style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc; width: 100%">
<i class="fa fa-calendar"></i>&nbsp;
@ -158,28 +171,36 @@ table.dataTable tbody td {
<thead class="bg-light">
<tr>
<th>S.No</th>
<th>Client Name</th>
<!-- <th>Client Name</th> -->
<th>Insurer</th>
<th>Policy</th>
<th>Endorsement No</th>
<th>Insurer<br> Branch</th>
<th>Statement<br> Month</th>
<th>Statement<br> No</th>
<th>Invoice No</th>
<th>Invoice Status</th>
<th>Invoice Date</th>
<th>Invoice Amount</th>
<th>Realization Amount</th>
<th>Outstanding Amount</th>
<th>Realization <br>Amount</th>
<th>Outstanding <br>Amount</th>
</tr>
</thead>
<tbody>
<?php if (isset($outstanding_list)) { ?>
<?php foreach($outstanding_list as $index => $row){ ?>
<?php
// dd($outstanting_list);
if (isset($outstanting_list)) { ?>
<?php foreach($outstanting_list as $index => $row){ ?>
<tr>
<td><?= $index + 1 ?></td>
<td><?php echo $row['client_name']; ?></td>
<td><?php echo $row['insurer_name']; ?></td>
<td><?php echo $row['policy_type'] .' - '. $row['policy_no']; ?></td>
<td><?php echo $row['endorsement_no']; ?></td>
<td><?php echo $row['short_name']; ?></td>
<td><?php echo $row['branch_name']; ?></td>
<td><?php echo change_date_format($row['month'],'Y-m-d','Y-m') ?></td>
<td><?php echo $row['stmt_sno']; ?></td>
<td><?php echo $row['invoice_no']; ?></td>
<td class="center-align-input"><?php echo isset($row['invoice_status']) ? $row['invoice_status'] : ' - '; ?></td>
<td><?php echo change_date_format($row['invoice_date'],'Y-m-d','d-M-Y'); ?></td>
<td class="right-align-input"><?php echo isset($row['invoice_amount']) ? $row['invoice_amount'] : '0.00'; ?></td>
<td class="right-align-input"><?php echo isset($row['realization_amount']) ? $row['realization_amount'] : '0.00'; ?></td>
<td class="right-align-input"><?php echo isset($row['total_paid']) ? $row['total_paid'] : '0.00'; ?></td>
<td class="right-align-input"><?php echo isset($row['outstanding_amount']) ? $row['outstanding_amount'] : '0.00'; ?></td>
</tr>
<?php } ?>
@ -364,10 +385,6 @@ $(function() {
startDate: start,
endDate: end,
ranges: {
'Today': [moment(), moment()],
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
'This Month': [moment().startOf('month'), moment().endOf('month')],
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month')
.endOf('month')

View File

@ -1099,6 +1099,7 @@
}
if (key.includes("family_floaters")) {
let checkboxes = document.querySelectorAll(`input[name="${key}[]"]`);
if (jsonObject[key]) {
@ -1133,6 +1134,8 @@
$('#family_floaters').val('1PIL');
} else if (jsonObject[key]['parents-in-law'] == 2) {
$('#family_floaters').val('2PIL');
} else if (jsonObject[key]['either-parents-pil'] == 2) {
$('#family_floaters').val('4EPORPIL');
}
}

View File

@ -36,6 +36,73 @@ table.dataTable thead th {
padding: 10px;
margin-bottom: 10px;
}
custom-dropdown-menu {
display: none;
position: fixed;
background-color: #ffffff !important;
border: 1px solid rgba(0,0,0,.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
clear: both !important;
font-weight: 400 !important;
color: #212529 !important;
text-align: inherit !important;
white-space: nowrap !important;
background-color: transparent !important;
border: 0 !important;
text-decoration: none !important;
position: relative !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
.custom-dropdown-menu .dropdown-item i {
margin-right: 8px !important;
vertical-align: middle !important;
}
.table tbody tr {
cursor: pointer;
}
/* Ensure the dropdown menu has a solid background */
.custom-dropdown-menu::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #ffffff;
z-index: -1;
}
/* Add a subtle backdrop effect */
.custom-dropdown-menu::after {
content: '';
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.05);
z-index: -2;
pointer-events: none;
}
</style>
<div class="row" id="endorsement_filter">
@ -232,7 +299,96 @@ table.dataTable thead th {
<!-- end table row -->
<?php include('policy_transaction_endorsement_form.php'); ?>
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
// Create custom dropdown
function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
// Hide any active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
// Set as active dropdown
activeDropdown = customDropdown;
event.stopPropagation();
});
// Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
</script>
<script>
var client_list = ''; // local variable for storing the client branch list

File diff suppressed because it is too large Load Diff

View File

@ -45,6 +45,73 @@ table.dataTable tbody td {
.addbtnStyle{
margin-left: 20px !important;
}
custom-dropdown-menu {
display: none;
position: fixed;
background-color: #ffffff !important;
border: 1px solid rgba(0,0,0,.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
clear: both !important;
font-weight: 400 !important;
color: #212529 !important;
text-align: inherit !important;
white-space: nowrap !important;
background-color: transparent !important;
border: 0 !important;
text-decoration: none !important;
position: relative !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
.custom-dropdown-menu .dropdown-item i {
margin-right: 8px !important;
vertical-align: middle !important;
}
.table tbody tr {
cursor: pointer;
}
/* Ensure the dropdown menu has a solid background */
.custom-dropdown-menu::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #ffffff;
z-index: -1;
}
/* Add a subtle backdrop effect */
.custom-dropdown-menu::after {
content: '';
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.05);
z-index: -2;
pointer-events: none;
}
</style>
<style>
@ -339,6 +406,95 @@ table.dataTable tbody td {
</div>
</div>
</div>
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
// Create custom dropdown
function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
// Hide any active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
// Set as active dropdown
activeDropdown = customDropdown;
event.stopPropagation();
});
// Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
</script>
<script>

View File

@ -1,3 +1,71 @@
<style>
.custom-dropdown-menu {
display: none;
position: fixed;
background-color: #ffffff !important;
border: 1px solid rgba(0,0,0,.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
clear: both !important;
font-weight: 400 !important;
color: #212529 !important;
text-align: inherit !important;
white-space: nowrap !important;
background-color: transparent !important;
border: 0 !important;
text-decoration: none !important;
position: relative !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
.custom-dropdown-menu .dropdown-item i {
margin-right: 8px !important;
vertical-align: middle !important;
}
.table tbody tr {
cursor: pointer;
}
/* Ensure the dropdown menu has a solid background */
.custom-dropdown-menu::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #ffffff;
z-index: -1;
}
/* Add a subtle backdrop effect */
.custom-dropdown-menu::after {
content: '';
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.05);
z-index: -2;
pointer-events: none;
}
</style>
<div class="row" id="policy_list">
<div class="col-12">
<div class="card">
@ -51,6 +119,90 @@
</div>
<!-- end row -->
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
// Create custom dropdown
function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
// Hide any active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
// Set as active dropdown
activeDropdown = customDropdown;
event.stopPropagation();
});
// Preserve click handlers
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
e.stopPropagation();
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
</script>
<script>
$(document).ready(function(){

View File

@ -27,7 +27,7 @@ table.dataTable tbody td {
<div class="card-body">
<div class="row" style="padding-bottom: 10px;">
<div class="col-6" style="align-self: center;">
<h4 style="position: relative;">BDS Report</h4>
<h4 style="position: relative;">BDS Report <span id="bds_title"></span></h4>
</div>
</div>
@ -62,17 +62,9 @@ table.dataTable tbody td {
<th>Base <br> Revenue %</th>
<th>TP / Terrorism <br> Revenue %</th>
<th>Total IRDA <br> Revenue INR</th>
<th>GST on Revenue</th>
<th>Total Amount <br> Receivable</th>
<th>Billed Amount</th>
<th>UnBilled Amount</th>
<th>Rewards</th>
<th>Invoice Number</th>
<th>Invoice Date</th>
<th>Invoice Amount</th>
<th>Realization Amount</th>
<th>Outstanding Amount</th>
<th>Payment Status</th>
<th>UTR</th>
<th>Payment Date</th>
</tr>
</thead>
<tbody>
@ -105,28 +97,11 @@ table.dataTable tbody td {
<td class="right-align-input"><?php echo $row['total_premium']; ?></td>
<td class="right-align-input"><?php echo $row['agreed_bp_per']; ?>&nbsp;%</td>
<td class="right-align-input"><?php echo $row['agreed_tp_or_ter_per'];?>&nbsp;%</td>
<td class="right-align-input"><?php echo $row['total_irda']; ?></td>
<td class="right-align-input"><?php echo $row['gst_on_revenue']; ?></td>
<td class="right-align-input"><?php echo $row['total_amt_received']; ?></td>
<td class="right-align-input" onclick="showCoShareStatementDetails(this)" data-id="<?= $row['pt_id'] ?>"><?php echo empty($row['total_irda_amt']) ? $row['exp_amt'] : $row['total_irda_amt']; ?></td>
<td class="right-align-input"><?php echo empty($row['billed_amt']) ? '0.00' : $row['billed_amt'] ?></td>
<!-- <td class="right-align-input"><?php echo empty($row['unbilled_amt']) ? '0.00' : $row['unbilled_amt']?></td> -->
<td class="right-align-input"><?php echo number_format((float)$row['total_irda_amt'] - $row['billed_amt'],2, '.', '')?></td>
<td class="right-align-input"><?php echo $row['reward']; ?></td>
<td><?php echo $row['invoice_no']; ?></td>
<td><?php echo empty($row['invoice_date']) ? '' : date('d/m/Y', strtotime($row['invoice_date'])); ?></td>
<td class="right-align-input"><?php echo $row['invoice_amount']; ?></td>
<td class="right-align-input"><?php echo $row['realization_amount']; ?></td>
<td class="right-align-input"><?php echo $row['outstanding_amount']; ?></td>
<td>
<?php
if($row['outstanding_amount'] == '0.00'){
echo 'Payment Received';
}else if($row['outstanding_amount'] == NULL){
echo '';
}else{
echo 'Partially Received';
}
?>
</td>
<td><?php echo $row['utr_numbers']; ?></td>
<td><?php echo $row['payment_dates']; ?></td>
</tr>
<?php } ?>
<?php } ?>
@ -140,6 +115,38 @@ table.dataTable tbody td {
</div>
</div>
<!-- modal content -->
<div class="modal fade" id="centermodal" tabindex="-1" role="dialog" aria-hidden="true" aria-modal="true" data-backdrop="static">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header" style="background-color: gainsboro;">
<h4 class="modal-title" id="myCenterModalLabel">Statement Details <span id="heading"></span></h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body" id="modal_body">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead class="bg-light" id="table_head_data">
<tr>
<th>Statement No.</th>
<th>Statement Month</th>
<th>Actual Amount</th>
<th>Invoice No.</th>
<th>Invoice Date.</th>
<th>Invoice Status.</th>
</tr>
</thead>
<tbody id="table_data">
</tbody>
</table>
</div> <!-- end table-responsive-->
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-------------------------------------------------------------------------------------------------->
<script>
// Datatable document ready
$(document).ready(function() {
@ -197,8 +204,68 @@ $(document).ready(function() {
ordering: false,
});
} else {
console.error("Table not found.");
console.error("Table atet found.");
}
});
// ----------------------------------------------------------------------------------------------------
function showCoShareStatementDetails(input){
let pt_id = $(input).data('id');
console.log('pt_id', pt_id)
var myModal = new bootstrap.Modal(document.getElementById('centermodal'));
myModal.show();
getCoShareStatementDetails(pt_id)
}
function getCoShareStatementDetails(pt_id){
let url = '<?= base_url('util/getCoShareStatementDetails/') ?>' + pt_id;
sendAjaxRequestForGlobal(url, 'GET', {}, function(response) {
console.log('Data fetched successfully:', response);
if (response.status === true) {
appendTableData(response.data)
} else {
toastr.warning(response.message, 'WARNING');
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
});
}
function appendTableData(data) {
// Ensure the table body selector matches your table's structure
let tableBody = $("#table_data");
// Clear the table body before appending new rows
tableBody.empty();
// Loop through the data and append rows
data.forEach(row => {
let tableRow = `
<tr>
<td>${row.stmt_sno ?? '-'}</td>
<td>${row.month ?? '-'}</td>
<td>${row.sum_of_actual_amt ?? '-'}</td>
<td>${row.invoice_no ?? '-'}</td>
<td>${row.invoice_date ?? '-'}</td>
<td>${row.invoice_status ?? '-'}</td>
</tr>
`;
tableBody.append(tableRow);
});
}
</script>

View File

@ -22,31 +22,35 @@
<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" >
<select class="form-control" id="client_id" name="client_id" onchange="getClientPolicyDataBasedOnClientAndInsuer()">
<option value="0">Select Client</option>
<?php
if (isset($clients) && count($clients)) {
foreach ($clients as $key => $value) {
echo "<option value='" . $value['id'] . "'>" . $value['client_name'] . "</option>";
}
}
?>
</select>
</div>
<div class="form-group col-md-3">
<label for="addon_policy"> Insurer <span id="base_danger" class="text-danger"></span></label>
<select class="form-control" id="insurer_id" name="insurer_id" >
<label for="client_branch_id">Client Branch<span class="text-danger"></span></label>
<select class="form-control" id="client_branch_id" name="client_branch_id" onchange="getClientPolicyDataBasedOnClientAndInsuer()">
<option value="0">Select Client Branch</option>
</select>
</div>
<div class="form-group col-md-3">
<label for="insurer_id"> Insurer <span id="base_danger" class="text-danger"></span></label>
<select class="form-control" id="insurer_id" name="insurer_id" onchange="getClientPolicyDataBasedOnClientAndInsuer()" >
<option value="0" selected>Select Insurer</option>
<?php foreach ($insurer as $value) { ?>
<option value="<?= $value['id']?>"><?= $value['name']?></option>
<?php } ?>
</select>
</div>
<div class="form-group col-md-3">
<label for="insurer_branch_id"> Insurer Branch <span id="base_danger" class="text-danger"></span></label>
<select class="form-control" id="insurer_branch_id" name="insurer_branch_id" onchange="getClientPolicyDataBasedOnClientAndInsuer()">
<option value="0" selected>Select Insurer Branch</option>
</select>
</div>
<div class="form-group col-md-3">
<label for="email"> Policy Type <span class="text-danger"></span></label>
<select class="form-control" id="policy_type_id" name="policy_type_id" >
<select class="form-control" id="policy_type_id" name="policy_type_id" onchange="getClientPolicyDataBasedOnClientAndInsuer()">
<option value="0">Select Policy Type</option>
<?php
if (isset($policy_types) && count($policy_types)) {
@ -58,6 +62,13 @@
</select>
</div>
<div class="form-group col-md-3">
<label for="client_policy_id"> Client Policy <span id="base_danger" class="text-danger"></span></label>
<select class="form-control" id="client_policy_id" name="client_policy_id" >
<option value="0" selected>Select client policy</option>
</select>
</div>
<div class="form-group col-md-3">
<label for="client_branch">Issuer<span class="text-danger">*</span></label>
<select class="form-control" id="issuer" name="issuer" required>
@ -72,13 +83,10 @@
</select>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-3">
<label>Date Type<span class="text-danger"></span></label>
<select class="form-control" id="date_type" name="date_type" onchange="hideDateField()">
<select class="form-control" id="date_type" name="date_type" onchange="hideDateField(); changeTitle();">
<option value="0">Select Date Type</option>
<?php
if (isset($date_type) && count($date_type)) {
@ -100,7 +108,7 @@
<input type="hidden" id="endDate">
</div>
<div class="form-group col-md-3 text-right m-b-0" style="margin-top: 29px;">
<div class="form-group col-md-12 text-right m-b-0" style="margin-top: 29px;">
<a href="<?= base_url("/policy_tranction/report/list"); ?>" class="btn btn-secondary" id="clear-filters">Clear</a>
<a href="<?= base_url("/policy_tranction/report/list"); ?>" class="btn btn-primary" id="get-emp-list" onclick="fetchEmpolyeeList(event);">Submit</a>
</div>
@ -130,11 +138,23 @@
<script>
let client_list = [];
let branch_list = [];
let policy_list = [];
let insurer_list = [];
let insurer_branch_list = [];
$(document).ready(function() {
getClientAndBranchAndPolicy()
getURLParams()
$('#client_id').select2();
$('#client_branch_id').select2();
$('#insurer_id').select2();
$('#insurer_branch_id').select2();
$('#policy_type_id').select2();
$('#client_policy_id').select2();
})
function fetchEmpolyeeList(event)
@ -148,6 +168,9 @@ function fetchEmpolyeeList(event)
var policy_type_id = $('#policy_type_id').val();
var date_type = $('#date_type').val();
var issuer = $('#issuer').val();
var client_branch_id = $('#client_branch_id').val();
var insurer_branch_id = $('#insurer_branch_id').val();
var client_policy_id = $('#client_policy_id').val();
console.log(start_date + '-' + end_date);
@ -159,6 +182,9 @@ function fetchEmpolyeeList(event)
policy_type_id: policy_type_id,
date_type: date_type,
issuer: issuer,
client_branch_id: client_branch_id,
insurer_branch_id: insurer_branch_id,
client_policy_id: client_policy_id,
};
const queryString = objectToQueryString(queryParams);
@ -184,6 +210,9 @@ function getURLParams()
const policy_type_id = params.get('policy_type_id') || 0; // Default to 0 if not found
const date_type = params.get('date_type') || 0; // Default to 0 if not found
const issuer = params.get('issuer') || 0; // Default to 0 if not found
const client_branch_id = params.get('client_branch_id') || 0; // Default to 0 if not found
const insurer_branch_id = params.get('insurer_branch_id') || 0; // Default to 0 if not found
const client_policy_id = params.get('client_policy_id') || 0; // Default to 0 if not found
hideDateField(date_type)
@ -194,6 +223,9 @@ function getURLParams()
console.log('policy_type_id', policy_type_id)
console.log('date_type', date_type)
console.log('issuer', issuer)
console.log('client_branch_id', client_branch_id)
console.log('insurer_branch_id', insurer_branch_id)
console.log('client_policy_id', client_policy_id)
// Log the values or use them as needed
console.log('Start Date:', startDate);
@ -203,11 +235,18 @@ function getURLParams()
setTimeout(function(){
$('#start_date').val(startDate)
$('#end_date').val(endDate)
$('#client_id').val(client_id).change()
$('#insurer_id').val(insurer_id).change()
$('#policy_type_id').val(policy_type_id).change()
$('#date_type').val(date_type)
$('#client_id').val(client_id).select2()
$('#insurer_id').val(insurer_id).select2()
$('#policy_type_id').val(policy_type_id).select2()
$('#date_type').val(date_type).trigger('change');
$('#issuer').val(issuer)
setTimeout(function(){
$('#client_branch_id').val(client_branch_id).select2()
$('#insurer_branch_id').val(insurer_branch_id).select2()
setTimeout(function(){
$('#client_policy_id').val(client_policy_id).select2();
}, 1000);
}, 2000)
},1000)
}
@ -283,4 +322,225 @@ function hideDateField(input = null)
}
}
// -----------------------------------------------------------------------------------------------
//featch client, client branch, insurer, insurer branch and client policy list data
function getClientAndBranchAndPolicy()
{
$.ajax({
url: '<?= base_url("/util/getClientAndBranchAndPolicy") ?>',
type: "GET",
dataType: 'json',
success: function(res) {
console.log('getClientAndBranchAndPolicy', res);
if(res.status == true){
client_list = res.client_data;
branch_list = res.branch_data;
policy_list = res.policy_data;
insurer_list = res.insurer_data;
insurer_branch_list = res.insurer_branch_data;
appendClients(res.client_data);
appendInsurer(res.insurer_data);
}else{
console.log('No data found');
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
}
//append clients for filter
function appendClients(data)
{
$('#client_id').empty();
$('#client_id').append($('<option>', {
value: '',
text: 'Select Client'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.client_name,
'data-cn': item.client_name,
'data-ct': item.client_type,
class: (item.client_type == 1) ? 'group' : (item.client_type == 2) ? 'individual' : ''
});
$('#client_id').append(option);
});
}
//append clients branch for filter
function appendBranch(data)
{
$('#client_branch_id').empty();
$('#client_branch_id').append($('<option>', {
value: '',
text: 'Select Branch'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.branch_name
});
$('#client_branch_id').append(option);
});
}
//append insurer for filter
function appendInsurer(data)
{
$('#insurer_id').empty();
$('#insurer_id').append($('<option>', {
value: '',
text: 'Select Insurer'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.name,
});
$('#insurer_id').append(option);
});
}
//append insurer branch for filter
function appendInsurerBranch(data)
{
$('#insurer_branch_id').empty();
$('#insurer_branch_id').append($('<option>', {
value: '',
text: 'Select Insurer Branch'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.branch_name
});
$('#insurer_branch_id').append(option);
});
}
//append client policy for filter
function appendPolicies(data)
{
// console.log('appendPolicies', data);
// console.log('appendPolicies', $('#client_policy_id'));
$('#client_policy_id').empty();
$('#client_policy_id').append($('<option>', {
value: '',
text: 'Select Policy',
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.policy_type + '-' + item.policy_no,
});
$('#client_policy_id').append(option);
});
}
// -------------------------------------------------------------------------------------------------
//client branch and insurer branch onchange document ready function
$(document).ready(function(){
$('#client_id').change(function(){
let client_id = $(this).val();
console.log('client_id', client_id);
if(branch_list != '') {
// console.log(branch_list[client_id]);
let data = branch_list[client_id];
appendBranch(data);
}
})
$('#insurer_id').change(function(){
let insurer_id = $(this).val();
console.log('insurer_id', insurer_id);
if(insurer_branch_list != '') {
// console.log(insurer_branch_list[insurer_id]);
let data = insurer_branch_list[insurer_id];
appendInsurerBranch(data);
}
})
});
//get policy list based on the client, client_branch, insurer, insurer_branch and policy type
function getClientPolicyDataBasedOnClientAndInsuer(){
let client_id = $('#client_id').val() ?? 0;
let client_branch_id = $('#client_branch_id').val() ?? 0;
let insurer_id = $('#insurer_id').val() ?? 0;
let insurer_branch_id = $('#insurer_branch_id').val() ?? 0;
let policy_type_id = $('#policy_type_id').val() ?? 0;
let url = '<?= base_url('util/getClientPolicyDataBasedOnClientAndInsuer/') ?>';
let requestData = {
client_id: client_id,
client_branch_id: client_branch_id,
insurer_id: insurer_id,
insurer_branch_id: insurer_branch_id,
policy_type_id: policy_type_id,
};
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status === true) {
appendPolicies(response.data)
} else {
toastr.warning(response.message, 'WARNING');
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
});
}
//for the change title
function changeTitle(input){
let val = $(input).val();
if(val == 'statement_month'){
$('#bds_title').text(' - Statement Month Wise List')
}else{
$('#bds_title').text(' - Policy Wise List')
}
}
</script>

View File

@ -0,0 +1,204 @@
<style>
.table th,
.table td {
padding: 8px;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
.col-12 {
max-width: 98% !important;
}
.dataTables_filter {
position: absolute;
}
.right-align-input {
text-align: right;
}
</style>
<div class="col-12" id="second_page">
<div class="card">
<div class="card-body">
<div class="row" style="padding-bottom: 10px;">
<div class="col-6" style="align-self: center;">
<h4 style="position: relative;">BDS Report</h4>
</div>
</div>
<div class="table-responsive">
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="bg-light">
<tr>
<th>S. No</th>
<th>Month</th>
<th>Business Type</th>
<th>Client Type</th>
<th>Insured Name</th>
<th>Policy/<br>Endorsement</th>
<th>Policy Type</th>
<th>BAP Group</th>
<th>Vehicle Number</th>
<th>Policy No</th>
<th>Endorsement No</th>
<th>Insurer Name</th>
<th>Insurer Branch</th>
<th>TPA</th>
<th>Endorsement <br> Effective Date</th>
<th>Policy <br> Effective Date</th>
<th>Policy <br> Expiry Date</th>
<th>Reference</th>
<th>Remarks</th>
<th>Base Premium</th>
<th>Terrorism/TP</th>
<th>Premium <br> (without GST)</th>
<th>GST @ 18%</th>
<th>Total Premium</th>
<th>Base <br> Revenue %</th>
<th>TP / Terrorism <br> Revenue %</th>
<th>Total IRDA <br> Revenue INR</th>
<th>GST on Revenue</th>
<th>Total Amount <br> Receivable</th>
<th>Rewards</th>
<th>Invoice Number</th>
<th>Invoice Date</th>
<th>Invoice Amount</th>
<th>Realization Amount</th>
<th>Outstanding Amount</th>
<th>Payment Status</th>
<th>UTR</th>
<th>Payment Date</th>
</tr>
</thead>
<tbody>
<?php if (isset($report_list)) { ?>
<?php foreach($report_list as $index => $row){ ?>
<tr>
<td><?= $index + 1 ?></td>
<td><?php echo $row['policy_issue_month']; ?></td>
<td><?php echo $row['revenue_type']; ?></td>
<td><?php echo $row['client_type']; ?></td>
<td><?php echo $row['client_name']; ?></td>
<td><?php echo $row['action_type']; ?></td>
<td><?php echo $row['policy_type']; ?></td>
<td><?php echo $row['bap']; ?></td>
<td><?php echo $row['vehicle_no'] ?? 'N.A'; ?></td>
<td><?php echo $row['policy_no']; ?></td>
<td><?php echo $row['endorsement_no']; ?></td>
<td><?php echo $row['insurer_name']; ?> </td>
<td><?php echo $row['insurer_branch_name']; ?></td>
<td><?php echo $row['tpa_name']; ?></td>
<td><?php echo empty($row['endorse_eff_date']) ? '' : date('d/m/Y', strtotime($row['endorse_eff_date'])) ?></td>
<td><?php echo empty($row['policy_start_date']) ? '' : date('d/m/Y', strtotime($row['policy_start_date'])); ?></td>
<td><?php echo empty($row['policy_end_date']) ? '' : date('d/m/Y', strtotime($row['policy_end_date'])); ?></td>
<td><?php echo $row['ref']; ?></td>
<td><?php echo $row['remarks']; ?></td>
<td class="right-align-input"><?php echo $row['bp_amt']; ?></td>
<td class="right-align-input"><?php echo $row['tp_or_ter']; ?></td>
<td class="right-align-input"><?php echo $row['premium_wo_gst']; ?></td>
<td class="right-align-input"><?php echo $row['gst_amount']; ?></td>
<td class="right-align-input"><?php echo $row['total_premium']; ?></td>
<td class="right-align-input"><?php echo $row['agreed_bp_per']; ?>&nbsp;%</td>
<td class="right-align-input"><?php echo $row['agreed_tp_or_ter_per'];?>&nbsp;%</td>
<td class="right-align-input"><?php echo $row['total_irda']; ?></td>
<td class="right-align-input"><?php echo $row['gst_on_revenue']; ?></td>
<td class="right-align-input"><?php echo $row['total_amt_received']; ?></td>
<td class="right-align-input"><?php echo $row['reward']; ?></td>
<td><?php echo $row['invoice_no']; ?></td>
<td><?php echo empty($row['invoice_date']) ? '' : date('d/m/Y', strtotime($row['invoice_date'])); ?></td>
<td class="right-align-input"><?php echo $row['invoice_amount']; ?></td>
<td class="right-align-input"><?php echo $row['realization_amount']; ?></td>
<td class="right-align-input"><?php echo $row['outstanding_amount']; ?></td>
<td>
<?php
if($row['outstanding_amount'] == '0.00'){
echo 'Payment Received';
}else if($row['outstanding_amount'] == NULL){
echo '';
}else{
echo 'Partially Received';
}
?>
</td>
<td><?php echo $row['utr_numbers']; ?></td>
<td><?php echo $row['payment_dates']; ?></td>
</tr>
<?php } ?>
<?php } ?>
</tbody>
</table>
<div>
</div>
</div>
</div><!-- end col -->
</div>
</div>
<script>
// Datatable document ready
$(document).ready(function() {
var ticketsTable = $('#scroll-horizontal-datatable');
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
buttons: [
{
extend: 'csv',
text: 'CSV',
title: 'Policy-Tranction-BDS-List',
},
{
extend: 'excel',
text: 'Excel',
title: 'Policy-Tranction-BDS-List',
customize: function(xlsx) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
var total = 0;
// Find cells in column AB (28th column in Excel)
$('row c[r^="AB"]', sheet).each(function() {
var value = parseFloat($('v', this).text()); // Get the value inside the cell
if (!isNaN(value)) {
total += value;
}
});
// Get the last row index and append the total row
var lastRow = $('row:last', sheet);
var rowIndex = parseInt(lastRow.attr('r')) + 2; // Find the next row index
var totalRow = '<row r="' + rowIndex + '">' +
'<c t="inlineStr" r="AA' + rowIndex + '"><is><t>Total</t></is></c>' + // Insert "Total" in AA
'<c t="n" r="AB' + rowIndex + '"><v>' + total.toFixed(2) + '</v></c>' + // Insert sum in AB
'</row>';
// Append the new total row to the sheet
$(sheet).find('sheetData').append(totalRow);
}
}
],
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."
},
paging: true, // Enable pagination
pageLength: 25, // Set default number of rows per page (optional)
ordering: false,
});
} else {
console.error("Table not found.");
}
});
</script>

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,71 @@
<style>
custom-dropdown-menu {
display: none;
position: fixed;
background-color: #ffffff !important;
border: 1px solid rgba(0,0,0,.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
clear: both !important;
font-weight: 400 !important;
color: #212529 !important;
text-align: inherit !important;
white-space: nowrap !important;
background-color: transparent !important;
border: 0 !important;
text-decoration: none !important;
position: relative !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
.custom-dropdown-menu .dropdown-item i {
margin-right: 8px !important;
vertical-align: middle !important;
}
.table tbody tr {
cursor: pointer;
}
/* Ensure the dropdown menu has a solid background */
.custom-dropdown-menu::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #ffffff;
z-index: -1;
}
/* Add a subtle backdrop effect */
.custom-dropdown-menu::after {
content: '';
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.05);
z-index: -2;
pointer-events: none;
}
</style>
<div class="row" id="tpa_list">
<div class="col-12">
<div class="card">
@ -42,6 +110,94 @@
</div><!-- end col -->
</div>
<!-- end row -->
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
// Create custom dropdown
function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
// Hide any active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
// Set as active dropdown
activeDropdown = customDropdown;
event.stopPropagation();
});
// Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
</script>
<script>

View File

@ -27,6 +27,7 @@ table.dataTable tbody td {
</style>
<div class="row" id="varience_filter">
<div class="col-12" style="margin-top: -12px;">
<div id="accordion" class="mb-3">
<div class="card mb-1">
@ -43,34 +44,35 @@ table.dataTable tbody td {
<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">
<select class="form-control" id="client_id" name="client_id" onchange="getClientPolicyDataBasedOnClientAndInsuer()">
<option value="0">Select Client</option>
<?php
if (isset($clients) && count($clients)) {
foreach ($clients as $key => $value) {
echo "<option value='" . $value['id'] . "'>" . $value['client_name'] . "</option>";
}
}
?>
</select>
</div>
<div class="form-group col-md-3">
<label for="addon_policy"> Insurer <span id="base_danger"
class="text-danger"></span></label>
<select class="form-control" id="insurer_id" name="insurer_id">
<label for="client_branch_id">Client Branch<span class="text-danger"></span></label>
<select class="form-control" id="client_branch_id" name="client_branch_id" onchange="getClientPolicyDataBasedOnClientAndInsuer()">
<option value="0">Select Client Branch</option>
</select>
</div>
<div class="form-group col-md-3">
<label for="insurer_id"> Insurer <span id="base_danger" class="text-danger"></span></label>
<select class="form-control" id="insurer_id" name="insurer_id" onchange="getClientPolicyDataBasedOnClientAndInsuer()" >
<option value="0" selected>Select Insurer</option>
<?php if(isset($insurer) && count($insurer)){ ?>
<?php foreach ($insurer as $value) { ?>
<option value="<?= $value['id']?>"><?= $value['name']?></option>
<?php } ?>
<?php } ?>
</select>
</div>
<div class="form-group col-md-3">
<label for="insurer_branch_id"> Insurer Branch <span id="base_danger" class="text-danger"></span></label>
<select class="form-control" id="insurer_branch_id" name="insurer_branch_id" onchange="getClientPolicyDataBasedOnClientAndInsuer()">
<option value="0" selected>Select Insurer Branch</option>
</select>
</div>
<div class="form-group col-md-3">
<label for="email"> Policy Type <span class="text-danger"></span></label>
<select class="form-control" id="policy_type_id" name="policy_type_id">
<select class="form-control" id="policy_type_id" name="policy_type_id" onchange="getClientPolicyDataBasedOnClientAndInsuer()">
<option value="0">Select Policy Type</option>
<?php
if (isset($policy_types) && count($policy_types)) {
@ -82,6 +84,13 @@ table.dataTable tbody td {
</select>
</div>
<div class="form-group col-md-3">
<label for="client_policy_id"> Client Policy <span id="base_danger" class="text-danger"></span></label>
<select class="form-control" id="client_policy_id" name="client_policy_id" >
<option value="0" selected>Select client policy</option>
</select>
</div>
<div class="form-group col-md-3">
<label for="client_branch">Issuer<span class="text-danger">*</span></label>
<select class="form-control" id="issuer" name="issuer" required>
@ -96,10 +105,6 @@ table.dataTable tbody td {
</select>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-3">
<label>Date Type<span class="text-danger"></span></label>
<select class="form-control" id="date_type" name="date_type"
@ -135,6 +140,7 @@ table.dataTable tbody td {
class="btn btn-primary" id="get-emp-list"
onclick="fetchEmpolyeeList(event);">Submit</a>
</div>
</div>
</div>
</div>
@ -158,17 +164,15 @@ table.dataTable tbody td {
<thead class="bg-light">
<tr>
<th>S.No</th>
<th>Client Name</th>
<th>Client</th>
<th>Client Branch</th>
<th>Insurer</th>
<th>Insurer Branch</th>
<th>Policy</th>
<!-- <th>Policy No</th> -->
<th>Endorsement No</th>
<th>Expected Amount</th>
<th>Invoice Status</th>
<th>Invoice Amount</th>
<th>Realization Amount</th>
<th>Statement Amount</th>
<th>Variance</th>
<!-- <th>Action</th> -->
</tr>
</thead>
<tbody>
@ -177,34 +181,14 @@ table.dataTable tbody td {
<tr>
<td><?= $index + 1 ?></td>
<td><?php echo $row['client_name']; ?></td>
<td><?php echo $row['client_branch_name']; ?></td>
<td><?php echo $row['insurer_name']; ?></td>
<td><?php echo $row['insurer_branch_name']; ?></td>
<td><?php echo $row['policy_type'] .' - '. $row['policy_no']; ?></td>
<!-- <td><?php echo $row['policy_no']; ?></td> -->
<td><?php echo $row['endorsement_no']; ?></td>
<td class="right-align-input"><?php echo $row['exp_amt']; ?></td>
<td class="center-align-input"><?php echo isset($row['invoice_status']) ? $row['invoice_status'] : ' - '; ?></td>
<td class="right-align-input"><?php echo isset($row['invoice_amount']) ? $row['invoice_amount'] : '0.00'; ?></td>
<td class="right-align-input"><?php echo isset($row['realization_amount']) ? $row['realization_amount'] : '0.00'; ?></td>
<td class="right-align-input"><?php echo $row['variance']; ?></td>
<!-- <td>
<div class="btn-group dropdown">
<a href="javascript: void(0);"
class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"
aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a href="
<?php
if ($row['action_type'] == 'I') {
echo base_url("/policy_tranction/inception/list") . '?pt_id=' . $row['id'];
} else {
echo base_url("/policy_tranction/endorsement/list") . '?pt_id=' . $row['id'];
}
?>" id="get-policy-list" class="dropdown-item btnEdit">
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
</a>
</div>
</div>
</td> -->
<td class="right-align-input"><?php echo $row['statement_amount']; ?></td>
<td class="right-align-input"><?php echo $row['variance_amt']; ?></td>
</tr>
<?php } ?>
<?php } ?>
@ -219,6 +203,13 @@ table.dataTable tbody td {
</div>
<script>
let client_list = [];
let branch_list = [];
let policy_list = [];
let insurer_list = [];
let insurer_branch_list = [];
// Datatable document ready
$(document).ready(function() {
@ -282,13 +273,18 @@ $(document).ready(function() {
});
$(document).ready(function() {
getClientAndBranchAndPolicy()
getURLParams()
$('#client_id').select2();
$('#client_branch_id').select2();
$('#insurer_id').select2();
$('#insurer_branch_id').select2();
$('#client_policy_id').select2();
$('#policy_type_id').select2();
})
function fetchEmpolyeeList(event) {
function fetchEmpolyeeList(event)
{
event.preventDefault(); // Prevent default action
var start_date = $('#startDate').val();
@ -298,6 +294,9 @@ function fetchEmpolyeeList(event) {
var policy_type_id = $('#policy_type_id').val();
var date_type = $('#date_type').val();
var issuer = $('#issuer').val();
var client_branch_id = $('#client_branch_id').val();
var insurer_branch_id = $('#insurer_branch_id').val();
var client_policy_id = $('#client_policy_id').val();
console.log(start_date + '-' + end_date);
@ -309,6 +308,9 @@ function fetchEmpolyeeList(event) {
policy_type_id: policy_type_id,
date_type: date_type,
issuer: issuer,
client_branch_id: client_branch_id,
insurer_branch_id: insurer_branch_id,
client_policy_id: client_policy_id,
};
const queryString = objectToQueryString(queryParams);
@ -321,7 +323,8 @@ function objectToQueryString(obj) {
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
}
function getURLParams() {
function getURLParams()
{
const url = new URL(window.location.href);
const params = new URLSearchParams(url.search);
@ -332,6 +335,9 @@ function getURLParams() {
const policy_type_id = params.get('policy_type_id') || 0; // Default to 0 if not found
const date_type = params.get('date_type') || 0; // Default to 0 if not found
const issuer = params.get('issuer') || 0; // Default to 0 if not found
const client_branch_id = params.get('client_branch_id') || 0; // Default to 0 if not found
const insurer_branch_id = params.get('insurer_branch_id') || 0; // Default to 0 if not found
const client_policy_id = params.get('client_policy_id') || 0; // Default to 0 if not found
hideDateField(date_type)
@ -339,16 +345,19 @@ function getURLParams() {
console.log('endDate', endDate)
console.log('client_id', client_id)
console.log('insurer_id', insurer_id)
console.log('policy_type_id', policy_type_id)
console.log('policy_type_id', policy_type_id)
console.log('date_type', date_type)
console.log('issuer', issuer)
console.log('client_branch_id', client_branch_id)
console.log('insurer_branch_id', insurer_branch_id)
console.log('client_policy_id', client_policy_id)
// Log the values or use them as needed
console.log('Start Date:', startDate);
console.log('End Date:', endDate);
if (startDate != 0 && endDate != 0) {
setTimeout(function() {
setTimeout(function(){
$('#start_date').val(startDate)
$('#end_date').val(endDate)
$('#client_id').val(client_id).change()
@ -356,7 +365,14 @@ function getURLParams() {
$('#policy_type_id').val(policy_type_id).change()
$('#date_type').val(date_type)
$('#issuer').val(issuer)
}, 1000)
setTimeout(function(){
$('#client_branch_id').val(client_branch_id).change()
$('#insurer_branch_id').val(insurer_branch_id).change()
setTimeout(function(){
$('#client_policy_id').val(client_policy_id).change();
}, 1000);
}, 2000)
},2000)
}
@ -432,7 +448,6 @@ function hideDateField(input = null) {
}
}
function sendPolicyTransactionID(event, pt_id) {
event.preventDefault(); // Prevent default action
@ -447,4 +462,214 @@ function sendPolicyTransactionID(event, pt_id) {
console.log(apiURL);
window.location.href = apiURL;
}
// -------------------------------------------------------------------------------------------------
//featch client, client branch, insurer, insurer branch and client policy list data
function getClientAndBranchAndPolicy()
{
$.ajax({
url: '<?= base_url("/util/getClientAndBranchAndPolicy") ?>',
type: "GET",
dataType: 'json',
success: function(res) {
console.log('getClientAndBranchAndPolicy', res);
if(res.status == true){
client_list = res.client_data;
branch_list = res.branch_data;
policy_list = res.policy_data;
insurer_list = res.insurer_data;
insurer_branch_list = res.insurer_branch_data;
appendClients(res.client_data);
appendInsurer(res.insurer_data);
}else{
console.log('No data found');
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
}
//append clients for filter
function appendClients(data)
{
$('#client_id').empty();
$('#client_id').append($('<option>', {
value: '',
text: 'Select Client'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.client_name,
'data-cn': item.client_name,
'data-ct': item.client_type,
class: (item.client_type == 1) ? 'group' : (item.client_type == 2) ? 'individual' : ''
});
$('#client_id').append(option);
});
}
//append clients branch for filter
function appendBranch(data)
{
$('#client_branch_id').empty();
$('#client_branch_id').append($('<option>', {
value: '',
text: 'Select Branch'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.branch_name
});
$('#client_branch_id').append(option);
});
}
//append insurer for filter
function appendInsurer(data)
{
$('#insurer_id').empty();
$('#insurer_id').append($('<option>', {
value: '',
text: 'Select Insurer'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.name,
});
$('#insurer_id').append(option);
});
}
//append insurer branch for filter
function appendInsurerBranch(data)
{
$('#insurer_branch_id').empty();
$('#insurer_branch_id').append($('<option>', {
value: '',
text: 'Select Insurer Branch'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.branch_name
});
$('#insurer_branch_id').append(option);
});
}
//append client policy for filter
function appendPolicies(data)
{
// console.log('appendPolicies', data);
// console.log('appendPolicies', $('#client_policy_id'));
$('#client_policy_id').empty();
$('#client_policy_id').append($('<option>', {
value: '',
text: 'Select Policy',
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.policy_type + '-' + item.policy_no,
});
$('#client_policy_id').append(option);
});
}
// -------------------------------------------------------------------------------------------------
//client branch and insurer branch onchange document ready function
$(document).ready(function(){
$('#client_id').change(function(){
let client_id = $(this).val();
console.log('client_id', client_id);
if(branch_list != '') {
// console.log(branch_list[client_id]);
let data = branch_list[client_id];
appendBranch(data);
}
})
$('#insurer_id').change(function(){
let insurer_id = $(this).val();
console.log('insurer_id', insurer_id);
if(insurer_branch_list != '') {
// console.log(insurer_branch_list[insurer_id]);
let data = insurer_branch_list[insurer_id];
appendInsurerBranch(data);
}
})
});
//get policy list based on the client, client_branch, insurer, insurer_branch and policy type
function getClientPolicyDataBasedOnClientAndInsuer(){
let client_id = $('#client_id').val() ?? 0;
let client_branch_id = $('#client_branch_id').val() ?? 0;
let insurer_id = $('#insurer_id').val() ?? 0;
let insurer_branch_id = $('#insurer_branch_id').val() ?? 0;
let policy_type_id = $('#policy_type_id').val() ?? 0;
let url = '<?= base_url('util/getClientPolicyDataBasedOnClientAndInsuer/') ?>';
let requestData = {
client_id: client_id,
client_branch_id: client_branch_id,
insurer_id: insurer_id,
insurer_branch_id: insurer_branch_id,
policy_type_id: policy_type_id,
};
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status === true) {
appendPolicies(response.data)
} else {
toastr.warning(response.message, 'WARNING');
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
});
}
</script>

View File

@ -21,6 +21,33 @@ table.dataTable tbody td {
background-color: #f0f0f0;
color: #666;
}
.custom-dropdown-menu {
display: none;
position: absolute;
background-color: #ffffff !important;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
color: #212529 !important;
text-decoration: none !important;
background-color: transparent !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
</style>
<div class="row" id="client_list">
@ -323,6 +350,98 @@ table.dataTable tbody td {
</div>
<!-- end of Client form content modal -->
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("scroll-horizontal-datatable");
// Create custom dropdown
function createCustomDropdown(row) {
// Get the original dropdown menu
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
// Create new dropdown menu with the same content
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
// Copy content of the original dropdown
customDropdown.innerHTML = originalDropdown.innerHTML;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
// Append custom dropdown to the body
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Prevent opening dropdown if clicking on the action column (button)
if (event.target.closest('td:last-child') || event.target.closest('.dropdown-toggle')) {
return;
}
// Close any existing active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get the position of the clicked cell
const rect = event.target.getBoundingClientRect();
// Position the dropdown based on where you click in the row (excluding action column)
customDropdown.style.display = 'block';
customDropdown.style.position = 'absolute';
customDropdown.style.left = `${rect.left + window.scrollX}px`; // Align with the clicked position
customDropdown.style.top = `${rect.bottom + window.scrollY + 5}px`; // 5px gap below the row
// Set this dropdown as the active one
activeDropdown = customDropdown;
event.stopPropagation(); // Prevent event from bubbling up
});
// Add click event to handle dropdown item actions
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation(); // Prevent event from bubbling up
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function(event) {
if (activeDropdown && !event.target.closest('.custom-dropdown-menu')) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
</script>
<script>
var client_list = ''; // local variable for storing the client list

View File

@ -8,7 +8,7 @@
<div class="col-md-4"></div>
<div class="col-md-4">
<i class="font-24"></i>
<h4>CD Account No : <?php echo isset($insurerName->cd_ac_no) && !empty($insurerName->cd_ac_no) ? $insurerName->cd_ac_no : 'N/A' ?></h4>
<h4>CD Account No : <?php echo isset($insurerName->cd_master_account_no) && !empty($insurerName->cd_master_account_no) ? $insurerName->cd_master_account_no : 'N/A' ?></h4>
</div>
</div>
</div>

File diff suppressed because it is too large Load Diff

View File

@ -17,15 +17,15 @@
"dompdf/dompdf": "^2.0",
"firebase/php-jwt": "^6.10",
"google/apiclient": "^2.15.0",
"kreait/firebase-php": "^7.0",
"laminas/laminas-escaper": "^2.9",
"php-amqplib/php-amqplib": "^2.8",
"phpmailer/phpmailer": "^6.9",
"phpoffice/phpspreadsheet": "^2.1",
"psr/http-message": "^1.0",
"psr/log": "^1.1",
"slim/slim": "^4.13",
"zircote/swagger-php": "^4.8",
"psr/http-message": "^1.0",
"kreait/firebase-php":"^7.0"
"zircote/swagger-php": "^4.8"
},
"require-dev": {
"codeigniter/coding-standard": "^1.7",
@ -33,6 +33,7 @@
"friendsofphp/php-cs-fixer": "^3.47.1",
"kint-php/kint": "^5.0.4",
"mikey179/vfsstream": "^1.6",
"mockery/mockery": "^1.6",
"nexusphp/cs-config": "^3.6",
"phpunit/phpunit": "^9.1",
"predis/predis": "^1.1 || ^2.0"

Binary file not shown.

View File

@ -0,0 +1,38 @@
<?php
require_once 'vendor/autoload.php';
use PHPUnit\Framework\TestCase;
use App\Helpers\ExcelMergeHelper;
class ExcelMergeHelperTest extends TestCase
{
public function testMergeExcelFiles_Success()
{
// Use the paths you provided
$filePaths = [
['file_path' =>WRITEPATH.'uploads/lead_files/Member_Data.xlsx','sheets' => []],
['file_path' =>WRITEPATH.'/tmp/RFQ_ABC_GMC_20241220140640.xlsx','sheets' => []],
// ['file_path' =>'/home/venba/Downloads/Employee_data.xlsx','sheets' => []],
];
$outputPath = '/home/venba/Documents/merged_file.xlsx'; // Output path for the merged file
// Call the mergeExcelFiles function
$result = ExcelMergeHelper::mergeExcelFiles($filePaths, $outputPath);
echo('result is -> '.$result);
// Check if the result is true (indicating success)
$this->assertFileExists($result);
$this->assertTrue(filesize($result) > 0);
}
}
// $temp_file_path = WRITEPATH.'tmp/RFQ_ABC_GMC_20241219172307.xlsx';
// $temp_file_name = 'RFQ_ABC_GMC_20241219172307.xlsx';
// $lead_file_path = WRITEPATH.'uploads/lead_files/Member_Data.xlsx';
// $filePaths = [
// ['file_path' => $temp_file_path,'sheets' =>[]],
// ['file_path' =>$lead_file_path ,'sheets' =>[]]
// ];
// $outputPath = dirname($temp_file_path).'/'.$temp_file_name.'_merged';

View File

@ -0,0 +1,183 @@
<?php
namespace Tests\unit;
use Exception;
use CodeIgniter\Test\CIUnitTestCase;
use App\Controllers\LeadsController;
class LeadsControllerTest extends CIUnitTestCase
{
protected $leadsController;
protected function setUp(): void
{
parent::setUp();
$this->leadsController = new LeadsController();
}
public function testGetDemographyDataBasicScenario()
{
echo('passed 0');
// Arrange
$members = [
// Header row
['Name', 'Age', 'Relationship', 'SI Enhancement'],
// Data rows
['John', '25', 'Self', '100000'],
['Jane', '23', 'Spouse', '100000'],
['Kid', '5', 'Child', '50000']
];
echo('passed 1');
$age_band_data = [
['0-17', '18-35', '36-45', 'Above 46']
];
echo('passed 2');
$members_heading = ['Name', 'Age', 'Relationship', 'SI Enhancement'];
$available_col = 'age';print_rr($available_col);
$col_index = 1;
echo('passed 3');
try{
echo('Inside try');
// Act
echo('passed 3.5');
$result = $this->leadsController->getDemographyData($members,$age_band_data,$members_heading,$available_col,$col_index);
echo('passed 4');
} catch (Exception $e) {
echo "Message: " . $e->getMessage() . "\n";
echo "File: " . $e->getFile() . "\n";
echo "Line: " . $e->getLine() . "\n";
// Optionally, print the full stack trace
echo "Stack trace: " . $e->getTraceAsString() . "\n";
}
var_dump($result);
// Assert
$this->assertIsArray($result);
$this->assertArrayHasKey('general', $result);
$this->assertArrayHasKey('100000', $result);
$this->assertArrayHasKey('50000', $result);
// Check counts for general category
$this->assertEquals(1, $result['general']['Self']['18-35']);
$this->assertEquals(1, $result['general']['Spouse']['18-35']);
$this->assertEquals(1, $result['general']['Child']['0-17']);
}
public function testGetDemographyDataWithDOB()
{
// Arrange
$members = [
// Header row
['Name', 'DOB', 'Relationship', 'SI Enhancement'],
// Data rows
['John', '01-Jan-1995', 'Self', '100000'],
['Jane', '01-Jan-1998', 'Spouse', '100000']
];
$age_band_data = [
['18-35', '36-45', '46+']
];
$members_heading = ['Name', 'DOB', 'Relationship', 'SI Enhancement'];
$available_col = 'dob';
$col_index = 1;
// Act
$result = $this->leadsController->getDemographyData(
$members,
$age_band_data,
$members_heading,
$available_col,
$col_index
);
// Assert
$this->assertIsArray($result);
$this->assertArrayHasKey('general', $result);
$this->assertArrayHasKey('100000', $result);
// Both members should be in 18-35 age band
$this->assertEquals(1, $result['general']['Self']['18-35']);
$this->assertEquals(1, $result['general']['Spouse']['18-35']);
}
public function testGetDemographyDataWithEmptyMembers()
{
// Arrange
$members = [
// Only header row
['Name', 'Age', 'Relationship', 'SI Enhancement']
];
$age_band_data = [
['0-17', '18-35', '36-45', '46+']
];
$members_heading = ['Name', 'Age', 'Relationship', 'SI Enhancement'];
$available_col = 'age';
$col_index = 1;
// Act
$result = $this->leadsController->getDemographyData(
$members,
$age_band_data,
$members_heading,
$available_col,
$col_index
);
// Assert
$this->assertIsArray($result);
$this->assertArrayHasKey('general', $result);
// Check that all totals are zero
$this->assertEquals(0, $result['general']['Grand Total']['Grand Total']);
}
public function testGetDemographyDataWithMultipleSIBands()
{
// Arrange
$members = [
// Header row
['Name', 'Age', 'Relationship', 'SI Enhancement'],
// Data rows with different SI amounts
['John', '25', 'Self', '100000'],
['Jane', '23', 'Spouse', '200000'],
['Kid1', '5', 'Child', '100000'],
['Kid2', '7', 'Child', '200000']
];
$age_band_data = [
['0-17', '18-35', '36-45', '46+']
];
$members_heading = ['Name', 'Age', 'Relationship', 'SI Enhancement'];
$available_col = 'age';
$col_index = 1;
// Act
$result = $this->leadsController->getDemographyData(
$members,
$age_band_data,
$members_heading,
$available_col,
$col_index
);
// Assert
$this->assertIsArray($result);
$this->assertArrayHasKey('100000', $result);
$this->assertArrayHasKey('200000', $result);
// Check counts for different SI bands
$this->assertEquals(1, $result['100000']['Self']['18-35']);
$this->assertEquals(1, $result['200000']['Spouse']['18-35']);
$this->assertEquals(1, $result['100000']['Child']['0-17']);
$this->assertEquals(1, $result['200000']['Child']['0-17']);
// Check general category totals
$this->assertEquals(2, $result['general']['Child']['0-17']);
$this->assertEquals(2, $result['general']['Child']['Grand Total']);
}
}