MERGE_Branch

This commit is contained in:
Srinivas-Saravanan 2024-12-23 10:15:08 +05:30
commit 11af72eed5
28 changed files with 3900 additions and 863 deletions

View File

@ -327,6 +327,9 @@ $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->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
@ -362,6 +365,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");
});
});
@ -375,6 +380,7 @@ $routes->group("leads", ["filter" => "authMVC"], function ($routes) {
$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) {

View File

@ -3298,11 +3298,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 +3310,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 +3351,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 +3381,7 @@ class ClientController extends AdminController
}
}
//get policy count
foreach ($clients as &$client) {
$client['client_policy_count'] = $policyCount[$client['id']] ?? 0;
}
@ -3361,6 +3394,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 {
@ -3832,6 +3867,10 @@ class ClientController extends AdminController
// $PolicyTransactionController = new PolicyTransactionController();
// $res = $PolicyTransactionController->validateInsurerStatement(['file_id' => '36']);
// $empServiceController = new EmployeeServiceController();
// $res = $empServiceController->excelFileDataValidation(['file_id' => '319']);
// dd($res);
}
// -------------------------------------------------------------------------------------------------------

View File

@ -3315,7 +3315,7 @@ class EmpDataServiceController extends BaseController
$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']);
// $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');
}
@ -3329,9 +3329,9 @@ class EmpDataServiceController extends BaseController
// 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,7 +3343,7 @@ 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);

View File

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

View File

