FEAT_OPD_POLICY
This commit is contained in:
parent
447702c5e4
commit
dc172e5c83
@ -2726,7 +2726,9 @@ class ClientController extends AdminController
|
||||
$search_term = 'GMC';
|
||||
} else if (preg_match($gpa_pattern, $subject) || $policy_type_id == 6 || $policy_type_id == 7) {
|
||||
$search_term = 'GPA';
|
||||
} else {
|
||||
} else if($policy_type_id == 72){
|
||||
$search_term = 'GMC';
|
||||
}else {
|
||||
$search_term = "";
|
||||
}
|
||||
|
||||
@ -2736,7 +2738,7 @@ class ClientController extends AdminController
|
||||
if ($search_term === 'GPA' || $policy_type_id == 6 || $policy_type_id == 7) {
|
||||
|
||||
$premiumData = $this->policyPremium1Model->where(['client_id' => $record['client_id'], 'client_policy_id' => $client_policy_id, 'is_active' => 1])->findAll();
|
||||
} else if ($search_term === 'GMC') {
|
||||
} else if ($search_term === 'GMC' || $policy_type_id == 72) {
|
||||
|
||||
$premiumData = $this->policyPremium2Model->where(['client_id' => $record['client_id'], 'client_policy_id' => $client_policy_id, 'is_active' => 1])->findAll();
|
||||
|
||||
@ -2766,7 +2768,7 @@ class ClientController extends AdminController
|
||||
// echo '<pre>';
|
||||
// echo $family_floater;
|
||||
|
||||
if ($search_term === 'GMC') {
|
||||
if ($search_term === 'GMC' || $policy_type_id == 72 ) {
|
||||
|
||||
// $resultss = [];
|
||||
$resultss = $results;
|
||||
@ -3400,6 +3402,7 @@ class ClientController extends AdminController
|
||||
[
|
||||
'Status' => true,
|
||||
'code' => 200,
|
||||
'policy_type_id' => $record['policy_type_id'],
|
||||
'data' => $record['policy_terms'],
|
||||
'policy_addon' => $record['is_addon'],
|
||||
'emp_count_by_policy' => $emp_count_by_policy
|
||||
@ -4225,34 +4228,41 @@ class ClientController extends AdminController
|
||||
$client_policy_id = $this->request->getPost("client_policy_id");
|
||||
$policy_terms = $this->request->getPost("policy_terms");
|
||||
$policy_terms = json_decode($policy_terms, true);
|
||||
|
||||
$data = [];
|
||||
|
||||
foreach ($policy_terms as $key => $value) {
|
||||
|
||||
if (str_ends_with($key, '_display')) {
|
||||
|
||||
$original_key = substr($key, 0, -8);
|
||||
|
||||
$newKey = implode(' ', array_map('ucfirst', explode('_', $original_key)));
|
||||
|
||||
$data['enrollment_display_key'][$newKey] = $policy_terms[$original_key] ?? " ";
|
||||
} else {
|
||||
|
||||
$data[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($data)) {
|
||||
$policy_terms['is_payable_employee']['self'] = 0;
|
||||
$policy_terms = json_encode($data);
|
||||
}
|
||||
|
||||
|
||||
$record = $this->clientPolicyModel->where('id', $client_policy_id)->first();
|
||||
// print_r($policy_terms); die;
|
||||
|
||||
if(empty($policy_terms)){
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Policy terms data could not be empty', 'formdata' => $this->request->getPost()], 200);
|
||||
}
|
||||
|
||||
if ($record) {
|
||||
|
||||
$data = [];
|
||||
|
||||
foreach ($policy_terms as $key => $value) {
|
||||
|
||||
if (str_ends_with($key, '_display')) {
|
||||
|
||||
$original_key = substr($key, 0, -8);
|
||||
|
||||
$newKey = implode(' ', array_map('ucfirst', explode('_', $original_key)));
|
||||
|
||||
$data['enrollment_display_key'][$newKey] = $policy_terms[$original_key] ?? " ";
|
||||
} else {
|
||||
|
||||
$data[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if($record['policy_type_id'] == 72){
|
||||
$data['enrollment_display_key'] = $this->otherPolicyTermsDisplayKeyConstruct($policy_terms);
|
||||
}
|
||||
|
||||
if (!empty($data)) {
|
||||
$policy_terms['is_payable_employee']['self'] = 0;
|
||||
$policy_terms = json_encode($data);
|
||||
}
|
||||
|
||||
$update = $this->clientPolicyModel->where('id', $client_policy_id)->set('policy_terms', $policy_terms)->update();
|
||||
|
||||
if ($update) {
|
||||
@ -4260,12 +4270,34 @@ class ClientController extends AdminController
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to update data', 'formdata' => $this->request->getPost()], 200);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to store data. The client policy does not exist', 'formdata' => $this->request->getPost()], 200);
|
||||
}
|
||||
}
|
||||
|
||||
public function otherPolicyTermsDisplayKeyConstruct($data)
|
||||
{
|
||||
$labels = $data['special_condition_label'] ?? [];
|
||||
$values = $data['special_condition_input'] ?? [];
|
||||
|
||||
$special_conditions = [];
|
||||
|
||||
foreach ($labels as $i => $label) {
|
||||
$value = $values[$i] ?? '';
|
||||
|
||||
// skip if label or value is empty
|
||||
if (trim($label) === '' || trim($value) === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$special_conditions[$label] = $value;
|
||||
}
|
||||
|
||||
return $special_conditions;
|
||||
}
|
||||
|
||||
public function checkPolicyType($policy_type_id, $client_branch_id, $client_id)
|
||||
{
|
||||
|
||||
@ -5971,8 +6003,8 @@ class ClientController extends AdminController
|
||||
// ---------- EMP SERVICE CONTROLLER --------------------------------------------------------------------------------
|
||||
|
||||
$empServiceController = new EmployeeServiceController();
|
||||
// $res = $empServiceController->excelFileFormatValidation(['file_id' => '1126']);
|
||||
// $res = $empServiceController->excelFileDataValidation(['file_id' => '865']);
|
||||
// $res = $empServiceController->excelFileFormatValidation(['file_id' => '1248']);
|
||||
// $res = $empServiceController->excelFileDataValidation(['file_id' => '1248']);
|
||||
// $res = $empServiceController->employeesOnboardPreprocess(['file_id' => 1183]);
|
||||
// $res = $empServiceController->employeesOnboardPreprocess(['file_id' => 1169]);
|
||||
// $res = $empServiceController->employeesOnboardProcess(['file_id' => 835]);
|
||||
|
||||
@ -72,6 +72,11 @@
|
||||
margin-left: 30px;
|
||||
width: 689px;
|
||||
}
|
||||
|
||||
.other-speciial-condition{
|
||||
margin-left: 150px;
|
||||
width: 564px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="OtherPolicyTermsForm" style="display:none">
|
||||
@ -83,35 +88,180 @@
|
||||
|
||||
<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" 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" 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="sumInsuredDiv" 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 style="margin-top: 10px;margin-bottom:15px;" id="sum_insured_add_more" ></div>
|
||||
<div style="margin-top: 10px;margin-bottom:15px;" id="sum_insured_add_more"></div>
|
||||
<div id="append_html_for_other_policy_terms"></div>
|
||||
|
||||
<hr>
|
||||
<div id="familyFloaterDiv_others" class="row mb-2">
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Family Floater</label>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<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: 52px !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">No</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="familyFloaterDiv_others_two" class="row" style="margin-bottom: 10px;">
|
||||
|
||||
<div class="col" style="background-color:#F5FFFF;border-radius:10px;box-shadow:0px 2px 2px 0px #00000040;padding:20px;">
|
||||
|
||||
<!-- SELF -->
|
||||
<div class="d-flex align-items-center policy-base-info">
|
||||
<input type="checkbox" name="family_floaters[]" value="self" id="self_others" checked>
|
||||
|
||||
<span style="margin-right:150px;color:black;">Self:</span>
|
||||
|
||||
<div class="self-age">
|
||||
<span style="margin-right:10px;color:black;">Min Age:</span>
|
||||
<input class="underline-input min_age"
|
||||
type="number"
|
||||
name="self_min_age"
|
||||
id="self_min_age_others"
|
||||
value="<?= isset($self_min_age) && $self_min_age > 0 ? $self_min_age : '18'; ?>"
|
||||
onchange="lowerIsEighteenOthers(this)">
|
||||
</div>
|
||||
|
||||
<div class="self-age">
|
||||
<span style="margin-right:10px;color:black;">Max Age:</span>
|
||||
<input class="underline-input max_age"
|
||||
type="number"
|
||||
name="self_max_age"
|
||||
id="self_max_age_others"
|
||||
value="<?= isset($self_max_age) ? $self_max_age : '60'; ?>"
|
||||
onchange="lowerIsEighteenOthers(this)">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- SPOUSE -->
|
||||
<div class="d-flex align-items-center policy-base-info">
|
||||
<input type="checkbox" name="family_floaters[]" value="spouse" id="spouse_others">
|
||||
|
||||
<span style="margin-right:125px;color:black;">Spouse:</span>
|
||||
|
||||
<div class="spouse-age">
|
||||
<span style="margin-right:10px;color:black;">Min Age:</span>
|
||||
<input class="underline-input min_age"
|
||||
type="number"
|
||||
name="spouse_min_age"
|
||||
id="spouse_min_age_others"
|
||||
value="<?= isset($spouse_min_age) ? $spouse_min_age : '18'; ?>"
|
||||
onchange="lowerIsEighteenOthers(this)">
|
||||
</div>
|
||||
|
||||
<div class="spouse-age">
|
||||
<span style="margin-right:10px;color:black;">Max Age:</span>
|
||||
<input class="underline-input max_age"
|
||||
type="number"
|
||||
name="spouse_max_age"
|
||||
id="spouse_max_age_others"
|
||||
value="<?= isset($spouse_max_age) ? $spouse_max_age : '60'; ?>"
|
||||
onchange="lowerIsEighteenOthers(this)">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- CHILDREN -->
|
||||
<div class="d-flex align-items-center policy-base-info">
|
||||
<span style="color:black;" class="mr-2">Children:</span>
|
||||
|
||||
<select name="family_floaters[]" id="children_others" class="px-1" style="margin-right:60px;">
|
||||
<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>
|
||||
|
||||
<div class="child-age">
|
||||
<span style="margin-right:10px;color:black;">Min Age:</span>
|
||||
<input class="underline-input min_age"
|
||||
type="number"
|
||||
name="child_min_age"
|
||||
id="child_min_age_others"
|
||||
value="<?= isset($child_min_age) ? $child_min_age : '0'; ?>">
|
||||
</div>
|
||||
|
||||
<div class="child-age">
|
||||
<span style="margin-right:10px;color:black;">Max Age:</span>
|
||||
<input class="underline-input max_age"
|
||||
type="number"
|
||||
name="child_max_age"
|
||||
id="child_max_age_others"
|
||||
value="<?= isset($child_max_age) ? $child_max_age : '25'; ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- OTHER MEMBERS -->
|
||||
<div class="d-flex align-items-center policy-base-info flex-nowrap">
|
||||
|
||||
<span class="fw-bold text-dark mr-3"><b>Select Other Members:</b></span>
|
||||
|
||||
<select name="family_floaters[]" id="family_floaters_others" class="form-select mr-3 px-1">
|
||||
<option value="0">None</option>
|
||||
<option value="1P">Only one parent</option>
|
||||
<option value="2P">Only two parents</option>
|
||||
<option value="1PIL">Only one parent in law</option>
|
||||
<option value="2PIL">Only two parents in law</option>
|
||||
<option value="2EPORPIL">Parents or PIL (Any two)</option>
|
||||
<option value="EPORPIL">Either Parents or PIL</option>
|
||||
<option value="4EPORPIL">Parents + PIL</option>
|
||||
</select>
|
||||
|
||||
<span class="text-dark mr-2">Elders Count:</span>
|
||||
<input class="underline-input"
|
||||
type="number"
|
||||
name="elder_member_count"
|
||||
id="member_count_others"
|
||||
readonly>
|
||||
|
||||
<span class="text-dark mr-2">Min Age:</span>
|
||||
<input class="underline-input"
|
||||
type="number"
|
||||
name="other_member_min_age"
|
||||
id="other_member_min_age_others"
|
||||
value="<?= isset($other_member_min_age) ? $other_member_min_age : '18'; ?>">
|
||||
|
||||
<span class="text-dark mr-2">Max Age:</span>
|
||||
<input class="underline-input"
|
||||
type="number"
|
||||
name="other_member_max_age"
|
||||
id="other_member_max_age_others"
|
||||
value="<?= isset($other_member_max_age) ? $other_member_max_age : '60'; ?>">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="other_special_condition">
|
||||
|
||||
</div>
|
||||
|
||||
<br>
|
||||
@ -126,7 +276,6 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
$("#otherPolicyTerms").submit(function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
@ -162,10 +311,9 @@
|
||||
formObject[baseKey] = [];
|
||||
}
|
||||
formObject[baseKey].push(value.replace(/,/g, ''));
|
||||
} else if(key == 'sum_insureds'){
|
||||
} else if (key == 'sum_insureds') {
|
||||
formObject['sum_insured'] = value.replace(/,/g, '');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
formObject[key] = value;
|
||||
}
|
||||
}
|
||||
@ -215,7 +363,10 @@
|
||||
}
|
||||
});
|
||||
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
window.scrollTo({
|
||||
top: 0,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
setTimeout(function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
@ -295,7 +446,7 @@
|
||||
if (key.includes("special_condition_label") || key.includes(
|
||||
"special_condition_input")) {
|
||||
if (key.includes("special_condition_label")) {
|
||||
|
||||
|
||||
for (let index = 0; index <
|
||||
otherTermsJsonObjectSpecialCondition[key].length; index++) {
|
||||
specialConditionForOthers();
|
||||
@ -319,12 +470,12 @@
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!key.startsWith("special_condition") && !key.startsWith('multiple_sum_insured') && !key.startsWith("sum_insured") && !key.startsWith("enrollment_display_key") ) {
|
||||
|
||||
termsHTML = `
|
||||
if (!key.startsWith("special_condition") && !key.startsWith('multiple_sum_insured') && !key.startsWith("sum_insured") && !key.startsWith("enrollment_display_key")) {
|
||||
|
||||
termsHTML = `
|
||||
<div class="row" style="margin-bottom: 10px;">
|
||||
<div class="col-md-1">
|
||||
<input type="checkbox" style="margin-top: 12px" name="${key}_display"
|
||||
@ -350,7 +501,7 @@
|
||||
value.forEach(item => appendOtherSIAddMore(item));
|
||||
} else if (typeof value === 'object' && value !== null) {
|
||||
Object.values(value).forEach(item => appendOtherSIAddMore(item));
|
||||
}
|
||||
}
|
||||
// else if (typeof value === 'string') {
|
||||
// appendOtherSIAddMore(value); // Use directly, no loop
|
||||
// }
|
||||
@ -368,10 +519,10 @@
|
||||
|
||||
let elements = document.getElementsByName(key);
|
||||
|
||||
if(key == 'sum_insured'){
|
||||
if (key == 'sum_insured') {
|
||||
elements = document.getElementsByName('sum_insureds')
|
||||
}
|
||||
|
||||
|
||||
console.log(elements)
|
||||
|
||||
if (elements && elements.length > 0) {
|
||||
@ -424,17 +575,19 @@
|
||||
|
||||
}
|
||||
|
||||
if(policy_type_id > 7) {
|
||||
if (policy_type_id > 7 && policy_type_id != 72) {
|
||||
$("#sumInsuredDiv").empty();
|
||||
}
|
||||
|
||||
$("#sumInsuredDiv").empty();
|
||||
if(policy_type_id != 72){
|
||||
$("#familyFloaterDiv_others").empty();
|
||||
$("#familyFloaterDiv_others_two").empty();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
document.getElementById('otherButtonSpecialCondition').addEventListener('click', function(event) {
|
||||
|
||||
console.log('specialConditionForOthers callback clicked')
|
||||
@ -461,7 +614,7 @@
|
||||
<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[]">
|
||||
<input type="text" name="special_condition_input[]" id="special_condition_input[]" class="form-control other-speciial-condition special_condition_input[]">
|
||||
</div>`;
|
||||
console.log($(this));
|
||||
$('.other_special_condition').each(function() {
|
||||
@ -475,7 +628,7 @@
|
||||
|
||||
$(document).on('click', '#otherPolicyTermsClose', function() {
|
||||
|
||||
//clear the intervel for the autosave
|
||||
//clear the intervel for the autosave
|
||||
stopAutoSubmit();
|
||||
|
||||
$('#OtherPolicyTermsForm').css('display', 'none');
|
||||
@ -528,27 +681,27 @@
|
||||
|
||||
if (policy_type == 7) {
|
||||
|
||||
|
||||
|
||||
// <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>
|
||||
termsHTML = `
|
||||
// <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>
|
||||
termsHTML = `
|
||||
|
||||
<div class="form-group">
|
||||
<div class="row" style="margin-bottom: 10px;">
|
||||
@ -646,27 +799,27 @@
|
||||
|
||||
} else if (policy_type == 6) {
|
||||
|
||||
|
||||
|
||||
// <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>
|
||||
termsHTML = `
|
||||
// <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>
|
||||
termsHTML = `
|
||||
|
||||
<div class="form-group EDLI">
|
||||
|
||||
@ -765,14 +918,14 @@
|
||||
|
||||
function beautifyString(str) {
|
||||
return str
|
||||
.split('_') // Split the string by underscores
|
||||
.map(word =>
|
||||
word.charAt(0).toUpperCase() + word.slice(1).toLowerCase() // Capitalize each word
|
||||
.split('_') // Split the string by underscores
|
||||
.map(word =>
|
||||
word.charAt(0).toUpperCase() + word.slice(1).toLowerCase() // Capitalize each word
|
||||
)
|
||||
.join(' '); // Join with spaces instead of underscores
|
||||
.join(' '); // Join with spaces instead of underscores
|
||||
}
|
||||
|
||||
function autoSaveOtherTerms(){
|
||||
function autoSaveOtherTerms() {
|
||||
|
||||
console.log('autoSaveOtherTerms function called');
|
||||
|
||||
@ -789,10 +942,10 @@
|
||||
var formData = new FormData(form);
|
||||
var hasData = false;
|
||||
|
||||
|
||||
|
||||
for (let [key, value] of formData.entries()) {
|
||||
console.log("Key:", key, "Value:", value);
|
||||
if(key == "sum_insureds"){
|
||||
if (key == "sum_insureds") {
|
||||
if (value && value.toString().trim() !== '') {
|
||||
hasData = true;
|
||||
break;
|
||||
@ -820,10 +973,9 @@
|
||||
formObject[baseKey] = [];
|
||||
}
|
||||
formObject[baseKey].push(value.replace(/,/g, ''));
|
||||
} else if(key == 'sum_insureds'){
|
||||
} else if (key == 'sum_insureds') {
|
||||
formObject['sum_insured'] = value.replace(/,/g, '');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
formObject[key] = value;
|
||||
}
|
||||
}
|
||||
@ -853,7 +1005,7 @@
|
||||
|
||||
if (res.status == true) {
|
||||
showTinyToast();
|
||||
}else{
|
||||
} else {
|
||||
console.log('Policy terms Dose Not save', 'Error');
|
||||
return;
|
||||
}
|
||||
@ -867,19 +1019,19 @@
|
||||
}
|
||||
|
||||
function debounceothers(fn, delay) {
|
||||
let timeout;
|
||||
return function () {
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(fn, delay);
|
||||
};
|
||||
let timeout;
|
||||
return function() {
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(fn, delay);
|
||||
};
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
$(document).ready(function() {
|
||||
const form = document.querySelector("#otherPolicyTerms");
|
||||
|
||||
// MutationObserver (always runs)
|
||||
const observer = new MutationObserver(() => {
|
||||
$("#otherPolicyTerms").find("input, select, textarea").each(function () {
|
||||
$("#otherPolicyTerms").find("input, select, textarea").each(function() {
|
||||
if (other_auto_save_enable) { // only bind autosave if enabled
|
||||
if (!$(this).attr("data-observed")) {
|
||||
const debouncedSave = debounceothers(autoSaveOtherTerms, 1000);
|
||||
@ -890,18 +1042,103 @@
|
||||
});
|
||||
});
|
||||
|
||||
observer.observe(form, { childList: true, subtree: true });
|
||||
observer.observe(form, {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
|
||||
// Bind for existing fields (only if enabled)
|
||||
if (other_auto_save_enable) {
|
||||
const debouncedSave = debounceothers(autoSaveOtherTerms, 1000);
|
||||
$("#otherPolicyTerms").find("input, select, textarea").each(function () {
|
||||
$("#otherPolicyTerms").find("input, select, textarea").each(function() {
|
||||
$(this).on("input change", debouncedSave);
|
||||
$(this).attr("data-observed", "true");
|
||||
});
|
||||
} else {
|
||||
console.log("This policy has employee processed (autosave disabled) -- OTHERS") ;
|
||||
console.log("This policy has employee processed (autosave disabled) -- OTHERS");
|
||||
}
|
||||
});
|
||||
|
||||
$('#self_others').change(function() {
|
||||
if ($(this).prop('checked')) {
|
||||
$('.self-age').css('display', '');
|
||||
} else {
|
||||
$('.self-age').css('display', 'none');
|
||||
}
|
||||
});
|
||||
|
||||
$('#spouse_others').change(function() {
|
||||
console.log('spouse changed')
|
||||
if ($(this).prop('checked')) {
|
||||
$('.spouse-age').css('display', '');
|
||||
if ($('#spouse_min_age_others').val() < 17 || $('#spouse_min_age_others').val() == '') {
|
||||
$('#spouse_min_age_others').val(18);
|
||||
}
|
||||
if ($('#spouse_max_age_others').val() < 17 || $('#spouse_max_age_others').val() == '') {
|
||||
$('#spouse_max_age_others').val(60);
|
||||
}
|
||||
} else {
|
||||
$('.spouse-age').css('display', 'none');
|
||||
}
|
||||
});
|
||||
|
||||
$('#children_others').change(function() {
|
||||
if ($(this).val() != 0) {
|
||||
$('.child-age').css('display', '');
|
||||
|
||||
if ($('#child_min_age_others').val() < 0 || $('#child_min_age_others').val() == '') {
|
||||
$('#child_min_age_others').val(0);
|
||||
}
|
||||
if ($('#child_max_age_others').val() < 24 || $('#child_max_age_others').val() == '') {
|
||||
$('#child_max_age_others').val(25);
|
||||
}
|
||||
} else {
|
||||
$('.child-age').css('display', 'none');
|
||||
}
|
||||
});
|
||||
|
||||
$('#family_floaters_others').change(function() {
|
||||
|
||||
checkAdditionPremiumJSON()
|
||||
|
||||
var family_floaters = $(this).val();
|
||||
if ($('#family_floaters').val() != 0) {
|
||||
$('.other-member-age').css('display', '');
|
||||
if ($('#other_member_min_age_others').val() < 17 || $('#other_member_min_age_others').val() == '') {
|
||||
$('#other_member_min_age_others').val(18);
|
||||
}
|
||||
if ($('#other_member_max_age_others').val() < 79 || $('#other_member_max_age_others').val() == '') {
|
||||
$('#other_member_max_age_others').val(60);
|
||||
}
|
||||
|
||||
} else {
|
||||
$('.other-member-age').css('display', 'none');
|
||||
}
|
||||
|
||||
if (family_floaters == '1P') {
|
||||
$('#member_count_others').val(1);
|
||||
} else if (family_floaters == '2P') {
|
||||
$('#member_count_others').val(2);
|
||||
} else if (family_floaters == '1PIL') {
|
||||
$('#member_count_others').val(1);
|
||||
} else if (family_floaters == '2PIL') {
|
||||
$('#member_count_others').val(2);
|
||||
} else if (family_floaters == '2EPORPIL') {
|
||||
$('#member_count_others').val(2);
|
||||
} else if (family_floaters == 'EPORPIL') {
|
||||
$('#member_count_others').val(2);
|
||||
} else if (family_floaters == '4EPORPIL') {
|
||||
$('#member_count_others').val(4);
|
||||
}
|
||||
});
|
||||
|
||||
function lowerIsEighteenOthers(params) {
|
||||
var value = $(params).val();
|
||||
|
||||
if (value < 18) {
|
||||
$(params).val(18);
|
||||
} else if (value > 99) {
|
||||
$(params).val(99);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -3522,7 +3522,7 @@ function hideShowPolicyPremium(policy_type_string, unique_id = null)
|
||||
individual = $('#individual_' + unique_id);
|
||||
}
|
||||
|
||||
if (policy_type_string == 'GMC') {
|
||||
if (policy_type_string == 'GMC' || policy_type_string == 'OPD') {
|
||||
premium_type.show();
|
||||
individual.prop('checked', true)
|
||||
} else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user