4551 lines
208 KiB
PHP
Executable File
4551 lines
208 KiB
PHP
Executable File
|
||
<?php include('policy_grid_excel.php')?>
|
||
|
||
<style>
|
||
|
||
/* .modal-full-width {
|
||
width: 95% !important;
|
||
} */
|
||
|
||
.radio-group {
|
||
display: flex;
|
||
align-items: center;
|
||
margin-bottom: 10px;
|
||
}
|
||
|
||
.radio-group .form-check {
|
||
margin-right: -335px;
|
||
}
|
||
|
||
.radioalign{
|
||
position: relative;
|
||
bottom: 6px;
|
||
}
|
||
|
||
.highlight-duplicate {
|
||
border: 2px solid red; /* or any other style you prefer */
|
||
}
|
||
|
||
/* .unitDiv{
|
||
display: none;
|
||
} */
|
||
</style>
|
||
|
||
<style>
|
||
#grid_content_input {
|
||
overflow-y: auto;
|
||
overflow-x: hidden;
|
||
max-height: 350px;
|
||
}
|
||
|
||
/* Custom scrollbar styles */
|
||
#grid_content_input::-webkit-scrollbar {
|
||
width: 8px; /* Set the width of the scrollbar */
|
||
}
|
||
|
||
#grid_content_input::-webkit-scrollbar-thumb {
|
||
background-color: #888; /* Color of the scrollbar thumb */
|
||
border-radius: 4px; /* Rounded corners of the scrollbar thumb */
|
||
}
|
||
|
||
#grid_content_input::-webkit-scrollbar-thumb:hover {
|
||
background-color: #555; /* Color of the scrollbar thumb on hover */
|
||
}
|
||
|
||
#grid_content_input::-webkit-scrollbar-track {
|
||
background-color: #f1f1f1; /* Background color of the scrollbar track */
|
||
}
|
||
</style>
|
||
|
||
<!-- 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">
|
||
<div class="col-md-6">
|
||
<h4 class="modal-title" id="myLargeModalLabel">Rack Rate <span id="PolicyNameForTitle"></span></h4>
|
||
</div>
|
||
<div class="col-md-5" style="position: relative;left: 20px;" id="add_new_rack_rate_tab_div">
|
||
<button class="btn btn-info waves-effect waves-light mr-1 float-right" id="add_new_rack_rate_tab" onclick="appendNewTab()">Add Rack Rate</button>
|
||
</div>
|
||
<div class="col-md-1" style="position: relative;top: 10px;">
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
</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" id="nav_pills">
|
||
<li class="nav-item" id="primary_rack_rate_tab_list">
|
||
<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" id="tabname">Primary Rack Rate</span>
|
||
</a>
|
||
</li>
|
||
</ul>
|
||
|
||
<div class="tab-content" id="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_name" id="rack_rate_name" value="Primary" />
|
||
<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-4">
|
||
<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(this)" required>
|
||
</select>
|
||
</div>
|
||
<input type="hidden" id="hidden_unit" />
|
||
<div class="form-group col-md-6"
|
||
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>
|
||
<input type="radio" id="single_and_individual" name="premium_type" value="3">
|
||
<label for="single" style="position: relative;top: 5px;left: 5px;"> Family Floater cum Individual </label>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-row" id="relationship" class="relationship" >
|
||
</div>
|
||
|
||
<a href="#" id="copyfromexcel" onclick="copyFromExcel(this)">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('na')">Copy Excel Headers</a> <h2 id="please_wait" style="display: none;"> please wait.... </h2></p>
|
||
<textarea class="form-control excel_textarea" id="copied_excel_data" name="copied_excel_data" style="width:100%;height:200px;" oninput="generateTable('na')"></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 class="btn btn-primary waves-effect waves-light mr-1 saveButtonChange" id="btnGridSubmit_2">Save</button>
|
||
<a class="btn btn-secondary waves-effect waves-light mr-1" id="btnGridrename" onclick="renameRackRateTab(this, null)">Rename</a>
|
||
</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()
|
||
{
|
||
localStorage.removeItem('client_units');
|
||
|
||
$('#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");
|
||
}
|
||
|
||
for (var i = 1; i <= 13; i++) {
|
||
$('#grid_' + i).remove();
|
||
$('#add_grid_' + i).remove();
|
||
$('#removeChild_' + i).remove();
|
||
}
|
||
});
|
||
|
||
$(document).on('click', '.close', function() {
|
||
$('#tab_content .tab-pane').not('#primary_rack_rate_tab').remove();
|
||
$('#nav_pills li').not('#primary_rack_rate_tab_list').remove();
|
||
});
|
||
|
||
var rarc_rate_json_array = [];
|
||
|
||
$(document).on('submit', 'form[id^="GridForm_"]', function(event) {
|
||
|
||
console.log('submitted function called')
|
||
|
||
event.preventDefault(); // Prevent the default form submission
|
||
|
||
var form = $(this);
|
||
console.log('form', form)
|
||
var formId = form.attr('id'); // Get the form ID
|
||
console.log('formId', formId)
|
||
|
||
var secondaryValue = '';
|
||
if(formId){
|
||
var unique_id = formId.split('_');
|
||
if (unique_id.length > 1) {
|
||
secondaryValue = unique_id[1];
|
||
secondaryValue = String(secondaryValue);
|
||
}
|
||
}
|
||
// console.log('formId secondaryValue', secondaryValue);
|
||
|
||
var check = checkDuplicate(secondaryValue);
|
||
if (check) {
|
||
return;
|
||
}
|
||
|
||
var checkUnits = checkValideUnits(secondaryValue);
|
||
if (checkUnits) {
|
||
return;
|
||
}
|
||
|
||
// Validate the form using Parsley
|
||
var isValid = $('#' + formId).parsley().validate();
|
||
if (!isValid) {
|
||
toastr.log('Form is Empty', 'Warning');
|
||
return;
|
||
}
|
||
|
||
// Create FormData object
|
||
var formData = new FormData(form[0]);
|
||
for (var pair of formData.entries()) {
|
||
console.log(pair[0] + ': ' + pair[1]);
|
||
}
|
||
|
||
let desiredKeys = ["self", "spouse", "childrens", "parents", "parents-in-law"];
|
||
|
||
// Convert FormData to a plain object, only including desired keys
|
||
let formObject = {};
|
||
formData.forEach((value, key) => {
|
||
if (desiredKeys.includes(key)) {
|
||
formObject[key] = value;
|
||
}
|
||
});
|
||
|
||
// Ensure all desired keys are present, adding any missing keys with value 'NA'
|
||
desiredKeys.forEach(key => {
|
||
if (!formObject.hasOwnProperty(key)) {
|
||
formObject[key] = 'NA';
|
||
}
|
||
});
|
||
|
||
console.log('formObject', formObject)
|
||
let isEqual = checkFamiliFloatersKeysDuplicate(rarc_rate_json_array, formObject, secondaryValue);
|
||
console.log('checkFamiliFloatersKeysDuplicate', isEqual)
|
||
|
||
if(isEqual){
|
||
toastr.warning('Family floaters alerdey exist', 'Warning');
|
||
return false;
|
||
}
|
||
|
||
// Show loader
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
|
||
var policy_form_action = '<?= base_url("client/premimum/create") ?>'; // Action URL
|
||
var result = false;
|
||
result = checkPolicyTermsSI(secondaryValue);
|
||
|
||
if (!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("rack rate submit Response", res);
|
||
console.log("rack rate submit Response JSON", res.rack_rate_json);
|
||
|
||
if (res.status === false) {
|
||
toastr.error('Policy Dose Not Create', 'Error');
|
||
return;
|
||
}
|
||
|
||
rarc_rate_json_array.push(res.rack_rate_json);
|
||
|
||
console.log('rarc_rate_json_array inside the submit function', rarc_rate_json_array)
|
||
|
||
$('.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) {
|
||
// Get the current timestamp
|
||
var timestamp = new Date().toISOString();
|
||
|
||
// Log detailed error information
|
||
console.error('Timestamp:', timestamp);
|
||
console.error('Status Code:', xhr.status);
|
||
console.error('Status Text:', xhr.statusText);
|
||
console.error('Response Text:', xhr.responseText);
|
||
console.error('Ready State:', xhr.readyState);
|
||
console.error('AJAX Status:', status);
|
||
console.error('Error Thrown:', error);
|
||
|
||
// Handle UI elements
|
||
$('.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.`);
|
||
}
|
||
|
||
});
|
||
|
||
var rack_rate_array = '';
|
||
var policy_type_string = '';
|
||
var family_floter_obj = '';
|
||
var employee_count = '';
|
||
var client_policy_for_additional_rack_rate = '';
|
||
var terms_si_amount_array = [];
|
||
var unit_length = 0;
|
||
var branch_units = [];
|
||
|
||
$('body').on('click', '.btnPolicyModel', function()
|
||
{
|
||
$('#tab_content .tab-pane').not('#primary_rack_rate_tab').remove();
|
||
$('#nav_pills li').not('#primary_rack_rate_tab_list').remove();
|
||
|
||
var client_policy_id = $(this).data('id');
|
||
var policy_type_id = $(this).data('typeid');
|
||
policy_type_string = $(this).attr('id');
|
||
|
||
$('#client_policy_id').val(client_policy_id);
|
||
client_policy_for_additional_rack_rate = String(client_policy_id);
|
||
|
||
if (policy_type_id) {
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
if (policy_type_string == 'GPA' || policy_type_id == 6 || policy_type_id == 7) {
|
||
$('.saveButtonChange').text('Submit');
|
||
$('#add_new_rack_rate_tab_div').hide();
|
||
$('#rack_rate_one').hide();
|
||
} else {
|
||
$('.saveButtonChange').text('Save');
|
||
$('#add_new_rack_rate_tab_div').show();
|
||
$('#rack_rate_one').show();
|
||
}
|
||
|
||
$('#rack_rate_one').click();
|
||
|
||
|
||
$.ajax({
|
||
url: '<?= base_url("util/policy-premium") ?>',
|
||
type: "GET",
|
||
data: { client_policy_id: client_policy_id },
|
||
dataType: 'json',
|
||
success: function(res) {
|
||
|
||
console.log('rack rate responce', (res.ranch_units))
|
||
console.log('rack rate responce jsonArray', res.jsonArray);
|
||
// console.log('rack rate responce.premium data', res.premiumData)
|
||
// console.log('rack rate responce.premium data parsed', JSON.parse(res.premiumData));
|
||
|
||
console.log('rack rate responce length', JSON.parse(res.branch_units).length);
|
||
|
||
branch_units = JSON.parse(res.branch_units) ?? [];
|
||
|
||
if (branch_units && branch_units.length == 1) {
|
||
|
||
$("#hidden_unit").val(branch_units[0]);
|
||
console.log('unit', branch_units[0]);
|
||
$("#gpa_unit1").val(branch_units[0]);
|
||
}
|
||
|
||
var data_for_the_rack_rate = JSON.parse(res.premiumData) ?? [];
|
||
var groupedData = groupByRackRateName(data_for_the_rack_rate) ?? [];
|
||
rarc_rate_json_array.push(res.jsonArray);
|
||
console.log('groupedData', groupedData)
|
||
|
||
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');
|
||
}
|
||
}
|
||
|
||
setTimeout(function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}, 500);
|
||
|
||
hideShowPolicyPremium(policy_type_string)
|
||
hideShowSubmitButton(res.count);
|
||
|
||
rack_rate_array = res.data;
|
||
family_floter_obj = res.self;
|
||
employee_count = res.count;
|
||
terms_si_amount_array = res.terms_si_amount_array;
|
||
localStorage.setItem('client_units', res.branch_units)
|
||
var client_units_for_hide_unit_text_field = JSON.parse(res.branch_units);
|
||
branch_units = client_units_for_hide_unit_text_field;
|
||
|
||
if(client_units_for_hide_unit_text_field){
|
||
unit_length = client_units_for_hide_unit_text_field.length;
|
||
}
|
||
|
||
// console.log('unit_length', unit_length);
|
||
|
||
var policy_grid_id_value = null;
|
||
var secondary_policy_grid_id_value = null;
|
||
var secondary = 0;
|
||
var additional_relationship = null;
|
||
var premium_type_for_primary_rr = [];
|
||
var first = 0;
|
||
|
||
var premiumData = groupedData.Primary ?? (function() {
|
||
var firstKey = Object.keys(groupedData)[0];
|
||
var firstValue = groupedData[firstKey];
|
||
|
||
if (firstValue !== undefined) {
|
||
delete groupedData[firstKey];
|
||
}
|
||
return firstValue || [];
|
||
})();
|
||
|
||
|
||
console.log('----- premiumData for primary rack rate -----', premiumData);
|
||
|
||
if (premiumData.length > 0 && premiumData != 'undefined') {
|
||
$.each(premiumData, function(index, item) {
|
||
|
||
policy_grid_id_value = item.policy_grid_id;
|
||
first = item.policy_grid_id;
|
||
|
||
if (policy_type_string == 'GPA' || policy_type_id == 6 || policy_type_id == 7) {
|
||
premium_type_for_primary_rr.push(item.premium_type);
|
||
|
||
} else {
|
||
secondary_policy_grid_id_value = item.policy_grid_id;
|
||
secondary = item.policy_grid_id;
|
||
additional_relationship = item.additional_relationship;
|
||
}
|
||
});
|
||
}
|
||
|
||
console.log('premiumData for primary rack rate', premiumData);
|
||
console.log('additional_relationship for primary rack rate', additional_relationship);
|
||
|
||
var checkboxdata = res.self;
|
||
|
||
$('#grid_content_input').empty()
|
||
|
||
if (policy_type_string === 'GPA' || policy_type_id === 6 || policy_type_id === 7) {
|
||
|
||
const checkboxDataObject = {
|
||
self: 1,
|
||
spouse: 0,
|
||
childrens: 0,
|
||
parents: 0,
|
||
parents_in_law: 0
|
||
};
|
||
|
||
checkboxdata = checkboxDataObject;
|
||
}
|
||
|
||
createCheckboxes(checkboxdata, additional_relationship, null, policy_type_id);
|
||
appendGridData(res.data, policy_grid_id_value);
|
||
if(premiumData[0]){
|
||
if(premiumData[0].premium_type){
|
||
editPolicyPremiumCalculationSetValue(premiumData[0].premium_type)
|
||
}
|
||
}
|
||
|
||
var si_or_bp_value = '';
|
||
if (premiumData.length > 0) {
|
||
|
||
if (premiumData[0].si_or_bp) {
|
||
si_or_bp_value = premiumData[0].si_or_bp;
|
||
}
|
||
|
||
addGridHTML(false, premiumData[0], premiumData[0].policy_grid_id, si_or_bp_value);
|
||
// alert("hi");
|
||
// alert('policy_grid_id_value', policy_grid_id_value);
|
||
$('#tabname').text(premiumData[0].rack_rate_name);
|
||
$('#rack_rate_name').val(premiumData[0].rack_rate_name);
|
||
|
||
premiumData.shift();
|
||
$.each(premiumData, function(index, item) {
|
||
if (item.si_or_bp == '1') {
|
||
console.log('gpa basic pay items', item);
|
||
appendGridtHtml('1', null, item);
|
||
} else {
|
||
appendGridtHtml(item.policy_grid_id, null, item);
|
||
}
|
||
});
|
||
|
||
} else {
|
||
console.log("res.premiumData is undefined, null, or empty.");
|
||
}
|
||
|
||
try {
|
||
if (policy_type_string == 'GMC') {
|
||
$.each(groupedData, function(index, item) {
|
||
if (index !== 'Primary') {
|
||
appendNewTab(index, item);
|
||
}
|
||
});
|
||
}
|
||
} catch (error) {
|
||
console.error('An error occurred:', error);
|
||
console.error('Error Name:', error.name);
|
||
console.error('Error Message:', error.message);
|
||
console.error('Error Stack:', error.stack);
|
||
console.error('An error occurred while processing the data. Please try again.');
|
||
}
|
||
|
||
$('#bs-example-modal-lg').modal('show');
|
||
$("#gpa_si").trigger("keyup");
|
||
$("#gpa_si_9").trigger("keyup");
|
||
$("#gpa_premium").trigger("keyup");
|
||
$('#basic_pay').trigger('keyup');
|
||
$('#4_si').trigger('keyup');
|
||
|
||
$('input[name="gpa_si"]').each(function() {
|
||
// console.log('gpa_si[]', $(this));
|
||
$(this).trigger('keyup');
|
||
});
|
||
|
||
$('input[name="gpa_premium"]').each(function() {
|
||
// console.log('gpa_si[]', $(this));
|
||
$(this).trigger('keyup');
|
||
});
|
||
|
||
$('input[name="gpa_si29[]"]').each(function() {
|
||
// console.log('gpa_si[]', $(this));
|
||
$(this).trigger('keyup');
|
||
});
|
||
|
||
$('input[name="gpa_premium29[]"]').each(function() {
|
||
// console.log('gpa_si[]', $(this));
|
||
$(this).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');
|
||
});
|
||
|
||
|
||
$(`input[name="${first}_si[]"]`).each(function() {
|
||
// console.log(first+'_si[]', $(this));
|
||
$(this).trigger('keyup');
|
||
});
|
||
|
||
$(`input[name="${first}_premium[]"]`).each(function() {
|
||
// console.log(first+"_premium[]", $(this));
|
||
$(this).trigger('keyup');
|
||
});
|
||
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
console.log('Something Wrong!', 'warning');
|
||
}
|
||
});
|
||
|
||
} 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")
|
||
}
|
||
|
||
|
||
});
|
||
|
||
$(document).on('change', 'select[id^="grid_"]', function(event)
|
||
{
|
||
|
||
$('.excel_textarea').val('');
|
||
var grid_id = $(this)[0].value;
|
||
var client_policy_id = $('#client_policy_id')[0].value;
|
||
|
||
if(unit_length == 1 || unit_length == 0){
|
||
|
||
// $('.unitDiv').hide();
|
||
// $('.unitDiv').find('input').removeAttr('required');
|
||
setTimeout(() => {
|
||
$('.unitDiv').hide();
|
||
$('.unitDiv input').removeAttr('required');
|
||
}, 1000);
|
||
}else{
|
||
$('.unitDiv').show();
|
||
$('.unitDiv').find('input').attr('required', true);
|
||
}
|
||
|
||
$.ajax({
|
||
url: '<?= base_url("util/policy-premium") ?>',
|
||
type: "GET",
|
||
data: {
|
||
client_policy_id: client_policy_id
|
||
},
|
||
dataType: 'json',
|
||
success: function(res) {
|
||
|
||
console.log('change response', res)
|
||
|
||
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);
|
||
}
|
||
});
|
||
})
|
||
|
||
//--------------------------------------------------------------------------------------------------------
|
||
|
||
$('#grid').change(function()
|
||
{
|
||
console.log('unit_length', unit_length)
|
||
|
||
$('.excel_textarea').val('');
|
||
var grid_id = $(this)[0].value;
|
||
var client_policy_id = $('#client_policy_id')[0].value;
|
||
|
||
if(unit_length == 1 || unit_length == 0){
|
||
|
||
// $('.unitDiv').hide();
|
||
// $('.unitDiv').find('input').removeAttr('required');
|
||
setTimeout(() => {
|
||
$('.unitDiv').hide();
|
||
$('.unitDiv input').removeAttr('required');
|
||
}, 1000);
|
||
}else{
|
||
$('.unitDiv').show();
|
||
$('.unitDiv').find('input').attr('required', true);
|
||
}
|
||
|
||
$.ajax({
|
||
url: '<?= base_url("util/policy-premium") ?>',
|
||
type: "GET",
|
||
data: {
|
||
client_policy_id: client_policy_id
|
||
},
|
||
dataType: 'json',
|
||
success: function(res) {
|
||
|
||
console.log('change response', res)
|
||
|
||
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);
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
console.log('Something Wrong!', 'warning');
|
||
}
|
||
});
|
||
})
|
||
|
||
function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = false, unique_id = false)
|
||
{
|
||
console.log('addgridhtmll function data', data)
|
||
console.log('addgridhtmll function unique id', unique_id)
|
||
console.log('addGridHTML si_or_bp', si_or_bp);
|
||
console.log('addGridHTML event', event);
|
||
console.log('addGridHTML ui_type', ui_type);
|
||
|
||
// console.log('addgridhtmll function data.unit', data.unit)
|
||
// console.log('addgridhtmll function data.unit type',typeof data.unit)
|
||
|
||
|
||
var secondaryValue = unique_id;
|
||
var grid_container = document.getElementById('grid_content_input');
|
||
// console.log('step 1', grid_container);
|
||
|
||
if (secondaryValue != false && secondaryValue != null) {
|
||
grid_container_id = 'grid_content_input_for_additional_' + secondaryValue;
|
||
grid_container = document.getElementById(grid_container_id);
|
||
// console.log('step 2', grid_container);
|
||
}
|
||
// console.log('step 3', grid_container);
|
||
|
||
var id_var = 'grid_';
|
||
|
||
var default_unit = $('#hidden_unit').val();
|
||
// alert(default_unit);
|
||
|
||
var dataIdValue = ''
|
||
if (event === false) {
|
||
var dataIdValue = ui_type
|
||
} else {
|
||
var dataIdValue = event.value;
|
||
}
|
||
|
||
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-3 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '3' ? data.unit : '') : ''}" type="text" class="form-control" placeholder="Enter Unit" name="gpa_unit_3[]" id="gpa_unit3" required>
|
||
</div>
|
||
<div class="form-group col-md-1" id="">
|
||
<label for="mobile">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="Band" name="gpa_band[]" id="gpa_band" required>
|
||
</div>
|
||
<div class="form-group col-md-3" 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-3">
|
||
<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-2" 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" style = "margin-bottom: -10px;margin-top: 17px;">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-3 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '1' ? data.unit : default_unit) : default_unit}" type="text" class="form-control" placeholder="Enter Unit" name="gpa_unit_1[]" id="gpa_unit1" required>
|
||
</div>
|
||
<div class="form-group col-md-3" 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-3">
|
||
<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-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_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-group col-md-3 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '2' ? data.unit : '') : ''}" type="text" class="form-control" placeholder="Enter Unit" name="gpa_unit[]" id="gpa_unit2" required>
|
||
</div>
|
||
<div class="form-col col-md-2">
|
||
<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-2">
|
||
<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-2" 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-4 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}" type="text" class="form-control" placeholder="Enter Unit" name="gpa_unit29[]" id="gpa_unit" required>
|
||
</div>
|
||
<div class="form-group col-md-4">
|
||
<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_si29[]" 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-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_premium29[]" 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') {
|
||
|
||
// console.log('secondaryValue type 3 step 1', secondaryValue)
|
||
// console.log('secondaryValue type 3', secondaryValue)
|
||
|
||
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-4 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}" type="text" class="form-control" placeholder="Enter Unit" name="3_unit[]" id="3_unit" required>
|
||
</div>
|
||
<div class="form-group col-md-4">
|
||
<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-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="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-4">
|
||
<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-4 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}" type="text" class="form-control" placeholder="Enter Unit" name="4_unit[]" id="4_unit" required>
|
||
</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="Age" name="4_age_from[]" id="4_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="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 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}" type="text" class="form-control" placeholder="Enter Unit" name="5_unit[]" id="5_unit" required>
|
||
</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 : ''}" 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-1">
|
||
<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="Age" name="5_age_from[]" id="5_age_from" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-1">
|
||
<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="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-4">
|
||
<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-4 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}" type="text" class="form-control" placeholder="Enter Unit" name="6_unit[]" id="6_unit" required>
|
||
</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="Age" name="6_age_from[]" id="6_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="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 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}" type="text" class="form-control" placeholder="Enter Unit" name="7_unit[]" id="7_unit" required>
|
||
</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 : ''}" 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-1">
|
||
<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="Age" name="7_age_from[]" id="7_age_from" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-1">
|
||
<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="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 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}" type="text" class="form-control" placeholder="Enter Unit" name="8_unit[]" id="8_unit" required>
|
||
</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 : ''}" 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-2">
|
||
<label for="mobile">Grade<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.grade : ''}" type="text" class="form-control" placeholder="Enter 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-4 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}" type="text" class="form-control" placeholder="Enter Unit" name="gpa_unit29[]" id="gpa_unit" required>
|
||
</div>
|
||
<div class="form-group col-md-4">
|
||
<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_si29[]" id="gpa_si_9" 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_premium29[]" 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 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}" type="text" class="form-control" placeholder="Enter Unit" name="10_unit[]" id="10_unit" required>
|
||
</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 : ''}" 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-1">
|
||
<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="Age" name="10_age_from[]" id="10_age_from" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-1">
|
||
<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="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-3 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}" type="text" class="form-control" placeholder="Enter Unit" name="11_unit[]" id="11_unit" required>
|
||
</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 : ''}" 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-1">
|
||
<label for="mobile">Grade<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.grade : ''}" type="text" class="form-control" placeholder="Band " name="11_grade[]" id="11_grade" required>
|
||
</div>
|
||
<div class="form-group col-md-2">
|
||
<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-3 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}" type="text" class="form-control" placeholder="Enter Unit" name="12_unit[]" id="12_unit" required>
|
||
</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 : ''}" 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-2">
|
||
<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 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}" type="text" class="form-control" placeholder="Enter Unit" name="13_unit[]" id="13_unit" required>
|
||
</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 : ''}" 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-1">
|
||
<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="Age" name="13_age_from[]" id="13_age_from" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-1">
|
||
<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="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-2">
|
||
<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();
|
||
|
||
}
|
||
|
||
// console.log('grid_container step 4', grid_container)
|
||
// console.log('grid_html', grid_html)
|
||
if(data == false){
|
||
$(grid_container).empty();
|
||
}
|
||
grid_container.insertAdjacentHTML('beforeend', grid_html);
|
||
// console.log('grid_container step 5');
|
||
// console.log('grid_container step 6', grid_container);
|
||
|
||
|
||
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');
|
||
// });
|
||
}
|
||
|
||
if(unit_length == 1 || unit_length == 0){
|
||
// $('.unitDiv').hide();
|
||
// $('.unitDiv').find('input').removeAttr('required');
|
||
setTimeout(() => {
|
||
$('.unitDiv').hide();
|
||
$('.unitDiv input').removeAttr('required');
|
||
}, 1000);
|
||
}else{
|
||
$('.unitDiv').show();
|
||
$('.unitDiv').find('input').attr('required', true);
|
||
}
|
||
|
||
if(unit_length == 1){
|
||
toAddUnitInManuall(unique_id, branch_units[0], 'addGridHTML')
|
||
}
|
||
|
||
$('#gpa_sum_insured').hide();
|
||
$('#btnGridSubmit').show();
|
||
|
||
$('#si_or_bp').val(si_or_bp);
|
||
setTimeout(() => {
|
||
$('#si_or_bp').trigger('change');
|
||
}, 300);
|
||
|
||
};
|
||
|
||
var Count = 1;
|
||
|
||
function appendGridtHtml(ui_type = false, secondary = false, data = false)
|
||
{
|
||
console.log('appendGridtHtml function data', data);
|
||
console.log('appendGridtHtml function ui_type', ui_type);
|
||
console.log('appendGridtHtml function secondary', secondary);
|
||
console.log('appendGridtHtml function typeof secondary', typeof secondary);
|
||
|
||
// console.log('appendGridtHtml function data.unit', data.unit);
|
||
// console.log('appendGridtHtml function data.unit type',typeof data.unit);
|
||
|
||
var html = '';
|
||
Count++;
|
||
|
||
var container = document.getElementById('grid_content_input');
|
||
// console.log('appendGridtHtml function container step 1', container);
|
||
|
||
if (secondary != false && secondary != 'false' && secondary != null && secondary != 'null') {
|
||
container_id = 'grid_content_input_for_additional_' + secondary;
|
||
container = document.getElementById(container_id);
|
||
// console.log('appendGridtHtml function container step 2', container);
|
||
}
|
||
|
||
// console.log('appendGridtHtml function container step 3', container);
|
||
|
||
if (ui_type == '1') {
|
||
|
||
// console.log('step 1')
|
||
|
||
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-3 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== default_unit ? data.unit : default_unit}"}" type="text" class="form-control" placeholder="Enter Unit" name="gpa_unit_1[]" id="gpa_unit1" required>
|
||
</div>
|
||
<div class="form-group col-md-3" 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-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="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-3 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}"}" type="text" class="form-control" placeholder="Enter Unit" name="gpa_unit_3[]" id="gpa_unit3" required>
|
||
</div>
|
||
|
||
<div class="form-group col-md-1" id="">
|
||
<label for="mobile">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="Band" name="gpa_band[]" id="gpa_band" required>
|
||
</div>
|
||
|
||
<div class="form-group col-md-3" 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-3">
|
||
<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-group col-md-3 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}"}" type="text" class="form-control" placeholder="Enter Unit" name="gpa_unit[]" id="gpa_unit2" required>
|
||
</div>
|
||
|
||
<div class="form-col col-md-2">
|
||
<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-2">
|
||
<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-4 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}" type="text" class="form-control" placeholder="Enter unit" name="3_unit[]" id="3_unit_${Count}" required>
|
||
</div>
|
||
<div class="form-group col-md-4">
|
||
<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-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="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-4 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}" type="text" class="form-control" placeholder="Enter unit" name="4_unit[]" id="4_unit_${Count}" required>
|
||
</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="Age" name="4_age_from[]" id="4_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="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 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}" type="text" class="form-control" placeholder="Enter unit" name="5_unit[]" id="5_unit_${Count}" required>
|
||
</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 : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="5_si[]" id="5_unit_${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-1">
|
||
<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="Age" name="5_age_from[]" id="5_age_from" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-1">
|
||
<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="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-4 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}" type="text" class="form-control" placeholder="Enter unit" name="6_unit[]" id="6_unit_${Count}" required>
|
||
</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="Age" name="6_age_from[]" id="6_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=" 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 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}" type="text" class="form-control" placeholder="Enter unit" name="7_unit[]" id="7_unit_${Count}" required>
|
||
</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 : ''}" 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-1">
|
||
<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="Age" name="7_age_from[]" id="7_age_from" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-1">
|
||
<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="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 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}" type="text" class="form-control" placeholder="Enter unit" name="8_unit[]" id="8_unit_${Count}" required>
|
||
</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 : ''}" 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-2">
|
||
<label for="mobile">Grade<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.grade : ''}" type="text" class="form-control" placeholder="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 == '2' || ui_type == '9') {
|
||
|
||
html = `
|
||
<div class="form-row" id="removeChild_${Count}" style="/*width:84%*/">
|
||
<div class="form-group col-md-4 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}" type="text" class="form-control" placeholder="Enter unit" name="gpa_unit29[]" id="9_unit_${Count}" required>
|
||
</div>
|
||
<div class="form-group col-md-4">
|
||
<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_si29[]" 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-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_premium29[]" 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 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}" type="text" class="form-control" placeholder="Enter unit" name="10_unit[]" id="10_unit_${Count}" required>
|
||
</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 : ''}" 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-1">
|
||
<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="Age" name="10_age_from[]" id="10_age_from" onkeypress = "return onlyNumbers(event)" required>
|
||
</div>
|
||
<div class="form-group col-md-1">
|
||
<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="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-3 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}" type="text" class="form-control" placeholder="Enter unit" name="11_unit[]" id="11_unit_${Count}" required>
|
||
</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 : ''}" 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-1">
|
||
<label for="mobile">Grade<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.grade : ''}" type="text" class="form-control" placeholder="Enter Band " name="11_grade[]" id="11_grade" required>
|
||
</div>
|
||
<div class="form-group col-md-2">
|
||
<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-3 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}" type="text" class="form-control" placeholder="Enter unit" name="12_unit[]" id="12_unit_${Count}" required>
|
||
</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 : ''}" 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-2">
|
||
<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-4 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}" type="text" class="form-control" placeholder="Enter unit" name="13_unit[]" id="13_unit_${Count}" required>
|
||
</div>
|
||
<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="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="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('appendGridtHtml function container step 4', container);
|
||
container.insertAdjacentHTML('beforeend', html);
|
||
// console.log('appendGridtHtml function container step 5', container);
|
||
|
||
// $('#gmc_add_more').hide();
|
||
// $('#gmc_add_more2').hide();
|
||
// $('#gmc_remove').show();
|
||
// Count--
|
||
// $('#gmc_add_more_' + Count).hide()
|
||
// Count++
|
||
|
||
if(unit_length == 1 || unit_length == 0){
|
||
// $('.unitDiv').hide();
|
||
// $('.unitDiv').find('input').removeAttr('required');
|
||
setTimeout(() => {
|
||
$('.unitDiv').hide();
|
||
$('.unitDiv input').removeAttr('required');
|
||
}, 1000);
|
||
}else{
|
||
$('.unitDiv').show();
|
||
$('.unitDiv').find('input').attr('required', true);
|
||
}
|
||
|
||
if(unit_length == 1){
|
||
console.log(typeof secondary);
|
||
let unique_id = secondary == 'false' ? null : secondary;
|
||
toAddUnitInManuall(unique_id, branch_units[0], 'appendGridtHtml')
|
||
}
|
||
|
||
|
||
// 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)
|
||
{
|
||
|
||
console.log('remove button function called')
|
||
|
||
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(unique_id = null)
|
||
{
|
||
console.log('checkDuplicate function called')
|
||
// console.log('checkDuplicate unique_id', unique_id)
|
||
|
||
var id = $('#grid')[0];
|
||
var container = $('#grid_content_input');
|
||
|
||
// console.log('checkDuplicate id 1', id);
|
||
// console.log('checkDuplicate container 1', container);
|
||
|
||
if (unique_id) {
|
||
id = $('#grid_'+unique_id)[0];
|
||
container = $('#grid_content_input_for_additional_'+unique_id);
|
||
|
||
// console.log('checkDuplicate id 2', id);
|
||
// console.log('checkDuplicate container 2', container);
|
||
}
|
||
|
||
// console.log('checkDuplicate id 3', id);
|
||
// console.log('checkDuplicate container 3', container);
|
||
|
||
// var highlightDuplicates = function(duplicateIndices) {
|
||
// duplicateIndices.forEach(index => {
|
||
// container.find('input').eq(index).addClass('highlight-duplicate');
|
||
// });
|
||
// };
|
||
|
||
// var removeHighlight = function() {
|
||
// container.find('input').removeClass('highlight-duplicate');
|
||
// };
|
||
|
||
// removeHighlight();
|
||
|
||
if (id.value === '3') {
|
||
|
||
var siInputs = container.find('input[name="3_si[]"]');
|
||
var units = container.find('input[name="3_unit[]"]');
|
||
|
||
var siValues = [];
|
||
var unitValues = [];
|
||
// var duplicateIndices = [];
|
||
var siDuplicates = false;
|
||
|
||
// Extract values from input arrays
|
||
siInputs.each(function() {
|
||
var value = $(this).val();
|
||
var cleanedValue = value.replace(/,/g, '');
|
||
var numericValue = parseFloat(cleanedValue);
|
||
siValues.push(numericValue);
|
||
});
|
||
|
||
units.each(function() {
|
||
var value = $(this).val();
|
||
unitValues.push(value);
|
||
});
|
||
|
||
console.log('checkDuplicate function siValues', siValues)
|
||
console.log('checkDuplicate function unitValues', unitValues)
|
||
|
||
for (var i = 0; i < siValues.length; i++) {
|
||
for (var j = i + 1; j < siValues.length; j++) {
|
||
if (unitValues[i] === unitValues[j] && siValues[i] === siValues[j]) {
|
||
siDuplicates = true;
|
||
// duplicateIndices.push(i, j);
|
||
}
|
||
}
|
||
}
|
||
|
||
if (siDuplicates) {
|
||
// highlightDuplicates(duplicateIndices);
|
||
toastr.warning('Duplicates found!', 'Warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
} else if (id.value === '2' || id.value === '9') {
|
||
|
||
var siInputs = container.find('input[name="gpa_si29[]"]');
|
||
var units = container.find('input[name="gpa_unit29[]"]');
|
||
|
||
var siValues = [];
|
||
var unitValues = [];
|
||
// var duplicateIndices = [];
|
||
var siDuplicates = false;
|
||
|
||
// Extract values from input arrays
|
||
siInputs.each(function() {
|
||
var value = $(this).val();
|
||
var cleanedValue = value.replace(/,/g, '');
|
||
var numericValue = parseFloat(cleanedValue);
|
||
siValues.push(numericValue);
|
||
});
|
||
|
||
units.each(function() {
|
||
var value = $(this).val();
|
||
unitValues.push(value);
|
||
});
|
||
|
||
console.log('checkDuplicate function siValues', siValues)
|
||
console.log('checkDuplicate function unitValues', unitValues)
|
||
|
||
for (var i = 0; i < siValues.length; i++) {
|
||
for (var j = i + 1; j < siValues.length; j++) {
|
||
if (unitValues[i] === unitValues[j] && siValues[i] === siValues[j]) {
|
||
siDuplicates = true;
|
||
// duplicateIndices.push(i, j);
|
||
}
|
||
}
|
||
}
|
||
|
||
if (siDuplicates) {
|
||
// highlightDuplicates(duplicateIndices);
|
||
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 units = container.find('input[name="4_unit[]"]');
|
||
|
||
|
||
var ageFromValues = [];
|
||
var ageToValues = [];
|
||
var unitValues = [];
|
||
var ageDuplicates = false;
|
||
|
||
// Extract values from input arrays
|
||
ageFrom.each(function() {
|
||
ageFromValues.push($(this).val());
|
||
});
|
||
|
||
ageTo.each(function() {
|
||
ageToValues.push($(this).val());
|
||
});
|
||
|
||
units.each(function() {
|
||
var value = $(this).val();
|
||
unitValues.push(value);
|
||
});
|
||
|
||
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 (unitValues[i] === unitValues[j] && 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 units = container.find('input[name="5_unit[]"]');
|
||
|
||
|
||
var si_array = [];
|
||
var ageFrom_array = [];
|
||
var ageTo_array = [];
|
||
var unitValues = [];
|
||
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());
|
||
});
|
||
|
||
units.each(function() {
|
||
var value = $(this).val();
|
||
unitValues.push(value);
|
||
});
|
||
|
||
for (var i = 0; i < ageFrom_array.length; i++) {
|
||
for (var j = i + 1; j < ageFrom_array.length; j++) {
|
||
if (unitValues[i] === unitValues[j] && 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 units = container.find('input[name="6_unit[]"]');
|
||
|
||
|
||
var ageFromValues = [];
|
||
var ageToValues = [];
|
||
var unitValues = [];
|
||
var ageDuplicates = false;
|
||
|
||
// Extract values from input arrays
|
||
ageFrom.each(function() {
|
||
ageFromValues.push($(this).val());
|
||
});
|
||
|
||
ageTo.each(function() {
|
||
ageToValues.push($(this).val());
|
||
});
|
||
|
||
units.each(function() {
|
||
var value = $(this).val();
|
||
unitValues.push(value);
|
||
});
|
||
|
||
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 (unitValues[i] === unitValues[j] && 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 units = container.find('input[name="7_unit[]"]');
|
||
|
||
|
||
var si_array = [];
|
||
var ageFrom_array = [];
|
||
var ageTo_array = [];
|
||
var unitValues = [];
|
||
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());
|
||
});
|
||
|
||
units.each(function() {
|
||
var value = $(this).val();
|
||
unitValues.push(value);
|
||
});
|
||
|
||
for (var i = 0; i < ageFrom_array.length; i++) {
|
||
for (var j = i + 1; j < ageFrom_array.length; j++) {
|
||
if (unitValues[i] === unitValues[j] && 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 units = container.find('input[name="10_unit[]"]');
|
||
|
||
|
||
var si_array = [];
|
||
var ageFrom_array = [];
|
||
var ageTo_array = [];
|
||
var unitValues = [];
|
||
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());
|
||
});
|
||
|
||
units.each(function() {
|
||
var value = $(this).val();
|
||
unitValues.push(value);
|
||
});
|
||
|
||
for (var i = 0; i < ageFrom_array.length; i++) {
|
||
for (var j = i + 1; j < ageFrom_array.length; j++) {
|
||
if (unitValues[i] === unitValues[j] && 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 units = container.find('input[name="8_unit[]"]');
|
||
|
||
|
||
var siValues = [];
|
||
var gradeValues = [];
|
||
var unitValues = [];
|
||
var duplicatesFound = false;
|
||
|
||
// Extract values from input arrays
|
||
siInputs.each(function() {
|
||
siValues.push($(this).val());
|
||
});
|
||
|
||
gradeInputs.each(function() {
|
||
gradeValues.push($(this).val());
|
||
});
|
||
|
||
units.each(function() {
|
||
var value = $(this).val();
|
||
unitValues.push(value);
|
||
});
|
||
|
||
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 (unitValues[i] === unitValues[j] && 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 units = container.find('input[name="11_unit[]"]');
|
||
|
||
|
||
var siValues = [];
|
||
var gradeValues = [];
|
||
var maxSiValues = [];
|
||
var unitValues = [];
|
||
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());
|
||
});
|
||
|
||
units.each(function() {
|
||
var value = $(this).val();
|
||
unitValues.push(value);
|
||
});
|
||
|
||
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 (unitValues[i] === unitValues[j] && 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 === '12'){
|
||
|
||
var siInputs = container.find('input[name="12_si[]"]');
|
||
var relationship = container.find('select[name="12_relationship[]"]');
|
||
var units = container.find('input[name="12_unit[]"]');
|
||
|
||
var siValues = [];
|
||
var relationshipValue = [];
|
||
var unitValues = [];
|
||
var duplicatesFound = false;
|
||
|
||
// Extract values from input arrays
|
||
siInputs.each(function() {
|
||
siValues.push($(this).val());
|
||
});
|
||
|
||
relationship.each(function() {
|
||
relationshipValue.push($(this).val());
|
||
});
|
||
|
||
units.each(function() {
|
||
var value = $(this).val();
|
||
unitValues.push(value);
|
||
});
|
||
|
||
// console.log('siInputs array', siInputs)
|
||
// console.log('relationship array', relationship)
|
||
// console.log('units array', units)
|
||
|
||
for (var i = 0; i < siValues.length; i++) {
|
||
for (var j = i + 1; j < siValues.length; j++) {
|
||
if (unitValues[i] === unitValues[j] && siValues[i] === siValues[j] && relationshipValue[i] === relationshipValue[j]) {
|
||
console.log('depulicate si :', siValues[i])
|
||
console.log('depulicate relation :', relationshipValue[i])
|
||
duplicatesFound = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (duplicatesFound) {
|
||
toastr.warning('Duplicates found!', 'Warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
|
||
} else if (id.value === '13'){
|
||
|
||
var siInputs = container.find('input[name="13_si[]"]');
|
||
var relationship = container.find('select[name="13_relationship[]"]');
|
||
var units = container.find('input[name="13_unit[]"]');
|
||
var ageFrom = container.find('input[name="13_age_from[]"]');
|
||
var ageTo = container.find('input[name="13_age_to[]"]');
|
||
|
||
|
||
var siValues = [];
|
||
var relationshipValue = [];
|
||
var unitValues = [];
|
||
var fromAgeValue = [];
|
||
var toAgeValue = [];
|
||
var duplicatesFound = false;
|
||
|
||
// Extract values from input arrays
|
||
siInputs.each(function() {
|
||
siValues.push($(this).val());
|
||
});
|
||
|
||
relationship.each(function() {
|
||
relationshipValue.push($(this).val());
|
||
});
|
||
|
||
ageFrom.each(function() {
|
||
fromAgeValue.push($(this).val());
|
||
});
|
||
|
||
ageTo.each(function() {
|
||
toAgeValue.push($(this).val());
|
||
});
|
||
|
||
units.each(function() {
|
||
var value = $(this).val();
|
||
unitValues.push(value);
|
||
});
|
||
|
||
for (var i = 0; i < siValues.length; i++) {
|
||
for (var j = i + 1; j < siValues.length; j++) {
|
||
if (unitValues[i] === unitValues[j] && siValues[i] === siValues[j] && relationshipValue[i] === relationshipValue[j] && fromAgeValue[i] === fromAgeValue[j] && toAgeValue[i] === toAgeValue[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 units = container.find('input[name="gpa_unit_1[]"]');
|
||
|
||
var siValues = [];
|
||
var unitValues = [];
|
||
var siDuplicates = false;
|
||
|
||
// Extract values from input arrays
|
||
siInputs.each(function() {
|
||
siValues.push($(this).val());
|
||
});
|
||
|
||
units.each(function() {
|
||
unitValues.push($(this).val());
|
||
});
|
||
|
||
for (var i = 0; i < siValues.length; i++) {
|
||
for (var j = i + 1; j < siValues.length; j++) {
|
||
if (unitValues[i] === unitValues[j] && siValues[i] === siValues[j]) {
|
||
siDuplicates = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
if (siDuplicates) {
|
||
toastr.warning('Duplicates found!', 'Warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
|
||
} else if (selectedValue == 3) {
|
||
|
||
var siInputs = container.find('input[name="gpa_sum_si2[]"]');
|
||
var bandInputs = container.find('input[name="gpa_band[]"]');
|
||
var units = container.find('input[name="gpa_unit_3[]"]');
|
||
|
||
var siValues = [];
|
||
var bandValues = [];
|
||
var unitValues = [];
|
||
var siDuplicates = false;
|
||
|
||
|
||
// Extract values from input arrays
|
||
siInputs.each(function() {
|
||
siValues.push($(this).val());
|
||
});
|
||
|
||
bandInputs.each(function() {
|
||
bandValues.push($(this).val());
|
||
});
|
||
|
||
units.each(function() {
|
||
unitValues.push($(this).val());
|
||
});
|
||
|
||
for (var i = 0; i < siValues.length; i++) {
|
||
for (var j = i + 1; j < siValues.length; j++) {
|
||
if (unitValues[j] === unitValues[j] && siValues[i] === siValues[j] && bandValues[i] === bandValues[j]) {
|
||
siDuplicates = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
if (siDuplicates) {
|
||
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_unit1').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_unit3').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);
|
||
$('#gpa_unit2').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_unit2').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_unit3').removeAttr('required', false);
|
||
|
||
|
||
$('#gpa_sum_multiplier').attr('required', true);
|
||
$('#gpa_sum_si').attr('required', true);
|
||
$('#gpa_sum_premium').attr('required', true);
|
||
$('#gpa_unit1').attr('required', false);
|
||
|
||
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_unit2').removeAttr('required', false);
|
||
|
||
$('#gpa_sum_multiplier').attr('required', false);
|
||
$('#gpa_sum_si').attr('required');
|
||
$('#gpa_sum_premium').attr('required');
|
||
$('#gpa_unit1').removeAttr('required', false);
|
||
|
||
$('#gpa_sum_multiplier2').removeAttr('required', true);
|
||
$('#gpa_sum_si2').removeAttr('required', true);
|
||
$('#gpa_band').removeAttr('required', true);
|
||
$('#gpa_sum_premium2').removeAttr('required', true);
|
||
$('#gpa_unit3').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 = [], unique_id = null, policy_type = null)
|
||
{
|
||
console.log('createCheckboxes function object', obj);
|
||
console.log('createCheckboxes function additional_relationship', additional_relationship);
|
||
|
||
if (typeof additional_relationship === 'string') {
|
||
additional_relationship = JSON.parse(additional_relationship);
|
||
} else if (!Array.isArray(additional_relationship)) {
|
||
additional_relationship = [];
|
||
}
|
||
|
||
if (obj['either-parents-pil'] && obj['either-parents-pil'] > 0) {
|
||
obj['parents'] = 1;
|
||
obj['parents-in-law'] = 1;
|
||
}
|
||
|
||
let $relationshipElement = $('#relationship');
|
||
|
||
if(unique_id){
|
||
$relationshipElement = $('#relationship_' + unique_id);
|
||
}
|
||
|
||
$relationshipElement.empty();
|
||
|
||
let html = `
|
||
|
||
<div class="form-group col-md-12">
|
||
<label>Choose applicable family members</label>
|
||
<table style="border-collapse: collapse;">
|
||
<tbody>`;
|
||
|
||
|
||
if (obj['self'] > 0) {
|
||
let selfValue = additional_relationship['self'] || '1';
|
||
console.log('selfValue', selfValue);
|
||
|
||
html += `
|
||
<tr>
|
||
<td><label>Self:</label></td>
|
||
<td>
|
||
<div class="radio-group">
|
||
<div class="form-check">
|
||
<input class="form-check-input" type="radio" name="self" id="self-yes" value="1" ${selfValue == '1' ? 'checked' : ''}>
|
||
<label class="form-check-label radioalign" for="self-yes">Yes</label>
|
||
</div>
|
||
<div class="form-check">
|
||
<input class="form-check-input" type="radio" name="self" id="self-no" value="0" ${selfValue == '0' ? 'checked' : ''}>
|
||
<label class="form-check-label radioalign" for="self-no">No</label>
|
||
</div>
|
||
<div class="form-check">
|
||
<input class="form-check-input" type="radio" name="self" id="self-any" value="any" ${selfValue == 'any' ? 'checked' : ''}>
|
||
<label class="form-check-label radioalign" for="self-any">Maybe</label>
|
||
</div>
|
||
<div class="form-check">
|
||
<input class="form-check-input" type="radio" name="self" id="self-na" value="NA" ${selfValue == 'NA' ? 'checked' : ''}>
|
||
<label class="form-check-label radioalign" for="self-na">NA</label>
|
||
</div>
|
||
</div>
|
||
</td>
|
||
</tr>`;
|
||
}
|
||
|
||
if (obj['spouse'] > 0) {
|
||
let spouseValue = additional_relationship['spouse'] || 'any';
|
||
|
||
html += `
|
||
<tr>
|
||
<td><label>Spouse:</label></td>
|
||
<td>
|
||
<div class="radio-group">
|
||
<div class="form-check">
|
||
<input class="form-check-input" type="radio" name="spouse" id="spouse-yes" value="1" ${spouseValue == '1' ? 'checked' : ''}>
|
||
<label class="form-check-label radioalign" for="spouse-yes">Yes</label>
|
||
</div>
|
||
<div class="form-check">
|
||
<input class="form-check-input" type="radio" name="spouse" id="spouse-no" value="0" ${spouseValue == '0' ? 'checked' : ''}>
|
||
<label class="form-check-label radioalign" for="spouse-no">No</label>
|
||
</div>
|
||
<div class="form-check">
|
||
<input class="form-check-input" type="radio" name="spouse" id="spouse-any" value="any" ${spouseValue == 'any' ? 'checked' : ''}>
|
||
<label class="form-check-label radioalign" for="spouse-any">Maybe</label>
|
||
</div>
|
||
<div class="form-check">
|
||
<input class="form-check-input" type="radio" name="spouse" id="spouse-na" value="NA" ${spouseValue == 'NA' ? 'checked' : ''}>
|
||
<label class="form-check-label radioalign" for="spouse-na">NA</label>
|
||
</div>
|
||
</div>
|
||
</td>
|
||
</tr>`;
|
||
}
|
||
|
||
if (obj['childrens'] > 0) {
|
||
let childrensValue = additional_relationship['childrens'] || 'any';
|
||
|
||
html += `
|
||
<tr>
|
||
<td><label>Children:</label></td>
|
||
<td>
|
||
<div class="radio-group">
|
||
<div class="form-check">
|
||
<input class="form-check-input" type="radio" name="childrens" id="children-all" value="4" ${childrensValue === '4' ? 'checked' : ''}>
|
||
<label class="form-check-label radioalign" for="children-4">4</label>
|
||
</div>
|
||
<div class="form-check">
|
||
<input class="form-check-input" type="radio" name="childrens" id="children-3" value="3" ${childrensValue === '3' ? 'checked' : ''}>
|
||
<label class="form-check-label radioalign" for="children-3">3</label>
|
||
</div>
|
||
<div class="form-check">
|
||
<input class="form-check-input" type="radio" name="childrens" id="children-2" value="2" ${childrensValue === '2' ? 'checked' : ''}>
|
||
<label class="form-check-label radioalign" for="children-2">2</label>
|
||
</div>
|
||
<div class="form-check">
|
||
<input class="form-check-input" type="radio" name="childrens" id="children-1" value="1" ${childrensValue === '1' ? 'checked' : ''}>
|
||
<label class="form-check-label radioalign" for="children-1">1</label>
|
||
</div>
|
||
<div class="form-check">
|
||
<input class="form-check-input" type="radio" name="childrens" id="children-no" value="0" ${childrensValue === '0' ? 'checked' : ''}>
|
||
<label class="form-check-label radioalign" for="children-no">No</label>
|
||
</div>
|
||
<div class="form-check">
|
||
<input class="form-check-input" type="radio" name="childrens" id="children-any" value="any" ${childrensValue === 'any' ? 'checked' : ''}>
|
||
<label class="form-check-label radioalign" for="children-any">Any</label>
|
||
</div>
|
||
<div class="form-check">
|
||
<input class="form-check-input" type="radio" name="childrens" id="children-unset" value="NA" ${childrensValue === 'NA' ? 'checked' : ''}>
|
||
<label class="form-check-label radioalign" for="children-unset">NA</label>
|
||
</div>
|
||
</div>
|
||
</td>
|
||
</tr>`;
|
||
}
|
||
|
||
if (obj['parents'] > 0) {
|
||
let parentsValue = additional_relationship['parents'] || 'any';
|
||
|
||
html += `
|
||
<tr>
|
||
<td><label>Parents:</label></td>
|
||
<td>
|
||
<div class="radio-group">
|
||
<div class="form-check">
|
||
<input class="form-check-input" type="radio" name="parents" id="parents-single" value="1" ${parentsValue === '1' ? 'checked' : ''}>
|
||
<label class="form-check-label radioalign" for="parents-single">1</label>
|
||
</div>
|
||
<div class="form-check">
|
||
<input class="form-check-input" type="radio" name="parents" id="parents-double" value="2" ${parentsValue === '2' ? 'checked' : ''}>
|
||
<label class="form-check-label radioalign" for="parents-double">2</label>
|
||
</div>
|
||
<div class="form-check">
|
||
<input class="form-check-input" type="radio" name="parents" id="parents-no" value="0" ${parentsValue === '0' ? 'checked' : ''}>
|
||
<label class="form-check-label radioalign" for="parents-no">No</label>
|
||
</div>
|
||
<div class="form-check">
|
||
<input class="form-check-input" type="radio" name="parents" id="parents-any" value="any" ${parentsValue === 'any' ? 'checked' : ''}>
|
||
<label class="form-check-label radioalign" for="parents-any">Any</label>
|
||
</div>
|
||
<div class="form-check">
|
||
<input class="form-check-input" type="radio" name="parents" id="parents-unset" value="NA" ${parentsValue === 'NA' ? 'checked' : ''}>
|
||
<label class="form-check-label radioalign" for="parents-unset">NA</label>
|
||
</div>
|
||
</div>
|
||
</td>
|
||
</tr>`;
|
||
}
|
||
|
||
if (obj['parents-in-law'] > 0) {
|
||
let parentsInLawValue = additional_relationship['parents-in-law'] || 'any';
|
||
html += `
|
||
<tr>
|
||
<td><label>Parents In Law:</label></td>
|
||
<td>
|
||
<div class="radio-group">
|
||
<div class="form-check">
|
||
<input class="form-check-input" type="radio" name="parents-in-law" id="parents-in-law-single" value="1" ${parentsInLawValue === '1' ? 'checked' : ''}>
|
||
<label class="form-check-label radioalign" for="parents-in-law-single">1</label>
|
||
</div>
|
||
<div class="form-check">
|
||
<input class="form-check-input" type="radio" name="parents-in-law" id="parents-in-law-double" value="2" ${parentsInLawValue === '2' ? 'checked' : ''}>
|
||
<label class="form-check-label radioalign" for="parents-in-law-double">2</label>
|
||
</div>
|
||
<div class="form-check">
|
||
<input class="form-check-input" type="radio" name="parents-in-law" id="parents-in-law-no" value="0" ${parentsInLawValue === '0' ? 'checked' : ''}>
|
||
<label class="form-check-label radioalign" for="parents-in-law-no">No</label>
|
||
</div>
|
||
<div class="form-check">
|
||
<input class="form-check-input" type="radio" name="parents-in-law" id="parents-in-law-any" value="any" ${parentsInLawValue === 'any' ? 'checked' : ''}>
|
||
<label class="form-check-label radioalign" for="parents-in-law-any">Any</label>
|
||
</div>
|
||
<div class="form-check">
|
||
<input class="form-check-input" type="radio" name="parents-in-law" id="parents-in-law-unset" value="NA" ${parentsInLawValue === 'NA' ? 'checked' : ''}>
|
||
<label class="form-check-label radioalign" for="parents-in-law-unset">NA</label>
|
||
</div>
|
||
</div>
|
||
</td>
|
||
</tr>`;
|
||
}
|
||
|
||
html += `
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
|
||
`;
|
||
|
||
// console.log(html);
|
||
|
||
$relationshipElement.append(html);
|
||
|
||
// if (obj['self'] > 0 && obj['spouse'] == 0 && obj['childrens'] == 0 && obj['parents'] == 0 && obj['parents-in-law'] == 0) {
|
||
// $('.radio-group .form-check').css('margin-right', '-60px');
|
||
// } else if (obj['self'] == 0 && obj['spouse'] > 0 && obj['childrens'] > 0 && obj['parents'] == 0 && obj['parents-in-law'] == 0) {
|
||
// $('.radio-group .form-check').css('margin-right', '-110px');
|
||
// } else if (obj['self'] == 0 && obj['spouse'] == 0 && obj['childrens'] == 0 && obj['parents'] > 0 && obj['parents-in-law'] == 0) {
|
||
// $('.radio-group .form-check').css('margin-right', '-60px');
|
||
// } else if (obj['self'] == 0 && obj['spouse'] == 0 && obj['childrens'] == 0 && obj['parents'] == 0 && obj['parents-in-law'] > 0) {
|
||
// $('.radio-group .form-check').css('margin-right', '-60px');
|
||
// } else if (obj['self'] > 0 && obj['spouse'] == 0 && obj['childrens'] > 0 && obj['parents'] == 0 && obj['parents-in-law'] == 0) {
|
||
// $('.radio-group .form-check').css('margin-right', '-110px');
|
||
// } else if (obj['self'] == 0 && obj['spouse'] == 0 && obj['childrens'] > 0 && obj['parents'] == 0 && obj['parents-in-law'] == 0) {
|
||
// $('.radio-group .form-check').css('margin-right', '-110px');
|
||
// } else if (obj['self'] > 0 && obj['spouse'] > 0 && obj['childrens'] == 0 && obj['parents'] > 0 && obj['parents-in-law'] > 0){
|
||
// $('.radio-group .form-check').css('margin-right', '-60px');
|
||
// } else if (obj['self'] > 0 && obj['spouse'] == 0 && obj['childrens'] == 0 && obj['parents'] > 0 && obj['parents-in-law'] > 0){
|
||
// $('.radio-group .form-check').css('margin-right', '-60px');
|
||
// } else {
|
||
// $('.radio-group .form-check').css('margin-right', '-60px');
|
||
// }
|
||
|
||
// if(policy_type == 1 || policy_type == 6 || policy_type == 7){
|
||
// $('.radio-group .form-check').css('margin-right', '-50px');
|
||
// }
|
||
|
||
}
|
||
|
||
function formatString(str)
|
||
{
|
||
return str.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
|
||
}
|
||
|
||
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', 'Warning');
|
||
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(unique_id = null)
|
||
{
|
||
console.log(unique_id)
|
||
console.log('checkPolicyTermsSI function called');
|
||
|
||
var id = $('#grid')[0];
|
||
var container = $('#grid_content_input');
|
||
|
||
var val = 0;
|
||
|
||
if (unique_id) {
|
||
id = $('#grid_'+unique_id)[0];
|
||
container = $('#grid_content_input_for_additional_'+unique_id);
|
||
}
|
||
|
||
console.log(id);
|
||
console.log(container);
|
||
|
||
var siInputs = $();
|
||
|
||
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 policy_terms_si = terms_si_amount_array;
|
||
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) {
|
||
return true;callback
|
||
} else {
|
||
return false;
|
||
}
|
||
|
||
}
|
||
|
||
//-----------------------------------------------------------------------------------------------------------
|
||
|
||
function appendNewTab(tabNameData = null, data = null)
|
||
{
|
||
console.log('appendNewTab function called');
|
||
console.log('appendNewTab function tabNameData', tabNameData);
|
||
console.log('appendNewTab function data', data);
|
||
|
||
let tabName = tabNameData;
|
||
|
||
if(tabNameData == null){
|
||
tabName = prompt("Enter rack rate name:");
|
||
}
|
||
|
||
const myTabs = document.getElementById('nav_pills');
|
||
const tabContent = document.getElementById('tab_content');
|
||
|
||
// Unique ID and name for the new tab
|
||
if (tabName) {
|
||
let tabId = tabName.replace(/\s+/g, "-").toLowerCase();
|
||
// Ensure the tab ID is unique
|
||
let uniqueId = tabId;
|
||
let counter = 1;
|
||
while (document.getElementById(uniqueId)) {
|
||
uniqueId = `${tabId}-${counter}`;
|
||
counter++;
|
||
}
|
||
tabId = uniqueId;
|
||
|
||
let newSpan = document.createElement('span');
|
||
newSpan.classList.add('d-none', 'd-sm-inline-block');
|
||
newSpan.setAttribute('id', `tabname_${tabId}`);
|
||
newSpan.textContent = tabName;
|
||
|
||
// Create tab link
|
||
let newTabLink = document.createElement('a');
|
||
newTabLink.classList.add('nav-link', 'nav-link', 'px-3', 'py-2');
|
||
newTabLink.setAttribute('data-toggle', 'tab');
|
||
newTabLink.setAttribute('href', `#${tabId}`);
|
||
// newTabLink.setAttribute('id', `link_${tabId}`);
|
||
// newTabLink.textContent = tabName;
|
||
newTabLink.appendChild(newSpan);
|
||
|
||
// Create tab list item
|
||
let newTabListItem = document.createElement('li');
|
||
newTabListItem.classList.add('nav-item');
|
||
newTabListItem.setAttribute('id', 'list_'+tabId);
|
||
newTabListItem.appendChild(newTabLink);
|
||
myTabs.appendChild(newTabListItem);
|
||
|
||
// Create tab pane
|
||
let newTabPane = document.createElement('div');
|
||
newTabPane.classList.add('tab-pane', 'fade');
|
||
newTabPane.setAttribute('id', tabId);
|
||
newTabPane.innerHTML = `
|
||
<form role="form" class="parsley-examples" method="post" id="GridForm_${tabId}"
|
||
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_${tabId}" value="`+client_policy_for_additional_rack_rate+`"/>
|
||
<input type="hidden" name="rack_rate_name" id="rack_rate_name_${tabId}" value="${tabName}">
|
||
<input type="hidden" id="grid_emp_count" />
|
||
<div class="form-group">
|
||
|
||
<div class="form-row" id="rac_rate_dropdown_${tabId}">
|
||
<div class="form-group col-md-4">
|
||
<label for="emp_code">Policy Premium Type<span
|
||
class="text-danger">*</span></label>
|
||
<select class="form-control" id="grid_${tabId}" name="policy_grid_id"
|
||
onchange="addGridHTML(this, false, false, false, '${tabId}')" required>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-6"
|
||
style="position: relative; left: 45px; display:none" id="premium_type_${tabId}">
|
||
<label for="css"> Premium Calculation </label>
|
||
<div style="display: flex; align-items: center;">
|
||
<input type="radio" id="individual_${tabId}" name="premium_type" value="2">
|
||
<label for="individual" style="position: relative;top: 5px;left: 5px;">
|
||
Individual </label>
|
||
<input type="radio" id="single_${tabId}" name="premium_type" value="1">
|
||
<label for="single" style="position: relative;top: 5px;left: 5px;"> Family Floater </label>
|
||
<input type="radio" id="single_and_individual_${tabId}" name="premium_type" value="3">
|
||
<label for="single" style="position: relative;top: 5px;left: 5px;"> Family Floater cum Individual </label>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-row" id="relationship_${tabId}" class="relationship" >
|
||
</div>
|
||
|
||
<a href="#" id="copyfromexcel_${tabId}" onclick="copyFromExcel(this, '${tabId}')">Copy from excel</a>
|
||
<hr>
|
||
|
||
<div class="form-row" id="grid_content_input_for_additional_${tabId}" style="display: true;">
|
||
</div>
|
||
|
||
|
||
<div class="form-row" id="grid_content_from_excel_${tabId}" style="display: none;">
|
||
<p>Paste excel data here: <a href="#" type="button" onclick="copyHeaders('${tabId}')">Copy Excel Headers</a></p>
|
||
<textarea class="form-control excel_textarea" id="copied_excel_data_${tabId}" name="copied_excel_data" style="width:100%;height:200px;" oninput="generateTable('${tabId}')"></textarea><br>
|
||
<hr>
|
||
<div class="excel_table_class" id="excel_table_${tabId}" style="display: none;"></div>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<div class="form-group text-right m-b-0" id="hide_smbt_btn_${tabId}">
|
||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="btnGridSubmit_2_${tabId}">Save</button>
|
||
<a class="btn btn-danger waves-effect waves-light mr-1" id="btnGridremove_2_${tabId}" onclick="removeTab(this, '${tabId}', '${tabName}')">Delete</a>
|
||
<a class="btn btn-secondary waves-effect waves-light mr-1" id="btnGridrename_${tabId}" onclick="renameRackRateTab(this, '${tabId}', '${tabName}')">Rename</a>
|
||
</div>
|
||
</form>`;
|
||
tabContent.appendChild(newTabPane);
|
||
|
||
applyStyles(tabId);
|
||
|
||
var policy_grid_id = null;
|
||
var additional_relationship = [];
|
||
var premium_type = null;
|
||
var si_or_bp_value = ''
|
||
if(data){
|
||
|
||
console.log('appendNewTab function first index data', data[0])
|
||
console.log('appendNewTab function first index data[0].policy_grid_id', data[0].policy_grid_id)
|
||
|
||
if (data[0].policy_grid_id == 4 || data[0].policy_grid_id == 6) {
|
||
|
||
appendFourthAndSixthRackRate(data[0], tabId);
|
||
policy_grid_id = data[0].policy_grid_id
|
||
additional_relationship = data[0].additional_relationship;
|
||
premium_type = data[0].premium_type;
|
||
|
||
data.shift(); //remove first index of the array
|
||
}
|
||
|
||
$.each(data, function(index, item) {
|
||
|
||
// console.log('appendNewTab function index', index)
|
||
policy_grid_id = item.policy_grid_id
|
||
additional_relationship = item.additional_relationship;
|
||
premium_type = item.premium_type;
|
||
|
||
appendGridtHtml(item.policy_grid_id, tabId, item);
|
||
});
|
||
|
||
$(`input[name="${policy_grid_id}_si[]"]`).each(function() {
|
||
$(this).trigger('keyup');
|
||
});
|
||
|
||
$(`input[name="${policy_grid_id}_premium[]"]`).each(function() {
|
||
$(this).trigger('keyup');
|
||
});
|
||
}
|
||
|
||
appendGridData(rack_rate_array, policy_grid_id, tabId);
|
||
hideShowPolicyPremium(policy_type_string, tabId);
|
||
createCheckboxes(family_floter_obj, additional_relationship, tabId);
|
||
hideShowSubmitButton(employee_count, tabId);
|
||
editPolicyPremiumCalculationSetValue(premium_type, tabId);
|
||
|
||
if(data == null){
|
||
$('#link_'+tabId).click();
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
function appendGridData(data, policy_grid_id_value = null, unique_id = null)
|
||
{
|
||
console.log('appendGridData function called');
|
||
console.log('appendGridData policy_grid_id_value', policy_grid_id_value)
|
||
console.log('appendGridData data', data)
|
||
|
||
var rack_rate_id = $('#grid');
|
||
|
||
if(unique_id){
|
||
rack_rate_id = $('#grid_'+unique_id)
|
||
}
|
||
|
||
rack_rate_id.empty();
|
||
|
||
rack_rate_id.append($('<option>', {
|
||
value: '',
|
||
text: 'Select Premium Type',
|
||
selected: true
|
||
}));
|
||
|
||
$.each(data, function(index, item) {
|
||
|
||
var option = $('<option>', {
|
||
value: item.id,
|
||
text:item.policy_grid_type,
|
||
'data-id' : item.ui_type
|
||
});
|
||
if (policy_grid_id_value == item.id) {
|
||
option.attr('selected', true);
|
||
}
|
||
rack_rate_id.append(option);
|
||
});
|
||
|
||
}
|
||
|
||
function hideShowPolicyPremium(policy_type_string, unique_id = null)
|
||
{
|
||
var premium_type = $('#premium_type');
|
||
var individual = $('#individual');
|
||
if(unique_id){
|
||
premium_type = $('#premium_type_' + unique_id);
|
||
individual = $('#individual_' + unique_id);
|
||
}
|
||
|
||
if (policy_type_string == 'GMC') {
|
||
premium_type.show();
|
||
individual.prop('checked', true)
|
||
} else {
|
||
premium_type.hide();
|
||
individual.prop('checked', true)
|
||
}
|
||
|
||
}
|
||
|
||
function hideShowSubmitButton(emp_count, unique_id = null)
|
||
{
|
||
var hide_smbt_btn = $("#hide_smbt_btn");
|
||
if(unique_id){
|
||
hide_smbt_btn = $("#hide_smbt_btn_"+unique_id);
|
||
}
|
||
|
||
if (emp_count > 0) {
|
||
hide_smbt_btn.hide();
|
||
} else {
|
||
hide_smbt_btn.show();
|
||
}
|
||
|
||
}
|
||
|
||
function removeTab(input, tabID, tabName)
|
||
{
|
||
var client_policy_id = $('#client_policy_id_'+tabID).val();
|
||
console.log('removeTab input', input)
|
||
console.log('removeTab tabID', tabID)
|
||
console.log('removeTab tabName', tabName)
|
||
console.log('removeTab client_policy_id', client_policy_id)
|
||
|
||
|
||
Swal.fire({
|
||
title: "Are you sure?",
|
||
text: "Do you want to remove this Rack Rate.",
|
||
icon: "info",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#3085d6",
|
||
confirmButtonText: "Yes",
|
||
}).then((result) => {
|
||
|
||
if (result.isConfirmed) {
|
||
|
||
$('#'+tabID).remove();
|
||
$('#list_'+tabID).remove();
|
||
$('#rack_rate_one').click();
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
var form_action = '<?= base_url("util/remove_rack_rate/") ?>' + tabName + '/' + client_policy_id;
|
||
console.log(form_action)
|
||
$.ajax({
|
||
url: form_action,
|
||
type: "GET",
|
||
dataType: 'json',
|
||
processData: false,
|
||
contentType: false,
|
||
success: function(res) {
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
console.log(res)
|
||
|
||
if(res){
|
||
if (res.status == true) {
|
||
Swal.fire({
|
||
title: "Success",
|
||
text: res.message,
|
||
icon: "success"
|
||
});
|
||
// toastr.success('Policy removed successfully.', 'Success');
|
||
} else {
|
||
if(res.rr_count > 0){
|
||
Swal.fire({
|
||
title: "warning!",
|
||
text: res.message,
|
||
icon: "warning"
|
||
});
|
||
}else{
|
||
Swal.fire({
|
||
title: "Success",
|
||
text: 'Rack Rate removed successfully',
|
||
icon: "success"
|
||
});
|
||
}
|
||
|
||
// toastr.warning('Failed to remove policy', 'Warning');
|
||
}
|
||
}
|
||
},
|
||
error: function (xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
console.log('Something Wrong!', 'Warning');
|
||
}
|
||
});
|
||
}
|
||
|
||
});
|
||
}
|
||
|
||
function copyFromExcel(input, unique_id = null)
|
||
{
|
||
|
||
console.log('called');
|
||
console.log('input', input);
|
||
|
||
var grid_content_input = $('#grid_content_input');
|
||
var grid_content_from_excel = $('#grid_content_from_excel');
|
||
|
||
if(unique_id){
|
||
grid_content_input = $('#grid_content_input_for_additional_'+unique_id);
|
||
grid_content_from_excel = $('#grid_content_from_excel_'+unique_id);
|
||
}
|
||
|
||
if ($(input).text() == "Copy from excel") {
|
||
$(input).text("Manual entry");
|
||
|
||
} else {
|
||
$(input).text("Copy from excel");
|
||
}
|
||
|
||
grid_content_input.toggle();
|
||
grid_content_from_excel.toggle();
|
||
|
||
}
|
||
|
||
function renameRackRateTab(input, unique_id = null, tabName = null)
|
||
{
|
||
|
||
var client_policy_id = $('#client_policy_id').val();
|
||
|
||
var tabid = 'tabname' ;
|
||
if(unique_id){
|
||
tabid = 'tabname_' + unique_id
|
||
client_policy_id = $('#client_policy_id_'+unique_id).val();
|
||
}
|
||
|
||
if(tabName == null){
|
||
tabName = $('#rack_rate_name').val();
|
||
}
|
||
|
||
var newTabName = prompt('Enter rack rate name:')
|
||
|
||
|
||
console.log('renameRackRateTab function input', input);
|
||
console.log('renameRackRateTab function unique_id', unique_id);
|
||
console.log('renameRackRateTab function tabName', tabName);
|
||
console.log('renameRackRateTab function client_policy_id', client_policy_id);
|
||
console.log('renameRackRateTab function tabid', tabid);
|
||
console.log('renameRackRateTab function newTabName',newTabName);
|
||
|
||
if(newTabName){
|
||
|
||
$('#'+tabid).text(newTabName);
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
var form_action = '<?= base_url("util/rename_rack_rate_tab/") ?>' + tabName + '/'+ newTabName + '/' + client_policy_id;
|
||
console.log(form_action)
|
||
$.ajax({
|
||
url: form_action,
|
||
type: "GET",
|
||
dataType: 'json',
|
||
processData: false,
|
||
contentType: false,
|
||
success: function(res) {
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
console.log(res)
|
||
|
||
if(res){
|
||
if (res.status == true) {
|
||
Swal.fire({
|
||
title: "Success",
|
||
text: res.message,
|
||
icon: "success"
|
||
});
|
||
|
||
$('#rack_rate_name').val(newTabName);
|
||
|
||
// toastr.success('Policy removed successfully.', 'Success');
|
||
} else {
|
||
if(res.rr_count > 0){
|
||
Swal.fire({
|
||
title: "warning!",
|
||
text: res.message,
|
||
icon: "warning"
|
||
});
|
||
}else{
|
||
Swal.fire({
|
||
title: "Success",
|
||
text: 'Rack Rate renamed successfully',
|
||
icon: "success"
|
||
});
|
||
|
||
$('#rack_rate_name').val(newTabName);
|
||
|
||
}
|
||
|
||
// toastr.warning('Failed to remove policy', 'Warning');
|
||
}
|
||
}
|
||
},
|
||
error: function (xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
console.log('Something Wrong!', 'Warning');
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
function groupByRackRateName(data)
|
||
{
|
||
var acc = {};
|
||
|
||
$.each(data, function(index, item) {
|
||
var rackRateName = item.rack_rate_name;
|
||
|
||
if (!acc[rackRateName]) {
|
||
acc[rackRateName] = [];
|
||
}
|
||
|
||
acc[rackRateName].push(item);
|
||
});
|
||
|
||
return acc;
|
||
}
|
||
|
||
function editPolicyPremiumCalculationSetValue(premium_type, unique_id = null)
|
||
{
|
||
console.log('editPolicyPremiumCalculationSetValue unique id', unique_id);
|
||
console.log('editPolicyPremiumCalculationSetValue premium_type', premium_type);
|
||
|
||
if(unique_id){
|
||
|
||
// console.log('editPolicyPremiumCalculationSetValue step 1');
|
||
if (premium_type === '2') {
|
||
// console.log('editPolicyPremiumCalculationSetValue step 2');
|
||
$('#single_'+unique_id).prop('checked', false);
|
||
$('#individual_'+unique_id).prop('checked', true);
|
||
$('#single_and_individual_'+unique_id).prop('checked', false);
|
||
|
||
} else if (premium_type === '1') {
|
||
// console.log('editPolicyPremiumCalculationSetValue step 3');
|
||
$('#single_'+unique_id).prop('checked', true);
|
||
$('#individual_'+unique_id).prop('checked', false);
|
||
$('#single_and_individual_'+unique_id).prop('checked', false);
|
||
|
||
}else if (premium_type === '3') {
|
||
// console.log('editPolicyPremiumCalculationSetValue step 3');
|
||
$('#single_'+unique_id).prop('checked', false);
|
||
$('#individual_'+unique_id).prop('checked', false);
|
||
$('#single_and_individual_'+unique_id).prop('checked', true);
|
||
|
||
} else {
|
||
// console.log('editPolicyPremiumCalculationSetValue step 4');
|
||
$('#single_'+unique_id).prop('checked', false);
|
||
$('#individual_'+unique_id).prop('checked', true);
|
||
$('#single_and_individual_'+unique_id).prop('checked', false);
|
||
|
||
}
|
||
}else{
|
||
|
||
// console.log('editPolicyPremiumCalculationSetValue step 5');
|
||
if (premium_type === '2') {
|
||
// console.log('editPolicyPremiumCalculationSetValue step 6');
|
||
$('#single').prop('checked', false);
|
||
$('#individual').prop('checked', true);
|
||
$('#single_and_individual').prop('checked', false);
|
||
|
||
} else if (premium_type === '1') {
|
||
// console.log('editPolicyPremiumCalculationSetValue step 7');
|
||
$('#single').prop('checked', true);
|
||
$('#individual').prop('checked', false);
|
||
$('#single_and_individual').prop('checked', false);
|
||
|
||
}else if (premium_type === '3') {
|
||
// console.log('editPolicyPremiumCalculationSetValue step 7');
|
||
$('#single').prop('checked', false);
|
||
$('#individual').prop('checked', false);
|
||
$('#single_and_individual').prop('checked', true);
|
||
|
||
} else {
|
||
// console.log('editPolicyPremiumCalculationSetValue step 8');
|
||
$('#single').prop('checked', false);
|
||
$('#individual').prop('checked', true);
|
||
$('#single_and_individual').prop('checked', false);
|
||
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
function checkFamiliFloatersKeysDuplicate(rarc_rate_json_array, formObject, unique_id = null)
|
||
{
|
||
|
||
console.log('unique_id', unique_id);
|
||
|
||
console.log('rarc_rate_json_array', rarc_rate_json_array);
|
||
console.log('formObject', formObject);
|
||
|
||
console.log('rarc_rate_json_array length', rarc_rate_json_array.length);
|
||
console.log('formObject length', formObject.length);
|
||
|
||
console.log('formObject type', typeof formObject);
|
||
console.log('rarc_rate_json_array type', typeof rarc_rate_json_array);
|
||
|
||
var rack_rate_name = $('#rack_rate_name').val();
|
||
|
||
var grid_id = $('#grid').val();
|
||
|
||
if(unique_id != null && unique_id != ''){
|
||
rack_rate_name = $('#rack_rate_name_'+unique_id).val()
|
||
grid_id = $('#grid_'+unique_id).val();
|
||
}
|
||
|
||
console.log('rack rate name', rack_rate_name)
|
||
console.log('grid_id', grid_id)
|
||
|
||
if(grid_id != '1' || grid_id != '2'){
|
||
|
||
return false;
|
||
|
||
}
|
||
|
||
let isEqualto = false;
|
||
|
||
if (rarc_rate_json_array.length > 0) {
|
||
$.each(rarc_rate_json_array, function(index, item) {
|
||
|
||
let parsedItem;
|
||
|
||
if (typeof item === 'string') {
|
||
try {
|
||
// Attempt to parse the string as JSON
|
||
parsedItem = JSON.parse(item);
|
||
} catch (error) {
|
||
console.error('Invalid JSON string:', error);
|
||
parsedItem = null; // Handle as needed, or keep null
|
||
}
|
||
} else if (typeof item === 'object' && item !== null) {
|
||
// If it's already an object, no need to parse
|
||
parsedItem = item;
|
||
} else {
|
||
// Handle other types (e.g., undefined, null, numbers, etc.)
|
||
console.error('Item is not a valid JSON string or object:', item);
|
||
parsedItem = null; // Handle as needed, or keep null
|
||
}
|
||
|
||
console.log('Parsed item:', parsedItem);
|
||
|
||
let rackRateName = Object.keys(parsedItem)[0]; // Assuming single key per item
|
||
let rrItem = parsedItem[rackRateName];
|
||
|
||
// console.log('rarc_rate_json_array item', item);
|
||
// console.log('rarc_rate_json_array parsedItem', parsedItem);
|
||
// console.log('rackRateName', rackRateName);
|
||
// console.log('formObject', formObject);
|
||
|
||
// console.log('formObject type', typeof formObject);
|
||
// console.log('rarc_rate_json_array item type', typeof item);
|
||
// console.log('rarc_rate_json_array parsedItem type', typeof parsedItem);
|
||
|
||
// console.log('self', 'formobject : ', formObject['self'], 'rr_item : ', rrItem['self']);
|
||
// console.log('spouse', 'formobject : ', formObject['spouse'], 'rr_item : ', rrItem['spouse']);
|
||
// console.log('childrens', 'formobject : ', formObject['childrens'], 'rr_item : ', rrItem['childrens']);
|
||
// console.log('parents', 'formobject : ', formObject['parents'], 'rr_item : ', rrItem['parents']);
|
||
// console.log('parents-in-law', 'formobject : ', formObject['parents-in-law'], 'rr_item : ', rrItem['parents-in-law']);
|
||
|
||
if(rack_rate_name != rackRateName){
|
||
|
||
if (formObject['self'] == rrItem['self'] &&
|
||
formObject['spouse'] == rrItem['spouse'] &&
|
||
formObject['childrens'] == rrItem['childrens'] &&
|
||
formObject['parents'] == rrItem['parents'] &&
|
||
formObject['parents-in-law'] == rrItem['parents-in-law']) {
|
||
console.log('true');
|
||
isEqualto = true;
|
||
return false; // breaks out of the loop
|
||
} else {
|
||
console.log('false');
|
||
isEqualto = false;
|
||
}
|
||
}else{
|
||
console.log('false');
|
||
isEqualto = false;
|
||
}
|
||
});
|
||
}
|
||
|
||
return isEqualto;
|
||
}
|
||
|
||
function appendFourthAndSixthRackRate(data = null, uniqueId = null)
|
||
{
|
||
console.log('appendFourthAndSixthRackRate function called');
|
||
console.log('appendFourthAndSixthRackRate function uniqueId', uniqueId);
|
||
console.log('appendFourthAndSixthRackRate function data', data);
|
||
|
||
|
||
grid_html = `
|
||
<div class="form-row" id="grid_4">
|
||
<div class="form-group col-md-4">
|
||
<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-4 unitDiv">
|
||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}" type="text" class="form-control" placeholder="Enter Unit" name="4_unit[]" id="4_unit" required>
|
||
</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="Age" name="4_age_from[]" id="4_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="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, '${uniqueId}')">+</button>
|
||
</div>
|
||
</div>
|
||
</div>`;
|
||
|
||
grid_container_id = 'grid_content_input_for_additional_' + uniqueId;
|
||
console.log('appendFourthAndSixthRackRate function', grid_container_id);
|
||
grid_container = document.getElementById(grid_container_id);
|
||
console.log('appendFourthAndSixthRackRate function', grid_container);
|
||
grid_container.insertAdjacentHTML('beforeend', grid_html);
|
||
|
||
if(unit_length == 1 || unit_length == 0){
|
||
// $('.unitDiv').hide();
|
||
// $('.unitDiv').find('input').removeAttr('required');
|
||
setTimeout(() => {
|
||
$('.unitDiv').hide();
|
||
$('.unitDiv input').removeAttr('required');
|
||
}, 1000);
|
||
}else{
|
||
$('.unitDiv').show();
|
||
$('.unitDiv').find('input').attr('required', true);
|
||
}
|
||
|
||
if(unit_length == 1){
|
||
toAddUnitInManuall(uniqueId, branch_units[0], 'appendFourthAndSixthRackRate')
|
||
}
|
||
}
|
||
|
||
function checkValideUnits(unique_id = null)
|
||
{
|
||
console.log('checkValideUnits unique_id', unique_id)
|
||
|
||
var id = $('#grid')[0];
|
||
var container = $('#grid_content_input');
|
||
|
||
if (unique_id) {
|
||
id = $('#grid_'+unique_id)[0];
|
||
container = $('#grid_content_input_for_additional_'+unique_id);
|
||
}
|
||
|
||
console.log('checkValideUnits id', id.value);
|
||
console.log('checkValideUnits container', container);
|
||
|
||
if (id.value === '3') {
|
||
|
||
var units = container.find('input[name="3_unit[]"]');
|
||
var unitValues = [];
|
||
|
||
units.each(function() {
|
||
var value = $(this).val();
|
||
unitValues.push(value);
|
||
});
|
||
|
||
console.log('checkValideUnits function branch_units', branch_units)
|
||
console.log('checkValideUnits function unitValues', unitValues)
|
||
|
||
var uncommonValues = [];
|
||
$.each(unitValues, function(index, value) {
|
||
if ($.inArray(value, branch_units) === -1) {
|
||
uncommonValues.push(value);
|
||
}
|
||
});
|
||
|
||
console.log('checkValideUnits function uncommonValues', uncommonValues);
|
||
|
||
if (uncommonValues.length > 0) {
|
||
toastr.warning('Given unit does not exist in the branch!', 'Warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
} else if (id.value === '4') {
|
||
|
||
var units = container.find('input[name="4_unit[]"]');
|
||
var unitValues = [];
|
||
|
||
units.each(function() {
|
||
var value = $(this).val();
|
||
unitValues.push(value);
|
||
});
|
||
|
||
console.log('checkValideUnits function branch_units', branch_units)
|
||
console.log('checkValideUnits function unitValues', unitValues)
|
||
|
||
var uncommonValues = [];
|
||
$.each(unitValues, function(index, value) {
|
||
if ($.inArray(value, branch_units) === -1) {
|
||
uncommonValues.push(value);
|
||
}
|
||
});
|
||
|
||
console.log('checkValideUnits function uncommonValues', uncommonValues);
|
||
|
||
if (uncommonValues.length > 0) {
|
||
toastr.warning('Given unit does not exist in the branch!', 'Warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
|
||
} else if (id.value === '2' || id.value === '9') {
|
||
|
||
var units = container.find('input[name="gpa_unit29[]"]');
|
||
var unitValues = [];
|
||
|
||
units.each(function() {
|
||
var value = $(this).val();
|
||
unitValues.push(value);
|
||
});
|
||
|
||
console.log('checkValideUnits function branch_units', branch_units)
|
||
console.log('checkValideUnits function unitValues', unitValues)
|
||
|
||
var uncommonValues = [];
|
||
$.each(unitValues, function(index, value) {
|
||
if ($.inArray(value, branch_units) === -1) {
|
||
uncommonValues.push(value);
|
||
}
|
||
});
|
||
|
||
console.log('checkValideUnits function uncommonValues', uncommonValues);
|
||
|
||
if (uncommonValues.length > 0) {
|
||
toastr.warning('Given unit does not exist in the branch!', 'Warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
|
||
} else if (id.value === '5') {
|
||
|
||
var units = container.find('input[name="5_unit[]"]');
|
||
var unitValues = [];
|
||
|
||
units.each(function() {
|
||
var value = $(this).val();
|
||
unitValues.push(value);
|
||
});
|
||
|
||
console.log('checkValideUnits function branch_units', branch_units)
|
||
console.log('checkValideUnits function unitValues', unitValues)
|
||
|
||
var uncommonValues = [];
|
||
$.each(unitValues, function(index, value) {
|
||
if ($.inArray(value, branch_units) === -1) {
|
||
uncommonValues.push(value);
|
||
}
|
||
});
|
||
|
||
console.log('checkValideUnits function uncommonValues', uncommonValues);
|
||
|
||
if (uncommonValues.length > 0) {
|
||
toastr.warning('Given unit does not exist in the branch!', 'Warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
|
||
|
||
} else if (id.value === '6') {
|
||
|
||
var units = container.find('input[name="6_unit[]"]');
|
||
var unitValues = [];
|
||
|
||
units.each(function() {
|
||
var value = $(this).val();
|
||
unitValues.push(value);
|
||
});
|
||
|
||
console.log('checkValideUnits function branch_units', branch_units)
|
||
console.log('checkValideUnits function unitValues', unitValues)
|
||
|
||
var uncommonValues = [];
|
||
$.each(unitValues, function(index, value) {
|
||
if ($.inArray(value, branch_units) === -1) {
|
||
uncommonValues.push(value);
|
||
}
|
||
});
|
||
|
||
console.log('checkValideUnits function uncommonValues', uncommonValues);
|
||
|
||
if (uncommonValues.length > 0) {
|
||
toastr.warning('Given unit does not exist in the branch!', 'Warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
|
||
} else if (id.value === '7') {
|
||
|
||
var units = container.find('input[name="7_unit[]"]');
|
||
var unitValues = [];
|
||
|
||
units.each(function() {
|
||
var value = $(this).val();
|
||
unitValues.push(value);
|
||
});
|
||
|
||
console.log('checkValideUnits function branch_units', branch_units);
|
||
console.log('checkValideUnits function unitValues', unitValues);
|
||
|
||
var uncommonValues = [];
|
||
$.each(unitValues, function(index, value) {
|
||
if ($.inArray(value, branch_units) === -1) {
|
||
uncommonValues.push(value);
|
||
}
|
||
});
|
||
|
||
console.log('checkValideUnits function uncommonValues', uncommonValues);
|
||
|
||
if (uncommonValues.length > 0) {
|
||
toastr.warning('Given unit does not exist in the branch!', 'Warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
|
||
} else if (id.value === '10') {
|
||
|
||
var units = container.find('input[name="10_unit[]"]');
|
||
var unitValues = [];
|
||
|
||
units.each(function() {
|
||
var value = $(this).val();
|
||
unitValues.push(value);
|
||
});
|
||
|
||
console.log('checkValideUnits function branch_units', branch_units)
|
||
console.log('checkValideUnits function unitValues', unitValues)
|
||
|
||
var uncommonValues = [];
|
||
$.each(unitValues, function(index, value) {
|
||
if ($.inArray(value, branch_units) === -1) {
|
||
uncommonValues.push(value);
|
||
}
|
||
});
|
||
|
||
console.log('checkValideUnits function uncommonValues', uncommonValues);
|
||
|
||
if (uncommonValues.length > 0) {
|
||
toastr.warning('Given unit does not exist in the branch!', 'Warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
|
||
} else if (id.value === '8') {
|
||
|
||
var units = container.find('input[name="8_unit[]"]');
|
||
var unitValues = [];
|
||
|
||
units.each(function() {
|
||
var value = $(this).val();
|
||
unitValues.push(value);
|
||
});
|
||
|
||
console.log('checkValideUnits function branch_units', branch_units)
|
||
console.log('checkValideUnits function unitValues', unitValues)
|
||
|
||
var uncommonValues = [];
|
||
$.each(unitValues, function(index, value) {
|
||
if ($.inArray(value, branch_units) === -1) {
|
||
uncommonValues.push(value);
|
||
}
|
||
});
|
||
|
||
console.log('checkValideUnits function uncommonValues', uncommonValues);
|
||
|
||
if (uncommonValues.length > 0) {
|
||
toastr.warning('Given unit does not exist in the branch!', 'Warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
|
||
} else if (id.value === '11') {
|
||
|
||
var units = container.find('input[name="11_unit[]"]');
|
||
var unitValues = [];
|
||
|
||
units.each(function() {
|
||
var value = $(this).val();
|
||
unitValues.push(value);
|
||
});
|
||
|
||
console.log('checkValideUnits function branch_units', branch_units)
|
||
console.log('checkValideUnits function unitValues', unitValues)
|
||
|
||
var uncommonValues = [];
|
||
$.each(unitValues, function(index, value) {
|
||
if ($.inArray(value, branch_units) === -1) {
|
||
uncommonValues.push(value);
|
||
}
|
||
});
|
||
|
||
console.log('checkValideUnits function uncommonValues', uncommonValues);
|
||
|
||
if (uncommonValues.length > 0) {
|
||
toastr.warning('Given unit does not exist in the branch!', 'Warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
|
||
} else if (id.value === '12') {
|
||
|
||
var units = container.find('input[name="12_unit[]"]');
|
||
var unitValues = [];
|
||
|
||
units.each(function() {
|
||
var value = $(this).val();
|
||
unitValues.push(value);
|
||
});
|
||
|
||
console.log('checkValideUnits function branch_units', branch_units)
|
||
console.log('checkValideUnits function unitValues', unitValues)
|
||
|
||
var uncommonValues = [];
|
||
$.each(unitValues, function(index, value) {
|
||
if ($.inArray(value, branch_units) === -1) {
|
||
uncommonValues.push(value);
|
||
}
|
||
});
|
||
|
||
console.log('checkValideUnits function uncommonValues', uncommonValues);
|
||
|
||
if (uncommonValues.length > 0) {
|
||
toastr.warning('Given unit does not exist in the branch!', 'Warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
|
||
} else if (id.value === '13') {
|
||
|
||
var units = container.find('input[name="13_unit[]"]');
|
||
var unitValues = [];
|
||
|
||
units.each(function() {
|
||
var value = $(this).val();
|
||
unitValues.push(value);
|
||
});
|
||
|
||
console.log('checkValideUnits function branch_units', branch_units)
|
||
console.log('checkValideUnits function unitValues', unitValues)
|
||
|
||
var uncommonValues = [];
|
||
$.each(unitValues, function(index, value) {
|
||
if ($.inArray(value, branch_units) === -1) {
|
||
uncommonValues.push(value);
|
||
}
|
||
});
|
||
|
||
console.log('checkValideUnits function uncommonValues', uncommonValues);
|
||
|
||
if (uncommonValues.length > 0) {
|
||
toastr.warning('Given unit does not exist in the branch!', 'Warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
|
||
} else if (id.value === '1') {
|
||
|
||
var selectedValue = $('#si_or_bp').val();
|
||
console.log('checkValideUnits selectedValue', selectedValue);
|
||
if (selectedValue == 1) {
|
||
|
||
var units = container.find('input[name="gpa_unit_1[]"]');
|
||
var unitValues = [];
|
||
|
||
units.each(function() {
|
||
unitValues.push($(this).val());
|
||
});
|
||
|
||
console.log('checkValideUnits function branch_units', branch_units)
|
||
console.log('checkValideUnits function unitValues', unitValues)
|
||
|
||
var uncommonValues = [];
|
||
$.each(unitValues, function(index, value) {
|
||
if ($.inArray(value, branch_units) === -1) {
|
||
uncommonValues.push(value);
|
||
}
|
||
});
|
||
|
||
console.log('checkValideUnits function uncommonValues', uncommonValues);
|
||
|
||
if (uncommonValues.length > 0) {
|
||
toastr.warning('Given unit does not exist in the branch!', 'Warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
|
||
} else if (selectedValue == 3) {
|
||
|
||
var units = container.find('input[name="gpa_unit_3[]"]');
|
||
var unitValues = [];
|
||
|
||
units.each(function() {
|
||
unitValues.push($(this).val());
|
||
});
|
||
|
||
console.log('checkValideUnits function branch_units', branch_units)
|
||
console.log('checkValideUnits function unitValues', unitValues)
|
||
|
||
var uncommonValues = [];
|
||
$.each(unitValues, function(index, value) {
|
||
if ($.inArray(value, branch_units) === -1) {
|
||
uncommonValues.push(value);
|
||
}
|
||
});
|
||
|
||
console.log('checkValideUnits function uncommonValues', uncommonValues);
|
||
|
||
if (uncommonValues.length > 0) {
|
||
toastr.warning('Given unit does not exist in the branch!', 'Warning');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
function applyStyles(tabId) {
|
||
var dynamicId = `grid_content_input_for_additional_${tabId}`;
|
||
var element = document.getElementById(dynamicId);
|
||
|
||
if (element) {
|
||
element.style.overflowY = 'auto';
|
||
element.style.overflowX = 'hidden';
|
||
element.style.maxHeight = '350px';
|
||
|
||
var style = document.createElement('style');
|
||
style.innerHTML = `
|
||
#${dynamicId}::-webkit-scrollbar {
|
||
width: 8px;
|
||
}
|
||
#${dynamicId}::-webkit-scrollbar-thumb {
|
||
background-color: #888;
|
||
border-radius: 4px;
|
||
}
|
||
#${dynamicId}::-webkit-scrollbar-thumb:hover {
|
||
background-color: #555;
|
||
}
|
||
#${dynamicId}::-webkit-scrollbar-track {
|
||
background-color: #f1f1f1;
|
||
}
|
||
`;
|
||
document.head.appendChild(style);
|
||
}
|
||
}
|
||
|
||
function toAddUnitInManuall(unique_id = null, branch_unit = '', whichFunction) {
|
||
|
||
console.log('toAddUnitInManuall unique_id', unique_id)
|
||
console.log('toAddUnitInManuall unique_id', typeof unique_id)
|
||
console.log('toAddUnitInManuall whichFunction', whichFunction)
|
||
|
||
var id = $('#grid').val();
|
||
console.log(id);
|
||
var container = $('#grid_content_input');
|
||
|
||
if (unique_id !== 'null' && unique_id !== null && unique_id !== false && unique_id !== 'false') {
|
||
id = $('#grid_'+unique_id).val();
|
||
console.log(id);
|
||
container = $('#grid_content_input_for_additional_'+unique_id);
|
||
}
|
||
|
||
console.log('checkValideUnits id', id);
|
||
console.log('checkValideUnits container', container);
|
||
|
||
if (id === '3') {
|
||
|
||
var units = container.find('input[name="3_unit[]"]');
|
||
var unitValues = [];
|
||
|
||
units.each(function() {
|
||
var value = $(this).val(branch_unit);
|
||
});
|
||
|
||
} else if (id === '4') {
|
||
|
||
var units = container.find('input[name="4_unit[]"]');
|
||
var unitValues = [];
|
||
|
||
units.each(function() {
|
||
var value = $(this).val(branch_unit);
|
||
});
|
||
|
||
} else if (id === '2' || id === '9') {
|
||
|
||
var units = container.find('input[name="gpa_unit29[]"]');
|
||
|
||
units.each(function() {
|
||
var value = $(this).val(branch_unit);
|
||
});
|
||
|
||
} else if (id === '5') {
|
||
|
||
var units = container.find('input[name="5_unit[]"]');
|
||
|
||
units.each(function() {
|
||
var value = $(this).val(branch_unit);
|
||
});
|
||
|
||
} else if (id === '6') {
|
||
|
||
var units = container.find('input[name="6_unit[]"]');
|
||
|
||
units.each(function() {
|
||
var value = $(this).val(branch_unit);
|
||
});
|
||
|
||
} else if (id === '7') {
|
||
|
||
var units = container.find('input[name="7_unit[]"]');
|
||
|
||
units.each(function() {
|
||
var value = $(this).val(branch_unit);
|
||
});
|
||
|
||
} else if (id === '10') {
|
||
|
||
var units = container.find('input[name="10_unit[]"]');
|
||
|
||
units.each(function() {
|
||
var value = $(this).val(branch_unit);
|
||
});
|
||
|
||
} else if (id === '8') {
|
||
|
||
var units = container.find('input[name="8_unit[]"]');
|
||
|
||
units.each(function() {
|
||
var value = $(this).val(branch_unit);
|
||
});
|
||
|
||
} else if (id === '11') {
|
||
|
||
var units = container.find('input[name="11_unit[]"]');
|
||
|
||
units.each(function() {
|
||
var value = $(this).val(branch_unit);
|
||
});
|
||
|
||
} else if (id === '12') {
|
||
|
||
var units = container.find('input[name="12_unit[]"]');
|
||
|
||
units.each(function() {
|
||
var value = $(this).val(branch_unit);
|
||
});
|
||
|
||
} else if (id === '13') {
|
||
|
||
var units = container.find('input[name="13_unit[]"]');
|
||
|
||
units.each(function() {
|
||
var value = $(this).val(branch_unit);
|
||
});
|
||
|
||
} else if (id === '1') {
|
||
|
||
console.log('checkValideUnits id', id);
|
||
|
||
var selectedValue = $('#si_or_bp').val();
|
||
if (selectedValue == 1) {
|
||
|
||
console.log('checkValideUnits id 1', id);
|
||
var units = container.find('input[name="gpa_unit_1[]"]');
|
||
|
||
units.each(function() {
|
||
$(this).val(branch_unit);
|
||
});
|
||
|
||
} else if (selectedValue == 3) {
|
||
|
||
console.log('checkValideUnits id 3', id);
|
||
var units = container.find('input[name="gpa_unit_3[]"]');
|
||
|
||
units.each(function() {
|
||
$(this).val(branch_unit);
|
||
});
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
</script>
|