@ -182,7 +182,14 @@ class LeadsController extends BaseController
{
// print_r($data); die;
$processedData = [];
foreach ($data['policy_type_id'] as $index => $value) {
$uploadFilePath = WRITEPATH . 'uploads/lead_files/';
// Get all uploaded files for 'file_name[]'
$files = $this->request->getFileMultiple('file_name');
// print_r($files); die;
foreach($data['policy_type_id'] as $index => $value){
// Separate the insurer and insurer branch, handle missing or invalid data
@ -229,6 +236,20 @@ class LeadsController extends BaseController
$policy_end_date = null;
}
if(!empty($data['incurred_claims_date'][$index])){
$incurred_claims_date = change_date_format($data['incurred_claims_date'][$index], 'd/m/Y', 'Y-m-d');
}else{
$incurred_claims_date = null;
}
if(!empty($data['premium_date'][$index])){
$premium_date = change_date_format($data['premium_date'][$index], 'd/m/Y', 'Y-m-d');
}else{
$premium_date = null;
}
$file_name = file_Upload($files[$index], $uploadFilePath);
$processedData[] = [
'lead_type' => $data['lead_type'],
'issuer' => $data['issuer'],
@ -250,20 +271,43 @@ class LeadsController extends BaseController
'policy_type_id' => $value,
'salse_person_id' => $data['salse_person_id'] ?? 0,
'insurer_id' => $insurer_id ?? 0,
'insurer_branch_id' => $insurer_branch_id ?? 0,
'tpa_id' => $tpa_id ?? 0,
'tpa_branch_id' => $tpa_branch_id ?? 0,
'policy_start_date' => $policy_start_date,
'policy_end_date' => $policy_end_date,
'no_of_lives' => $data['no_of_lives'][$index] ?? null,
'claims' => $data['claims'][$index] ?? null,
'location' => $data['location'][$index] ?? null,
'proposed_insurer_id' => $proposed_insurer_id ?? 0,
'proposed_insurer_branch_id' => $proposed_insurer_branch_id ?? 0,
'proposed_tpa_id' => $proposed_tpa_id ?? 0,
'insurer_id' => $insurer_id ?? 0,
'insurer_branch_id' => $insurer_branch_id ?? 0,
'tpa_id' => $tpa_id ?? 0,
'tpa_branch_id' => $tpa_branch_id ?? 0,
'policy_start_date' => $policy_start_date,
'policy_end_date' => $policy_end_date,
'no_of_lives' => $data['no_of_lives'][$index] ?? null,
'incurred_claims' => $data['incurred_claims'][$index] ?? 0,
'location' => $data['location'][$index] ?? null,
'proposed_insurer_id' => $proposed_insurer_id ?? 0,
'proposed_insurer_branch_id' => $proposed_insurer_branch_id ?? 0,
'proposed_tpa_id' => $proposed_tpa_id ?? 0,
'proposed_tpa_branch_id' => $proposed_tpa_branch_id ?? 0,
'renewal_emp_count' => $data['renewal_emp_count'][$index] ?? 0,
'renewal_dept_count' => $data['renewal_dept_count'][$index] ?? 0,
'renewal_no_of_lives' => $data['renewal_no_of_lives'][$index] ?? 0,
'incept_emp_count' => $data['incept_emp_count'][$index] ?? 0,
'incept_dept_count' => $data['incept_dept_count'][$index] ?? 0,
'incept_no_of_lives' => $data['incept_no_of_lives'][$index] ?? 0,
'exp_emp_count' => $data['exp_emp_count'][$index] ?? 0,
'exp_dept_count' => $data['exp_dept_count'][$index] ?? 0,
'exp_no_of_lives' => $data['exp_no_of_lives'][$index] ?? 0,
'incurred_claims_date' => $incurred_claims_date,
'paid_claims' => $data['paid_claims'][$index] ?? 0,
'outstanding_claims' => $data['outstanding_claims'][$index] ?? 0,
'policy_run_days' => $data['policy_run_days'][$index] ?? 0,
'premium_at_inception' => $data['premium_at_inception'][$index] ?? 0,
'premium_date' => $premium_date,
'earned_premium' => $data['earned_premium'][$index] ?? 0,
'annualised_claims' => $data['annualised_claims'][$index] ?? 0,
'incurred_claims_ratio' => $data['incurred_claims_ratio'][$index] ?? 0,
'earned_claims_ratio' => $data['earned_claims_ratio'][$index] ?? 0,
'file_name' => $file_name,
'status' => $data['status'] ?? null,
'notes' => $data['notes'] ?? null,
];
@ -344,16 +388,16 @@ class LeadsController extends BaseController
{
$data['rfq_data'] = $this->RFQModel
->where('lead_id', $id)
->where('type', $type)
->where('is_active', 1)
->first();
->where('lead_id', $id)
// ->where('type', $type)
->where('is_active', 1)
->first();
$data['rfq_count'] = $this->RFQModel
->where('lead_id', $id)
->where('type', 1)
->where('is_active', 1)
->countAllResults();
->where('lead_id', $id)
// ->where('type', 1)
->where('is_active', 1)
->countAllResults();
$data['qcr_count'] = $this->RFQModel
->where('lead_id', $id)
@ -365,11 +409,11 @@ class LeadsController extends BaseController
$data['lead_id'] = $id;
$lead_data = $this->leadsModel
->select('leads.*, policy_type.question_json')
->join('policy_type', 'leads.policy_type_id = policy_type.id')
->where('leads.id', $id)
->where('leads.is_active', 1)
->first();
->select('leads.*, policy_type.question_json, policy_type.policy_type')
->join('policy_type', 'leads.policy_type_id = policy_type.id')
->where('leads.id', $id)
->where('leads.is_active', 1)
->first();
// dd($lead_data);
@ -388,8 +432,9 @@ class LeadsController extends BaseController
$this->loadLayout('view_rfq.php', $data);
}
public function createRFQ()
{
public function createRFQ(){
// print_r($this->request->getPost('json')); die();
$data = $this->request->getPost();
$lead_id = $data['lead_id'];
@ -473,8 +518,9 @@ class LeadsController extends BaseController
public function constructExcelToSaveTemp($lead_id, $type, $propsal_and_insurer = null)
{
$rfq_data = $this->RFQModel->getRFQTableDataWithLeadIDAndType($lead_id, $type);
// dd($rfq_data, $lead_id, $type);
// dd($rfq_data, $lead_id, $type, $propsal_and_insurer);
// print_r($propsal_and_insurer); die;
$lead_data = [
'Insured' => $rfq_data['client_name'],
@ -484,12 +530,14 @@ class LeadsController extends BaseController
$data = json_decode($rfq_data['json'], true);
if ($type == 2) {
$data = $this->convertJsonForQCR($data, 'stc');
if ($propsal_and_insurer !== null) {
if($type == 2){
$data = $this->convertJsonForQCR($data, $type);
if($propsal_and_insurer !== null){
list($proposal_key, $insurer_key) = explode('-', $propsal_and_insurer, 2);
$data = $this->transformProposelData($data, $proposal_key, $insurer_key);
}
}else if($type == 1){
$data = $this->convertJsonForQCR($data, $type);
}
$spreadsheet = new Spreadsheet();
@ -1104,11 +1152,13 @@ class LeadsController extends BaseController
//gather lead info
$lead_data = $this->leadsModel
->select('leads.*,policy_type.long_name,policy_type.policy_type,user_profiles.email as created_person_email')
->join('policy_type', 'leads.policy_type_id = policy_type.id')
->join('user_profiles', 'leads.created_by = user_profiles.id')
->join('policy_type', 'leads.policy_type_id = policy_type.id', 'left')
->join('user_profiles', 'leads.created_by = user_profiles.id', 'left')
->where('leads.id', $lead_id)
->first();
// print_r($lead_data ); die;
$cc_mails = [];
//get CC Mails
@ -1116,6 +1166,7 @@ class LeadsController extends BaseController
$cc_data = isset($params['cc']) ? $params['cc'] : "";
$param_cc_mail = json_decode($cc_data, true);
if (isset($param_cc_mail) && is_array($param_cc_mail) && count($param_cc_mail) > 0) {
// Fetch user data where ID is in the param_cc_mail array
$userData = $this->userModel
@ -1131,12 +1182,13 @@ class LeadsController extends BaseController
// print_r(json_encode($cc_mails)); die;
// If no emails were found, return an error response
if (empty($cc_mails)) {
return $this->respond(['status' => 'failed', 'code' => 400, 'data' => '', 'message' => 'No valid CC mail addresses found!'], 200);
}
// if (empty($cc_mails)) {
// return $this->respond(['status' => 'failed','code' => 400,'data' => '','message' => 'No valid CC mail addresses found!'], 200);
// }
} else {
// Handle case where param_cc_mail is not valid
return $this->respond(['status' => 'failed', 'code' => 400, 'data' => '', 'message' => 'CC mail not found!'], 200);
// return $this->respond(['status' => 'failed','code' => 400,'data' => '','message' => 'CC mail not found!'], 200);
}
}
@ -1225,7 +1277,12 @@ class LeadsController extends BaseController
$data = [
'proposel_data' => json_encode($lead_update_data),
'status' => 'won'
'status' => 'won',
'placement_date' => change_date_format($params['placement_date'], 'd/m/Y', 'Y-m-d'),
'utr_no' => $params['utr_no'],
'premium_amount' => $params['premium_amount'],
'total_amount' => $params['total_amount'],
'cd_amount' => $params['cd_amount'],
];
$this->leadsModel->where('id', $lead_id)->set($data)->update();
@ -1266,8 +1323,7 @@ class LeadsController extends BaseController
}
}
function transformProposelData($data, $proposel, $insurer)
{
public function transformProposelData($data, $proposel, $insurer){
// print_r($data['premium_data']['data']); die;
@ -1373,15 +1429,18 @@ class LeadsController extends BaseController
return $data;
}
function convertJsonForQCR($json, $type)
public function convertJsonForQCR($json, $type)
{
if ($json) {
// Deep copy of JSON
$first_json = json_decode(json_encode($json), true);
// dd($first_json);
// Column-wise Check: Remove headers and relevant data if qcr == 0
foreach ($json['proposal_data']['over_all_column_data'] as $proposalKey => $proposalData) {
if ($proposalData['stc'] == 0 || $proposalData['stc'] === false) {
// Remove matching parentHeader in headers
foreach ($first_json['table_data']['headers'] as $index => $header) {
@ -1399,8 +1458,8 @@ class LeadsController extends BaseController
// Remove proposalKey from over_all_column_data
unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]);
if ($type == 'stc') {
if($type == 2){
// Remove proposalKey from premium_data
unset($first_json['premium_data']['data'][$proposalKey]);
}
@ -1427,7 +1486,7 @@ class LeadsController extends BaseController
// Remove insurer from proposal's insurers array
unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]['insurers'][$insurerIndex]);
if ($type == 'stc') {
if($type == 2){
unset($first_json['premium_data']['data'][$proposalKey][$insurer['display_name']]);
}
}
@ -1786,4 +1845,12 @@ class LeadsController extends BaseController
return $this->respond(['status' => false, 'message' => 'Failed to create policy', 'data' => $data], 200);
}
//------------------------------------------------------------------------------------------------
public function transformMailContent()
{
}
}

View File

@ -1502,25 +1502,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 +1540,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
]);
}
@ -1674,6 +1683,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

@ -179,6 +179,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();
@ -473,6 +474,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
];
}
@ -786,10 +788,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 +1345,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 +1406,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 +1505,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 +1519,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);
}
@ -2120,5 +2220,143 @@ 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);
}
}

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

