Fix_Policy – Multiple Insurer
This commit is contained in:
parent
b88a37bf40
commit
841f67c33d
@ -3610,28 +3610,39 @@
|
||||
let hasEmptyInsurer = false;
|
||||
let firstEmptyField = null;
|
||||
|
||||
// $('select[name="follow_insurer_id[]"]').each(function() {
|
||||
// const $field = $(this);
|
||||
// const errorId = 'error-' + $field.attr('id');
|
||||
|
||||
// // Remove any old message
|
||||
// $('#' + errorId).remove();
|
||||
|
||||
// if ($field.val().trim() === "") {
|
||||
// hasEmptyInsurer = true;
|
||||
// $field.addClass('is-invalid');
|
||||
|
||||
// // Add error message only once
|
||||
// if (!$field.next('.text-danger').length) {
|
||||
// $field.after(`<small id="${errorId}" class="text-danger">This value is required.</small>`);
|
||||
// }
|
||||
|
||||
// if (!firstEmptyField) {
|
||||
// firstEmptyField = this; // store first empty field
|
||||
// }
|
||||
// } else {
|
||||
// $field.removeClass('is-invalid');
|
||||
// $('#' + errorId).remove(); // remove if filled
|
||||
// }
|
||||
// });
|
||||
$('select[name="follow_insurer_id[]"]').each(function() {
|
||||
const $field = $(this);
|
||||
const errorId = 'error-' + $field.attr('id');
|
||||
|
||||
// Remove any old message
|
||||
$('#' + errorId).remove();
|
||||
|
||||
if ($field.val().trim() === "") {
|
||||
if ($(this).val().trim() === "") {
|
||||
hasEmptyInsurer = true;
|
||||
$field.addClass('is-invalid');
|
||||
|
||||
// Add error message only once
|
||||
if (!$field.next('.text-danger').length) {
|
||||
$field.after(`<small id="${errorId}" class="text-danger">This value is required.</small>`);
|
||||
}
|
||||
|
||||
$(this).addClass('is-invalid');
|
||||
if (!firstEmptyField) {
|
||||
firstEmptyField = this; // store first empty field
|
||||
firstEmptyField = this; // store the first invalid field
|
||||
}
|
||||
} else {
|
||||
$field.removeClass('is-invalid');
|
||||
$('#' + errorId).remove(); // remove if filled
|
||||
$(this).removeClass('is-invalid');
|
||||
}
|
||||
});
|
||||
|
||||
@ -4570,7 +4581,7 @@
|
||||
switch(index) {
|
||||
case 0: // Insurer selection
|
||||
newCell = `<td>
|
||||
<select class="form-control follow_insurer" data-count="${insurerCount}" id="follow_insurer_id_${insurerCount}" name="follow_insurer_id[]" onchange="getCDAccountNumber(this)" required>
|
||||
<select class="form-control follow_insurer" data-language="1" data-count="${insurerCount}" id="follow_insurer_id_${insurerCount}" name="follow_insurer_id[]" onchange="getCDAccountNumber(this)" required>
|
||||
<option value="" selected>Select Insurer</option>
|
||||
<?php foreach ($insurer_branch as $value) { ?>
|
||||
<option value="<?= $value['id'] . '-' . $value['insurer_id'] ?>" data-id="<?= $value['insurer_id'] ?>" data-bid="<?= $value['id'] ?>" data-ic="<?= $value['category'] ?>">
|
||||
@ -4591,7 +4602,7 @@
|
||||
break;
|
||||
case 2: // CD Account Number selectionclass="std_tp_td"
|
||||
newCell = `<td>
|
||||
<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-language="2" data-count="${insurerCount}" id="cd_ac_no_${insurerCount}" name="cd_ac_no_for_child[]" onchange="addCDAccountNumber(this); restrictCDACNO(this)">
|
||||
<option value="" selected>Select CD No</option>
|
||||
<option value="add_cd"> + Add CD No</option>
|
||||
</select>
|
||||
@ -4783,11 +4794,11 @@
|
||||
$('[name="standard_tp[]"]').val(std_tp);
|
||||
$('[name="standard_ter[]"]').val(std_tep);
|
||||
|
||||
if(insurerCount > 1){
|
||||
$('.follow_insurer').prop('required', true);
|
||||
}else{
|
||||
$('.follow_insurer').prop('required', false);
|
||||
}
|
||||
// if(insurerCount > 1){
|
||||
// $('.follow_insurer').prop('required', true);
|
||||
// }else{
|
||||
// $('.follow_insurer').prop('required', false);
|
||||
// }
|
||||
|
||||
});
|
||||
|
||||
@ -4804,6 +4815,12 @@
|
||||
// });
|
||||
|
||||
co_share_percentage_calculation(insurerCount, "add");
|
||||
|
||||
if (insurerCount === 0) {
|
||||
$('.follow_insurer').prop('required', false);
|
||||
} else {
|
||||
$('.follow_insurer').prop('required', true);
|
||||
}
|
||||
}
|
||||
|
||||
function removeInsurerColumn(index, count_index) {
|
||||
@ -4834,6 +4851,11 @@
|
||||
insurer_count_array = insurer_count_array.filter(item => item !== count_index);
|
||||
co_share_percentage_calculation(null, "remove");
|
||||
insurerCount--;
|
||||
if (insurerCount === 0) {
|
||||
$('.follow_insurer').prop('required', false);
|
||||
} else {
|
||||
$('.follow_insurer').prop('required', true);
|
||||
}
|
||||
|
||||
console.log('#################################### END Remove Insurer Column ####################################');
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user