nhance-enrollment/app/Views/other_policy_terms.php

1103 lines
49 KiB
PHP
Executable File

<style>
.underline-input {
border: none;
border-bottom: 1px solid #6c757d;
outline: none;
padding: 2px 6px;
font-size: 15px;
background: transparent;
}
#OtherPolicyTermsForm .policy-term-main-label {
width: auto !important;
min-width: 0;
max-width: none;
height: auto;
padding-top: 8px;
margin-bottom: 0;
font-weight: 600;
}
#OtherPolicyTermsForm .policy-72-sum-input-group.input-group {
width: 100% !important;
max-width: 440px;
}
#OtherPolicyTermsForm #familyFloaterDiv_others .form-check-inline .form-check-input {
margin-right: 4px;
}
#OtherPolicyTermsForm #familyFloaterDiv_others .form-check-inline .form-check-label {
margin-right: 14px;
}
.btn-si-add-teal {
background-color: #00a8b5;
border: 1px solid #00a8b5;
color: #fff;
font-size: 1.35rem;
line-height: 1;
padding: 0.4rem 0.85rem;
border-radius: 0 4px 4px 0;
}
.btn-si-add-teal:hover {
background-color: #008e99;
border-color: #008e99;
color: #fff;
}
.policy-72-family-grid {
padding-top: 4px;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
}
.policy-72-ff-table {
width: 100%;
min-width: 860px;
table-layout: auto;
}
.policy-72-ff-table td {
vertical-align: top;
padding: 3px 6px;
}
.policy-72-ff-table .ff-age-wrap {
display: flex;
align-items: center;
gap: 6px;
}
.policy-72-ff-table .ff-elders-wrap {
display: flex;
align-items: center;
gap: 8px;
}
.policy-72-ff-table .ff-pay-wrap {
display: inline-flex;
align-items: center;
gap: 6px;
}
.policy-72-other-members-age-row {
display: none;
}
.policy-72-other-members-age-row.policy-72-other-ages-open {
display: table-row;
}
.policy-72-ff-table .ff-field-label {
white-space: nowrap;
font-size: 0.9rem;
color: #212529;
}
.policy-72-ff-table .ff-pay-wrap .ff-field-label {
white-space: nowrap;
font-size: 12px;
line-height: 1.2;
}
.policy-72-ff-table .ff-age-input {
width: 68px;
min-width: 48px;
}
.policy-72-ff-table .ff-elders-count-input {
width: 64px;
background: #d3d3d3;
}
.policy-72-ff-table .ff-pay-label-col .ff-field-label {
display: inline-block;
margin-right: 4px;
}
.policy-72-ff-table .ff-pay-check-col .form-check-input {
margin-left: 0;
}
.policy-72-ff-table .ff-pay-label-top,
.policy-72-ff-table .ff-pay-check-top {
vertical-align: top !important;
padding-top: 3px;
}
.policy-72-ff-table .ff-pay-check-top .form-check-input {
margin-top: 2px !important;
}
.button-like {
display: inline-block;
padding: 8px 15px;
background-color: #02a8b5;
color: white;
text-decoration: none;
border-radius: 2px;
cursor: pointer;
margin-right: -85px;
}
.radiobuttondiv {
margin-left: 32px;
}
.form-control-client-policy-master {
width: 62% !important;
margin-left: 30px;
margin-top: 3px
}
/* .form-group.col-md-6 */
.form-group-client-policy-master {
display: -webkit-box;
max-width: 100% !important;
/* border:1px solid; */
/* background-color: #0001; */
}
.form-group-client-policy-masters {
display: -webkit-box;
max-width: 100% !important;
}
.flex-container {
display: block;
/* flex-wrap: wrap; */
/* align-items: center; Align items vertically center */
}
.flex-container>div {
flex: 1;
/* Each div takes equal space */
}
label {
padding-top: 7px;
width: 400px;
/* background-color: #0001; */
height: 36px;
/* text-align: center; */
}
.jodit-status-bar {
display: none;
}
.input-group {
width: 64.5% !important;
}
.input-group-append-client-policy-master {
margin-top: 3px;
}
.jodit-wysiwyg {
margin-bottom: 162px;
}
.form-control-client-policy-masters {
margin-left: 30px;
width: 689px;
}
</style>
<div id="OtherPolicyTermsForm" style="display:none">
<span id="otherPolicyTermsClose"
style="float: right;font-size: 26px;color: red;margin-top: -42px;margin-left: 3px;margin-right: 7px;">x</span>
<h5><label for="gpaTerms" style="margin-bottom: 20px;">Policy Terms <span
id="nameOfThePolicyOnOther"></span></label>
</h5>
<form role="form" class="parsley-examples" method="post" id="otherPolicyTerms" 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="other_client_policy_id" />
<input type="hidden" name="policy_id" id="gpa_policy_id" />
<input type="hidden" id="emp_count" />
<div id="sumInsuredDiv" class="row align-items-start mb-3" style="display:none;">
<div class="col-md-4 col-lg-3">
<label for="sum_insured_others_72" class="form-label policy-term-main-label">Sum Insured</label>
</div>
<div class="col-md-8 col-lg-7">
<div class="input-group policy-72-sum-input-group">
<input type="text" name="sum_insureds" id="sum_insured_others_72" class="form-control" style="border-radius: 4px 0 0 4px;" onkeypress="return onlyNumbers(event)" onkeyup=" formatNumber(this); si_keup_num_to_word2(this)">
<button type="button" class="btn btn-si-add-teal si-add-more" onclick="appendOtherSIAddMore()">+</button>
</div>
<div id="numberToWordOthers_72" class="policy-term-number-words fst-italic text-muted small mt-1"></div>
</div>
</div>
<div style="margin-top: 10px;margin-bottom:15px;" id="sum_insured_add_more"></div>
<div id="append_html_for_other_policy_terms"></div>
<div id="familyFloaterDiv_others" class="row align-items-center mb-1" style="display:none;">
<div class="col-md-4 col-lg-3">
<label class="form-label policy-term-main-label mb-0">Family Floater</label>
</div>
<div class="col-md-8 col-lg-7">
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="familyFloaterYes_others" name="family_floater" value="1">
<label class="form-check-label" for="familyFloaterYes_others" style="width: auto !important;">Yes</label>
<input class="form-check-input" type="radio" id="familyFloaterNo_others" name="family_floater" value="0">
<label class="form-check-label" for="familyFloaterNo_others" style="width: auto !important;">No</label>
</div>
</div>
</div>
<div id="familyFloaterDiv_others_two" class="row mb-3" style="display:none;">
<div class="col-md-4 col-lg-3 d-none d-md-block"></div>
<div class="col-md-8 col-lg-8 policy-72-family-grid">
<table class="policy-72-ff-table">
<tbody>
<tr>
<td style="width: 11%;"><span style="margin-right: 20px;" class="text-dark fw-semibold">Self:</span></td>
<td style="width: 11%;">
<input class="form-check-input mt-0" type="checkbox" name="family_floaters[]" value="self" id="self_others" checked>
</td>
<td style="width: 28%;">
<div class="ff-age-wrap"><span class="ff-field-label" style="margin-right: 20px;">Min Age:</span>
<input class="underline-input ff-age-input min_age" type="number" name="self_min_age" id="self_min_age_others" value="18">
</div>
</td>
<td style="width: 28%;">
<div class="ff-age-wrap"><span class="ff-field-label" style="margin-right: 20px;">Max Age:</span>
<input class="underline-input ff-age-input max_age" type="number" name="self_max_age" id="self_max_age_others" value="60">
</div>
</td>
<td class="ff-pay-label-top" style="width: 11%;"><span class="ff-field-label" style="margin-right: 20px;font-size: 12px;">Is Payable by employee:</span></td>
<td class="ff-pay-check-top" style="width: 11%;">
<input class="form-check-input mt-0" type="checkbox" name="is_payable_employee_for_self" id="is_payable_employee_for_self_others" value="1" checked>
</td>
</tr>
<tr>
<td style="width: 11%;"><span style="margin-right: 20px;" class="text-dark fw-semibold">Spouse:</span></td>
<td style="width: 11%;">
<input class="form-check-input mt-0" type="checkbox" name="family_floaters[]" value="spouse" id="spouse_others" checked>
</td>
<td style="width: 28%;">
<div class="ff-age-wrap"><span class="ff-field-label" style="margin-right: 20px;">Min Age:</span>
<input class="underline-input ff-age-input min_age" type="number" name="spouse_min_age" id="spouse_min_age_others" value="18">
</div>
</td>
<td style="width: 28%;">
<div class="ff-age-wrap"><span class="ff-field-label" style="margin-right: 20px;">Max Age:</span>
<input class="underline-input ff-age-input max_age" type="number" name="spouse_max_age" id="spouse_max_age_others" value="60">
</div>
</td>
<td class="ff-pay-label-top" style="width: 11%;"><span class="ff-field-label" style="margin-right: 20px;font-size: 12px;">Is Payable by employee:</span></td>
<td class="ff-pay-check-top" style="width: 11%;">
<input class="form-check-input mt-0" type="checkbox" name="is_payable_employee_for_spouse" id="is_payable_employee_for_spouse_others" value="1">
</td>
</tr>
<tr>
<td style="width: 11%;"><span class="text-dark fw-semibold">Children:</span></td>
<td style="width: 11%;">
<select name="family_floaters[]" id="children_others" class="form-select form-control d-inline-block" style="width: 86px;">
<option value="0">None</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</td>
<td style="width: 28%;">
<div class="ff-age-wrap"><span class="ff-field-label" style="margin-right: 20px;">Min Age:</span>
<input class="underline-input ff-age-input min_age" type="number" name="child_min_age" id="child_min_age_others" value="0">
</div>
</td>
<td style="width: 28%;">
<div class="ff-age-wrap"><span class="ff-field-label" style="margin-right: 20px;">Max Age:</span>
<input class="underline-input ff-age-input max_age" type="number" name="child_max_age" id="child_max_age_others" value="25">
</div>
</td>
<td class="ff-pay-label-top" style="width: 11%;"><span class="ff-field-label" style="margin-right: 20px;font-size: 12px;">Is Payable by employee:</span></td>
<td class="ff-pay-check-top" style="width: 11%;">
<input class="form-check-input mt-0" type="checkbox" name="is_payable_employee_for_child" id="is_payable_employee_for_child_others" value="1">
</td>
</tr>
<tr>
<td colspan="2"><span class="text-dark">Select Other Members:</span></td>
<td colspan="4">
<select name="family_floaters[]" id="family_floaters_others" class="form-select form-control" style="max-width: 430px;">
<option value="0">None</option>
<option value="1P">Only one parent (Either Father / Mother)</option>
<option value="2P">Only two parents (Father+Mother)</option>
<option value="1PIL">Only one parent in law (Either MIL / FIL)</option>
<option value="2PIL">Only two parents in law (FIL + MIL)</option>
<option value="2EPORPIL">Parents or PIL (Any two of Father, Mother, MIL, FIL)</option>
<option value="EPORPIL">Either Parents or PIL (Parents or Parents In Law)</option>
<option value="4EPORPIL">Parents + PIL (Father + Mother + MIL + FIL)</option>
</select>
</td>
</tr>
<tr id="other_members_age_row" class="policy-72-other-members-age-row">
<td colspan="2" style="width: 22%;">
<div class="ff-elders-wrap"><span class="ff-field-label" style="margin-right: 20px;">Elders Count:</span>
<input class="underline-input ff-elders-count-input" type="number" name="elder_member_count" id="member_count_others" value="0" readonly>
</div>
</td>
<td style="width: 28%;">
<div class="ff-age-wrap"><span class="ff-field-label" style="margin-right: 20px;">Min Age:</span>
<input class="underline-input ff-age-input" type="number" name="other_member_min_age" id="other_member_min_age_others" value="18">
</div>
</td>
<td style="width: 28%;">
<div class="ff-age-wrap"><span class="ff-field-label" style="margin-right: 20px;">Max Age:</span>
<input class="underline-input ff-age-input" type="number" name="other_member_max_age" id="other_member_max_age_others" value="60">
</div>
</td>
<td class="ff-pay-label-top" style="width: 11%;"><span class="ff-field-label" style="margin-right: 20px;font-size: 12px;">Is Payable by employee:</span></td>
<td class="ff-pay-check-top" style="width: 11%;">
<input class="form-check-input mt-0" type="checkbox" name="is_payable_employee_for_elders" id="is_payable_employee_for_elders_others" value="1">
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="append_html_for_other_policy_terms_72_after_family"></div>
<hr>
<div class="other_special_condition">
</div>
<br>
<div class="form-group text-right m-b-0" style="margin-top: -49px;">
<a href="#" class="button-like" id="otherButtonSpecialCondition" title="Special Condition">Special
Condition</a>
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="btnOtherTermsSubmit"
style="margin-top: 100px;">Submit</button>
</div>
</form>
</div>
<script>
$("#otherPolicyTerms").submit(function(event) {
event.preventDefault();
var isValid = $('#otherPolicyTerms').parsley().validate();
console.log('isvalid', isValid);
if ($('#emp_count').val() == true) {
toastr.warning('Client has active employees', 'Warning');
return;
}
if (!isValid) {
console.log('Form is Empty', 'Warning');
return;
}
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var formData = new FormData($('#otherPolicyTerms')[0]);
var policy_form_action = '<?= base_url("client/terms/other_terms") ?>';
// Convert the FormData object to a JSON object
const formObject = {};
formData.forEach((value, key) => {
if (key != 'csrf_test_name' && key != 'client_policy_id' && key != 'policy_id' && key !=
'client_id') {
if (key.endsWith('[]')) {
const baseKey = key.slice(0, -2);
if (!formObject[baseKey]) {
formObject[baseKey] = [];
}
formObject[baseKey].push(value.replace(/,/g, ''));
} else if(key == 'sum_insureds'){
formObject['sum_insured'] = value.replace(/,/g, '');
}
else {
formObject[key] = value;
}
}
});
console.log(formObject);
const jsonString = JSON.stringify(formObject);
console.log(jsonString);
// return;
// Append the JSON string to the FormData object
formData.append('policy_terms', jsonString);
$.ajax({
data: formData,
url: policy_form_action,
type: "POST",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
$('#otherPolicyTerms')[0].reset();
$('.text-danger-2').html('');
console.log(res);
if (res.status === false) {
toastr.error(res.message, 'Error');
return;
}
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, 1000);
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
$('#OtherPolicyTermsForm').css('display', 'none');
$('#police-tab').css('display', '');
$('.nav.nav-pills.navtab-bg').css('display', '');
$('.nav.nav-pills.navtab-bg').prev().css('display', '');
var message = 'Policy Terms Updated successfully';
toastr.success(message, 'Success');
}, 1000);
});
$('body').on('click', '.btnPolicyMaster', function() {
var client_policy_id = $(this).data('id');
var policy_type_id = $(this).data('typeid');
console.log('policy_type_id', policy_type_id);
console.log('client_policy_id :', client_policy_id);
$('#other_client_policy_id').val(client_policy_id);
appendPolicyTermsHTML(policy_type_id);
var gpa_policy_type_id = $(this).attr('id');
// console.log('gpa_policy_type_id', gpa_policy_type_id)
if (policy_type_id > 5) {
$('#OtherPolicyTermsForm').css('display', '');
$('#police-tab').css('display', 'none');
$('.nav.nav-pills.navtab-bg').css('display', 'none');
$('.nav.nav-pills.navtab-bg').prev().css('display', 'none');
$('.removeDom').remove()
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$.ajax({
url: '<?= base_url("client/policy/getterms") ?>',
method: 'GET',
data: {
client_policy_id: client_policy_id
},
success: function(res) {
console.log('response of the other policy terms', res);
console.log('employee count', res.emp_count_by_policy);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, 500);
// $('#nameOfThePolicyOnOther').html(' - ' + res.policy_name.name);
$('#emp_count').val(res.count)
if (res.emp_count_by_policy != 0) {
$("#btnOtherTermsSubmit").hide();
$("#otherButtonSpecialCondition").hide();
} else {
$("#btnOtherTermsSubmit").show();
$("#otherButtonSpecialCondition").show();
}
if (res) {
//special conditions fields
let gpaJsonObjectForSpecialCondition = JSON.parse(res.data);
Object.keys(gpaJsonObjectForSpecialCondition).forEach(function(key) {
if (key.includes("special_condition_label") || key.includes("special_condition_input") ||
key.includes("other_special_condition_label") || key.includes("other_special_condition_input")) {
if (key.includes("special_condition_label") || key.includes("other_special_condition_label")) {
for (let index = 0; index <
gpaJsonObjectForSpecialCondition[key].length; index++) {
specialConditionForOthers();
}
}
let elements = document.getElementsByName(`${key}[]`);
if (elements) {
elements.forEach((element, index) => {
if (gpaJsonObjectForSpecialCondition[key][
index
] == undefined) {
element.value = " ";
} else {
element.value =
gpaJsonObjectForSpecialCondition[key][
index
];
}
});
}
}
if (key.includes("multiple_sum_insured")) {
const value = gpaJsonObjectForSpecialCondition[key];
if (Array.isArray(value)) {
value.forEach(item => appendOtherSIAddMore(item));
} else if (typeof value === 'object' && value !== null) {
Object.values(value).forEach(item => appendOtherSIAddMore(item));
}
}
});
//normal terms fields
let jsonObject = JSON.parse(res.data);
Object.keys(jsonObject).forEach(function(key) {
console.log(key)
let elements = document.getElementsByName(key);
if(key == 'sum_insured'){
elements = document.getElementsByName('sum_insureds')
}
console.log(elements)
if (elements && elements.length > 0) {
let element = elements[0];
if (element.tagName === 'INPUT' && (element.type ===
'checkbox' || element.type === 'radio')) {
if (element.type === 'checkbox') {
element.checked = jsonObject[key] === '1';
} else if (element.type === 'radio') {
element.checked = element.value === jsonObject[key];
}
} else {
if (jsonObject[key] == undefined) {
element.value = " ";
} else {
element.value = jsonObject[key];
console.log(element);
console.log(jsonObject[key]);
console.log(element.value);
}
}
}
if (policy_type_id == 72) {
if (key == "family_floater") {
$('#familyFloaterYes_others').prop('checked', jsonObject[key] == 1);
$('#familyFloaterNo_others').prop('checked', jsonObject[key] != 1);
}
if (key.includes("family_floaters") && jsonObject[key]) {
$('#children_others').val(String(jsonObject[key].childrens != null ? jsonObject[key].childrens : 0));
$('#self_others').prop('checked', jsonObject[key].self != 0);
$('#spouse_others').prop('checked', jsonObject[key].spouse != 0);
if (jsonObject[key]['either-parents-pil'] == 1) $('#family_floaters_others').val('EPORPIL');
else if (jsonObject[key].parents == 1 && jsonObject[key]['parents-in-law'] == 1) $('#family_floaters_others').val('2EPORPIL');
else if (jsonObject[key].parents == 2 && jsonObject[key]['parents-in-law'] == 2) $('#family_floaters_others').val('4EPORPIL');
else if (jsonObject[key].parents == 1) $('#family_floaters_others').val('1P');
else if (jsonObject[key].parents == 2) $('#family_floaters_others').val('2P');
else if (jsonObject[key]['parents-in-law'] == 1) $('#family_floaters_others').val('1PIL');
else if (jsonObject[key]['parents-in-law'] == 2) $('#family_floaters_others').val('2PIL');
else if (jsonObject[key]['either-parents-pil'] == 2) $('#family_floaters_others').val('2EPORPIL');
else $('#family_floaters_others').val('0');
}
if (key.includes("age_ratio") && jsonObject[key]) {
$('#self_min_age_others').val(jsonObject[key].self.min);
$('#self_max_age_others').val(jsonObject[key].self.max);
$('#spouse_min_age_others').val(jsonObject[key].spouse.min);
$('#spouse_max_age_others').val(jsonObject[key].spouse.max);
$('#child_min_age_others').val(jsonObject[key].child.min);
$('#child_max_age_others').val(jsonObject[key].child.max);
$('#other_member_min_age_others').val(jsonObject[key].elders.min);
$('#other_member_max_age_others').val(jsonObject[key].elders.max);
}
if (key.includes("enrollment_display_key") && jsonObject[key]) {
processOtherEnrollmentDisplayKey(jsonObject[key]);
}
}
});
if (policy_type_id == 72) {
if (jsonObject.is_payable_employee) {
var pe = jsonObject.is_payable_employee;
$('#is_payable_employee_for_self_others').prop('checked', pe.self == 1);
$('#is_payable_employee_for_spouse_others').prop('checked', pe.spouse == 1);
$('#is_payable_employee_for_child_others').prop('checked', pe.childern == 1);
$('#is_payable_employee_for_elders_others').prop('checked', pe.elders == 1);
}
initPolicy72FamilyFloaterUi();
}
}
$('#sum_insured_others').trigger('keyup');
$('#sum_insured_others_72').trigger('keyup');
$(".multiple_sum_insured").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');
}
});
}
});
</script>
<script>
document.getElementById('otherButtonSpecialCondition').addEventListener('click', function(event) {
console.log('specialConditionForOthers callback clicked')
event.preventDefault();
specialConditionForOthers();
});
function specialConditionForOthers(count = 0) {
console.log('specialConditionForOthers function called')
console.log('before if count', count)
if (count === 0) {
console.log('after if count', count)
var index = $('.modifyclassinput').length;
var appendElement = `<div class="form-group col-md-6 form-group-client-policy-masters removeDom">
<label for="specialconditionlabel" class="special_condition_label[]" style="width: 450px;position: relative;bottom: 6px;">
<input class="form-control" name="special_condition_label[]" id="special_condition_label[]" style="position: relative;right: 15px;">
<span class="specialConditionClose" style="color: red; float: right;position: relative;bottom: 28px;left: 15px;">X</span>
</label>
<input type="text" name="special_condition_input[]" id="special_condition_input[]" class="form-control s special_condition_input[]">
</div>`;
console.log($(this));
$('.other_special_condition').each(function() {
$(this).append(appendElement);
});
} else {
console.log('else')
}
}
$(document).on('click', '#otherPolicyTermsClose', function() {
$('#OtherPolicyTermsForm').css('display', 'none');
$('#police-tab').css('display', '');
$('.nav.nav-pills.navtab-bg').css('display', '');
$('.nav.nav-pills.navtab-bg').prev().css('display', '');
$('#otherPolicyTerms')[0].reset();
$('.text-danger-2').html('');
});
$("#sum_insured_others").on("keyup", function() {
var inputNumber = $(this).val();
console.log('sum_insured_others keyup', inputNumber)
if (inputNumber) {
var result = convertCommaNumberToWords(inputNumber);
$("#numberToWordOthers").text(result);
} else {
$("#numberToWordOthers").text("");
}
});
$("#totalSumInsured").on("keyup", function() {
var inputNumber = $(this).val();
if (inputNumber) {
var result = convertCommaNumberToWords(inputNumber);
$("#numberToWordTotalSumInsured").text(result);
} else {
$("#numberToWordTotalSumInsured").text("");
}
});
function si_keup_num_to_word2(input) {
console.log('keyup sum insured');
var inputNumber = $(input).val();
console.log(inputNumber)
if (inputNumber) {
var result = convertCommaNumberToWords(inputNumber);
$("#numberToWordOthers").text(result);
$("#numberToWordOthers_72").text(result);
} else {
$("#numberToWordOthers").text("");
$("#numberToWordOthers_72").text("");
}
};
function syncPolicy72ElderMemberCount() {
var map = { '0': 0, '1P': 1, '2P': 2, '1PIL': 1, '2PIL': 2, '2EPORPIL': 2, 'EPORPIL': 1, '4EPORPIL': 4 };
var v = $('#family_floaters_others').val();
var elderCount = map[v] !== undefined ? map[v] : 0;
$('#member_count_others').val(elderCount);
}
function togglePolicy72OtherMembersAgeRow() {
var v = $('#family_floaters_others').val();
if (v && v !== '0') {
$('#other_members_age_row').addClass('policy-72-other-ages-open').css('display', 'table-row');
} else {
$('#other_members_age_row').removeClass('policy-72-other-ages-open').css('display', 'none');
}
}
function initPolicy72FamilyFloaterUi() {
syncPolicy72ElderMemberCount();
togglePolicy72OtherMembersAgeRow();
}
$(document).on('change', '#family_floaters_others', function() {
syncPolicy72ElderMemberCount();
togglePolicy72OtherMembersAgeRow();
});
function appendPolicyTermsHTML(policy_type) {
var termsHTML = "";
var targetContainer = '#append_html_for_other_policy_terms';
if (policy_type == 72) {
targetContainer = '#append_html_for_other_policy_terms_72_after_family';
}
$(targetContainer).empty();
if (policy_type == 7) {
termsHTML = `
<div class="form-group">
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="sumInsured">Sum Insured</label>
</div>
<div class="col-md-4">
<input style="width: 128%;" type="text" name="sum_insureds" id="sum_insured_others" class="form-control" onkeypress = "return onlyNumbers(event)" onkeyup=" formatNumber(this); si_keup_num_to_word2(this)">
</div>
<div class="col-md-2" style="position: relative;left: 88px;">
<button type="button" class="btn btn-primary si-add-more" onclick="appendOtherSIAddMore()">+</button>
</div>
<div class="col-md-6">
</div>
<div class="col-md-6">
<div id='numberToWordOthers' class="text-danger-2" ></div>
</div>
</div>
<div id="sum_insured_add_more" ></div>
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="totalSumInsured">Policy Type</label>
</div>
<div class="col-md-6">
<input type="text" name="policy_type" id="policy_type" class="form-control">
</div>
</div>
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="totalSumInsured">Existing Insurer</label>
</div>
<div class="col-md-6">
<input type="text" name="existing_insurer" id="existing_insurer" class="form-control">
</div>
</div>
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="renewal_lives">Renewal Lives</label>
</div>
<div class="col-md-6">
<input type="text" name="renewal_lives" id="renewal_lives" class="form-control">
</div>
</div>
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="totalSumInsured">Total Sum Assured</label>
</div>
<div class="col-md-6">
<input type="text" style="width: 100% !important;" class="form-control" name="total_sum_insured"
id="total_sum_insured" onkeypress="return onlyNumbers(event)" onkeyup="formatNumber(this)">
</div>
<div class="col-md-6">
</div>
<div class="col-md-6">
<div id='numberToWordTotalSumInsured' class="text-danger-2"></div>
</div>
</div>
<div class="row" style="margin-bottom: 10px;display:true;">
<div class="col-md-6">
<label for="lives_at_inception">Lives at Inception</label>
</div>
<div class="col-md-6">
<input type="text" name="lives_at_inception" id="lives_at_inception" class="form-control">
</div>
</div>
<div class="row" style="margin-bottom: 10px;display:true;">
<div class="col-md-6">
<label for="totalSumInsured">Total Sum Insured at Inception</label>
</div>
<div class="col-md-6">
<input type="text" name="total_sum_insured_at_inception" id="total_sum_insured_at_inception"
class="form-control" onkeypress="return onlyNumbers(event)" onkeyup="formatNumber(this)">
</div>
</div>
<div class="row" style="margin-bottom: 10px;display:true;">
<div class="col-md-6">
<label for="totalSumInsured">Premium at Inception (Excl GST)</label>
</div>
<div class="col-md-6">
<input type="text" name="premium_at_inception" id="premium_at_inception" class="form-control">
</div>
</div>
<div class="row" style="margin-bottom: 10px;display:true;">
<div class="col-md-6">
<label for="coverage">Coverage</label>
</div>
<div class="col-md-6">
<input type="text" name="coverage " id="coverage" class="form-control">
</div>
</div>
<div class="row" style="margin-bottom: 10px;display:true;">
<div class="col-md-6">
<label for="free_cover_limit">Free Cover Limit</label>
</div>
<div class="col-md-6">
<input type="text" name="free_cover_limit" id="free_cover_limit" class="form-control">
</div>
</div>
</div>
`
} else if (policy_type == 6) {
termsHTML = `
<div class="form-group EDLI">
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="sumInsured">Sum Insured</label>
</div>
<div class="col-md-4" >
<input style="width: 128%;" type="text" name="sum_insureds" id="sum_insured_others" class="form-control" onkeypress = "return onlyNumbers(event)" onkeyup=" formatNumber(this); si_keup_num_to_word2(this)">
</div>
<div class="col-md-2" style="position: relative;left: 88px;">
<button type="button" class="btn btn-primary si-add-more" onclick="appendOtherSIAddMore()">+</button>
</div>
<div class="col-md-6">
</div>
<div class="col-md-6">
<div id='numberToWordOthers' class="text-danger-2" ></div>
</div>
</div>
<div id="sum_insured_add_more" ></div>
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="totalSumInsured">Existing Insurer</label>
</div>
<div class="col-md-6">
<input type="text" name="existing_insurer" id="existing_insurer" class="form-control">
</div>
</div>
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="renewal_lives">Renewal Lives</label>
</div>
<div class="col-md-6">
<input type="text" name="renewal_lives" id="renewal_lives" class="form-control">
</div>
</div>
<div class="row" style="margin-bottom: 10px;display:true;">
<div class="col-md-6">
<label for="lives_at_inception">Lives at Inception</label>
</div>
<div class="col-md-6">
<input type="text" name="lives_at_inception" id="lives_at_inception" class="form-control">
</div>
</div>
<div class="row" style="margin-bottom: 10px;display:true;">
<div class="col-md-6">
<label for="totalSumInsured">Total Sum Insured at Inception</label>
</div>
<div class="col-md-6">
<input type="text" name="total_sum_insured_at_inception" id="total_sum_insured_at_inception"
class="form-control" onkeypress="return onlyNumbers(event)" onkeyup="formatNumber(this)">
</div>
</div>
<div class="row" style="margin-bottom: 10px;display:true;">
<div class="col-md-6">
<label for="coverage">Coverage</label>
</div>
<div class="col-md-6">
<input type="text" name="coverage " id="coverage" class="form-control">
</div>
</div>
<div class="row" style="margin-bottom: 10px;display:true;">
<div class="col-md-6">
<label for="free_cover_limit">Free Cover Limit for Base Cover</label>
</div>
<div class="col-md-6">
<input type="text" name="free_cover_limit_for_base_cover" id="free_cover_limit_for_base_cover" class="form-control">
</div>
</div>
</div>
`
} else if (policy_type == 72) {
termsHTML = `
<div class="form-group OPD_POLICY_TERMS">
<div class="row" style="margin-bottom: 10px;"><div class="col-md-1"><input type="checkbox" style="margin-top: 12px" name="mode_of_serviceability_display" id="mode_of_serviceability_display" class="unchecked" checked></div><div class="col-md-5"><label for="mode_of_serviceability">Mode of Serviceability</label></div><div class="col-md-6"><input type="text" name="mode_of_serviceability" id="mode_of_serviceability" class="form-control"></div></div>
<div class="row" style="margin-bottom: 10px;"><div class="col-md-1"><input type="checkbox" style="margin-top: 12px" name="eligibility_display" id="eligibility_display" class="unchecked" checked></div><div class="col-md-5"><label for="eligibility">Eligibility</label></div><div class="col-md-6"><input type="text" name="eligibility" id="eligibility" class="form-control"></div></div>
<div class="row" style="margin-bottom: 10px;"><div class="col-md-1"><input type="checkbox" style="margin-top: 12px" name="total_sum_insured_limit_display" id="total_sum_insured_limit_display" class="unchecked" checked></div><div class="col-md-5"><label for="total_sum_insured_limit">Total Sum Insured limit</label></div><div class="col-md-6"><input type="text" name="total_sum_insured_limit" id="total_sum_insured_limit" class="form-control" value="INR 15000"></div></div>
<div class="row" style="margin-bottom: 10px;"><div class="col-md-1"><input type="checkbox" style="margin-top: 12px" name="in_person_doctor_consultation_display" id="in_person_doctor_consultation_display" class="unchecked" checked></div><div class="col-md-5"><label for="in_person_doctor_consultation">In Person Doctor Consultation</label></div><div class="col-md-6"><input type="text" name="in_person_doctor_consultation" id="in_person_doctor_consultation" class="form-control"></div></div>
<div class="row" style="margin-bottom: 10px;"><div class="col-md-1"><input type="checkbox" style="margin-top: 12px" name="prescribed_lab_test_pathology_radiology_display" id="prescribed_lab_test_pathology_radiology_display" class="unchecked" checked></div><div class="col-md-5"><label for="prescribed_lab_test_pathology_radiology">Prescribed Lab test (Pathology & Radiology)</label></div><div class="col-md-6"><input type="text" name="prescribed_lab_test_pathology_radiology" id="prescribed_lab_test_pathology_radiology" class="form-control"></div></div>
<div class="row" style="margin-bottom: 10px;"><div class="col-md-1"><input type="checkbox" style="margin-top: 12px" name="prescribed_pharmacy_display" id="prescribed_pharmacy_display" class="unchecked" checked></div><div class="col-md-5"><label for="prescribed_pharmacy">Prescribed Pharmacy</label></div><div class="col-md-6"><input type="text" name="prescribed_pharmacy" id="prescribed_pharmacy" class="form-control"></div></div>
<div class="row" style="margin-bottom: 10px;"><div class="col-md-1"><input type="checkbox" style="margin-top: 12px" name="dental_display" id="dental_display" class="unchecked" checked></div><div class="col-md-5"><label for="dental">Dental</label></div><div class="col-md-6"><input type="text" name="dental" id="dental" class="form-control"></div></div>
<div class="row" style="margin-bottom: 10px;"><div class="col-md-1"><input type="checkbox" style="margin-top: 12px" name="vision_display" id="vision_display" class="unchecked" checked></div><div class="col-md-5"><label for="vision">Vision</label></div><div class="col-md-6"><input type="text" name="vision" id="vision" class="form-control"></div></div>
<div class="row" style="margin-bottom: 10px;"><div class="col-md-1"><input type="checkbox" style="margin-top: 12px" name="vaccination_for_children_and_adults_display" id="vaccination_for_children_and_adults_display" class="unchecked" checked></div><div class="col-md-5"><label for="vaccination_for_children_and_adults">Vaccination for children & adults</label></div><div class="col-md-6"><input type="text" name="vaccination_for_children_and_adults" id="vaccination_for_children_and_adults" class="form-control"></div></div>
</div>`;
}
if (policy_type == 72) {
$('#sumInsuredDiv').show();
$('#familyFloaterDiv_others').show();
$('#familyFloaterDiv_others_two').show();
initPolicy72FamilyFloaterUi();
} else {
$('#sumInsuredDiv').hide();
$('#familyFloaterDiv_others').hide();
$('#familyFloaterDiv_others_two').hide();
$('#append_html_for_other_policy_terms_72_after_family').empty();
}
$(targetContainer).append(termsHTML);
}
function appendOtherSIAddMore(data = null) {
const addMoreContainer = document.getElementById('sum_insured_add_more');
console.log(addMoreContainer)
const html = `
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<label for="sumInsured">Additional Sum Insured</label>
</div>
<div class="col-md-4">
<input style="width: 128%;" value="${data ? data : ''}" type="text" name="multiple_sum_insured[]" class="form-control multiple_sum_insured" onkeypress="return onlyNumbers(event)" onkeyup="formatNumber(this); numtowordinkeyup(this)">
</div>
<div class="col-md-2" style="position: relative;left: 88px;">
<button type="button" class="btn btn-danger si-remove-multi" onclick="removeGMCAdditionalSI(this)">x</button>
<button type="button" class="btn btn-primary si-add-more" onclick="appendOtherSIAddMore()">+</button>
</div>
<div class="col-md-6">
</div>
<div class="col-md-6">
<div class="text-danger-2 numberToWordSumInsured"></div>
</div>
</div>`;
addMoreContainer.insertAdjacentHTML('beforeend', html);
}
function processOtherEnrollmentDisplayKey(displayObject) {
if (!displayObject || typeof displayObject !== 'object' || Array.isArray(displayObject)) {
return;
}
const displayMap = {
'Mode Of Serviceability': 'mode_of_serviceability_display',
'Eligibility': 'eligibility_display',
'Total Sum Insured Limit': 'total_sum_insured_limit_display',
'In Person Doctor Consultation': 'in_person_doctor_consultation_display',
'Prescribed Lab Test Pathology Radiology': 'prescribed_lab_test_pathology_radiology_display',
'Prescribed Pharmacy': 'prescribed_pharmacy_display',
'Dental': 'dental_display',
'Vision': 'vision_display',
'Vaccination For Children And Adults': 'vaccination_for_children_and_adults_display'
};
$('#append_html_for_other_policy_terms_72_after_family .unchecked').prop('checked', false);
Object.keys(displayObject).forEach(function(label) {
const checkboxId = displayMap[label];
if (checkboxId && displayObject[label] !== '' && displayObject[label] !== null && displayObject[label] !== undefined) {
$('#' + checkboxId).prop('checked', true);
}
});
}
</script>