@ -837,7 +837,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 +846,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 +873,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 +881,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 +898,8 @@ class EmployeePolicyModel extends Model
$results2 = $query2->get()->getResultArray();
$results = array_merge($results1, $results2);
// dd($this->db->getLastQuery());
return $results;

View File

@ -60,7 +60,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,34 @@ 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',
];

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

@ -113,8 +113,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 +312,256 @@ 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
$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 NOT 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 +717,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 +818,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 +978,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 +1075,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

@ -77,7 +77,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

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

@ -103,6 +103,10 @@ table.dataTable tbody td {
.slider.round:before {
border-radius: 50%;
}
.disabled-option {
color: gray;
}
</style>
<div class="row" id="inception_list">
@ -125,6 +129,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 +145,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 +178,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 +227,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 +280,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 +311,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 +377,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 +389,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>
@ -358,12 +418,14 @@ table.dataTable tbody td {
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 +433,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);
@ -384,6 +447,7 @@ table.dataTable tbody td {
// 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);
@ -399,6 +463,7 @@ table.dataTable tbody td {
}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);
@ -435,6 +500,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 +559,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 +585,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 +700,10 @@ 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;
if (!$('#invoice_date_modal').val()) {
// alert('nope');
@ -646,6 +723,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 +798,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 +849,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 +861,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 +891,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 +916,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 +938,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 +979,186 @@ 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');
var gst_per = document.getElementById('gst_per_modal').value;
var invoice_value_dom_obj = document.getElementById('invoice_value_modal');
var invoice_value = invoice_value_dom_obj.value;
var gst_value_dom_obj = document.getElementById('gst_value_modal');
var gst_value = gst_value_dom_obj.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 = (parseFloat(gst_per) / 100 ) * invoice_value;
invoice_amount_dom_obj.value = parseFloat(invoice_value_dom_obj.value) + parseFloat(gst_value_dom_obj.value);
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

@ -32,6 +32,7 @@
color: white !important;
margin-right: 5px;
}
</style>
<div class="row" id="leads_form" style="display:none;">
@ -404,9 +405,33 @@ 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);
$('#incurred_claims').val(res.data.incurred_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);
$('#file_name_display').text('Upload File Name : ' + res.data.file_name);
if (res.data.salse_person_id) {
selecSalsePerson(res.data.salse_person_id);
@ -419,12 +444,36 @@ 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')
}
}
@ -576,7 +625,6 @@ function getPolicyData(client_policy_id, increment_count) {
}
// Salse team user list data
function selecSalsePerson(salse_person_ids) {
@ -604,11 +652,29 @@ 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';
// 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">
@ -656,28 +722,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,13 +823,99 @@ 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">
<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">
<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>
`;
//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">
<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">
<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>
`;
//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" name="file_name[]" required>
<span class="text-danger" id="file_name_display"></span>
</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);
container.appendChild(newRow3);
container.appendChild(newRow2);
container.appendChild(newRow4);
container.appendChild(newRow7);
container.appendChild(newRow5);
var lead_type = $('#lead_type').val();
@ -722,9 +923,32 @@ function addHTMLInput(check) {
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')
} else {
// $('.proposed_div').hide().find('select, input').removeAttr('required');
$('.proposed_div').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')
}
}
// Scroll the newly added select into view and focus on it
@ -747,6 +971,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_', $("#incurred_claim_" + 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 +997,34 @@ 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('this object', this);
console.log('id of this element:', this.id);
let increment = this.element.id.split('_').pop();
console.log(increment); // Outputs: 1
console.log('selectedDates', 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()) {
console.log('selectedDates', selectedDates);
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)
@ -790,6 +1060,97 @@ function removeHTMLInput(element)
}
}
function calculatePolicyRunDays(increment) {
console.log('calculatePolicyRunDays function called');
var policyStartDate = flatpickr.parseDate($("#policy_start_date_" + increment).val(), "d/m/Y");
var incurredClaimDate = flatpickr.parseDate($("#incurred_claim_" + 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) {
@ -876,6 +1237,8 @@ $('#lead_type').change(function() {
$('#policy_start_date').removeAttr('required');
$('#claims').removeAttr('required');
$('#freshDiv').hide();
$('.freashDiv').show()
$('.renewalDiv').hide()
$('#gst').val('');
$('#pan').val('');
@ -885,6 +1248,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 +1272,23 @@ $('#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')
}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')
}
}
})
@ -929,6 +1313,12 @@ function tpaChange(input, unique_id) {
//-----------------------------------------------------------------------------------------------------------
function sumOfLives(input){
}
//-----------------------------------------------------------------------------------------------------------
function getURLParamsForReport() {
const params = new URLSearchParams(window.location.search);

View File

@ -102,11 +102,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>

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

File diff suppressed because it is too large Load Diff

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,10 @@ 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 $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 +114,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 +203,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>

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>

File diff suppressed because it is too large Load Diff