3115 lines
146 KiB
PHP
3115 lines
146 KiB
PHP
<?php include('policy_grid_excel.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" style="padding-right: 15px">
|
||
<div class="modal-dialog modal-full-width">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="myLargeModalLabel">Rack Rate <span id="PolicyNameForTitle"></span></h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body">
|
||
|
||
<input type="hidden" id="policy_terms_count">
|
||
|
||
<div class="text-center" id="no_data"></div>
|
||
|
||
<ul class="nav nav-pills navtab-bg">
|
||
<li class="nav-item">
|
||
<a href="#primary_rack_rate_tab" data-toggle="tab" aria-expanded="false"
|
||
class="nav-link px-3 py-2 active" id="rack_rate_one">
|
||
<span class="mr-1"><i class="mdi mdi-contacts"></i></span>
|
||
<span class="d-none d-sm-inline-block">Rack Rate</span>
|
||
</a>
|
||
</li>
|
||
<li class="nav-item">
|
||
<a href="#secondary_rack_rate_tab" data-toggle="tab" aria-expanded="true"
|
||
class="nav-link px-3 py-2" id="rack_rate_two">
|
||
<span class="mr-1"><i class="fa fa-file"></i></span>
|
||
<span class="d-none d-sm-inline-block">Additional Rack Rate</span>
|
||
</a>
|
||
</li>
|
||
</ul>
|
||
|
||
<div class="tab-content">
|
||
|
||
<div class="tab-pane fade active show" id="primary_rack_rate_tab">
|
||
|
||
<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" name="rack_rate_type" id="rack_rate_type" value="0" />
|
||
<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;"> Family Floater </label>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<a href="#" id='copyfromexcel'>Copy from excel</a>
|
||
<hr>
|
||
|
||
<div class="form-row" id="grid_content_input" style="display: true;">
|
||
</div>
|
||
|
||
|
||
<div class="form-row" id="grid_content_from_excel" style="display: none;">
|
||
|
||
<p>Paste excel data here: <a href="#" type="button" onclick="copyHeaders(0)">Copy Excel Headers</a></p>
|
||
<textarea class="form-control excel_textarea" id="copied_excel_data" name="copied_excel_data" style="width:100%;height:200px;" oninput="generateTable(0)"></textarea><br>
|
||
<hr>
|
||
<div class="excel_table_class" id="excel_table" style="display: none;"></div>
|
||
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
|
||
id="btnGridSubmit_2">Submit</button>
|
||
</div>
|
||
</form>
|
||
|
||
</div>
|
||
|
||
<div class="tab-pane fade" id="secondary_rack_rate_tab">
|
||
|
||
<form role="form" class="parsley-examples" method="post" id="AdditionalGridForm"
|
||
enctype="multipart/form-data">
|
||
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
|
||
<input type="hidden" name="client_id" id="Client_id_2"
|
||
value="<?= isset($client['id']) ? $client['id'] : '' ?>" />
|
||
<input type="hidden" name="client_policy_id" id="client_policy_id_2" />
|
||
<input type="hidden" name="rack_rate_type" id="rack_rate_type_2" value="1" />
|
||
<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 data-secondary="1" class="form-control" id="additional_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="additional_rack_rate_premium_type">
|
||
<label for="css"> Premium Calculation </label>
|
||
<div style="display: flex; align-items: center;">
|
||
<input type="radio" id="individual_2" name="premium_type" value="2">
|
||
<label for="individual" style="position: relative;top: 5px;left: 5px;">
|
||
Individual </label>
|
||
<input type="radio" id="single_2" name="premium_type" value="1">
|
||
<label for="single" style="position: relative;top: 5px;left: 5px;"> Family Floater </label>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-row" id="relationship">
|
||
</div>
|
||
|
||
<div class="form-row">
|
||
|
||
<div class="col-2">
|
||
<a href="#" id='copyfromexcelforadditional'>Copy from excel</a>
|
||
</div>
|
||
|
||
<div class="col-2" id="del_btn_col" style="display: none;">
|
||
<a class="btn btn-bordered-danger waves-effect waves-light fa fa-trash" id="del_btn"> Delete</a>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<hr>
|
||
|
||
<div class="form-row" id="additional_grid_content_input" style="display: true;">
|
||
</div>
|
||
|
||
<div class="form-row" id="additional_grid_content_from_excel" style="display: none;">
|
||
|
||
<p>Paste excel data here: <a href="#" type="button" onclick="copyHeaders(1)">Copy Excel Headers</a></p>
|
||
<textarea class="form-control excel_textarea" id="additional_copied_excel_data" name="additional_copied_excel_data" style="width:100%;height:200px;" oninput="generateTable(1)"></textarea><br>
|
||
<hr>
|
||
<div class="excel_table_class" id="additional_excel_table" style="display: none;"></div>
|
||
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<div class="form-group text-right m-b-0" id="secondary_rack_rate_btn_grp">
|
||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
|
||
id="additional_rack_rate_submit_btn">Submit</button>
|
||
</div>
|
||
</form>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
</div><!-- /.modal-content -->
|
||
</div><!-- /.modal-dialog -->
|
||
</div><!-- /.modal -->
|
||
|
||
|
||
<script>
|
||
var policy_grid_id = $('#client_id').val();
|
||
var grid_html = '';
|
||
|
||
$('#btnGridSubmit').hide();
|
||
|
||
$('.close').click(function() {
|
||
|
||
$('#grid_content_input').show();
|
||
$('#grid_content_from_excel').hide();
|
||
|
||
if ($('#copyfromexcel').text() == "Manual entry") {
|
||
$('#copyfromexcel').text("Copy from excel")
|
||
} else {
|
||
$('#copyfromexcel').text("Copy from excel");
|
||
}
|
||
|
||
|
||
$('#additional_grid_content_input').show();
|
||
$('#additional_grid_content_from_excel').hide();
|
||
|
||
if ($('#copyfromexcelforadditional').text() == "Manual entry") {
|
||
$('#copyfromexcelforadditional').text("Copy from excel")
|
||
} else {
|
||
$('#copyfromexcelforadditional').text("Copy from excel");
|
||
}
|
||
|
||
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#grid_' + i).remove();
|
||
$('#add_grid_' + i).remove();
|
||
$('#removeChild_' + i).remove();
|
||
}
|
||
});
|
||
|
||
$('#copyfromexcel').click(function() {
|
||
|
||
// alert('called');
|
||
// $('#copyfromexcel').toggle();
|
||
// $("#copied_excel_data").val(result.exampleMessage);
|
||
$('#copied_excel_data').val("");
|
||
if ($(this).text() == "Copy from excel") {
|
||
$(this).text("Manual entry")
|
||
|
||
} else {
|
||
$(this).text("Copy from excel");
|
||
}
|
||
|
||
$('#grid_content_input').toggle();
|
||
$('#grid_content_from_excel').toggle();
|
||
|
||
|
||
|
||
});
|
||
|
||
$('#copyfromexcelforadditional').click(function() {
|
||
|
||
if ($(this).text() == "Copy from excel") {
|
||
$(this).text("Manual entry")
|
||
|
||
} else {
|
||
$(this).text("Copy from excel");
|
||
}
|
||
|
||
$('#additional_grid_content_input').toggle();
|
||
$('#additional_grid_content_from_excel').toggle();
|
||
|
||
|
||
|
||
});
|
||
|
||
function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = false, rr_type = false) {
|
||
|
||
|
||
var secondaryValue = $(event.target).data('secondary');
|
||
//console.log('secondaryValue', secondaryValue)
|
||
//console.log(rr_type);
|
||
|
||
if (!secondaryValue) {
|
||
secondaryValue = rr_type
|
||
}
|
||
|
||
//console.log('secondaryValue', secondaryValue)
|
||
|
||
|
||
var grid_container = document.getElementById('grid_content_input');
|
||
var additional_grid_container = document.getElementById('additional_grid_content_input');
|
||
|
||
var id_var = 'grid_'
|
||
if (secondaryValue == 1 || rr_type == 1) {
|
||
grid_container = additional_grid_container;
|
||
$('#additional_grid_content_input').empty();
|
||
var id_var = 'add_grid_'
|
||
|
||
} else {
|
||
$('#grid_content_input').empty();
|
||
}
|
||
|
||
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)
|
||
}
|
||
|
||
//console.log(grid_container)
|
||
|
||
if (dataIdValue == '1') {
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#' + id_var + i).remove();
|
||
}
|
||
|
||
grid_html = `
|
||
<div class="form-row" id="${id_var}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" onchange="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)" onchange="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)" onchange="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', ${secondaryValue})">+</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" onchange="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)" onchange="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)" onchange="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', ${secondaryValue})">+</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 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 basic_multiplier" placeholder="Basic Multiplier" name="basic_multiplier" id="basic_multiplier" onchange='basicMultiplierAndPremiumMultipiler(this)' required>
|
||
</div>
|
||
|
||
<div class="form-col col-md-6">
|
||
<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 premium_multiplier" placeholder="Premium Multiplier" name="premium_multiplier" id="premium_multiplier" onchange='basicMultiplierAndPremiumMultipiler(this)' required>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<div class="form-row" style="padding: 10px;">
|
||
|
||
<div class="form-col col-md-3">
|
||
<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 basic_pay" placeholder="Enter Basic Pay" name="basic_pay[]" id="basic_pay" onkeypress = "return onlyNumbers(event)" onchange="formatNumber(this); basicPayMultiple(this)" required>
|
||
<div id='gpa_basic_pay_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
|
||
<div class="form-group col-md-3" 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 gpa_basic_si" placeholder="Enter Sum Insured" name="gpa_basic_si[]" id="gpa_basic_si_first" onkeypress = "return onlyNumbers(event)" onchange="formatNumber(this)" required readonly>
|
||
<div id='basic_gpa_si_number_word' class="text-danger-2" ></div>
|
||
</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.si_or_bp == '2' ? data.premium : '') : ''}" type="text" class="form-control basic_gpa_premium gpa_basic_premium" placeholder="Enter Premium" name="gpa_basic_premium[]" id="gpa_basic_premium_first" onkeypress="return onlyNumbers(event)" onchange="formatNumber(this)" required readonly>
|
||
<div id='basic_gpa_premium_number_word' class="text-danger-2" ></div>
|
||
</div>
|
||
|
||
<div class="form-group col-md-3" 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_more3" onclick="appendGridtHtml('1', ${secondaryValue})">+</button>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (dataIdValue == '2') {
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#' + id_var + i).remove();
|
||
}
|
||
|
||
grid_html = `
|
||
<div class="form-row" id="${id_var}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)" onchange="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)" onchange="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++) {
|
||
$('#' + id_var + i).remove();
|
||
}
|
||
|
||
grid_html = `
|
||
<div class="form-row" id="${id_var}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)" onchange="formatNumber(this)" oninput="" 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)" onchange="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, ${secondaryValue})">+</button>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (dataIdValue == '4') {
|
||
|
||
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#' + id_var + i).remove();
|
||
}
|
||
grid_html = `
|
||
<div class="form-row" id="${id_var}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)" onchange="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)" onchange="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, ${secondaryValue})">+</button>
|
||
</div>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (dataIdValue == '5') {
|
||
|
||
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#' + id_var + i).remove();
|
||
}
|
||
|
||
grid_html = `
|
||
<div class="form-row" id="${id_var}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)" onchange="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)" onchange="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, ${secondaryValue})">+</button>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (dataIdValue == '6') {
|
||
|
||
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#' + id_var + i).remove();
|
||
}
|
||
|
||
grid_html = `
|
||
<div class="form-row" id="${id_var}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)" onchange="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)" onchange="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, ${secondaryValue})">+</button>
|
||
</div>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (dataIdValue == '7') {
|
||
|
||
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#' + id_var + i).remove();
|
||
}
|
||
|
||
grid_html = `
|
||
<div class="form-row" id="${id_var}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)" onchange="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)" onchange="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, ${secondaryValue})">+</button>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (dataIdValue == '8') {
|
||
|
||
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#' + id_var + i).remove();
|
||
}
|
||
|
||
|
||
grid_html = `
|
||
|
||
<div class="form-row" id="${id_var}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)" onchange="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)" onchange="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, ${secondaryValue})">+</button>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (dataIdValue == '9') {
|
||
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#' + id_var + i).remove();
|
||
}
|
||
|
||
grid_html = `
|
||
<div class="form-row" id="${id_var}9" 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)" onchange="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)" onchange="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++) {
|
||
$('#' + id_var + i).remove();
|
||
}
|
||
|
||
grid_html = `
|
||
<div class="form-row" id="${id_var}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)" onchange="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)" onchange="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, ${secondaryValue})">+</button>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (dataIdValue == '11') {
|
||
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#' + id_var + i).remove();
|
||
}
|
||
|
||
grid_html = `
|
||
|
||
<div class="form-row" id="${id_var}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)" onchange="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)" onchange="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)" onchange="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, ${secondaryValue})">+</button>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (dataIdValue == '12') {
|
||
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#' + id_var + i).remove();
|
||
}
|
||
|
||
grid_html = `
|
||
|
||
<div class="form-row" id="${id_var}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)" onchange="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)" onchange="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, ${secondaryValue})">+</button>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else if (dataIdValue == '13') {
|
||
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#' + id_var + i).remove();
|
||
}
|
||
|
||
grid_html = `
|
||
|
||
<div class="form-row" id="${id_var}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)" onchange="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)" onchange="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, ${secondaryValue})">+</button>
|
||
</div>
|
||
</div>`;
|
||
|
||
} else {
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#' + id_var + 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');
|
||
$('#gpa_basic_si_first').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) {
|
||
|
||
event.preventDefault();
|
||
|
||
var check = checkDuplicate(0);
|
||
console.log(check)
|
||
if(check){
|
||
return;
|
||
}
|
||
|
||
|
||
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") ?>';
|
||
|
||
|
||
checkPolicyTermsSI(function(result) {
|
||
|
||
console.log('checkPolicyTermsSI callback')
|
||
console.log(result);
|
||
|
||
if (!result) {
|
||
|
||
console.log('after result');
|
||
|
||
|
||
if (check = false) {
|
||
$('.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;
|
||
}
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
var message = (policy_PrimaryKey === '') ? 'Policy Premium Added successfully' :'Policy Premium Added Successfully';
|
||
toastr.success(message, 'Success');
|
||
|
||
if($('#grid').val() == 1 || $('#grid').val() == 2){
|
||
$('.close').click();
|
||
}
|
||
|
||
},
|
||
error: function(xhr, status, error) {
|
||
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}
|
||
});
|
||
}
|
||
|
||
}else{
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
toastr.warning(`Sum Insured Amount does not exist in the Policy Terms.`);
|
||
}
|
||
|
||
}).catch(function(error) {
|
||
console.error('Error checking policy terms:', error);
|
||
// Handle error if necessary
|
||
console.log(`Error checking policy terms: ${error}`);
|
||
});
|
||
|
||
});
|
||
|
||
|
||
$("#AdditionalGridForm").submit(function(event) {
|
||
|
||
var check = checkDuplicate(1);
|
||
event.preventDefault();
|
||
|
||
if ($('#grid_emp_count').val() == 'false') {
|
||
toastr.warning('Client has active employees', 'Warning');
|
||
return;
|
||
}
|
||
|
||
if (!checkCheckboxes()) {
|
||
event.preventDefault();
|
||
return;
|
||
}
|
||
|
||
var isValid = $('#AdditionalGridForm').parsley().validate();
|
||
if (!isValid) {
|
||
//console.log('Form is Empty', 'Warning');
|
||
return;
|
||
}
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
var formData = new FormData($('#AdditionalGridForm')[0]);
|
||
var policy_form_action = '<?= base_url("client/premimum/create") ?>';
|
||
|
||
checkPolicyTermsSI(function(result) {
|
||
|
||
if (!result) {
|
||
|
||
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;
|
||
}
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
var message = (policy_PrimaryKey === '') ?
|
||
'Policy Additional Rack Rate Added successfully' :
|
||
'Policy Additional Rack Rate Added Successfully';
|
||
toastr.success(message, 'Success');
|
||
$('.close').click();
|
||
|
||
},
|
||
error: function(xhr, status, error) {
|
||
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}
|
||
});
|
||
}
|
||
|
||
}else{
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
toastr.warning(`Sum Insured Amount does not exist in the Policy Terms.`);
|
||
}
|
||
|
||
}).catch(function(error) {
|
||
console.error('Error checking policy terms:', error);
|
||
// Handle error if necessary
|
||
console.log(`Error checking policy terms: ${error}`);
|
||
});
|
||
|
||
});
|
||
|
||
|
||
$('body').on('click', '.btnPolicyModel', function() {
|
||
|
||
// $('#grid').empty();
|
||
var client_policy_id = $(this).data('id');
|
||
var policy_type_id = $(this).data('typeid');
|
||
|
||
$('#client_policy_id').val(client_policy_id);
|
||
$('#client_policy_id_2').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') {
|
||
if (policy_type_id) {
|
||
|
||
|
||
$('#GridForm').show();
|
||
$('#no_data').html('');
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
|
||
if (policy_type_string == 'GPA' || policy_type_id == 6 || policy_type_id == 7) {
|
||
$('#rack_rate_one').hide()
|
||
$('#rack_rate_two').hide()
|
||
$('#AdditionalGridForm').hide()
|
||
$('#additional_rack_rate_premium_type').hide()
|
||
|
||
} else {
|
||
$('#rack_rate_one').show()
|
||
$('#rack_rate_two').show()
|
||
$('#AdditionalGridForm').show()
|
||
$('#additional_rack_rate_premium_type').show()
|
||
}
|
||
|
||
|
||
$.ajax({
|
||
url: '<?= base_url("util/policy-premium") ?>',
|
||
type: "GET",
|
||
data: {
|
||
client_policy_id: client_policy_id
|
||
},
|
||
dataType: 'json',
|
||
success: function(res) {
|
||
|
||
if(policy_type_string == 'GMC'){
|
||
|
||
if (res.self == "") {
|
||
$('.close').click();
|
||
toastr.warning('Unable to create rack rate due to the absence of policy terms.',
|
||
'Warning');
|
||
}
|
||
|
||
}
|
||
|
||
$('#GridForm')[0].reset();
|
||
$('#AdditionalGridForm')[0].reset();
|
||
|
||
if (policy_type_string == 'GMC') {
|
||
$('#premium_type').show();
|
||
$('#individual').prop('checked', true)
|
||
} else {
|
||
$('#premium_type').hide();
|
||
$('#individual').prop('checked', true)
|
||
}
|
||
|
||
|
||
setTimeout(function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}, 500);
|
||
|
||
|
||
//console.log('policy grid responce', res);
|
||
var temp_for_premiumData = JSON.parse(res.premiumData);
|
||
res.premiumData = JSON.parse(res.premiumData);
|
||
|
||
console.log('policy grid responce', res.premiumData);
|
||
//console.log('policy name', res.policy_name);
|
||
|
||
|
||
$('#PolicyNameForTitle').text(' - ' + res.policy_name);
|
||
$('#grid_emp_count').val(res.count);
|
||
|
||
|
||
if (res.count > 0) {
|
||
$("#hide_smbt_btn").hide();
|
||
$("#secondary_rack_rate_btn_grp").hide();
|
||
} else {
|
||
$("#hide_smbt_btn").show();
|
||
$("#secondary_rack_rate_btn_grp").show();
|
||
}
|
||
|
||
|
||
if (res.status === false) {
|
||
toastr.error(res.status);
|
||
return;
|
||
}
|
||
|
||
var policy_grid_id_value = null;
|
||
var secondary_policy_grid_id_value = null;
|
||
var secondary = 0;
|
||
var additional_relationship = null;
|
||
var premium_type_for_sec_rr = []
|
||
var premium_type_for_primary_rr = []
|
||
var first = 0;
|
||
|
||
if (res.premiumData && res.premiumData.length > 0) {
|
||
$.each(res.premiumData, function(index, item) {
|
||
|
||
if (item.rack_rate_type == 0 || policy_type_string == 'GPA' || policy_type_id == 6 || policy_type_id == 7) {
|
||
policy_grid_id_value = item.policy_grid_id;
|
||
first = item.policy_grid_id;
|
||
premium_type_for_primary_rr.push(item.premium_type);
|
||
|
||
} else if (item.rack_rate_type == 1) {
|
||
|
||
secondary_policy_grid_id_value = item.policy_grid_id;
|
||
secondary = item.policy_grid_id;
|
||
additional_relationship = item.additional_relationship;
|
||
premium_type_for_sec_rr.push(item.premium_type);
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
//console.log('premium_type_for_sec_rr', premium_type_for_sec_rr)
|
||
|
||
if(premium_type_for_sec_rr.length > 0){
|
||
$('#del_btn_col').show();
|
||
}else{
|
||
$('#del_btn_col').hide();
|
||
}
|
||
|
||
|
||
if (premium_type_for_sec_rr.length > 0) {
|
||
|
||
if (premium_type_for_sec_rr[0] == '2') {
|
||
|
||
$('#individual_2').prop('checked', true)
|
||
$('#single_2').prop('checked', false)
|
||
|
||
} else if (premium_type_for_sec_rr[0] == '1') {
|
||
|
||
$('#single_2').prop('checked', true)
|
||
$('#individual_2').prop('checked', false)
|
||
|
||
} else {
|
||
|
||
$('#single_2').prop('checked', false)
|
||
$('#individual_2').prop('checked', true)
|
||
}
|
||
}else{
|
||
|
||
$('#single_2').prop('checked', false)
|
||
$('#individual_2').prop('checked', true)
|
||
|
||
}
|
||
|
||
createCheckboxes(res.self, additional_relationship);
|
||
|
||
//console.log('policy_grid_id_value', policy_grid_id_value);
|
||
//console.log('secondary_policy_grid_id_value', secondary_policy_grid_id_value);
|
||
|
||
$('#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>';
|
||
});
|
||
|
||
|
||
$('#additional_grid_content_input').empty();
|
||
var policeGridOptionHTMLforSecondary = '';
|
||
policeGridOptionHTMLforSecondary +=
|
||
` <option value="">Select Premium Type</option>`;
|
||
$.each(res.data, function(index, item) {
|
||
policeGridOptionHTMLforSecondary += '<option data-id="' + item.ui_type +
|
||
'" value="' + item.id + '" ' + (secondary_policy_grid_id_value ===
|
||
item.id ?
|
||
'selected="selected"' : '') + '>' + item.policy_grid_type +
|
||
'</option>';
|
||
});
|
||
|
||
|
||
$('#grid').html(policeGridOptionHTML);
|
||
$('#additional_grid').html(policeGridOptionHTMLforSecondary);
|
||
|
||
|
||
if (premium_type_for_primary_rr.length > 0) {
|
||
if (premium_type_for_primary_rr[0] === '2') {
|
||
$('#individual').prop('checked', true);
|
||
$('#single').prop('checked', false);
|
||
} else if (premium_type_for_primary_rr[0] === '1') {
|
||
$('#single').prop('checked', true);
|
||
$('#individual').prop('checked', false);
|
||
} else {
|
||
$('#single').prop('checked', false);
|
||
$('#individual').prop('checked', true);
|
||
}
|
||
}else{
|
||
$('#single').prop('checked', false);
|
||
$('#individual').prop('checked', true);
|
||
}
|
||
|
||
|
||
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[0].rack_rate_type);
|
||
|
||
res.premiumData.shift();
|
||
$.each(res.premiumData, function(index, item) {
|
||
|
||
if (item.si_or_bp == '1') {
|
||
console.log('gpa basic pay items', item)
|
||
appendGridtHtml('1', item.rack_rate_type, item);
|
||
} else {
|
||
appendGridtHtml(item.policy_grid_id, item.rack_rate_type, 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');
|
||
});
|
||
|
||
$('input[name="gpa_basic_si[]"]').each(function() {
|
||
$(this).trigger('keyup');
|
||
});
|
||
|
||
$('input[name="gpa_basic_premium[]"]').each(function() {
|
||
$(this).trigger('keyup');
|
||
});
|
||
|
||
$('input[name="basic_pay[]"]').each(function() {
|
||
$(this).trigger('keyup');
|
||
});
|
||
|
||
var id_for_trigger = [];
|
||
if (temp_for_premiumData.length > 0 && temp_for_premiumData[0] !== undefined) {
|
||
id_for_trigger = temp_for_premiumData[0].policy_grid_id;
|
||
}
|
||
|
||
|
||
// //console.log('id_for_trigger', id_for_trigger)
|
||
// //console.log('temp_for_premiumData', temp_for_premiumData)
|
||
// //console.log('temp_for_premiumData', temp_for_premiumData[0])
|
||
|
||
|
||
$(`input[name="${first}_si[]"]`).each(function() {
|
||
// //console.log($(this));
|
||
$(this).trigger('keyup');
|
||
});
|
||
|
||
$(`input[name="${first}_premium[]"]`).each(function() {
|
||
// //console.log($(this));
|
||
$(this).trigger('keyup');
|
||
});
|
||
|
||
$(`input[name="${secondary}_si[]"]`).each(function() {
|
||
// //console.log($(this));
|
||
$(this).trigger('keyup');
|
||
});
|
||
|
||
$(`input[name="${secondary}_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();
|
||
$('#PolicyNameForTitle').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() {
|
||
|
||
$('.excel_textarea').val('');
|
||
|
||
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.count > 0) {
|
||
// //console.log(' hide submit btn count ', res.count);
|
||
$("#hide_smbt_btn").hide();
|
||
} else {
|
||
$("#hide_smbt_btn").show();
|
||
// //console.log('show submit btn count ', res.count);
|
||
}
|
||
|
||
if (res.premiumData.length > 0 && res.premiumData[0].policy_grid_id === grid_id) {
|
||
|
||
$('#PolicyNameForTitle').html(' - ' + res.policy_name);
|
||
$('#grid_emp_count').val(res.count);
|
||
|
||
if (res.count > 0) {
|
||
// //console.log(' hide submit btn count ', res.count);
|
||
$("#hide_smbt_btn").hide();
|
||
} else {
|
||
$("#hide_smbt_btn").show();
|
||
// //console.log('show submit btn 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);
|
||
}
|
||
});
|
||
})
|
||
|
||
|
||
$('#additional_grid').change(function() {
|
||
|
||
$('.excel_textarea').val('');
|
||
|
||
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.count > 0) {
|
||
// //console.log(' hide submit btn count ', res.count);
|
||
$("#secondary_rack_rate_btn_grp").hide();
|
||
} else {
|
||
$("#secondary_rack_rate_btn_grp").show();
|
||
// //console.log('show submit btn count ', res.count);
|
||
}
|
||
|
||
if (res.premiumData.length > 0 && res.premiumData[0].policy_grid_id === grid_id) {
|
||
|
||
$('#PolicyNameForTitle').html(' - ' + res.policy_name);
|
||
$('#grid_emp_count').val(res.count);
|
||
|
||
if (res.count > 0) {
|
||
// //console.log(' hide submit btn count ', res.count);
|
||
$("#secondary_rack_rate_btn_grp").hide();
|
||
} else {
|
||
$("#secondary_rack_rate_btn_grp").show();
|
||
// //console.log('show submit btn 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;
|
||
}
|
||
|
||
$('#additional_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, 1);
|
||
|
||
res.premiumData.shift();
|
||
$.each(res.premiumData, function(index, item) {
|
||
appendGridtHtml(item.policy_grid_id, item, 1);
|
||
});
|
||
|
||
} 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, secondary = 0, 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 (secondary == 1) {
|
||
container = document.getElementById('additional_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)" onchange="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)" onchange="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', ${secondary})">+</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)" onchange="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)" onchange="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', ${secondary})">+</button>
|
||
</div>
|
||
</div>`;
|
||
|
||
}else if ($("#si_or_bp").val() == 2 || data.si_or_bp == '2') {
|
||
|
||
// console.log('step 3')
|
||
|
||
html = `
|
||
<div class="form-row gpa_basic_pay_remove" style="width:101%" id="removeChild_${Count}">
|
||
<div class="form-col col-md-3">
|
||
<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 basic_pay" placeholder="Enter Basic Pay" name="basic_pay[]" id="basic_pay_${Count}" onkeypress="return onlyNumbers(event)" onchange="formatNumber(this); basicPayMultiple(this)" required>
|
||
<div id='gpa_basic_pay_number_word' class="text-danger-2"></div>
|
||
</div>
|
||
<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_or_bp == '2' ? data.si : '') : ''}" type="text" class="form-control gpa_basic_si" placeholder="Enter Sum Insured" name="gpa_basic_si[]" id="gpa_basic_si_${Count}" onkeypress="return onlyNumbers(event)" onchange="formatNumber(this)" required readonly>
|
||
<div id='basic_gpa_si_number_word' class="text-danger-2"></div>
|
||
</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.si_or_bp == '2' ? data.premium : '') : ''}" type="text" class="form-control basic_gpa_premium gpa_basic_premium" placeholder="Enter Premium" name="gpa_basic_premium[]" id="gpa_basic_premium_${Count}" onkeypress="return onlyNumbers(event)" onchange="formatNumber(this)" required readonly>
|
||
<div id='basic_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', ${secondary})">+</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)" onchange="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)" onchange="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, ${secondary})">+</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)" onchange="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, ${secondary})">+</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)" onchange="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)" onchange="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, ${secondary})">+</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)" onchange="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, ${secondary})">+</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)" onchange="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)" onchange="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, ${secondary})">+</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)" onchange="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)" onchange="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, ${secondary})">+</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-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="9_si[]" id="9_si_${Count}" onkeypress = "return onlyNumbers(event)" onchange="formatNumber(this)" required>
|
||
<div id='sum_insured_number_word_${Count}' 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="9_premium[]" id="9_premium_${Count}" onkeypress = "return onlyNumbers(event)" onchange="formatNumber(this)" required>
|
||
<div id='premium_number_word_${Count}' class="text-danger-2" ></div>
|
||
</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)" onchange="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)" onchange="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, ${secondary})">+</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)" onchange="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)" onchange="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)" onchange="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, ${secondary})">+</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)" onchange="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)" onchange="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, ${secondary})">+</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)" onchange="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)" onchange="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, ${secondary})">+</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(val) {
|
||
|
||
$('#additional_grid_content_input');
|
||
$('#grid_content_input')
|
||
|
||
var id = $('#additional_grid')[0];
|
||
var container = $('#additional_grid_content_input');
|
||
if (val == 0) {
|
||
id = $('#grid')[0];
|
||
container = $('#grid_content_input');
|
||
}
|
||
|
||
//console.log(id);
|
||
//console.log(container);
|
||
|
||
if (id.value === '3') {
|
||
|
||
var siInputs = container.find('input[name="3_si[]"]');
|
||
var premiumInputs = container.find('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 (id.value === '4') {
|
||
|
||
var ageFrom = container.find('input[name="4_age_from[]"]');
|
||
var ageTo = container.find('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 (id.value === '5') {
|
||
var si = container.find('input[name="5_si[]"]');
|
||
var ageFrom = container.find('input[name="5_age_from[]"]');
|
||
var ageTo = container.find('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 (id.value === '6') {
|
||
var ageFrom = container.find('input[name="6_age_from[]"]');
|
||
var ageTo = container.find('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 (id.value === '7') {
|
||
var si = container.find('input[name="7_si[]"]');
|
||
var ageFrom = container.find('input[name="7_age_from[]"]');
|
||
var ageTo = container.find('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 (id.value === '10') {
|
||
var si = container.find('input[name="10_si[]"]');
|
||
var ageFrom = container.find('input[name="10_age_from[]"]');
|
||
var ageTo = container.find('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 (id.value === '8') {
|
||
var siInputs = container.find('input[name="8_si[]"]');
|
||
var gradeInputs = container.find('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 (id.value === '9') {
|
||
var siInputs = container.find('input[name="9_si[]"]');
|
||
var gradeInputs = container.find('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 (id.value === '11') {
|
||
var siInputs = container.find('input[name="11_si[]"]');
|
||
var gradeInputs = container.find('input[name="11_grade[]"]');
|
||
var maxSiInputs = container.find('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 (id.value === '1') {
|
||
var selectedValue = $('#si_or_bp').val();
|
||
|
||
if (selectedValue == 1) {
|
||
|
||
var siInputs = container.find('input[name="gpa_sum_si[]"]');
|
||
var premiumInputs = container.find('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 = container.find('input[name="gpa_sum_si2[]"]');
|
||
var premiumInputs = container.find('input[name="gpa_sum_premium2[]"]');
|
||
var bandInputs = container.find('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) {
|
||
|
||
console.log('basicPayMultiple function called')
|
||
|
||
var inputId = input.id;
|
||
var inputValue = input.value.replace(/,/g, '');
|
||
var count = inputId.split('_')[2];
|
||
console.log('count :', count)
|
||
console.log('input :', input);
|
||
console.log('input_id :', input.id);
|
||
console.log('input_class :', input.className);
|
||
|
||
if (input.className.includes('basic_pay')) {
|
||
|
||
if(!count){
|
||
count = 'first'
|
||
}
|
||
|
||
// Sum insured
|
||
var basicMultiplier = $('#basic_multiplier').val().replace(/,/g, '');
|
||
var multi = basicMultiplier * inputValue;
|
||
console.log('multi', multi);
|
||
$('#gpa_basic_si_' + count).val(multi).trigger('keyup');
|
||
|
||
// Premium
|
||
var gpaBasicSiValue = multi; // We just calculated this value
|
||
var premiumMultiplier = $('#premium_multiplier').val().replace(/,/g, '');
|
||
var multi_2 = gpaBasicSiValue * premiumMultiplier / 1000;
|
||
console.log('multi_2', multi_2);
|
||
$('#gpa_basic_premium_' + count).val(multi_2).trigger('keyup');
|
||
|
||
}
|
||
}
|
||
|
||
|
||
function basicMultiplierAndPremiumMultipiler(input){
|
||
|
||
console.log('basicPayMultipleforfirstone function called')
|
||
|
||
var inputId = input.id;
|
||
var inputValue = input.value.replace(/,/g, '');
|
||
|
||
console.log('input', input);
|
||
console.log('input id ', input.id);
|
||
console.log('input class ', input.className);
|
||
console.log('inputValue', inputValue);
|
||
|
||
if (input.className.includes('basic_multiplier')) {
|
||
|
||
console.log('basic_multiplier called')
|
||
|
||
var basic_pay = $('input[name="basic_pay[]"]');
|
||
var basic_multiplier = input.value;
|
||
var premium_multiplier = $('#premium_multiplier').val();
|
||
|
||
var sum_insured = $('input[name="gpa_basic_si[]"]');
|
||
var premium = $('input[name="gpa_basic_premium[]"]');
|
||
|
||
|
||
basic_pay.each(function(index) {
|
||
|
||
var basic_pay_amount = $(this).val().replace(/,/g, '');
|
||
console.log('basic_pay_amount', basic_pay_amount)
|
||
|
||
var sum_insured_amount = basic_pay_amount * basic_multiplier;
|
||
console.log('sum_insured_amount', sum_insured_amount);
|
||
$(sum_insured[index]).val(sum_insured_amount);
|
||
$(sum_insured[index]).trigger('keyup');
|
||
|
||
var premium_amount = (sum_insured_amount / 1000) * premium_multiplier;
|
||
console.log('premium_amount', premium_amount);
|
||
$(premium[index]).val(premium_amount);
|
||
$(premium[index]).trigger('keyup');
|
||
|
||
});
|
||
|
||
|
||
} else if (input.className.includes('premium_multiplier')) {
|
||
|
||
console.log('premium_multiplier called')
|
||
|
||
var premium_multiplier = input.value;
|
||
var sum_insured = $('input[name="gpa_basic_si[]"]');
|
||
var premium = $('input[name="gpa_basic_premium[]"]');
|
||
|
||
|
||
sum_insured.each(function(index) {
|
||
|
||
var sum_insured_amount = $(this).val().replace(/,/g, '');
|
||
console.log('sum_insured_amount', sum_insured_amount)
|
||
|
||
var premium_amount = (sum_insured_amount / 1000) * premium_multiplier;
|
||
console.log('premium_amount', premium_amount);
|
||
$(premium[index]).val(premium_amount);
|
||
$(premium[index]).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();
|
||
|
||
console.log('selectedValue', selectedValue)
|
||
|
||
if (selectedValue == 2) {
|
||
|
||
$('.gpa_sum_insure_remove').hide();
|
||
$('.gpa_band_remove').hide();
|
||
$('.gpa_basic_pay_remove').show();
|
||
|
||
$('#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();
|
||
$('.gpa_basic_pay_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_first').removeAttr('required', false);
|
||
$('#gpa_basic_premium_first').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();
|
||
$('.gpa_basic_pay_remove').hide();
|
||
|
||
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_first').removeAttr('required', false);
|
||
$('#gpa_basic_premium_first').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;
|
||
}
|
||
|
||
|
||
function createCheckboxes(obj, additional_relationship) {
|
||
//console.log('createCheckboxes function called');
|
||
|
||
console.log('object', obj);
|
||
console.log('additional_relationship', additional_relationship);
|
||
try {
|
||
additional_relationship = JSON.parse(additional_relationship);
|
||
//console.log(additional_relationship);
|
||
} catch (error) {
|
||
console.error("Error parsing additional_relationship:", error);
|
||
return;
|
||
}
|
||
|
||
$('#relationship').empty();
|
||
const $relationshipElement = $('#relationship');
|
||
let html = ` <div class="col-12">
|
||
<label>Additional Premium Applicable to</label>
|
||
</div>`;
|
||
|
||
if(obj['either-parents-pil'] && obj['either-parents-pil'] > 0){
|
||
obj['parents'] = 1;
|
||
obj['parents-in-law'] = 1;
|
||
}
|
||
|
||
|
||
$.each(obj, function(key, value) {
|
||
|
||
if (value > 0 && key != 'elders_count' && key != 'either-parents-pil') {
|
||
|
||
const isChecked = additional_relationship && typeof additional_relationship === 'object' && additional_relationship[key] == 1 ? 'checked' : '';
|
||
//console.log('isChecked', isChecked);
|
||
html += `
|
||
<div class="col-2">
|
||
<input class="relation_checkbox" type="checkbox" name="${key}" ${isChecked}>
|
||
<label style="position: relative;left: 18px;bottom: 30px;">${formatString(key)}</label>
|
||
</div>`;
|
||
}
|
||
});
|
||
|
||
$relationshipElement.append(html);
|
||
}
|
||
|
||
|
||
function formatString(str) {
|
||
return str.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
|
||
}
|
||
|
||
|
||
$('#del_btn').click(function() {
|
||
//console.log('delete btn clicked');
|
||
|
||
Swal.fire({
|
||
title: "Are you sure?",
|
||
text: "You need to Delete this!",
|
||
icon: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#3085d6",
|
||
confirmButtonText: "Yes",
|
||
}).then((result) => {
|
||
//console.log('after then entered');
|
||
|
||
if (result.isConfirmed) {
|
||
//console.log('isConfirmed entered');
|
||
|
||
var client_policy_id = $('#client_policy_id_2').val();
|
||
//console.log('client_policy_id', client_policy_id)
|
||
|
||
var rack_rate_type = $('#rack_rate_type_2').val();
|
||
//console.log('rack_rate_type', rack_rate_type)
|
||
|
||
var client_id = $('#Client_id_2').val();
|
||
//console.log('client_id', client_id)
|
||
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
$.ajax({
|
||
url: '<?php echo base_url('util/delete-additional-rack-rate/'); ?>' + client_id + '/' + client_policy_id + '/' + rack_rate_type,
|
||
type: 'GET',
|
||
success: function(res) {
|
||
|
||
//console.log('ajax success entered');
|
||
//console.log(res);
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
if (res.status === true) {
|
||
|
||
$('#additional_grid_content_input').empty();
|
||
$('#additional_grid').val('');
|
||
$('#individual_2').prop('checked', true)
|
||
$('#single_2').prop('checked', false)
|
||
$('input[type="checkbox"]').prop('checked', false);
|
||
|
||
|
||
toastr.success(res.message, 'Success');
|
||
|
||
} else if (res.status === false) {
|
||
toastr.warning(res.message, 'Warning');
|
||
return;
|
||
}
|
||
},
|
||
error: function(xhr, status, error) {
|
||
//console.log('ajax error entered');
|
||
console.error(xhr.responseText);
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}
|
||
});
|
||
|
||
// Removed the duplicated loader hiding code here
|
||
}
|
||
|
||
//console.log('after then entered end or cancel');
|
||
});
|
||
|
||
//console.log('delete btn clicked end');
|
||
});
|
||
|
||
|
||
function checkCheckboxes() {
|
||
|
||
var checkboxes = $('input.relation_checkbox');
|
||
var checkedCount = checkboxes.filter(':checked').length;
|
||
var uncheckedCount = checkboxes.not(':checked').length;
|
||
|
||
//console.log('Checked count:', checkedCount); // Debugging
|
||
//console.log('unchecked Count', uncheckedCount);
|
||
|
||
if (checkedCount < 1) {
|
||
toastr.warning('You must select at least one checkbox.', 'Warning');
|
||
return false;
|
||
} else if (checkedCount == uncheckedCount) {
|
||
toastr.warning('You can not select all of the checkboxes', 'Waraning');
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
|
||
|
||
function checkTermsSISameAsRackRateSI(input) {
|
||
|
||
console.log('checkTermsSISameAsRackRateSI testing..........');
|
||
console.log(input);
|
||
|
||
var client_policy_id = $('#client_policy_id').val();
|
||
console.log('client_policy_id', client_policy_id)
|
||
|
||
var inputValue = input.value.replace(/,/g, '');
|
||
inputValue = parseFloat(inputValue);
|
||
console.log(inputValue);
|
||
|
||
var url = '<?php echo base_url('util/getPolicyTerms/') ?>' + client_policy_id;
|
||
|
||
$.get(url, function(response) {
|
||
console.log(response);
|
||
console.log(response.data);
|
||
|
||
var policyTerms = response.data;
|
||
var valueExists = false;
|
||
|
||
for (var i = 0; i < policyTerms.length; i++) {
|
||
if (parseFloat(policyTerms[i]) === inputValue) {
|
||
valueExists = true;
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (!valueExists) {
|
||
input.value = "";
|
||
toastr.warning(`Value does not exist in the Policy Terms.`);
|
||
}
|
||
|
||
}).fail(function(xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
toastr.error(`Failed to retrieve Policy Terms. Error: ${error}`);
|
||
});
|
||
}
|
||
|
||
|
||
function checkPolicyTermsSI(callback) {
|
||
|
||
console.log('checkPolicyTermsSI function called');
|
||
|
||
var id = $('#additional_grid')[0];
|
||
var container = $('#additional_grid_content_input');
|
||
|
||
var val = 0;
|
||
|
||
if (val == 0) {
|
||
id = $('#grid')[0];
|
||
container = $('#grid_content_input');
|
||
}
|
||
|
||
console.log(id);
|
||
console.log(container);
|
||
|
||
var siInputs = null;
|
||
|
||
switch (id.value) {
|
||
case '1':
|
||
var selectedValue = $('#si_or_bp').val();
|
||
if (selectedValue == 1) {
|
||
siInputs = container.find('input[name="gpa_sum_si[]"]');
|
||
} else if (selectedValue == 3) {
|
||
siInputs = container.find('input[name="gpa_sum_si2[]"]');
|
||
}
|
||
break;
|
||
case '2':
|
||
siInputs = container.find('input[name="gpa_si"]');
|
||
break;
|
||
case '3':
|
||
siInputs = container.find('input[name="3_si[]"]');
|
||
break;
|
||
case '4':
|
||
siInputs = container.find('input[name="4_si"]');
|
||
break;
|
||
case '5':
|
||
siInputs = container.find('input[name="5_si[]"]');
|
||
break;
|
||
case '6':
|
||
siInputs = container.find('input[name="6_si"]');
|
||
break;
|
||
case '7':
|
||
siInputs = container.find('input[name="7_si[]"]');
|
||
break;
|
||
case '8':
|
||
siInputs = container.find('input[name="8_si[]"]');
|
||
break;
|
||
case '9':
|
||
siInputs = container.find('input[name="gpa_si"]');
|
||
break;
|
||
case '10':
|
||
siInputs = container.find('input[name="10_si[]"]');
|
||
break;
|
||
case '11':
|
||
siInputs = container.find('input[name="11_si[]"]');
|
||
break;
|
||
case '12':
|
||
siInputs = container.find('input[name="12_si[]"]');
|
||
break;
|
||
case '13':
|
||
siInputs = container.find('input[name="13_si[]"]');
|
||
break;
|
||
default:
|
||
siInputs = [];
|
||
}
|
||
|
||
console.log('siInputs', siInputs);
|
||
|
||
var client_policy_id = $('#client_policy_id').val();
|
||
console.log('client_policy_id', client_policy_id);
|
||
|
||
var url = '<?php echo base_url('util/getPolicyTerms/') ?>' + client_policy_id;
|
||
|
||
console.log('url', url);
|
||
|
||
$.ajax({
|
||
url: url,
|
||
type: 'GET',
|
||
dataType: 'json',
|
||
success: function(response) {
|
||
|
||
console.log(response);
|
||
console.log(response.data);
|
||
console.log(siInputs);
|
||
|
||
var policy_terms_si = response.data;
|
||
var rack_rate_si = [];
|
||
|
||
if(siInputs != null) {
|
||
siInputs.each(function() {
|
||
var input = $(this).val();
|
||
console.log('input value', input);
|
||
rack_rate_si.push(input.replace(/,/g, ''));
|
||
});
|
||
}
|
||
|
||
console.log('policy_terms_si', policy_terms_si);
|
||
console.log('rack_rate_si', rack_rate_si);
|
||
|
||
let new_array = [];
|
||
|
||
rack_rate_si.forEach(element => {
|
||
if (!policy_terms_si.includes(element)) {
|
||
new_array.push(element);
|
||
}
|
||
});
|
||
|
||
console.log('filtered array', new_array);
|
||
|
||
var arrayLength = new_array.length;
|
||
console.log('arrayLength', arrayLength);
|
||
|
||
if (arrayLength > 0) {
|
||
callback(true);
|
||
} else {
|
||
callback(false);
|
||
}
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.log(xhr.responseText);
|
||
console.log(status, error);
|
||
console.log(`Failed to retrieve Policy Terms. Error: ${error}`);
|
||
callback(false);
|
||
}
|
||
});
|
||
}
|
||
|
||
|
||
</script>
|