FIX_Raised issues KYC document list not fetched properly and Excepted required validation in Inception form

This commit is contained in:
sanjeev.p 2025-12-15 17:53:06 +05:30
parent 5ca59ab1a7
commit 919d15ed54
2 changed files with 396 additions and 171 deletions

View File

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

View File

@ -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;">
</small>
</label>
<select class="form-control follow_insurer_cd" data-count="${insurerCount}" id="cd_ac_no_${insurerCount}" name="cd_ac_no_for_child[]" onchange="addCDAccountNumber(this); restrictCDACNO(this);">
<select class="form-control follow_insurer_cd" data-count="${insurerCount}" id="cd_ac_no_${insurerCount}" name="cd_ac_no_for_child[]" onchange="addCDAccountNumber(this);">
<option value="" selected>Select CD No</option>
<option value="add_cd"> + Add CD No</option>
</select>