2121 lines
109 KiB
PHP
2121 lines
109 KiB
PHP
<!-- Modal content for the Large example -->
|
||
<div class="modal fade" id="bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
|
||
aria-hidden="true" aria-modal="true" data-backdrop="static">
|
||
<div class="modal-dialog modal-full-width">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="myLargeModalLabel">Policy Premium <span id="nameOfThePolicy"></span></h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body">
|
||
|
||
<div class="text-center" id="no_data"></div>
|
||
|
||
<form role="form" class="parsley-examples" method="post" id="GridForm" enctype="multipart/form-data">
|
||
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
|
||
<input type="hidden" name="client_id" id="Client_id"
|
||
value="<?= isset($client['id']) ? $client['id'] : '' ?>" />
|
||
<input type="hidden" name="client_policy_id" id="client_policy_id" />
|
||
<input type="hidden" id="grid_emp_count" />
|
||
<div class="form-group">
|
||
|
||
<div class="form-row" id="rac_rate_dropdown">
|
||
<div class="form-group col-md-6">
|
||
<label for="emp_code">Policy Premium Type<span class="text-danger">*</span></label>
|
||
<select class="form-control" id="grid" name="policy_grid_id"
|
||
onchange="addGridHTML(event)" required>
|
||
</select>
|
||
</div>
|
||
|
||
<!-- <div class="form-group col-md-4" style="position: relative; left: 45px;display:none" id="premium_type">
|
||
<label for="css"> Premium Calculation </label>
|
||
<div style="display: flex; align-items: center;">
|
||
<input type="radio" id="individual" name="premium_type" value="2">
|
||
<label for="individual" style="position: relative;top: 5px;left: 5px;"> Individual </label>
|
||
<input type="radio" id="single" name="premium_type" value="1">
|
||
<label for="single" style="position: relative;top: 5px;left: 5px;"> Single Insurance </label>
|
||
</div>
|
||
</div> -->
|
||
|
||
</div>
|
||
|
||
<hr>
|
||
|
||
<div class="form-row" id="grid_content_input">
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<div class="form-group text-right m-b-0">
|
||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
|
||
id="btnGridSubmit_2">Submit</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div><!-- /.modal-content -->
|
||
</div><!-- /.modal-dialog -->
|
||
</div><!-- /.modal -->
|
||
|
||
|
||
<script>
|
||
var policy_grid_id = $('#client_id').val();
|
||
var grid_html = '';
|
||
|
||
// $('#gmc_remove').hide();
|
||
$('#btnGridSubmit').hide();
|
||
|
||
$('.close').click(function() {
|
||
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#grid_' + i).remove();
|
||
}
|
||
});
|
||
|
||
|
||
function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = false) {
|
||
|
||
$('#grid_content_input').empty();
|
||
|
||
|
||
var grid_container = document.getElementById('grid_content_input');
|
||
var dataIdValue = ''
|
||
if (event === false) {
|
||
var dataIdValue = ui_type
|
||
} else {
|
||
var selectElement = event.target;
|
||
var selectedOption = selectElement.options[selectElement.selectedIndex];
|
||
dataIdValue = selectedOption.getAttribute('data-id');
|
||
// console.log('dataIdValue', dataIdValue)
|
||
}
|
||
|
||
|
||
if (dataIdValue == '1') {
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#grid_' + i).remove();
|
||
}
|
||
|
||
grid_html = `
|
||
<div class="form-row" id="grid_1">
|
||
<input value="1" type="hidden" name="policy_type">
|
||
|
||
<div class="form-group col-md-4">
|
||
<label for="mobile">Select <span class="text-danger">*</span></label>
|
||
<select class="form-control" id="si_or_bp" name="si_or_bp" onchange="si_orbp_change_function()" required>
|
||
<option value="2">Basic Pay</option>
|
||
<option value="1">Sum Insured</option>
|
||
<option value="3">Band/Grade</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div id="si_or_bp_full_div" style="display:none;">
|
||
|
||
<div id="si_or_bp_grade" class="form-row">
|
||
|
||
<div class="form-row col-md-4" style="margin-left: 346px; margin-top: -114px;">
|
||
<label for="mobile">Premium Multiplier<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '3' ? data.multiplier : '') : ''}" type="text" class="form-control" placeholder="Multiplier" name="gpa_sum_multiplier2" id="gpa_sum_multiplier2" onkeyup="gpaSumInsureMultiplier(this)" required>
|
||
</div>
|
||
|
||
<div class="form-row" style="width:101%;padding: 10px;" id="removeChild_${Count}">
|
||
<div class="form-group col-md-2" id="">
|
||
<label for="mobile">Band/Grade<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '3' ? data.grade : '') : ''}" type="text" class="form-control" placeholder="Enter Band/Grade" name="gpa_band[]" id="gpa_band" required>
|
||
</div>
|
||
<div class="form-group col-md-4" id="">
|
||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '3' ? data.si : '') : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="gpa_sum_si2[]" id="gpa_sum_si2" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='gpa_sum_si_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
|
||
<div class="form-group col-md-4">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '3' ? data.premium : '') : ''}" type="text" class="form-control" placeholder="Enter Premium" name="gpa_sum_premium2[]" id="gpa_sum_premium2" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='gpa_sum_premium_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
|
||
<div class="form-group col-md-4" style="position: absolute;left: 870px;">
|
||
<button style="margin-top: 44px;position: relative;right: 0px;" type="button" class="btn btn-danger" id="gmc_remove" onclick="removebutton()">x</button>
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-primary" id="gmc_add_more2" onclick="appendGridtHtml('1')">+</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="si_or_bp_sum_insure_child"></div>
|
||
|
||
</div>
|
||
|
||
<div id="si_or_bp_sum_insure" class="form-row">
|
||
|
||
<div class="form-row col-md-4" style="margin-left: 346px; margin-top: -114px;">
|
||
<label for="mobile">Premium Multiplier<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '1' ? data.multiplier : '') : ''}" type="text" class="form-control" placeholder="Multiplier" name="gpa_sum_multiplier" id="gpa_sum_multiplier" onkeyup="gpaSumInsureMultiplier(this)" required>
|
||
</div>
|
||
<div class="form-row" style="width:101%;padding: 10px;" id="removeChild_${Count}">
|
||
<div class="form-group col-md-4" id="">
|
||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '1' ? data.si : '') : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="gpa_sum_si[]" id="gpa_sum_si" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='gpa_sum_si_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group col-md-4">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '1' ? data.premium : '') : ''}" type="text" class="form-control" placeholder="Enter Premium" name="gpa_sum_premium[]" id="gpa_sum_premium" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='gpa_sum_premium_number_word' class="text-danger-2" ></div>
|
||
|
||
</div>
|
||
<div class="form-group col-md-4" style="position: relative;right: 6px;">
|
||
<button style="margin-top: 44px;position: relative;right: 0px;" type="button" class="btn btn-danger" id="gmc_remove" onclick="removebutton()">x</button>
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-primary" id="gmc_add_more" onclick="appendGridtHtml('1')">+</button>
|
||
</div>
|
||
</div>
|
||
<div id="si_or_bp_sum_insure_child"></div>
|
||
</div>
|
||
|
||
<div id="si_or_bp_basic_pay" class="form-row">
|
||
|
||
<div class="form-row" style="margin-left: 347px;/* margin-bottom: -106px; */margin-top: -97px;">
|
||
|
||
<div class="form-col col-md-6">
|
||
<label for="mobile">Basic Pay<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '2' ? data.basic_pay : '') : ''}" type="text" class="form-control" placeholder="Enter Basic Pay" name="basic_pay" id="basic_pay" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='gpa_basic_pay_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
|
||
<div class="form-col col-md-6">
|
||
<label for="mobile">Basic Multiplier<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '2' ? data.basic_multiplier : '') : ''}" type="text" class="form-control" placeholder="Basic Multiplier" name="basic_multiplier" id="basic_multiplier" onkeyup='basicPayMultiple(this)' required>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<div class="form-row" style="padding: 10px;">
|
||
|
||
|
||
<div class="form-group col-md-4" id="" style="width:84%">
|
||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '2' ? data.si : '') : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="gpa_basic_si" id="gpa_basic_si" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='basic_gpa_si_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
|
||
<div class="form-col col-md-4">
|
||
<label for="mobile">Premium Multiplier<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '2' ? data.multiplier : '') : ''}" type="text" class="form-control" placeholder="Premium Multiplier" name="premium_multiplier" id="premium_multiplier" onkeyup='basicPayMultiple(this)'required>
|
||
</div>
|
||
|
||
<div class="form-group col-md-4">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '2' ? data.premium : '') : ''}" type="text" class="form-control basic_gpa_premium" placeholder="Enter Premium" name="gpa_basic_premium" id="gpa_basic_premium" onkeypress="return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='basic_gpa_premium_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (dataIdValue == '2') {
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#grid_' + i).remove();
|
||
}
|
||
|
||
grid_html = `
|
||
<div class="form-row" id="grid_2" style="width:84%">
|
||
<input value="1" type="hidden" name="policy_type">
|
||
<div class="form-group col-md-6">
|
||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.si : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="gpa_si" id="gpa_si" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='gpa_si_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group col-md-6">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.premium : ''}" type="text" class="form-control" placeholder="Enter Premium" name="gpa_premium" id="gpa_premium" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='gpa_premium_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (dataIdValue == '3') {
|
||
|
||
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#grid_' + i).remove();
|
||
}
|
||
|
||
grid_html = `
|
||
<div class="form-row" id="grid_3" style="width:84%">
|
||
<div class="form-group col-md-5">
|
||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.si : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="3_si[]" id="3_si" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='gpa_si_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group col-md-5">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.premium : ''}" type="text" class="form-control" placeholder="Enter Premium" name="3_premium[]" id="3_premium" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='gpa_premium_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group">
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-danger" id="gmc_remove" onclick="removebutton(0, 3)">x</button>
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-primary" id="gmc_add_more" onclick="appendGridtHtml(3)">+</button>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (dataIdValue == '4') {
|
||
|
||
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#grid_' + i).remove();
|
||
}
|
||
grid_html = `
|
||
<div class="form-row" id="grid_4" style="width:84%">
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.si : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="4_si" id="4_si" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='sum_insured_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-row">
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">From Age<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.age_from : ''}" type="text" class="form-control" placeholder="Enter From Age" name="4_age_from[]" id="4_age_from" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">To Age<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.age_to : ''}" type="text" class="form-control" placeholder="Enter To Age" name="4_age_to[]" id="4_age_to" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.premium : ''}" type="text" class="form-control" placeholder="Enter Premium" name="4_premium[]" id="4_premium" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='premium_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group">
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-danger" id="gmc_remove" onclick="removebutton(0,4)">x</button>
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-primary" id="gmc_add_more" onclick="appendGridtHtml(4)">+</button>
|
||
</div>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (dataIdValue == '5') {
|
||
|
||
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#grid_' + i).remove();
|
||
}
|
||
|
||
grid_html = `
|
||
<div class="form-row" id="grid_5" style="width:84%">
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.si : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="5_si[]" id="5_si" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='sum_insured_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group col-md-2">
|
||
<label for="mobile">From Age<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.age_from : ''}" type="text" class="form-control" placeholder="Enter From Age" name="5_age_from[]" id="5_age_from" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-2">
|
||
<label for="mobile">To Age<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.age_to : ''}" type="text" class="form-control" placeholder="Enter To Age" name="5_age_to[]" id="5_age_to" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.premium : ''}" type="text" class="form-control" placeholder="Enter Premium" name="5_premium[]" id="5_premium" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='premium_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group">
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-danger" id="gmc_remove" onclick="removebutton(0,5)">x</button>
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-primary" id="gmc_add_more" onclick="appendGridtHtml(5)">+</button>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (dataIdValue == '6') {
|
||
|
||
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#grid_' + i).remove();
|
||
}
|
||
|
||
grid_html = `
|
||
<div class="form-row" id="grid_6" style="width:84%">
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.si : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="6_si" id="6_si" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='sum_insured_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-row">
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">From Age<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.age_from : ''}" type="text" class="form-control" placeholder="Enter From Age" name="6_age_from[]" id="6_age_from" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">To Age<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.age_to : ''}" type="text" class="form-control" placeholder="Enter To Age" name="6_age_to[]" id="6_age_to" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.premium : ''}" type="text" class="form-control" placeholder="Enter Premium" name="6_premium[]" id="6_premium" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='premium_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group">
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-danger" id="gmc_remove" onclick="removebutton(0,6)">x</button>
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-primary" id="gmc_add_more" onclick="appendGridtHtml(6)">+</button>
|
||
</div>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (dataIdValue == '7') {
|
||
|
||
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#grid_' + i).remove();
|
||
}
|
||
|
||
grid_html = `
|
||
<div class="form-row" id="grid_7" style="width:84%">
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.si : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="7_si[]" id="7_si" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='sum_insured_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group col-md-2">
|
||
<label for="mobile">From Age<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.age_from : ''}" type="text" class="form-control" placeholder="Enter From Age" name="7_age_from[]" id="7_age_from" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-2">
|
||
<label for="mobile">To Age<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.age_to : ''}" type="text" class="form-control" placeholder="Enter To Age" name="7_age_to[]" id="7_age_to" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.premium : ''}" type="text" class="form-control" placeholder="Enter Premium" name="7_premium[]" id="7_premium" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='premium_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group">
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-danger" id="gmc_remove" onclick="removebutton(0,7)">x</button>
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-primary" id="gmc_add_more" onclick="appendGridtHtml(7)">+</button>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (dataIdValue == '8') {
|
||
|
||
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#grid_' + i).remove();
|
||
}
|
||
|
||
|
||
grid_html = `
|
||
|
||
<div class="form-row" id="grid_8" style="width:84%">
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.si : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="8_si[]" id="8_si" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='sum_insured_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Grade/Band<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.grade : ''}" type="text" class="form-control" placeholder="Enter Grade/Band " name="8_grade[]" id="8_grade" required>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.premium : ''}" type="text" class="form-control" placeholder="Enter Premium" name="8_premium[]" id="8_premium" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='premium_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group">
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-danger" id="gmc_remove" onclick="removebutton(0,8)">x</button>
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-primary" id="gmc_add_more" onclick="appendGridtHtml(8)">+</button>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (dataIdValue == '9') {
|
||
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#grid_' + i).remove();
|
||
}
|
||
|
||
grid_html = `
|
||
<div class="form-row" id="grid_2" style="width:84%">
|
||
<input value="1" type="hidden" name="policy_type">
|
||
<div class="form-group col-md-6">
|
||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.si : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="gpa_si" id="gpa_si" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='gpa_si_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group col-md-6">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.premium : ''}" type="text" class="form-control" placeholder="Enter Premium" name="gpa_premium" id="gpa_premium" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='gpa_premium_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (dataIdValue == '10') {
|
||
|
||
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#grid_' + i).remove();
|
||
}
|
||
|
||
grid_html = `
|
||
<div class="form-row" id="grid_10" style="width:84%">
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.si : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="10_si[]" id="10_si" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='sum_insured_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group col-md-2">
|
||
<label for="mobile">From Age<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.age_from : ''}" type="text" class="form-control" placeholder="Enter From Age" name="10_age_from[]" id="10_age_from" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-2">
|
||
<label for="mobile">To Age<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.age_to : ''}" type="text" class="form-control" placeholder="Enter To Age" name="10_age_to[]" id="10_age_to" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.premium : ''}" type="text" class="form-control" placeholder="Enter Premium" name="10_premium[]" id="10_premium" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='premium_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group">
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-danger" id="gmc_remove" onclick="removebutton(0,10)">x</button>
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-primary" id="gmc_add_more" onclick="appendGridtHtml(10)">+</button>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (dataIdValue == '11') {
|
||
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#grid_' + i).remove();
|
||
}
|
||
|
||
grid_html = `
|
||
|
||
<div class="form-row" id="grid_11" style="width:84%">
|
||
<div class="form-group col-md-2">
|
||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.si : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="11_si[]" id="11_si" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='sum_insured_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Grade/Band<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.grade : ''}" type="text" class="form-control" placeholder="Enter Grade/Band " name="11_grade[]" id="11_grade" required>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.premium : ''}" type="text" class="form-control" placeholder="Enter Premium" name="11_premium[]" id="11_premium" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='premium_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group col-md-2">
|
||
<label for="mobile">Max SI<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.max_si : ''}" type="text" class="form-control" placeholder="Enter Max SI" name="11_max_si[]" id="11_max_si" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='max_si_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group">
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-danger" id="gmc_remove" onclick="removebutton(0,11)">x</button>
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-primary" id="gmc_add_more" onclick="appendGridtHtml(11)">+</button>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (dataIdValue == '12') {
|
||
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#grid_' + i).remove();
|
||
}
|
||
|
||
grid_html = `
|
||
|
||
<div class="form-row" id="grid_12" style="width:84%">
|
||
<div class="form-group col-md-2">
|
||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.si : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="12_si[]" id="12_si" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='sum_insured_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Releationship<span class="text-danger">*</span></label>
|
||
<select class="form-control" name="12_relationship[]" id="12_relationship" required>
|
||
<option value="">Select</option>
|
||
<option value="self" ${data !== false && data !== undefined && data !== '' && data.relationship === 'self' ? 'selected' : ''}>Self</option>
|
||
<option value="spouse" ${data !== false && data !== undefined && data !== '' && data.relationship === 'spouse' ? 'selected' : ''}>Spouse</option>
|
||
<option value="father" ${data !== false && data !== undefined && data !== '' && data.relationship === 'father' ? 'selected' : ''}>Father</option>
|
||
<option value="mother" ${data !== false && data !== undefined && data !== '' && data.relationship === 'mother' ? 'selected' : ''}>Mother</option>
|
||
<option value="father-in-law" ${data !== false && data !== undefined && data !== '' && data.relationship === 'father-in-law' ? 'selected' : ''}>Father in Law</option>
|
||
<option value="mother-in-law" ${data !== false && data !== undefined && data !== '' && data.relationship === 'mother-in-law' ? 'selected' : ''}>Mother in Law</option>
|
||
<option value="child" ${data !== false && data !== undefined && data !== '' && data.relationship === 'child' ? 'selected' : ''}>Child</option>
|
||
</select>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.premium : ''}" type="text" class="form-control" placeholder="Enter Premium" name="12_premium[]" id="12_premium" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='premium_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group">
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-danger" id="gmc_remove" onclick="removebutton(0,12)">x</button>
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-primary" id="gmc_add_more" onclick="appendGridtHtml(12)">+</button>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (dataIdValue == '13') {
|
||
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#grid_' + i).remove();
|
||
}
|
||
|
||
grid_html = `
|
||
|
||
<div class="form-row" id="grid_13" style="width:84%">
|
||
<div class="form-group col-md-2">
|
||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.si : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="13_si[]" id="13_si" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='sum_insured_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group col-md-2">
|
||
<label for="mobile">From Age<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.age_from : ''}" type="text" class="form-control" placeholder="Enter From Age" name="13_age_from[]" id="13_age_from" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-2">
|
||
<label for="mobile">To Age<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.age_to : ''}" type="text" class="form-control" placeholder="Enter To Age" name="13_age_to[]" id="13_age_to" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-2">
|
||
<label for="mobile">Relationship<span class="text-danger">*</span></label>
|
||
<select class="form-control" name="13_relationship[]" id="13_relationship" required>
|
||
<option value="">Select</option>
|
||
<option value="self" ${data !== false && data !== undefined && data !== '' && data.relationship === 'self' ? 'selected' : ''}>Self</option>
|
||
<option value="spouse" ${data !== false && data !== undefined && data !== '' && data.relationship === 'spouse' ? 'selected' : ''}>Spouse</option>
|
||
<option value="father" ${data !== false && data !== undefined && data !== '' && data.relationship === 'father' ? 'selected' : ''}>Father</option>
|
||
<option value="mother" ${data !== false && data !== undefined && data !== '' && data.relationship === 'mother' ? 'selected' : ''}>Mother</option>
|
||
<option value="father-in-law" ${data !== false && data !== undefined && data !== '' && data.relationship === 'father-in-law' ? 'selected' : ''}>Father in Law</option>
|
||
<option value="mother-in-law" ${data !== false && data !== undefined && data !== '' && data.relationship === 'mother-in-law' ? 'selected' : ''}>Mother in Law</option>
|
||
<option value="child" ${data !== false && data !== undefined && data !== '' && data.relationship === 'child' ? 'selected' : ''}>Child</option>
|
||
</select>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.premium : ''}" type="text" class="form-control" placeholder="Enter Premium" name="13_premium[]" id="13_premium" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='premium_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group">
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-danger" id="gmc_remove" onclick="removebutton(0,13)">x</button>
|
||
<button style="margin-top: 44px;position: absolute;margin-left: 5px;" type="button" class="btn btn-primary" id="gmc_add_more" onclick="appendGridtHtml(13)">+</button>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else {
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#grid_' + i).remove();
|
||
}
|
||
grid_html = '';
|
||
$('#btnGridSubmit').hide();
|
||
|
||
}
|
||
|
||
grid_container.insertAdjacentHTML('beforeend', grid_html);
|
||
|
||
if (dataIdValue == '1') {
|
||
$('#gpa_sum_si').trigger('keyup');
|
||
$('#gpa_sum_si2').trigger('keyup');
|
||
// $('input[name="gpa_sum_si[]"]').each(function() {
|
||
// console.log($(this));
|
||
// $(this).trigger('keyup');
|
||
// });
|
||
}
|
||
|
||
|
||
$('#gpa_sum_insured').hide();
|
||
$('#btnGridSubmit').show();
|
||
|
||
$('#si_or_bp').val(si_or_bp);
|
||
setTimeout(() => {
|
||
$('#si_or_bp').trigger('change');
|
||
}, 300);
|
||
|
||
};
|
||
|
||
|
||
$("#GridForm").submit(function(event) {
|
||
|
||
var check = checkDuplicate();
|
||
|
||
|
||
event.preventDefault();
|
||
|
||
if ($('#grid_emp_count').val() == 'false') {
|
||
toastr.warning('Client has active employees', 'Warning');
|
||
return;
|
||
}
|
||
|
||
var isValid = $('#GridForm').parsley().validate();
|
||
if (!isValid) {
|
||
console.log('Form is Empty', 'Warning');
|
||
return;
|
||
}
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
var formData = new FormData($('#GridForm')[0]);
|
||
var policy_form_action = '<?= base_url("client/premimum/create") ?>';
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
if (check) {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
} else {
|
||
$.ajax({
|
||
data: formData,
|
||
url: policy_form_action,
|
||
type: "POST",
|
||
dataType: 'json',
|
||
processData: false,
|
||
contentType: false,
|
||
success: function(res) {
|
||
|
||
console.log("Response", res);
|
||
|
||
if (res.status === false) {
|
||
toastr.error('Policy Dose Not Create', 'Error');
|
||
return;
|
||
}
|
||
|
||
setTimeout(function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
var message = (policy_PrimaryKey === '') ?
|
||
'Policy Premium Added successfully' :
|
||
'Policy Premium Added Successfully';
|
||
toastr.success(message, 'Success');
|
||
$('.close').click();
|
||
}, 1000);
|
||
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
setTimeout(function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
if (xhr.status === 404) {
|
||
toastr.warning('Resource not found', 'Warning');
|
||
} else if (xhr.status === 500) {
|
||
toastr.warning('Internal server error', 'Warning');
|
||
} else {
|
||
toastr.warning('Unknown error occurred', 'Warning');
|
||
}
|
||
}, 1000);
|
||
}
|
||
});
|
||
}
|
||
|
||
});
|
||
|
||
|
||
$('body').on('click', '.btnPolicyModel', function() {
|
||
|
||
// $('#grid').empty();
|
||
|
||
var client_policy_id = $(this).data('id');
|
||
$('#client_policy_id').val(client_policy_id);
|
||
console.log('client_policy_id', client_policy_id)
|
||
|
||
var policy_type_string = $(this).attr('id');
|
||
console.log('policy_type_string', policy_type_string)
|
||
|
||
if (policy_type_string == 'GPA' || policy_type_string == 'GMC') {
|
||
|
||
$('#GridForm').show();
|
||
$('#no_data').html('');
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
|
||
$.ajax({
|
||
url: '<?= base_url("util/policy-premium") ?>',
|
||
type: "GET",
|
||
data: {
|
||
client_policy_id: client_policy_id
|
||
},
|
||
dataType: 'json',
|
||
success: function(res) {
|
||
|
||
$('#GridForm')[0].reset();
|
||
|
||
// if(res.family_floater == 1){
|
||
// $('#premium_type').show();
|
||
// $('#individual').prop('checked', true)
|
||
// }else{
|
||
// $('#premium_type').hide();
|
||
// $('#individual').prop('checked', false)
|
||
// }
|
||
|
||
setTimeout(function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}, 1000);
|
||
|
||
console.log('policy grid responce', res);
|
||
var temp_for_premiumData = JSON.parse(res.premiumData);
|
||
console.log('policy grid responce', temp_for_premiumData);
|
||
res.premiumData = JSON.parse(res.premiumData);
|
||
console.log('policy grid responce', res.premiumData);
|
||
|
||
|
||
$('#nameOfThePolicy').html(' - ' + res.policy_name);
|
||
$('#grid_emp_count').val(res.count);
|
||
|
||
if (res.count > 0) {
|
||
console.log('count -- 2', res.count);
|
||
$("#btnGridSubmit_2").hide();
|
||
} else {
|
||
$("#btnGridSubmit_2").show();
|
||
console.log('count -- ', res.count);
|
||
}
|
||
|
||
if (res.status === false) {
|
||
toastr.error(res.status);
|
||
return;
|
||
}
|
||
|
||
var policy_grid_id_value = '';
|
||
if (res.premiumData && res.premiumData.length > 0 && res.premiumData[0]
|
||
.policy_grid_id) {
|
||
policy_grid_id_value = res.premiumData[0].policy_grid_id;
|
||
}
|
||
|
||
$('#grid_content_input').empty();
|
||
var policeGridOptionHTML = '';
|
||
policeGridOptionHTML += ` <option value="">Select Premium Type</option>`;
|
||
$.each(res.data, function(index, item) {
|
||
policeGridOptionHTML += '<option data-id="' + item.ui_type +
|
||
'" value="' + item.id + '" ' + (policy_grid_id_value === item.id ?
|
||
'selected="selected"' : '') + '>' + item.policy_grid_type +
|
||
'</option>';
|
||
});
|
||
$('#grid').html(policeGridOptionHTML);
|
||
|
||
// if (res.premiumData[0].hasOwnProperty('premium_type')) {
|
||
|
||
// if (res.premiumData[0].premium_type == '2') {
|
||
|
||
// $('#individual').prop('checked', true)
|
||
// $('#single').prop('checked', false)
|
||
|
||
// } else if (res.premiumData[0].premium_type == '1') {
|
||
|
||
// $('#single').prop('checked', true)
|
||
// $('#individual').prop('checked', false)
|
||
|
||
// } else {
|
||
// $('#single').prop('checked', false)
|
||
// $('#individual').prop('checked', false)
|
||
// }
|
||
|
||
// }
|
||
|
||
|
||
var si_or_bp_value = '';
|
||
if (res.premiumData && res.premiumData.length > 0) {
|
||
|
||
|
||
if (res.premiumData[0].si_or_bp) {
|
||
si_or_bp_value = res.premiumData[0].si_or_bp;
|
||
}
|
||
|
||
addGridHTML(false, res.premiumData[0], res.premiumData[0].policy_grid_id,
|
||
si_or_bp_value);
|
||
|
||
res.premiumData.shift();
|
||
$.each(res.premiumData, function(index, item) {
|
||
if (item.si_or_bp == '1') {
|
||
appendGridtHtml('1', item);
|
||
} else {
|
||
appendGridtHtml(item.policy_grid_id, item);
|
||
}
|
||
});
|
||
|
||
} else {
|
||
console.log("res.premiumData is undefined, null, or empty.");
|
||
}
|
||
|
||
$('#bs-example-modal-lg').modal('show');
|
||
|
||
|
||
$("#gpa_si").trigger("keyup");
|
||
$("#gpa_premium").trigger("keyup");
|
||
$('#basic_pay').trigger('keyup');
|
||
$('#4_si').trigger('keyup');
|
||
|
||
$('input[name="gpa_sum_si[]"]').each(function() {
|
||
$(this).trigger('keyup');
|
||
});
|
||
|
||
$('input[name="gpa_sum_si2[]"]').each(function() {
|
||
$(this).trigger('keyup');
|
||
});
|
||
|
||
$('input[name="gpa_sum_premium[]"]').each(function() {
|
||
$(this).trigger('keyup');
|
||
});
|
||
|
||
$('input[name="11_max_si[]"]').each(function() {
|
||
$(this).trigger('keyup');
|
||
});
|
||
|
||
var id_for_trigger = temp_for_premiumData[0].policy_grid_id;
|
||
$(`input[name="${id_for_trigger}_si[]"]`).each(function() {
|
||
console.log($(this));
|
||
$(this).trigger('keyup');
|
||
});
|
||
|
||
$(`input[name="${id_for_trigger}_premium[]"]`).each(function() {
|
||
console.log($(this));
|
||
$(this).trigger('keyup');
|
||
});
|
||
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
setTimeout(function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
toastr.warning('Something Wrong!', 'warning');
|
||
}, 1000);
|
||
}
|
||
});
|
||
|
||
} else {
|
||
|
||
$('#grid').empty();
|
||
$('#nameOfThePolicy').html('');
|
||
$('#GridForm').hide();
|
||
$('#no_data').html('The policy has no Policy Rack Rate');
|
||
toastr.warning("The policy has no Policy Rack Rate", "Warning")
|
||
}
|
||
|
||
|
||
});
|
||
|
||
|
||
$('#grid').change(function() {
|
||
var grid_id = $(this)[0].value;
|
||
var client_policy_id = $('#client_policy_id')[0].value;
|
||
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
$.ajax({
|
||
url: '<?= base_url("util/policy-premium") ?>',
|
||
type: "GET",
|
||
data: {
|
||
client_policy_id: client_policy_id
|
||
},
|
||
dataType: 'json',
|
||
success: function(res) {
|
||
|
||
console.log('responce :', res);
|
||
|
||
setTimeout(function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}, 1000);
|
||
if (res.premiumData.length > 0 && res.premiumData[0].policy_grid_id === grid_id) {
|
||
|
||
$('#nameOfThePolicy').html(' - ' + res.policy_name);
|
||
$('#grid_emp_count').val(res.count);
|
||
|
||
if (res.count == false) {
|
||
console.log('count -- 2', res.count);
|
||
$("#btnGridSubmit_2").hide();
|
||
} else {
|
||
$("#btnGridSubmit_2").show();
|
||
console.log('count -- ', res.count);
|
||
}
|
||
|
||
if (res.status === false) {
|
||
toastr.error(res.status);
|
||
return;
|
||
}
|
||
|
||
var policy_grid_id_value = '';
|
||
if (res.premiumData && res.premiumData.length > 0 && res.premiumData[0]
|
||
.policy_grid_id) {
|
||
policy_grid_id_value = res.premiumData[0].policy_grid_id;
|
||
}
|
||
|
||
$('#grid_content_input').empty();
|
||
var policeGridOptionHTML = '';
|
||
policeGridOptionHTML += ` <option value="">Select Premium Type</option>`;
|
||
$.each(res.data, function(index, item) {
|
||
policeGridOptionHTML += '<option data-id="' + item.ui_type +
|
||
'" value="' + item.id + '" ' + (policy_grid_id_value === item.id ?
|
||
'selected="selected"' : '') + '>' + item.policy_grid_type +
|
||
'</option>';
|
||
});
|
||
// $('#grid').html(policeGridOptionHTML);
|
||
var si_or_bp_value = '';
|
||
if (res.premiumData && res.premiumData.length > 0) {
|
||
|
||
if (res.premiumData[0].si_or_bp) {
|
||
si_or_bp_value = res.premiumData[0].si_or_bp;
|
||
|
||
$('#si_or_bp').val(si_or_bp_value);
|
||
|
||
}
|
||
|
||
|
||
|
||
addGridHTML(false, res.premiumData[0], res.premiumData[0].policy_grid_id,
|
||
si_or_bp_value);
|
||
|
||
res.premiumData.shift();
|
||
$.each(res.premiumData, function(index, item) {
|
||
appendGridtHtml(item.policy_grid_id, item);
|
||
});
|
||
|
||
} else {
|
||
console.log("res.premiumData is undefined, null, or empty.");
|
||
}
|
||
} else if (res.data[0].policy_type == "GPA") {
|
||
$('#si_or_bp').val('2');
|
||
|
||
setTimeout(() => {
|
||
$('#si_or_bp').trigger('change')
|
||
}, 300);
|
||
}
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
setTimeout(function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
toastr.warning('Something Wrong!', 'warning');
|
||
}, 1000);
|
||
}
|
||
});
|
||
})
|
||
|
||
var Count = 1
|
||
|
||
function appendGridtHtml(ui_type = false, data = false, ) {
|
||
|
||
console.log('appendGridtHtml function called')
|
||
console.log(ui_type)
|
||
console.log(data)
|
||
|
||
var html = '';
|
||
// console.log('Grid Content',data)
|
||
Count++;
|
||
var container = document.getElementById('grid_content_input');
|
||
|
||
if (ui_type == '1') {
|
||
|
||
console.log('step 1')
|
||
var currentTime = getCurrentTime();
|
||
console.log(currentTime);
|
||
|
||
if($("#si_or_bp").val() == 1 || data.si_or_bp == '1'){
|
||
|
||
console.log('step 2')
|
||
|
||
html = `<div class="form-row gpa_sum_insure_remove" style="width:101%" id="removeChild_${Count}">
|
||
<div class="form-group col-md-4" id="">
|
||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.si : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="gpa_sum_si[]" id="gpa_sum_si" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='gpa_si_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group col-md-4">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.premium : ''}" type="text" class="form-control" placeholder="Enter Premium" name="gpa_sum_premium[]" id="gpa_sum_premium" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='gpa_premium_number_word' class="text-danger-2" ></div>
|
||
|
||
</div>
|
||
<div class="form-group">
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-danger" id="gmc_remove" onclick="removebutton(${Count})">x</button>
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-primary" id="gmc_add_more_${Count}" onclick="appendGridtHtml('1')">+</button>
|
||
</div>
|
||
</div>`;
|
||
|
||
}else if($("#si_or_bp").val() == 3 || data.si_or_bp == '3'){
|
||
|
||
console.log('step 3')
|
||
|
||
html = `<div class="form-row gpa_band_remove" style="width:101%" id="removeChild_${Count}">
|
||
|
||
<div class="form-group col-md-2" id="">
|
||
<label for="mobile">Band/Grade<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '3' ? data.grade : '') : ''}" type="text" class="form-control" placeholder="Enter Band/Grade" name="gpa_band[]" id="gpa_band" required>
|
||
</div>
|
||
|
||
<div class="form-group col-md-4" id="">
|
||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '3' ? data.si : '') : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="gpa_sum_si2[]" id="gpa_sum_si2" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='gpa_si_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
|
||
<div class="form-group col-md-4">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '3' ? data.premium : '') : ''}" type="text" class="form-control" placeholder="Enter Premium" name="gpa_sum_premium2[]" id="gpa_sum_premium2" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='gpa_premium_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-danger" id="gmc_remove" onclick="removebutton(${Count})">x</button>
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-primary" id="gmc_add_more_${Count}" onclick="appendGridtHtml('1')">+</button>
|
||
</div>
|
||
</div>`;
|
||
|
||
}
|
||
|
||
console.log('step 4')
|
||
|
||
} else if (ui_type == '3') {
|
||
|
||
html = `
|
||
<div class="form-row" id="removeChild_${Count}" style="width:84%">
|
||
<div class="form-group col-md-5">
|
||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.si : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="3_si[]" id="3_si_${Count}" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='gpa_si_number_word_${Count}' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group col-md-5">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.premium : ''}" type="text" class="form-control" placeholder="Enter Premium" name="3_premium[]" id="3_premium_${Count}" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='gpa_premium_number_word_${Count}' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group">
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-danger" id="gmc_remove" onclick="removebutton(${Count})">x</button>
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-primary" id="gmc_add_more_${Count}" onclick="appendGridtHtml(3)">+</button>
|
||
</div>
|
||
</div>
|
||
`;
|
||
|
||
} else if (ui_type == '4') {
|
||
|
||
|
||
html = `
|
||
<div class="form-row" id="removeChild_${Count}" style="width:84%">
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">From Age<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.age_from : ''}" type="text" class="form-control" placeholder="Enter From Age" name="4_age_from[]" id="4_age_from" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">To Age<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.age_from : ''}" type="text" class="form-control" placeholder="Enter To Age" name="4_age_to[]" id="4_age_to" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.premium : ''}" type="text" class="form-control" placeholder="Enter Premium" name="4_premium[]" id="4_premium_${Count}" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='premium_number_word_${Count}' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group">
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-danger" id="gmc_remove" onclick="removebutton(${Count})">x</button>
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-primary" id="gmc_add_more_${Count}" onclick="appendGridtHtml(4)">+</button>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (ui_type == '5') {
|
||
|
||
|
||
html = `
|
||
<div class="form-row" id="removeChild_${Count}" style="width:84%">
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.si : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="5_si[]" id="5_si_${Count}" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='sum_insured_number_word_${Count}' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group col-md-2">
|
||
<label for="mobile">From Age<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.age_from : ''}" type="text" class="form-control" placeholder="Enter From Age" name="5_age_from[]" id="5_age_from" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-2">
|
||
<label for="mobile">To Age<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.age_to : ''}" type="text" class="form-control" placeholder="Enter To Age" name="5_age_to[]" id="5_age_to" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.premium : ''}" type="text" class="form-control" placeholder="Enter Premium" name="5_premium[]" id="5_premium_${Count}" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='premium_number_word_${Count}' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group">
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-danger" id="gmc_remove" onclick="removebutton(${Count})">x</button>
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-primary" id="gmc_add_more_${Count}" onclick="appendGridtHtml(5)">+</button>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (ui_type == '6') {
|
||
|
||
html = `
|
||
<div class="form-row" id="removeChild_${Count}" style="width:84%">
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">From Age<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.age_from : ''}" type="text" class="form-control" placeholder="Enter From Age" name="6_age_from[]" id="6_age_from" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">To Age<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.age_to : ''}" type="text" class="form-control" placeholder="Enter To Age" name="6_age_to[]" id="6_age_to" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.premium : ''}" type="text" class="form-control" placeholder="Enter Premium" name="6_premium[]" id="6_premium_${Count}" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='premium_number_word_${Count}' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group">
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-danger" id="gmc_remove" onclick="removebutton(${Count})">x</button>
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-primary" id="gmc_add_more_${Count}" onclick="appendGridtHtml(6)">+</button>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (ui_type == '7') {
|
||
|
||
html = `
|
||
<div class="form-row" id="removeChild_${Count}" style="width:84%">
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.si : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="7_si[]" id="7_si_${Count}" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='sum_insured_number_word_${Count}' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group col-md-2">
|
||
<label for="mobile">From Age<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.age_from : ''}" type="text" class="form-control" placeholder="Enter From Age" name="7_age_from[]" id="7_age_from" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-2">
|
||
<label for="mobile">To Age<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.age_to : ''}" type="text" class="form-control" placeholder="Enter To Age" name="7_age_to[]" id="7_age_to" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.premium : ''}" type="text" class="form-control" placeholder="Enter Premium" name="7_premium[]" id="7_premium_${Count}" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='premium_number_word_${Count}' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group">
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-danger" id="gmc_remove" onclick="removebutton(${Count})">x</button>
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-primary" id="gmc_add_more_${Count}" onclick="appendGridtHtml(7)">+</button>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (ui_type == '8') {
|
||
|
||
html = `
|
||
<div class="form-row" id="removeChild_${Count}" style="width:84%">
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.si : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="8_si[]" id="8_si_${Count}" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='sum_insured_number_word_${Count}' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Grade/Band<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.grade : ''}" type="text" class="form-control" placeholder="Enter Grade/Band " name="8_grade[]" id="8_grade" required>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.premium : ''}" type="text" class="form-control" placeholder="Enter Premium" name="8_premium[]" id="8_premium_${Count}" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='premium_number_word_${Count}' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group">
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-danger" id="gmc_remove" onclick="removebutton(${Count})">x</button>
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-primary" id="gmc_add_more_${Count}" onclick="appendGridtHtml(8)">+</button>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (ui_type == '9') {
|
||
|
||
html = `
|
||
<div class="form-row" id="removeChild_${Count}" style="width:84%">
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.si : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="9_si[]" id="9_si_${Count}" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='sum_insured_number_word_${Count}' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Grade/Band<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.grade : ''}" type="text" class="form-control" placeholder="Enter Grade/Band " name="9_grade[]" id="9_grade" required>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.premium : ''}" type="text" class="form-control" placeholder="Enter Premium" name="9_premium[]" id="9_premium_${Count}" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='premium_number_word_${Count}' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group">
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-danger" id="gmc_remove" onclick="removebutton(${Count})">x</button>
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-primary" id="gmc_add_more_${Count}" onclick="appendGridtHtml(9)">+</button>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (ui_type == '10') {
|
||
|
||
html = `
|
||
<div class="form-row" id="removeChild_${Count}" style="width:84%">
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.si : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="10_si[]" id="10_si_${Count}" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='sum_insured_number_word_${Count}' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group col-md-2">
|
||
<label for="mobile">From Age<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.age_from : ''}" type="text" class="form-control" placeholder="Enter From Age" name="10_age_from[]" id="10_age_from" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-2">
|
||
<label for="mobile">To Age<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.age_to : ''}" type="text" class="form-control" placeholder="Enter To Age" name="10_age_to[]" id="10_age_to" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.premium : ''}" type="text" class="form-control" placeholder="Enter Premium" name="10_premium[]" id="10_premium_${Count}" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='premium_number_word_${Count}' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group">
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-danger" id="gmc_remove" onclick="removebutton(${Count})">x</button>
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-primary" id="gmc_add_more_${Count}" onclick="appendGridtHtml(10)">+</button>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (ui_type == '11') {
|
||
|
||
html = `
|
||
<div class="form-row" id="removeChild_${Count}" style="width:84%">
|
||
<div class="form-group col-md-2">
|
||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.si : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="11_si[]" id="11_si_${Count}" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='sum_insured_number_word_${Count}' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Grade/Band<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.grade : ''}" type="text" class="form-control" placeholder="Enter Grade/Band " name="11_grade[]" id="11_grade" required>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.premium : ''}" type="text" class="form-control" placeholder="Enter Premium" name="11_premium[]" id="11_premium_${Count}" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='premium_number_word_${Count}' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group col-md-2">
|
||
<label for="mobile">Max SI<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.max_si : ''}" type="text" class="form-control" placeholder="Enter Max SI" name="11_max_si[]" id="11_max_si[]" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='max_si_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group">
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-danger" id="gmc_remove" onclick="removebutton(${Count})">x</button>
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-primary" id="gmc_add_more_${Count}" onclick="appendGridtHtml(11)">+</button>
|
||
</div>
|
||
</div>`;
|
||
} else if (ui_type == '12') {
|
||
|
||
html = `
|
||
<div class="form-row" id="removeChild_${Count}" style="width:84%">
|
||
<div class="form-group col-md-2">
|
||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.si : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="12_si[]" id="12_si_${Count}" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='sum_insured_number_word_${Count}' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Relationship<span class="text-danger">*</span></label>
|
||
<select class="form-control" name="12_relationship[]" id="12_relationship" required>
|
||
<option value="">Select</option>
|
||
<option value="self" ${data !== false && data !== undefined && data !== '' && data.relationship === 'self' ? 'selected' : ''}>Self</option>
|
||
<option value="spouse" ${data !== false && data !== undefined && data !== '' && data.relationship === 'spouse' ? 'selected' : ''}>Spouse</option>
|
||
<option value="father" ${data !== false && data !== undefined && data !== '' && data.relationship === 'father' ? 'selected' : ''}>Father</option>
|
||
<option value="mother" ${data !== false && data !== undefined && data !== '' && data.relationship === 'mother' ? 'selected' : ''}>Mother</option>
|
||
<option value="father-in-law" ${data !== false && data !== undefined && data !== '' && data.relationship === 'father-in-law' ? 'selected' : ''}>Father in Law</option>
|
||
<option value="mother-in-law" ${data !== false && data !== undefined && data !== '' && data.relationship === 'mother-in-law' ? 'selected' : ''}>Mother in Law</option>
|
||
<option value="child" ${data !== false && data !== undefined && data !== '' && data.relationship === 'child' ? 'selected' : ''}>Child</option>
|
||
</select>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.premium : ''}" type="text" class="form-control" placeholder="Enter Premium" name="12_premium[]" id="12_premium_${Count}" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='premium_number_word_${Count}' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group">
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-danger" id="gmc_remove" onclick="removebutton(${Count})">x</button>
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-primary" id="gmc_add_more_${Count}" onclick="appendGridtHtml(12)">+</button>
|
||
</div>
|
||
</div>`;
|
||
} else if (ui_type == '13') {
|
||
|
||
html = `
|
||
<div class="form-row" id="removeChild_${Count}" style="width:84%">
|
||
<div class="form-group col-md-2">
|
||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.si : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="13_si[]" id="13_si_${Count}" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='sum_insured_number_word_${Count}' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group col-md-2">
|
||
<label for="mobile">From Age<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.age_from : ''}" type="text" class="form-control" placeholder="Enter From Age" name="13_age_from[]" id="13_age_from" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-2">
|
||
<label for="mobile">To Age<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.age_to : ''}" type="text" class="form-control" placeholder="Enter To Age" name="13_age_to[]" id="13_age_to" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-2">
|
||
<label for="mobile">Relationship<span class="text-danger">*</span></label>
|
||
<select class="form-control" name="13_relationship[]" id="13_relationship" required>
|
||
<option value="">Select</option>
|
||
<option value="self" ${data !== false && data !== undefined && data !== '' && data.relationship === 'self' ? 'selected' : ''}>Self</option>
|
||
<option value="spouse" ${data !== false && data !== undefined && data !== '' && data.relationship === 'spouse' ? 'selected' : ''}>Spouse</option>
|
||
<option value="father" ${data !== false && data !== undefined && data !== '' && data.relationship === 'father' ? 'selected' : ''}>Father</option>
|
||
<option value="mother" ${data !== false && data !== undefined && data !== '' && data.relationship === 'mother' ? 'selected' : ''}>Mother</option>
|
||
<option value="father-in-law" ${data !== false && data !== undefined && data !== '' && data.relationship === 'father-in-law' ? 'selected' : ''}>Father in Law</option>
|
||
<option value="mother-in-law" ${data !== false && data !== undefined && data !== '' && data.relationship === 'mother-in-law' ? 'selected' : ''}>Mother in Law</option>
|
||
<option value="child" ${data !== false && data !== undefined && data !== '' && data.relationship === 'child' ? 'selected' : ''}>Child</option>
|
||
</select>
|
||
</div>
|
||
<div class="form-group col-md-3">
|
||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.premium : ''}" type="text" class="form-control" placeholder="Enter Premium" name="13_premium[]" id="13_premium_${Count}" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" required>
|
||
<div id='premium_number_word_${Count}' class="text-danger-2" ></div>
|
||
</div>
|
||
<div class="form-group">
|
||
<button style="margin-top: 44px;" type="button" class="btn btn-danger" id="gmc_remove" onclick="removebutton(${Count})">x</button>
|
||
<button style="margin-top: 44px;position: absolute;margin-left: 5px;" type="button" class="btn btn-primary" id="gmc_add_more_${Count}" onclick="appendGridtHtml(13)">+</button>
|
||
</div>
|
||
</div>`;
|
||
}
|
||
|
||
|
||
// console.log('html', html)
|
||
|
||
container.insertAdjacentHTML('beforeend', html);
|
||
|
||
$('#gmc_add_more').hide();
|
||
$('#gmc_add_more2').hide();
|
||
$('#gmc_remove').show();
|
||
Count--
|
||
$('#gmc_add_more_' + Count).hide()
|
||
Count++
|
||
|
||
|
||
// Number to word
|
||
$(document).keyup(function(event) {
|
||
if (event.target) {
|
||
var result = convertCommaNumberToWords(event.target.value);
|
||
var next = event.target.nextElementSibling;
|
||
if (next && next.tagName.toLowerCase() === 'div') {
|
||
next.textContent = result; // Set the content of the div
|
||
}
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
|
||
function removebutton(index, type) {
|
||
|
||
if (index == 0) {
|
||
var inputs = document.querySelectorAll('#grid_' + type + ' input');
|
||
inputs.forEach(function(input) {
|
||
input.value = '';
|
||
});
|
||
} else {
|
||
|
||
var element = document.getElementById('removeChild_' + index);
|
||
var gridContentDiv = document.getElementById('grid_content_input');
|
||
var count = gridContentDiv.childElementCount;
|
||
if (element) {
|
||
element.remove();
|
||
}
|
||
|
||
if (count == 2) {
|
||
$('#gmc_add_more').show();
|
||
$('#gmc_add_more2').show();
|
||
}
|
||
|
||
index--;
|
||
$('#gmc_add_more_' + index).show();
|
||
$('#gmc_add_more2_' + index).show();
|
||
}
|
||
|
||
}
|
||
|
||
function checkDuplicate() {
|
||
|
||
if ($('#grid')[0].value === '3') {
|
||
|
||
var siInputs = $('input[name="3_si[]"]');
|
||
var premiumInputs = $('input[name="3_premium[]"]');
|
||
|
||
var siValues = [];
|
||
var premiumValues = [];
|
||
var siDuplicates = false;
|
||
var premiumDuplicates = false;
|
||
|
||
// Extract values from input arrays
|
||
siInputs.each(function() {
|
||
siValues.push($(this).val());
|
||
});
|
||
|
||
premiumInputs.each(function() {
|
||
premiumValues.push($(this).val());
|
||
});
|
||
|
||
for (var i = 0; i < siValues.length; i++) {
|
||
for (var j = i + 1; j < siValues.length; j++) {
|
||
if (siValues[i] === siValues[j] && premiumValues[i] === premiumValues[j]) {
|
||
siDuplicates = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (siDuplicates || premiumDuplicates) {
|
||
toastr.warning('Duplicates found!', 'warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
} else if ($('#grid')[0].value === '4') {
|
||
|
||
var ageFrom = $('input[name="4_age_from[]"]');
|
||
var ageTo = $('input[name="4_age_to[]"]');
|
||
|
||
var ageFromValues = [];
|
||
var ageToValues = [];
|
||
var ageDuplicates = false;
|
||
|
||
// Extract values from input arrays
|
||
ageFrom.each(function() {
|
||
ageFromValues.push($(this).val());
|
||
});
|
||
|
||
ageTo.each(function() {
|
||
ageToValues.push($(this).val());
|
||
});
|
||
|
||
for (var i = 0; i < ageFromValues.length; i++) {
|
||
for (var j = i + 1; j < ageFromValues.length; j++) {
|
||
// Check for duplicates between age_from[] and age_to[]
|
||
if (ageFromValues[i] === ageFromValues[j] && ageToValues[i] === ageToValues[j]) {
|
||
ageDuplicates = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (ageDuplicates) {
|
||
toastr.warning('Duplicates found!', 'warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
|
||
} else if ($('#grid')[0].value === '5') {
|
||
var si = $('input[name="5_si[]"]');
|
||
var ageFrom = $('input[name="5_age_from[]"]');
|
||
var ageTo = $('input[name="5_age_to[]"]');
|
||
|
||
var si_array = [];
|
||
var ageFrom_array = [];
|
||
var ageTo_array = [];
|
||
var siDuplicates = false;
|
||
var ageDuplicates = false;
|
||
|
||
si.each(function() {
|
||
si_array.push($(this).val());
|
||
});
|
||
|
||
ageFrom.each(function() {
|
||
ageFrom_array.push($(this).val());
|
||
});
|
||
|
||
ageTo.each(function() {
|
||
ageTo_array.push($(this).val());
|
||
});
|
||
|
||
for (var i = 0; i < ageFrom_array.length; i++) {
|
||
for (var j = i + 1; j < ageFrom_array.length; j++) {
|
||
if (ageFrom_array[i] === ageFrom_array[j] && ageTo_array[i] === ageTo_array[j] && si_array[i] ===
|
||
si_array[j]) {
|
||
ageDuplicates = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (siDuplicates || ageDuplicates) {
|
||
toastr.warning('Duplicates found!', 'warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
} else if ($('#grid')[0].value === '6') {
|
||
var ageFrom = $('input[name="6_age_from[]"]');
|
||
var ageTo = $('input[name="6_age_to[]"]');
|
||
|
||
var ageFromValues = [];
|
||
var ageToValues = [];
|
||
var ageDuplicates = false;
|
||
|
||
// Extract values from input arrays
|
||
ageFrom.each(function() {
|
||
ageFromValues.push($(this).val());
|
||
});
|
||
|
||
ageTo.each(function() {
|
||
ageToValues.push($(this).val());
|
||
});
|
||
|
||
for (var i = 0; i < ageFromValues.length; i++) {
|
||
for (var j = i + 1; j < ageFromValues.length; j++) {
|
||
// Check for duplicates between age_from[] and age_to[]
|
||
if (ageFromValues[i] === ageFromValues[j] && ageToValues[i] === ageToValues[j]) {
|
||
ageDuplicates = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (ageDuplicates) {
|
||
toastr.warning('Duplicates found!', 'warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
} else if ($('#grid')[0].value === '7') {
|
||
var si = $('input[name="7_si[]"]');
|
||
var ageFrom = $('input[name="7_age_from[]"]');
|
||
var ageTo = $('input[name="7_age_to[]"]');
|
||
|
||
var si_array = [];
|
||
var ageFrom_array = [];
|
||
var ageTo_array = [];
|
||
var siDuplicates = false;
|
||
var ageDuplicates = false;
|
||
|
||
si.each(function() {
|
||
si_array.push($(this).val());
|
||
});
|
||
|
||
ageFrom.each(function() {
|
||
ageFrom_array.push($(this).val());
|
||
});
|
||
|
||
ageTo.each(function() {
|
||
ageTo_array.push($(this).val());
|
||
});
|
||
|
||
for (var i = 0; i < ageFrom_array.length; i++) {
|
||
for (var j = i + 1; j < ageFrom_array.length; j++) {
|
||
if (ageFrom_array[i] === ageFrom_array[j] && ageTo_array[i] === ageTo_array[j] && si_array[i] ===
|
||
si_array[j]) {
|
||
ageDuplicates = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (siDuplicates || ageDuplicates) {
|
||
toastr.warning('Duplicates found!', 'warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
} else if ($('#grid')[0].value === '10') {
|
||
var si = $('input[name="10_si[]"]');
|
||
var ageFrom = $('input[name="10_age_from[]"]');
|
||
var ageTo = $('input[name="10_age_to[]"]');
|
||
|
||
var si_array = [];
|
||
var ageFrom_array = [];
|
||
var ageTo_array = [];
|
||
var siDuplicates = false;
|
||
var ageDuplicates = false;
|
||
|
||
si.each(function() {
|
||
si_array.push($(this).val());
|
||
});
|
||
|
||
ageFrom.each(function() {
|
||
ageFrom_array.push($(this).val());
|
||
});
|
||
|
||
ageTo.each(function() {
|
||
ageTo_array.push($(this).val());
|
||
});
|
||
|
||
for (var i = 0; i < ageFrom_array.length; i++) {
|
||
for (var j = i + 1; j < ageFrom_array.length; j++) {
|
||
if (ageFrom_array[i] === ageFrom_array[j] && ageTo_array[i] === ageTo_array[j] && si_array[i] ===
|
||
si_array[j]) {
|
||
ageDuplicates = true;
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
if (siDuplicates || ageDuplicates) {
|
||
toastr.warning('Duplicates found!', 'warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
} else if ($('#grid')[0].value === '8') {
|
||
var siInputs = $('input[name="8_si[]"]');
|
||
var gradeInputs = $('input[name="8_grade[]"]');
|
||
|
||
var siValues = [];
|
||
var gradeValues = [];
|
||
var duplicatesFound = false;
|
||
|
||
// Extract values from input arrays
|
||
siInputs.each(function() {
|
||
siValues.push($(this).val());
|
||
});
|
||
|
||
gradeInputs.each(function() {
|
||
gradeValues.push($(this).val());
|
||
});
|
||
|
||
for (var i = 0; i < siValues.length; i++) {
|
||
for (var j = i + 1; j < siValues.length; j++) {
|
||
// Check for duplicates between si[] and grade[]
|
||
if (siValues[i] === siValues[j] && gradeValues[i] === gradeValues[j]) {
|
||
duplicatesFound = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (duplicatesFound) {
|
||
toastr.warning('Duplicates found!', 'warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
} else if ($('#grid')[0].value === '9') {
|
||
var siInputs = $('input[name="9_si[]"]');
|
||
var gradeInputs = $('input[name="9_grade[]"]');
|
||
|
||
var siValues = [];
|
||
var gradeValues = [];
|
||
var duplicatesFound = false;
|
||
|
||
// Extract values from input arrays
|
||
siInputs.each(function() {
|
||
siValues.push($(this).val());
|
||
});
|
||
|
||
gradeInputs.each(function() {
|
||
gradeValues.push($(this).val());
|
||
});
|
||
|
||
for (var i = 0; i < siValues.length; i++) {
|
||
for (var j = i + 1; j < siValues.length; j++) {
|
||
// Check for duplicates between si[] and grade[]
|
||
if (siValues[i] === siValues[j] && gradeValues[i] === gradeValues[j]) {
|
||
duplicatesFound = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (duplicatesFound) {
|
||
toastr.warning('Duplicates found!', 'warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
} else if ($('#grid')[0].value === '11') {
|
||
var siInputs = $('input[name="11_si[]"]');
|
||
var gradeInputs = $('input[name="11_grade[]"]');
|
||
var maxSiInputs = $('input[name="11_max_si[]"]');
|
||
|
||
var siValues = [];
|
||
var gradeValues = [];
|
||
var maxSiValues = [];
|
||
var duplicatesFound = false;
|
||
|
||
// Extract values from input arrays
|
||
siInputs.each(function() {
|
||
siValues.push($(this).val());
|
||
});
|
||
|
||
gradeInputs.each(function() {
|
||
gradeValues.push($(this).val());
|
||
});
|
||
|
||
maxSiInputs.each(function() {
|
||
maxSiValues.push($(this).val());
|
||
});
|
||
|
||
for (var i = 0; i < siValues.length; i++) {
|
||
for (var j = i + 1; j < siValues.length; j++) {
|
||
// console.log(maxSiValues);
|
||
// console.log("maxSiValues[i] ", maxSiValues[i] );
|
||
// console.log("maxSiValues[j]", maxSiValues[j]);
|
||
if (siValues[i] === siValues[j] && gradeValues[i] === gradeValues[j] && maxSiValues[i] === maxSiValues[
|
||
j]) {
|
||
duplicatesFound = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (duplicatesFound) {
|
||
toastr.warning('Duplicates found!', 'warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
}else if ($('#grid')[0].value === '1') {
|
||
var selectedValue = $('#si_or_bp').val();
|
||
|
||
if(selectedValue == 1){
|
||
|
||
var siInputs = $('input[name="gpa_sum_si[]"]');
|
||
var premiumInputs = $('input[name="gpa_sum_premium[]"]');
|
||
|
||
var siValues = [];
|
||
var premiumValues = [];
|
||
var siDuplicates = false;
|
||
var premiumDuplicates = false;
|
||
|
||
// Extract values from input arrays
|
||
siInputs.each(function() {
|
||
siValues.push($(this).val());
|
||
});
|
||
|
||
premiumInputs.each(function() {
|
||
premiumValues.push($(this).val());
|
||
});
|
||
|
||
for (var i = 0; i < siValues.length; i++) {
|
||
for (var j = i + 1; j < siValues.length; j++) {
|
||
if (siValues[i] === siValues[j]) {
|
||
siDuplicates = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
console.log('siValues', siValues);
|
||
console.log('premiumValues', premiumValues);
|
||
console.log('siDuplicates', siDuplicates);
|
||
console.log('premiumDuplicates', premiumDuplicates);
|
||
|
||
if (siDuplicates || premiumDuplicates) {
|
||
toastr.warning('Duplicates found!', 'warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
|
||
}else if(selectedValue == 3){
|
||
|
||
var siInputs = $('input[name="gpa_sum_si2[]"]');
|
||
var premiumInputs = $('input[name="gpa_sum_premium2[]"]');
|
||
var bandInputs = $('input[name="gpa_band[]"]');
|
||
|
||
var siValues = [];
|
||
var premiumValues = [];
|
||
var bandValues = [];
|
||
var siDuplicates = false;
|
||
var premiumDuplicates = false;
|
||
var bandDuplicates = false;
|
||
|
||
// Extract values from input arrays
|
||
siInputs.each(function() {
|
||
siValues.push($(this).val());
|
||
});
|
||
|
||
premiumInputs.each(function() {
|
||
premiumValues.push($(this).val());
|
||
});
|
||
|
||
bandInputs.each(function() {
|
||
bandValues.push($(this).val());
|
||
});
|
||
|
||
for (var i = 0; i < siValues.length; i++) {
|
||
for (var j = i + 1; j < siValues.length; j++) {
|
||
if (siValues[i] === siValues[j]) {
|
||
siDuplicates = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
for (var i = 0; i < bandValues.length; i++) {
|
||
for (var j = i + 1; j < bandValues.length; j++) {
|
||
if (bandValues[i] === bandValues[j]) {
|
||
bandDuplicates = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
console.log('siValues', siValues);
|
||
console.log('premiumValues', premiumValues);
|
||
console.log('bandValues', bandValues);
|
||
console.log('siDuplicates', siDuplicates);
|
||
console.log('premiumDuplicates', premiumDuplicates);
|
||
console.log('bandDuplicates', bandDuplicates);
|
||
|
||
if (siDuplicates || bandDuplicates || premiumDuplicates) {
|
||
toastr.warning('Duplicates found!', 'warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
function basicPayMultiple(input) {
|
||
|
||
if (input.id == 'basic_pay') {
|
||
var multi = $('#basic_multiplier')[0].value.replace(/,/g, '') * input.value.replace(/,/g, '');
|
||
|
||
$('#gpa_basic_si').val(multi).trigger('keyup');
|
||
|
||
var multi_2 = $('#gpa_basic_si')[0].value.replace(/,/g, '') * $('#premium_multiplier')[0].value.replace(/,/g,
|
||
'');
|
||
|
||
$('#gpa_basic_premium').val(multi_2).trigger('keyup');
|
||
|
||
} else if (input.id == 'basic_multiplier') {
|
||
|
||
var multi = input.value * $('#basic_pay')[0].value.replace(/,/g, '');
|
||
$('#gpa_basic_si').val(multi).trigger('keyup');
|
||
|
||
var multi_2 = $('#gpa_basic_si')[0].value.replace(/,/g, '') * $('#premium_multiplier')[0].value.replace(/,/g,'');
|
||
$('#gpa_basic_premium').val(multi_2).trigger('keyup');
|
||
|
||
} else if (input.id == 'premium_multiplier') {
|
||
|
||
var multi = input.value.replace(/,/g, '') / 1000 * $('#gpa_basic_si')[0].value.replace(/,/g, '');
|
||
$('#gpa_basic_premium').val(multi).trigger('keyup');
|
||
|
||
|
||
} else if (input.id == 'gpa_basic_si') {
|
||
|
||
var multi = input.value.replace(/,/g, '') * $('#premium_multiplier')[0].value.replace(/,/g, '');
|
||
|
||
$('#gpa_basic_premium').val(multi).trigger('keyup');
|
||
}
|
||
}
|
||
|
||
function gpaSumInsureMultiplier(element) {
|
||
|
||
console.log(element);
|
||
|
||
var element = $('#gpa_sum_multiplier')[0];
|
||
var sumInsured = $('input[name="gpa_sum_si[]"]');
|
||
|
||
if ($('#si_or_bp').val() == 3) {
|
||
|
||
var element = $('#gpa_sum_multiplier2')[0]
|
||
var sumInsured = $('input[name="gpa_sum_si2[]"]')
|
||
}
|
||
|
||
// console.log('sumInsured', sumInsured);
|
||
|
||
if ($('#si_or_bp').val() == 2) {
|
||
var premium = $('input[name="premium[]"]');
|
||
} else if ($('#si_or_bp').val() == 3) {
|
||
var premium = $('input[name="gpa_sum_premium2[]"]');
|
||
}else {
|
||
var premium = $('input[name="gpa_sum_premium[]"]');
|
||
}
|
||
|
||
// console.log(premium);
|
||
|
||
sumInsured.each(function(index) {
|
||
|
||
var siValue = $(this).val().replace(/,/g, '');
|
||
// console.log('siValue', siValue);
|
||
|
||
var premiumValue = (siValue / 1000) * element.value;
|
||
// console.log('premiumValue', premiumValue);
|
||
|
||
var premiumValuedata = premium[index];
|
||
// console.log('premiumValuedata', premiumValuedata);
|
||
|
||
|
||
if (premiumValuedata) {
|
||
premiumValuedata.value = Math.floor(premiumValue);
|
||
}
|
||
// premium[index].value = Math.floor(premiumValue);
|
||
$(premium[index]).trigger('keyup');
|
||
// premium.eq(index).val(Math.floor(premiumValue));
|
||
|
||
});
|
||
}
|
||
|
||
|
||
function si_orbp_change_function() {
|
||
|
||
// $('.gpa_sum_insure_remove').remove();
|
||
var selectedValue = $('#si_or_bp').val();
|
||
|
||
if (selectedValue == 2) {
|
||
|
||
$('.gpa_sum_insure_remove').hide();
|
||
$('.gpa_band_remove').hide();
|
||
|
||
$('#si_or_bp_full_div').css({
|
||
'display': '',
|
||
});
|
||
$('#si_or_bp_sum_insure').css({
|
||
'display': 'none'
|
||
});
|
||
$('#si_or_bp_basic_pay').css({
|
||
'display': ''
|
||
});
|
||
$('#si_or_bp_grade').css({
|
||
'display': 'none'
|
||
});
|
||
|
||
$('#gpa_sum_multiplier').removeAttr('required', false);
|
||
$('#gpa_sum_si').removeAttr('required', false);
|
||
$('#gpa_sum_premium').removeAttr('required', false);
|
||
|
||
$('#gpa_sum_multiplier2').removeAttr('required', false);
|
||
$('#gpa_sum_si2').removeAttr('required', false);
|
||
$('#gpa_band').removeAttr('required', false);
|
||
$('#gpa_sum_premium2').removeAttr('required', false);
|
||
|
||
|
||
|
||
$('#basic_multiplier').attr('required', true);
|
||
$('#premium_multiplier').attr('required', true);
|
||
$('#basic_pay').attr('required', true);
|
||
$('#gpa_basic_si').attr('required', true);
|
||
$('#gpa_basic_premium').attr('required', true);
|
||
|
||
|
||
var gridContentInput = $('#grid_content_input');
|
||
|
||
var elementsToHide = gridContentInput.find('.gpa_sum_insure_remove');
|
||
|
||
elementsToHide.hide();
|
||
|
||
|
||
} else if (selectedValue == 1) {
|
||
|
||
$('.gpa_sum_insure_remove').show();
|
||
$('.gpa_band_remove').hide();
|
||
|
||
var count = $("div.form-row.gpa_sum_insure_remove").length;
|
||
|
||
if(count == 0){
|
||
$('#gmc_add_more').show();
|
||
}else{
|
||
$('#gmc_add_more').hide();
|
||
}
|
||
|
||
console.log('gmcBandInput', count)
|
||
|
||
|
||
var gpaBandRemoveElements = $("#grid_1").nextAll("div").find(".gpa_band_remove").length;
|
||
console.log("Elements with class 'gpa_band_remove' within next div siblings:", gpaBandRemoveElements);
|
||
|
||
var gmcBandInput = $("#grid_1").find('input[name="gmc_band[]"]').length
|
||
console.log('gmcBandInput', gmcBandInput)
|
||
|
||
|
||
$('#si_or_bp_full_div').css({
|
||
'display': '',
|
||
});
|
||
$('#si_or_bp_sum_insure').css({
|
||
'display': ''
|
||
});
|
||
$('#si_or_bp_basic_pay').css({
|
||
'display': 'none'
|
||
});
|
||
$('#si_or_bp_grade').css({
|
||
'display': 'none'
|
||
});
|
||
|
||
|
||
$('#basic_multiplier').removeAttr('required', false);
|
||
$('#premium_multiplier').removeAttr('required', false);
|
||
$('#basic_pay').removeAttr('required', false);
|
||
$('#gpa_basic_si').removeAttr('required', false);
|
||
$('#gpa_basic_premium').removeAttr('required', false);
|
||
|
||
$('#gpa_sum_multiplier2').removeAttr('required', false);
|
||
$('#gpa_sum_si2').removeAttr('required', false);
|
||
$('#gpa_band').removeAttr('required', false);
|
||
$('#gpa_sum_premium2').removeAttr('required', false);
|
||
|
||
|
||
$('#gpa_sum_multiplier').attr('required', true);
|
||
$('#gpa_sum_si').attr('required', true);
|
||
$('#gpa_sum_premium').attr('required', true);
|
||
|
||
var gridContentInput = $('#grid_content_input');
|
||
|
||
var elementsToUnhide = gridContentInput.find('.gpa_sum_insure_remove');
|
||
|
||
elementsToUnhide.show();
|
||
|
||
} else if (selectedValue == 3) {
|
||
|
||
$('.gpa_sum_insure_remove').hide();
|
||
$('.gpa_band_remove').show();
|
||
|
||
var count = $("div.form-row.gpa_band_remove").length;
|
||
|
||
if(count == 0){
|
||
$('#gmc_add_more2').show();
|
||
}else{
|
||
$('#gmc_add_more2').hide();
|
||
}
|
||
|
||
console.log('gmcBandInput', count)
|
||
|
||
$('#si_or_bp_full_div').css({
|
||
'display': '',
|
||
});
|
||
$('#si_or_bp_grade').css({
|
||
'display': ''
|
||
});
|
||
$('#si_or_bp_basic_pay').css({
|
||
'display': 'none'
|
||
});
|
||
$('#si_or_bp_sum_insure').css({
|
||
'display': 'none'
|
||
});
|
||
|
||
|
||
$('#basic_multiplier').removeAttr('required', false);
|
||
$('#premium_multiplier').removeAttr('required', false);
|
||
$('#basic_pay').removeAttr('required', false);
|
||
$('#gpa_basic_si').removeAttr('required', false);
|
||
$('#gpa_basic_premium').removeAttr('required', false);
|
||
|
||
$('#gpa_sum_multiplier').attr('required', false);
|
||
$('#gpa_sum_si').attr('required');
|
||
$('#gpa_sum_premium').attr('required');
|
||
|
||
$('#gpa_sum_multiplier2').removeAttr('required', true);
|
||
$('#gpa_sum_si2').removeAttr('required', true);
|
||
$('#gpa_band').removeAttr('required', true);
|
||
$('#gpa_sum_premium2').removeAttr('required', true);
|
||
|
||
var gridContentInput = $('#grid_content_input');
|
||
|
||
var elementsToUnhide = gridContentInput.find('.gpa_sum_insure_remove');
|
||
|
||
// elementsToUnhide.show();
|
||
|
||
} else {
|
||
$('#si_or_bp_full_div').css({
|
||
'display': 'none',
|
||
});
|
||
$('#si_or_bp_sum_insure').css({
|
||
'display': ''
|
||
});
|
||
$('#si_or_bp_basic_pay').css({
|
||
'display': ''
|
||
});
|
||
$('#si_or_bp_grade').css({
|
||
'display': ''
|
||
});
|
||
}
|
||
|
||
|
||
}
|
||
|
||
function getCurrentTime() {
|
||
var now = new Date();
|
||
var hours = now.getHours();
|
||
var minutes = now.getMinutes();
|
||
var ampm = hours >= 12 ? 'PM' : 'AM';
|
||
hours = hours % 12;
|
||
hours = hours ? hours : 12; // 0 should be considered as 12
|
||
minutes = minutes < 10 ? '0' + minutes : minutes; // Add leading zero if minutes < 10
|
||
var timeString = hours + ':' + minutes + ' ' + ampm;
|
||
return timeString;
|
||
}
|
||
|
||
|
||
|
||
</script> |