diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php
index d5370b02..69b977b4 100755
--- a/app/Controllers/ClientController.php
+++ b/app/Controllers/ClientController.php
@@ -726,7 +726,7 @@ class ClientController extends AdminController
if ($requestFrom == 'rest') {
return $data;
}
-
+ // print_rr($data);die();
// Load the view for the new list page;
echo view('layout/header', $headerData);
echo view('view_deposit', $data);
@@ -741,12 +741,14 @@ class ClientController extends AdminController
$client_id = $this->request->getPost('client_id');
$insurer_id = $this->request->getPost('insurer_id');
$record_date = $this->request->getPost('record_date');
+ $cd_ac_pk = $this->request->getPost('cd_ac_pk');
+ $cd_ac_no = $this->request->getPost('cd_ac_no');
- $CD_Account_Number = $this->CDMasterModel
- ->where('client_id', $client_id)
- ->where('insurer_id', $insurer_id)
- ->where('is_active', 1)
- ->first();
+ // $CD_Account_Number = $this->CDMasterModel
+ // ->where('client_id', $client_id)
+ // ->where('insurer_id', $insurer_id)
+ // ->where('is_active', 1)
+ // ->first();
if (!empty($record_date)) {
@@ -762,8 +764,8 @@ class ClientController extends AdminController
'sub_type_id' => $this->request->getPost('sub_type_id'),
'client_id' => $this->request->getPost('client_id'),
'client_policy_id' => null,
- 'cd_ac_no' => $CD_Account_Number['cd_ac_no'] ?? null,
- 'cd_ac_pk' => $CD_Account_Number['id'] ?? null,
+ 'cd_ac_no' => $cd_ac_no ?? null,
+ 'cd_ac_pk' => $cd_ac_pk ?? null,
'endorsement_no' => null,
'insurer_id' => $this->request->getPost('insurer_id'),
'description' => $this->request->getPost('description'),
@@ -1099,6 +1101,8 @@ class ClientController extends AdminController
$kyc_id = $this->request->getPost('id');
$client_id = $this->request->getPost('client_id');
+ // echo "KID".$kyc_id;
+ // echo "CID".$client_id;
if (empty($kyc_id)) {
return $this->respond(['status' => false, 'code' => 400, 'message' => 'Missing document ID.'], 200);
@@ -1107,7 +1111,7 @@ class ClientController extends AdminController
$updateData['is_active'] = $this->request->getPost('is_active');
$delete = $this->clientKYCDocsModel->update($kyc_id, $updateData);
-
+ // $delete = 1;
if ($delete) {
$html = $this->generateKycSingleTable($client_id);
$dropdown = $this->fetch_dropdown($client_id);
diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php
index 8fa5f4bb..179aa7b3 100755
--- a/app/Controllers/EmpDataServiceController.php
+++ b/app/Controllers/EmpDataServiceController.php
@@ -5022,7 +5022,7 @@ class EmpDataServiceController extends BaseController
$processedCount++;
// Send batch emails or handle single email
- if ($count == 20 || $processedCount == count($ids)) {
+ if ($count == 20 || $processedCount == count($emp_details)) {
if (!empty($wholeData)) {
if ($single_mail == 1) {
$this->myLogger->logme('error', 'sendMailForDownloadingECard - Sending single mail');
@@ -5035,7 +5035,12 @@ class EmpDataServiceController extends BaseController
$wholeData = [];
$count = 0;
}
+ }else{
+ $this->myLogger->logme('error', 'sendMailForDownloadingECard - Whole mail data is empty');
}
+ }else{
+ $idscount = count($ids);
+ $this->myLogger->logme('error', "sendMailForDownloadingECard - processedCount not equal to ids count, processedCount : {$processedCount} and ids count : {$idscount}");
}
}
@@ -5048,9 +5053,19 @@ class EmpDataServiceController extends BaseController
return ['status' => false , 'message' => 'Employee Data not found'];
}
- } catch (\Exception $e) {
- $this->myLogger->logme('error', 'sendMailForDownloadingECard - Exception occurred: {message}', ['message' => $e->getMessage()]);
- return ['status' => false , 'message' => 'Exception occurred' . $e->getMessage()];
+ } catch (\Exception $th) {
+ $errorData = [
+ 'message' => $th->getMessage(),
+ 'file' => $th->getFile(),
+ 'line' => $th->getLine(),
+ 'code' => $th->getCode(),
+ 'trace' => $th->getTraceAsString(),
+ 'trace_array' => $th->getTrace(), // full array version (optional)
+ 'function' => $th->getTrace()[0]['function'] ?? null,
+ 'class' => $th->getTrace()[0]['class'] ?? null,
+ ];
+ $this->myLogger->logme('error', 'sendMailForDownloadingECard - Exception occurred: {message}', ['message' => $th->getMessage()]);
+ return ['status' => false , 'message' => 'Exception occurred' . $th->getMessage(), 'error_data' => $errorData];
}
}
diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php
index 82ecc4e1..d9e639e2 100755
--- a/app/Controllers/EmployeeRestController.php
+++ b/app/Controllers/EmployeeRestController.php
@@ -3608,9 +3608,9 @@ class EmployeeRestController extends AdminController
cl_rm.user_id as acm_id,
cp.insurer_id as insurer_id,
cp.tpa_id as tpa_id,
- emp.client_id ,
+ emp.client_id,
emp.id as emp_id,
- emp_pol.uhid as policy_no,
+ cp.policy_no,
emp.emp_code,
emp_pol.tpa_id as tpa_no,
emp.name as emp_name,
@@ -4408,7 +4408,8 @@ class EmployeeRestController extends AdminController
{
$client = \Config\Services::curlrequest();
$url = env('PRE_ENROLLMENT_BASEURL') . $endPoint;
- $response = $client->post($url, ['json' => $postData, 'http_errors' => false]);
+ $headers = [ 'App-Signature' => getenv('APP_SIGNATURE') ];
+ $response = $client->post($url, ['json' => $postData,'headers' => $headers,'http_errors' => false]);
// return json_decode($response->getBody(), true);
return $response->getBody();
}
diff --git a/app/Controllers/PayoutController.php b/app/Controllers/PayoutController.php
index 7dccb5ba..29e8b555 100644
--- a/app/Controllers/PayoutController.php
+++ b/app/Controllers/PayoutController.php
@@ -297,7 +297,8 @@ class PayoutController extends BaseController
'agent_id' => $json['agent_id'],
'invoice_date' => $json['invoice_date'],
'invoice_amount' => $json['invoice_amount'],
- 'payout_status' => 1
+ 'payout_status' => 1,
+ 'broker_id' => 1
];
$invoiceId = $this->invoiceModel->insert($invoiceData);
@@ -438,7 +439,7 @@ class PayoutController extends BaseController
$agentCode = $agent["agent_code"];
$today = date("Ymd");
- $likePattern = "INV/$agentCode/$today/%";
+ $likePattern = "NIIB/$agentCode/$today/%";
$count = $this->invoiceModel
->like("invoice_no", $likePattern)
@@ -446,7 +447,7 @@ class PayoutController extends BaseController
$nextNumber = $count + 1;
- return "INV/$agentCode/$today/$nextNumber";
+ return "NIIB/$agentCode/$today/$nextNumber";
}
// private function generateInvoiceNumber()
diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php
index 66798ee5..7cc91aca 100644
--- a/app/Controllers/PolicyTransactionController.php
+++ b/app/Controllers/PolicyTransactionController.php
@@ -1917,6 +1917,7 @@
$data['client_kyc_primary_table'] = $clientController->generateKycPrimaryTable($data['client_id']);
$data['client_kyc_other_table'] = $clientController->generateKycOthersTable($data['client_id']);
$data['client_kyc_single_table'] = $clientController->generateKycSingleTable($data['client_id']);
+ $data['client_kyc_dd_data'] = $clientController->fetch_dropdown($data['client_id']);
$data['vehicle_docs'] = $this->clientKYCDocsModel
->where('client_id', $data['client_id'])
diff --git a/app/Filters/CommissionApiFilter.php b/app/Filters/CommissionApiFilter.php
index b2707b98..342791ea 100644
--- a/app/Filters/CommissionApiFilter.php
+++ b/app/Filters/CommissionApiFilter.php
@@ -10,7 +10,7 @@ class CommissionApiFilter implements FilterInterface
{
public function before(RequestInterface $request, $arguments = null)
{
- // return null;
+ return null;
// Read API key from header
$authHeader = $request->getHeaderLine('AUTHORIZATION');
if(empty($authHeader))
diff --git a/app/Models/InvoiceModel.php b/app/Models/InvoiceModel.php
index dcbd93fc..bebd0022 100644
--- a/app/Models/InvoiceModel.php
+++ b/app/Models/InvoiceModel.php
@@ -23,6 +23,7 @@ class InvoiceModel extends Model
'created_by',
'updated_at',
'payout_status',
+ 'broker_id'
];
// Timestamps
@@ -107,7 +108,8 @@ class InvoiceModel extends Model
partner_agent.name as agent_name
")
->join('partner_agent', 'partner_invoice.agent_id = partner_agent.id')
- ->where('partner_invoice.is_active', 1);
+ ->where('partner_invoice.is_active', 1)
+ ->where('partner_invoice.broker_id', 1);
if(!empty($agent_id)){
$data->where('partner_invoice.agent_id', $agent_id);
@@ -218,7 +220,8 @@ class InvoiceModel extends Model
if ($flag == 1) { // Add mode
// EXCLUDE all policies that exist in partner_invoice_items
- $builder->where("pt.id NOT IN (SELECT policy_id FROM partner_invoice_items)", null, false);
+ $builder->where("pp.id NOT IN (SELECT policy_id FROM partner_invoice_items)", null, false);
+ $builder->where("pt.policy_no NOT IN (SELECT policy_no FROM partner_invoice_items)", null, false);
}
if ($flag == 2) { // Edit mode
diff --git a/app/Views/client_kyc_2.php b/app/Views/client_kyc_2.php
index 8a2ce5ed..b0240572 100755
--- a/app/Views/client_kyc_2.php
+++ b/app/Views/client_kyc_2.php
@@ -35,7 +35,7 @@
-
@@ -318,5 +318,29 @@
});
}
+ // Centralized Validation Function
+ function validateFile(fileInput) {
+ var file = fileInput.files[0];
+ if (!file) {
+ return true; // No file selected, considered valid or neutral
+ }
+
+ var type = file.type;
+
+ // Check if the type is PDF or starts with 'image/'
+ if (type === 'application/pdf' || type.startsWith('image/')) {
+ return true; // Valid
+ }
+
+ // Invalid format
+ toastr.warning('Invalid file format. Only PDF or Image files are allowed.', 'WARNING!');
+ $(fileInput).val(''); // clear file
+ return false; // Invalid
+ }
+
+ // Attach the centralized handler to BOTH classes
+ $(document).on('change', '.file-input, .edit_file-input', function () {
+ validateFile(this);
+ });
\ No newline at end of file
diff --git a/app/Views/client_kyc_single_table.php b/app/Views/client_kyc_single_table.php
index 4982bcdf..cae36927 100644
--- a/app/Views/client_kyc_single_table.php
+++ b/app/Views/client_kyc_single_table.php
@@ -24,6 +24,7 @@
@@ -45,7 +46,7 @@
diff --git a/app/Views/policy_transaction_inception_form_2.php b/app/Views/policy_transaction_inception_form_2.php
index 365c1594..13c7b309 100644
--- a/app/Views/policy_transaction_inception_form_2.php
+++ b/app/Views/policy_transaction_inception_form_2.php
@@ -1702,7 +1702,7 @@
$('#follower_policy_no_' + uniqueid).prop('readonly', false);
$('#calc_policy_issue_date_1').val(policy_issue_date).addClass('readonly-select');
}
-
+
});
$(document).on('change', 'select[name="relationship[]"]', function() {
@@ -2612,141 +2612,203 @@
console.log('variance', variance);
}
- function co_share_percentage_calculation(input, extra = null){
+ // function co_share_percentage_calculation(input, extra = null){
- console.log('input', input)
- var inputs = $('input[name="co_share_per[]"]'); // Specifically select input elements
- console.log('Number of inputs:', inputs.length);
+ // console.log('input', input)
+ // var inputs = $('input[name="co_share_per[]"]'); // Specifically select input elements
+ // console.log('Number of inputs:', inputs.length);
- let insurer_count = insurer_count_array.length;
- console.log('insurer_count', insurer_count);
- console.log('insurer_count_array', insurer_count_array);
+ // let insurer_count = insurer_count_array.length;
+ // console.log('insurer_count', insurer_count);
+ // console.log('insurer_count_array', insurer_count_array);
- if(input){
- if(insurer_count == 2){
+ // if ($('#cop_yes').is(':checked')) {
+ // console.log('cop_yes checked', $('#cop_yes').is(':checked'));
+ // if(input){
+ // if(insurer_count == 2){
- // Find the index of the value
- let index = insurer_count_array.indexOf(Number(input));
- let second_value_index = "";
+ // // Find the index of the value
+ // let index = insurer_count_array.indexOf(Number(input));
+ // let second_value_index = "";
- if (index !== -1) {
+ // if (index !== -1) {
- console.log(`Value ${input} exists at index ${index}.`);
+ // console.log(`Value ${input} exists at index ${index}.`);
- let beforeValue = index > 0 ? insurer_count_array[index - 1] : null;
- let afterValue = index < insurer_count_array.length - 1 ? insurer_count_array[index + 1] : null;
+ // let beforeValue = index > 0 ? insurer_count_array[index - 1] : null;
+ // let afterValue = index < insurer_count_array.length - 1 ? insurer_count_array[index + 1] : null;
- if (beforeValue != null) {
- second_value_index = beforeValue;
- } else if (afterValue != null) {
- second_value_index = afterValue;
- }
+ // if (beforeValue != null) {
+ // second_value_index = beforeValue;
+ // } else if (afterValue != null) {
+ // second_value_index = afterValue;
+ // }
- }
+ // }
- let value1 = $('#co_share_per_' + input).val();
- let value2 = $('#co_share_per_' + second_value_index).val();
+ // let value1 = $('#co_share_per_' + input).val();
+ // let value2 = $('#co_share_per_' + second_value_index).val();
- value1 = Number(value1);
- value2 = Number(value2);
+ // value1 = Number(value1);
+ // value2 = Number(value2);
- console.log('value1', value1);
- console.log('value2', value2);
+ // console.log('value1', value1);
+ // console.log('value2', value2);
- if(extra == "add"){
+ // if(extra == "add"){
- if(value2 == 0){
- value1 = 50;
- value2 = 50;
- }else{
- if(value2 == 100){
- value1 = 50;
- value2 = 50;
- }else{
- value1 = 100 - value2;
- }
- }
+ // if(value2 == 0){
+ // value1 = 50;
+ // value2 = 50;
+ // }else{
+ // if(value2 == 100){
+ // value1 = 50;
+ // value2 = 50;
+ // }else{
+ // value1 = 100 - value2;
+ // }
+ // }
- }else{
+ // }else{
- if(value1 == 100){
- value2 = 0;
- }else{
- value2 = 100 - value1;
- }
- }
+ // if(value1 == 100){
+ // value2 = 0;
+ // }else{
+ // value2 = 100 - value1;
+ // }
+ // }
- console.log('value1', value1);
- console.log('value2', value2);
+ // console.log('value1', value1);
+ // console.log('value2', value2);
- $('#co_share_per_' + input).val(value1);
- $('#co_share_per_' + second_value_index).val(value2);
+ // $('#co_share_per_' + input).val(value1);
+ // $('#co_share_per_' + second_value_index).val(value2);
- }else if(insurer_count > 2){
+ // }else if(insurer_count > 2){
- let total_val = 0;
+ // let total_val = 0;
- // Calculate the total sum of input values
- inputs.each(function () {
- let val = Number($(this).val()) || 0;
- if(val == 0){
- $(this).val(0)
- }
- total_val += val;
- });
+ // // Calculate the total sum of input values
+ // inputs.each(function () {
+ // let val = Number($(this).val()) || 0;
+ // if(val == 0){
+ // $(this).val(0)
+ // }
+ // total_val += val;
+ // });
- // if (total_val < 100) {
- // let remaining_val = 100 - total_val; // Calculate the remaining value
+ // // if (total_val < 100) {
+ // // let remaining_val = 100 - total_val; // Calculate the remaining value
- // // Assign the remaining value to the first empty input
- // let assigned = false;
- // inputs.each(function () {
- // let current_val = Number($(this).val()) || 0;
- // if (current_val === 0 && !assigned) { // Assign only once
- // $(this).val(remaining_val);
- // assigned = true;
- // } else if (current_val === 0) {
- // $(this).val(0); // Set other empty inputs to 0
- // }
- // });
- // } else if (total_val > 100) {
- // toastr.warning('Sum of the co-share is greater than 100');
- // }
+ // // // Assign the remaining value to the first empty input
+ // // let assigned = false;
+ // // inputs.each(function () {
+ // // let current_val = Number($(this).val()) || 0;
+ // // if (current_val === 0 && !assigned) { // Assign only once
+ // // $(this).val(remaining_val);
+ // // assigned = true;
+ // // } else if (current_val === 0) {
+ // // $(this).val(0); // Set other empty inputs to 0
+ // // }
+ // // });
+ // // } else if (total_val > 100) {
+ // // toastr.warning('Sum of the co-share is greater than 100');
+ // // }
- }
- }else{
- inputs.each(function (index) {
- if (inputs.length === 1) {
- $(this).val(100);
- } else if(inputs.length === 2) {
- let first = $('#co_share_per_1').val();
- first = Number(first)
- let second_val = 100 - first;
+ // }
+ // }else{
+ // inputs.each(function (index) {
+ // if (inputs.length === 1) {
+ // $(this).val(100);
+ // } else if(inputs.length === 2) {
+ // let first = $('#co_share_per_1').val();
+ // first = Number(first)
+ // let second_val = 100 - first;
- if (index === 1) {
- $(this).val(second_val);
- }
- }
- });
+ // if (index === 1) {
+ // $(this).val(second_val);
+ // }
+ // }
+ // });
- }
+ // }
+ // }
- let val_sum = 0;
+ // let val_sum = 0;
- inputs.each(function () {
- let val = Number($(this).val()) || 0;
- val_sum += val;
- });
+ // inputs.each(function () {
+ // let val = Number($(this).val()) || 0;
+ // val_sum += val;
+ // });
- if (val_sum > 100) {
- toastr.warning('Sum of the co-share is greater than 100', 'WARNING');
- }
+ // if ($('#cop_yes').is(':checked')) {
+ // if (val_sum > 100) {
+ // toastr.warning('Sum of the co-share is greater than 100', 'WARNING');
+ // }
+ // }
+ // }
+
+ function co_share_percentage_calculation(changedEl = null) {
+
+ let inputs = $('input[name="co_share_per[]"]');
+ let count = inputs.length;
+ let copChecked = $('#cop_yes').is(':checked');
+
+ /* =========================
+ COP UNCHECKED
+ ========================= */
+ if (!copChecked) {
+ inputs.val('');
+ return;
}
+ /* =========================
+ AUTO MODE (default / fetch / add / remove)
+ ========================= */
+ if (changedEl === null) {
+
+ // Single card → empty (means 100)
+ if (count === 1) {
+ inputs.val('');
+ return;
+ }
+
+ // Multiple cards → auto split
+ let split = (100 / count).toFixed(2);
+ inputs.val(split);
+ return;
+ }
+
+ /* =========================
+ USER MODE (manual edit)
+ ========================= */
+ let sum = 0;
+ let userTouched = false;
+
+ inputs.each(function () {
+ let v = $(this).val();
+
+ if (v !== '') {
+ userTouched = true;
+ sum += Number(v) || 0;
+ }
+ });
+
+ // Show warning ONLY if user changed something
+ if (userTouched && sum > 100) {
+ toastr.warning(
+ 'Sum of the co-share is greater than 100',
+ 'WARNING'
+ );
+ }
+}
+
+
+
$(document).on('change', '[name="base_premium"], [name="co_share_per[]"]', function() {
- console.log('Triggered change event.');
+ console.log('Triggered change event. base_premium');
// Get the first non-empty base premium value
// let basePremium = $('input[name="base_premium[]"]').toArray()
@@ -3276,7 +3338,7 @@
});
}
- function addCDAccountNumber(input)
+ function addCDAccountNumber_old(input)
{
var val = $(input).val();
var uniqueid = $(input).data('count');
@@ -3328,6 +3390,93 @@
}
}
+ function addCDAccountNumber(input)
+ {
+
+ var $input = $(input);
+ var val = $input.val();
+ var uniqueid = $input.data('count');
+
+ var client_id = $('#client_id').val();
+ var insurer_id = $('#follow_insurer_id_' + uniqueid).val();
+
+ var isCurrentLeader = $('#co_share_type_' + uniqueid).is(':checked');
+ var isAnyLeaderSelected = $('input[name="co_share_type[]"]:checked').length > 0;
+ var cop_yes = $('#cop_yes').is(':checked');
+
+
+
+ // Missing base data
+ if (!client_id || !insurer_id) {
+ toastr.warning('Client or Insurer does not exist.', 'WARNING!');
+ return;
+ }
+
+ // COP enabled but no leader selected
+ if (cop_yes && !isAnyLeaderSelected) {
+ toastr.warning('Please select a Leader.', 'WARNING!');
+ $input.val('');
+ return;
+ }
+
+ // CD allowed only for leader
+ if (cop_yes && !isCurrentLeader) {
+
+ toastr.warning(
+ 'CD account number allowed only for Leader.',
+ 'WARNING!'
+ );
+
+ // Clear current select
+ $input.val('');
+
+ // Disable CD for NON-leaders, enable only leader, clear balance div
+ $('select.follow_insurer_cd').each(function () {
+
+ var count = $(this).data('count');
+ var isLeaderRow = $('#co_share_type_' + count).is(':checked');
+
+ // Get the corresponding balance div
+ var balanceDiv = document.getElementById('cd_current_balance_info_' + count);
+
+ if (!isLeaderRow) {
+ $(this)
+ .prop('disabled', true)
+ .removeAttr('required')
+ .val('');
+
+ // Clear balance div if it exists
+ if (balanceDiv) {
+ balanceDiv.innerHTML = "";
+ }
+
+ } else {
+ $(this)
+ .prop('disabled', false)
+ .attr('required', true);
+ }
+ });
+
+ return;
+ }
+
+
+ // ➕ Add CD
+ if (val === 'add_cd') {
+ $('#premium_details_unique_id').val(uniqueid);
+ new bootstrap.Modal(
+ document.getElementById('cd_form_modal')
+ ).show();
+ $input.val('');
+ return;
+ }
+
+ // ✅ Valid selection (leader only)
+ $('#cd_ac_pk_for_leader').val(val);
+ getCdAmount(val, uniqueid);
+ }
+
+
function restrictCDACNO(currentSelect){
const selectedValue = $(currentSelect).val();
@@ -3780,85 +3929,160 @@
//-----------------------------------------------------------------------------------------------------------
- $('#cop_yes').change(function() {
+ // $('#cop_yes').change(function() {
- if ($(this).is(':checked')) {
- $('.add-insurer-button').removeClass('d-none');
- $('.payby').removeClass('d-none');
- $('.card_group_2').show()
- $('.card_group_3').show()
- $('.card_group_7').show()
- $('.card_group_35').removeClass('d-none');
+ // if ($(this).is(':checked')) {
+ // $('.add-insurer-button').removeClass('d-none');
+ // $('.payby').removeClass('d-none');
+ // $('.card_group_2').show()
+ // $('.card_group_3').show()
+ // $('.card_group_7').show()
+ // $('.card_group_35').removeClass('d-none');
- var selectedOption = $('#policy_type_id').find('option:selected');
- var bap = selectedOption.data('bap');
- var allocg = selectedOption.data('allocg');
- // console.log('allocg:', allocg);
+ // var selectedOption = $('#policy_type_id').find('option:selected');
+ // var bap = selectedOption.data('bap');
+ // var allocg = selectedOption.data('allocg');
+ // // console.log('allocg:', allocg);
- // do not remove this commented items
- // if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
- // $('.hidecoter').show()
- // $('.hidecotp').hide()
- // }else{
+ // // do not remove this commented items
+ // // if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
+ // // $('.hidecoter').show()
+ // // $('.hidecotp').hide()
+ // // }else{
- // if(bap == 'Motor'){
- // $('.hidecotp').show()
- // $('.hidecoter').hide()
- // }else{
- // $('.hidecoter').hide()
- // $('.hidecotp').hide()
- // }
- // }
+ // // if(bap == 'Motor'){
+ // // $('.hidecotp').show()
+ // // $('.hidecoter').hide()
+ // // }else{
+ // // $('.hidecoter').hide()
+ // // $('.hidecotp').hide()
+ // // }
+ // // }
- if(allocg == "EB"){
- $('.hideter').hide();
- $('.hidetp').hide();
- $('.hidecoter').hide()
- $('.hidecotp').hide()
- }else{
+ // if(allocg == "EB"){
+ // $('.hideter').hide();
+ // $('.hidetp').hide();
+ // $('.hidecoter').hide()
+ // $('.hidecotp').hide()
+ // }else{
- $('.hidetp').show();
- if($(this).is(':checked')){
- $('.hidecotp').show();
- }else{
- $('.hidecotp').hide();
- }
+ // $('.hidetp').show();
+ // if($(this).is(':checked')){
+ // $('.hidecotp').show();
+ // }else{
+ // $('.hidecotp').hide();
+ // }
- if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
- $('.hideter').show();
- if($(this).is(':checked')){
- $('.hidecoter').show();
- }else{
- $('.hidecoter').hide();
- }
- }else{
- $('.hideter').hide();
- }
- }
+ // if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
+ // $('.hideter').show();
+ // if($(this).is(':checked')){
+ // $('.hidecoter').show();
+ // }else{
+ // $('.hidecoter').hide();
+ // }
+ // }else{
+ // $('.hideter').hide();
+ // }
+ // }
- // $('input[name="co_share_per[]"], input[name="co_premium[]"]').each(function () {
- // $(this).val(''); // Clear value
- // console.log('Input cleared:', $(this).attr('name')); // Log cleared input
- // });
+ // // $('input[name="co_share_per[]"], input[name="co_premium[]"]').each(function () {
+ // // $(this).val(''); // Clear value
+ // // console.log('Input cleared:', $(this).attr('name')); // Log cleared input
+ // // });
- } else {
- $('.add-insurer-button').addClass('d-none');
- $('.payby').addClass('d-none');
- // $('#bro_payable_by').prop('checked', false);
- $('.card_group_2').hide()
- $('.card_group_3').hide()
- $('.card_group_7').hide()
- $('.card_group_35').addClass('d-none');
- $('.hidecoter').hide()
- $('.hidecotp').hide()
+ // } else {
+ // $('.add-insurer-button').addClass('d-none');
+ // $('.payby').addClass('d-none');
+ // // $('#bro_payable_by').prop('checked', false);
+ // $('.card_group_2').hide()
+ // $('.card_group_3').hide()
+ // $('.card_group_7').hide()
+ // $('.card_group_35').addClass('d-none');
+ // $('.hidecoter').hide()
+ // $('.hidecotp').hide()
- // $('input[name="co_share_per[]"], input[name="co_premium[]"]').each(function () {
- // $(this).val(''); // Clear value
- // console.log('Input cleared:', $(this).attr('name')); // Log cleared input
- // });
+ // // $('input[name="co_share_per[]"], input[name="co_premium[]"]').each(function () {
+ // // $(this).val(''); // Clear value
+ // // console.log('Input cleared:', $(this).attr('name')); // Log cleared input
+ // // });
+ // }
+ // });
+
+ $('#cop_yes').change(function () {
+
+ const isCoPayYes = $(this).is(':checked');
+
+ const selectedOption = $('#policy_type_id option:selected');
+ const bap = selectedOption.data('bap');
+ const allocg = selectedOption.data('allocg');
+
+ const $allPremiumCols = $('.csslabel, .cssbp, .csstp, .csstep');
+
+ /* =========================
+ VISIBILITY LOGIC
+ ========================= */
+ if (isCoPayYes) {
+
+ $('.add-insurer-button, .payby').removeClass('d-none');
+ $('.card_group_2, .card_group_3, .card_group_7').show();
+ $('.card_group_35').removeClass('d-none');
+
+ if (allocg === "EB") {
+ $('.hideter, .hidetp, .hidecoter, .hidecotp').hide();
+ } else {
+
+ $('.hidetp').show();
+ $('.hidecotp').show();
+
+ if (['Fire','Marine Cargo','Marine Hull'].includes(bap)) {
+ $('.hideter, .hidecoter').show();
+ } else {
+ $('.hideter, .hidecoter').hide();
+ }
}
- });
+
+ } else {
+
+ $('.add-insurer-button, .payby').addClass('d-none');
+ $('.card_group_2, .card_group_3, .card_group_7').hide();
+ $('.card_group_35').addClass('d-none');
+
+ $('.hideter, .hidetp, .hidecoter, .hidecotp').hide();
+ }
+
+ /* =========================
+ COLUMN LAYOUT LOGIC
+ ========================= */
+ $allPremiumCols
+ .filter(':visible')
+ .removeClass('col-3 col-4 col-6');
+
+ if (allocg === "EB") {
+
+ $allPremiumCols
+ .filter(':visible')
+ .addClass('col-6');
+
+ } else if (['Fire','Marine Cargo','Marine Hull'].includes(bap)) {
+
+ $allPremiumCols
+ .filter(':visible')
+ .addClass('col-3');
+
+ } else {
+
+ $allPremiumCols
+ .filter(':visible')
+ .addClass('col-4');
+ }
+
+ /* =========================
+ CO-SHARE RECALC
+ ========================= */
+ co_share_percentage_calculation();
+});
+
$('#client_type').change(function() {
@@ -4348,7 +4572,7 @@
style="font-size: x-small;">
-