FIX_RACK_RATE_ISSUES_AND_OTHER : RV

This commit is contained in:
VENKATESHWARAN 2024-06-21 15:38:49 +05:30
parent 51346c586b
commit b9320f22da
6 changed files with 335 additions and 207 deletions

View File

@ -1907,7 +1907,7 @@ class ClientController extends AdminController
"sum_insured" => "Sum Insured",
"family_floater" => "Family Floater",
"family_floaters" => "Family Floaters",
"member_count" => "Elders Count:",
"elders_count" => "Elders Count:",
"other_member_min_age" => "Min Age:",
"other_member_max_age" => "Min Age:",
"waiverofpreexistingdiseases" => "Waiver of Pre-existing Diseases",
@ -2067,19 +2067,27 @@ class ClientController extends AdminController
} else if (array_key_exists($key, $mapping)) {
$transformedData[$mapping[$key]] = $value;
} else if ($key == 'special_condition_label') {
foreach ($value as $key => $value) {
$transformedData[$value] = $data['special_condition_input'][$key];
if (is_array($value)) {
foreach ($value as $key => $value) {
$transformedData[$value] = $data['special_condition_input'][$key];
}
}
} else if ($key == 'gpa_special_condition_label') {
foreach ($value as $key => $value) {
$transformedData[$value] = $data['gpa_special_condition_input'][$key];
} else if ($key == 'gpa_special_condition_label') {
if (is_array($value)) {
foreach ($value as $key => $value) {
$transformedData[$value] = $data['gpa_special_condition_input'][$key];
}
}
} else if ($key == 'other_special_condition_label') {
if (is_array($value)) {
foreach ($value as $key => $value) {
$transformedData[$value] = $data['other_special_condition_label'][$key];
}
}
} else if ($key == 'age_ratio') {
if (isset($data['sumInsured2'])) {
$transformedData['Self'] = "(Min: " . $data['age_ratio']['self']['min'] . ", Max: " . $data['age_ratio']['self']['max'] . ")";
}
} else {
@ -2217,21 +2225,33 @@ class ClientController extends AdminController
}
public function getPolicyTerms($client_policy_id){
public function getPolicyTerms($client_policy_id)
{
$policy_terms = $this->clientPolicyModel->where('id', $client_policy_id)->first();
if(isset($policy_terms['policy_terms']) && $policy_terms['policy_terms'] != null){
if (isset($policy_terms['policy_terms']) && $policy_terms['policy_terms'] != null) {
$JSON = json_decode($policy_terms['policy_terms']);
$si = $JSON->sum_insured ?? $JSON->sumInsured2;
$multi_si = $JSON->multiple_sum_insured;
$multi_si[] = $si;
}else{
$$multi_si = [];
$si = null;
if (isset($JSON->sum_insured) && !empty($JSON->sum_insured)) {
$si = $JSON->sum_insured;
} elseif (isset($JSON->sumInsured2) && !empty($JSON->sumInsured2)) {
$si = $JSON->sumInsured2;
}
if ($si !== null) {
$multi_si = $JSON->multiple_sum_insured ?? [];
$multi_si[] = $si;
} else {
$multi_si = [];
}
} else {
$multi_si = [];
}
return $this->respond(['status' => true, 'data'=>$multi_si], 200);
return $this->respond(['status' => true, 'data' => $multi_si], 200);
}

View File

@ -270,18 +270,20 @@ $(document).ready(function() {
$(document).on('click', '.policy_terms', function() {
var terms = $(this).data('id');
console.log(terms);
console.log(JSON.stringify(terms));
// terms = JSON.parse(terms);
$('#modal_body').empty();
function createListItems(obj) {
const fragment = document.createDocumentFragment();
for (const key in obj) {
if (obj.hasOwnProperty(key) && obj[key] !== null && obj[key] !== '' && key !=
'family_floater' && key != 'gpa_special_condition_input' && key !=
'gpa_special_condition_label' && key != 'special_condition_label' && key !=
'special_condition_input' && key != 'age_ratio') {
'special_condition_input' && key != 'age_ratio' && key != "multiple_sum_insured" && key != "other_special_condition_label" && key != "other_special_condition_input") {
const listItem = document.createElement('li');
@ -326,6 +328,7 @@ $(document).on('click', '.policy_terms', function() {
}
$('#modal_body').append(createListItems(terms));
});
</script>

View File

@ -78,7 +78,8 @@ label {
<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><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() ?>" />
@ -87,7 +88,7 @@ label {
<input type="hidden" name="policy_id" id="gpa_policy_id" />
<input type="hidden" id="emp_count" />
<div id="append_html_for_other_policy_terms" ></div>
<div id="append_html_for_other_policy_terms"></div>
<hr>
@ -108,12 +109,10 @@ label {
<script>
$("#otherPolicyTerms").submit(function(event) {
event.preventDefault();
var isValid = $('#otherPolicyTerms').parsley().validate();
console.log('isvalid', isValid);
@ -133,30 +132,37 @@ $("#otherPolicyTerms").submit(function(event) {
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);
} else {
formObject[key] = value;
// 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);
console.log(formObject);
const jsonString = JSON.stringify(formObject);
console.log(jsonString);
const jsonString = JSON.stringify(formObject);
console.log(jsonString);
// Append the JSON string to the FormData object
formData.append('policy_terms', jsonString);
// return;
// Append the JSON string to the FormData object
formData.append('policy_terms', jsonString);
$.ajax({
@ -189,7 +195,6 @@ $("#otherPolicyTerms").submit(function(event) {
});
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
$('#OtherPolicyTermsForm').css('display', 'none');
@ -208,7 +213,7 @@ $('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);
console.log('client_policy_id :', client_policy_id);
$('#other_client_policy_id').val(client_policy_id);
@ -238,7 +243,7 @@ $('body').on('click', '.btnPolicyMaster', function() {
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');
@ -287,7 +292,16 @@ $('body').on('click', '.btnPolicyMaster', function() {
}
});
}
}
if (key.includes("multiple_sum_insured")) {
gpaJsonObjectForSpecialCondition[key].forEach((value, index) => {
appendOtherSIAddMore(value);
});
}
});
@ -295,9 +309,15 @@ $('body').on('click', '.btnPolicyMaster', function() {
let jsonObject = JSON.parse(res.data);
Object.keys(jsonObject).forEach(function(key) {
console.log(key)
let elements = document.getElementsByName(key);
// console.log(elements)
if(key == 'sum_insured'){
elements = document.getElementsByName('sum_insureds')
}
console.log(elements)
if (elements && elements.length > 0) {
let element = elements[0];
@ -309,7 +329,6 @@ $('body').on('click', '.btnPolicyMaster', function() {
element.checked = jsonObject[key] === '1';
} else if (element.type === 'radio') {
element.checked = element.value === jsonObject[key];
}
} else {
@ -317,7 +336,11 @@ $('body').on('click', '.btnPolicyMaster', function() {
if (jsonObject[key] == undefined) {
element.value = " ";
} else {
element.value = jsonObject[key];
console.log(element);
console.log(jsonObject[key]);
console.log(element.value);
}
}
}
@ -327,6 +350,10 @@ $('body').on('click', '.btnPolicyMaster', function() {
}
$('#sum_insured_others').trigger('keyup');
$(".multiple_sum_insured").trigger("keyup");
},
error: function(xhr, status, error) {
@ -338,7 +365,7 @@ $('body').on('click', '.btnPolicyMaster', function() {
}
});
}
}
});
</script>
@ -395,13 +422,14 @@ $(document).on('click', '#otherPolicyTermsClose', function() {
});
$("#sumInsured2").on("keyup", function() {
$("#sum_insured_others").on("keyup", function() {
var inputNumber = $(this).val();
console.log('sum_insured_others keyup', inputNumber)
if (inputNumber) {
var result = convertCommaNumberToWords(inputNumber);
$("#numberToWordSumInsured").text(result);
$("#numberToWordOthers").text(result);
} else {
$("#numberToWordSumInsured").text("");
$("#numberToWordOthers").text("");
}
});
@ -417,6 +445,20 @@ $("#totalSumInsured").on("keyup", function() {
});
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);
} else {
$("#numberToWordOthers").text("");
}
};
function appendPolicyTermsHTML(policy_type) {
@ -429,6 +471,25 @@ function appendPolicyTermsHTML(policy_type) {
<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>
@ -523,11 +584,30 @@ function appendPolicyTermsHTML(policy_type) {
`
} 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>
@ -592,28 +672,31 @@ function appendPolicyTermsHTML(policy_type) {
}
function appendOtherTermsSIAddMore(data = null){
function appendOtherSIAddMore(data = null) {
console.log('function called')
const addMoreContainer = document.getElementById('sum_insured_add_more');
var 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 value="${data == null || data == undefined || data == "" ? '' : data}" type="text" name="multiple_sum_insured[]" class="form-control multiple_sum_insured" onkeypress="return onlyNumbers(event)" onkeyup="formatNumber(this)">
</div>
<div class="col-md-2">
<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="appendGPASIAddMore()">+</button>
</div>
<div class="col-md-6">
<div class="text-danger-2 numberToWordSumInsured"></div>
</div>
</div>`;
console.log(addMoreContainer)
$('#other_si_add_more').append(html);
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);
}
</script>

View File

@ -111,9 +111,9 @@
<label for="sumInsured">Sum Insured</label>
</div>
<div class="col-md-4">
<input type="text" name="sum_insured" id="sum_insured" class="form-control" onkeypress = "return onlyNumbers(event)" onkeyup=" formatNumber(this); si_keup_num_to_word(this)">
<input style="width: 128%;" type="text" name="sum_insured" id="sum_insured" class="form-control" onkeypress = "return onlyNumbers(event)" onkeyup=" formatNumber(this); si_keup_num_to_word(this)">
</div>
<div class="col-md-2">
<div class="col-md-2" style="position: relative;left: 88px;">
<button type="button" class="btn btn-primary si-add-more" onclick="appendGMCSIAddMore()">+</button>
</div>
<div class="col-md-6">
@ -141,14 +141,14 @@
<tr>
<td style="width: 11%;"><span style="margin-right: 20px;">Self:</span></td>
<td style="width: 11%;"><input type="checkbox" style="margin-right: 70px;" name="family_floaters[]" value="self" id="self" checked> </td>
<td style="width: 28%;" ><div class="self-age"><span style="margin-right: 20px;">Min Age:</span><input class="underline-input min_age" value="<?php echo (isset($self_min_age) && $self_min_age > 0) ? $self_min_age : '18'; ?>" style="width: 35%;;" type="number" name="self_min_age" id="self_min_age" oninput="lowerIsEighteen(this)"></div></td>
<td style="width: 28%;" ><div class="self-age"><span style="margin-right: 20px;">Max Age:</span><input class="underline-input max_age" value="<?php echo isset($self_max_age) ? $self_max_age : '60'; ?>" style="width: 35%;;" type="number" name="self_max_age" id="self_max_age" oninput="lowerIsEighteen(this)"></div></td>
<td style="width: 28%;" ><div class="self-age"><span style="margin-right: 20px;">Min Age:</span><input class="underline-input min_age" value="<?php echo (isset($self_min_age) && $self_min_age > 0) ? $self_min_age : '18'; ?>" style="width: 35%;;" type="number" name="self_min_age" id="self_min_age" onchange="lowerIsEighteen(this)"></div></td>
<td style="width: 28%;" ><div class="self-age"><span style="margin-right: 20px;">Max Age:</span><input class="underline-input max_age" value="<?php echo isset($self_max_age) ? $self_max_age : '60'; ?>" style="width: 35%;;" type="number" name="self_max_age" id="self_max_age" onchange="lowerIsEighteen(this)"></div></td>
</tr><tr><td></td></tr><tr><td></td></tr><tr><td></td></tr>
<tr>
<td style="width: 11%;"><span style="margin-right: 20px;">Spouse:</span></td>
<td style="width: 11%;"><input type="checkbox" style="margin-right: 70px;"name="family_floaters[]" value="spouse" id="spouse"></td>
<td style="width: 28%;" ><div class="spouse-age"><span style="margin-right: 20px;">Min Age:</span><input class="underline-input min_age" value="<?php echo isset($spouse_min_age) ? $spouse_min_age : '18'; ?>" style="width: 35%;;" type="number" name="spouse_min_age" id="spouse_min_age" oninput="lowerIsEighteen(this)"></div></td>
<td style="width: 28%;" ><div class="spouse-age"><span style="margin-right: 20px;">Max Age:</span><input class="underline-input max_age" value="<?php echo isset($spouse_max_age) ? $spouse_max_age : '60'; ?>" style="width: 35%;;" type="number" name="spouse_max_age" id="spouse_max_age" oninput="lowerIsEighteen(this)"></div></td>
<td style="width: 28%;" ><div class="spouse-age"><span style="margin-right: 20px;">Min Age:</span><input class="underline-input min_age" value="<?php echo isset($spouse_min_age) ? $spouse_min_age : '18'; ?>" style="width: 35%;;" type="number" name="spouse_min_age" id="spouse_min_age" onchange="lowerIsEighteen(this)"></div></td>
<td style="width: 28%;" ><div class="spouse-age"><span style="margin-right: 20px;">Max Age:</span><input class="underline-input max_age" value="<?php echo isset($spouse_max_age) ? $spouse_max_age : '60'; ?>" style="width: 35%;;" type="number" name="spouse_max_age" id="spouse_max_age" onchange="lowerIsEighteen(this)"></div></td>
</tr><tr><td></td></tr><tr><td></td></tr><tr><td></td></tr>
<tr>
<td style="width: 11%;"><span for="children">Children:</span></td>
@ -190,8 +190,8 @@
<tbody>
<tr>
<td style="width: 22%;" ><div class="other-member-age"><span style="margin-right: 20px;">Elders Count:</span><input class="underline-input" id="member_count" style="width: 30%; width: 30%;background: lightgray;" type="number" name="elder_member_count" id="member_count" readonly></div></td>
<td style="width: 28%;" ><div class="other-member-age" style="margin-left: 32px;"><span style="margin-right: 20px;">Min Age:</span><input class="underline-input min_age" value="<?php echo isset($other_member_min_age) ? $other_member_min_age : '18'; ?>" style="width: 35%;;" type="number" class="underline-input min_age" name="other_member_min_age" id="other_member_min_age" oninput="lowerIsEighteen(this)"></div></td>
<td style="width: 28%;" ><div class="other-member-age" style="margin-left: 17px;"><span style="margin-right: 20px;">Max Age:</span><input class="underline-input max_age" value="<?php echo isset($other_member_max_age) ? $other_member_max_age : '60'; ?>" style="width: 35%;;" type="number" class="underline-input max_age" name="other_member_max_age" id="other_member_max_age" oninput="lowerIsEighteen(this)"></div></td>
<td style="width: 28%;" ><div class="other-member-age" style="margin-left: 32px;"><span style="margin-right: 20px;">Min Age:</span><input class="underline-input min_age" value="<?php echo isset($other_member_min_age) ? $other_member_min_age : '18'; ?>" style="width: 35%;;" type="number" class="underline-input min_age" name="other_member_min_age" id="other_member_min_age" onchange="lowerIsEighteen(this)"></div></td>
<td style="width: 28%;" ><div class="other-member-age" style="margin-left: 17px;"><span style="margin-right: 20px;">Max Age:</span><input class="underline-input max_age" value="<?php echo isset($other_member_max_age) ? $other_member_max_age : '60'; ?>" style="width: 35%;;" type="number" class="underline-input max_age" name="other_member_max_age" id="other_member_max_age" onchange="lowerIsEighteen(this)"></div></td>
</tr>
</tbody>
</table>
@ -1418,9 +1418,9 @@
<label for="sumInsured">Additional Sum Insured</label>
</div>
<div class="col-md-4">
<input value="${data == null || data == undefined || data == "" ? '' : data}" type="text" name="multiple_sum_insured[]" class="form-control multiple_sum_insured" onkeypress="return onlyNumbers(event)" onkeyup="formatNumber(this); numtowordinkeyup(this)">
<input style="width: 128%;" value="${data == null || data == undefined || 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">
<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="appendGMCSIAddMore()">+</button>
</div>

View File

@ -91,9 +91,9 @@
<label for="sumInsured">Sum Insured</label>
</div>
<div class="col-md-4">
<input class="form-control" type="text" name="sumInsured2" id="sumInsured2" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" style="width: 100% !important;">
<input style="width: 128%;" class="form-control" type="text" name="sumInsured2" id="sumInsured2" onkeypress = "return onlyNumbers(event)" onkeyup="formatNumber(this)" style="width: 100% !important;">
</div>
<div class="col-md-2">
<div class="col-md-2" style="position: relative;left: 88px;">
<button type="button" class="btn btn-primary si-add-more" onclick="appendGPASIAddMore()">+</button>
</div>
<div class="col-md-6">
@ -137,13 +137,13 @@
<td style="width: 20%;">
<div class="self-age">
<span style="margin-right: 20px;">Min Age:</span>
<input class="underline-input min_age" value="<?php echo isset($self_min_age) ? $self_min_age : '18'; ?>" style="width: 65%;" type="number" name="self_min_age" id="self_min_age_gpa" oninput="lowerIsEighteen(this)">
<input class="underline-input min_age" value="<?php echo isset($self_min_age) ? $self_min_age : '18'; ?>" style="width: 65%;" type="number" name="self_min_age" id="self_min_age_gpa" onchange="lowerIsEighteen(this)">
</div>
</td>
<td style="width: 20%;">
<div class="self-age">
<span style="margin-right: 20px;">Max Age:</span>
<input class="underline-input max_age" value="<?php echo isset($self_max_age) ? $self_max_age : '60'; ?>" style="width: 65%;" type="number" name="self_max_age" id="self_max_age_gpa" oninput="lowerIsEighteen(this)">
<input class="underline-input max_age" value="<?php echo isset($self_max_age) ? $self_max_age : '60'; ?>" style="width: 65%;" type="number" name="self_max_age" id="self_max_age_gpa" onchange="lowerIsEighteen(this)">
</div>
</td>
<td ></td>
@ -792,9 +792,9 @@
<label for="sumInsured">Additional Sum Insured</label>
</div>
<div class="col-md-4">
<input value="${data == null || data == undefined || data == "" ? '' : data}" type="text" name="multiple_sum_insured[]" class="form-control multiple_sum_insured" onkeypress="return onlyNumbers(event)" onkeyup="formatNumber(this); numtowordinkeyup(this)">
<input style="width: 128%;" value="${data == null || data == undefined || 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">
<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="appendGPASIAddMore()">+</button>
</div>

View File

@ -827,12 +827,16 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
};
$("#GridForm").submit(async function(event) {
$("#GridForm").submit(function(event) {
event.preventDefault();
var check = checkDuplicate(0);
console.log(check)
if(check){
return;
}
event.preventDefault();
if ($('#grid_emp_count').val() == 'false') {
toastr.warning('Client has active employees', 'Warning');
@ -854,9 +858,16 @@ $("#GridForm").submit(async function(event) {
checkPolicyTermsSI(function(result) {
console.log('checkPolicyTermsSI callback')
console.log(result);
if (!result) {
if (check) {
console.log('after result');
if (check = false) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
} else {
@ -901,15 +912,14 @@ $("#GridForm").submit(async function(event) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning(`Value does not exist in the Policy Terms.`);
toastr.warning(`Sum Insured Amount does not exist in the Policy Terms.`);
}
}).catch(function(error) {
console.error('Error checking policy terms:', error);
// Handle error if necessary
toastr.error(`Error checking policy terms: ${error}`);
});
}).catch(function(error) {
console.error('Error checking policy terms:', error);
// Handle error if necessary
console.log(`Error checking policy terms: ${error}`);
});
});
@ -941,46 +951,61 @@ $("#AdditionalGridForm").submit(function(event) {
var formData = new FormData($('#AdditionalGridForm')[0]);
var policy_form_action = '<?= base_url("client/premimum/create") ?>';
checkPolicyTermsSI(function(result) {
if (check) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
} else {
$.ajax({
data: formData,
url: policy_form_action,
type: "POST",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
//console.log("Response", res);
if (res.status === false) {
toastr.error('Policy Dose Not Create', 'Error');
return;
}
if (!result) {
if (check) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
} else {
$.ajax({
data: formData,
url: policy_form_action,
type: "POST",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
var message = (policy_PrimaryKey === '') ?
'Policy Additional Rack Rate Added successfully' :
'Policy Additional Rack Rate Added Successfully';
toastr.success(message, 'Success');
$('.close').click();
//console.log("Response", res);
},
error: function(xhr, status, error) {
if (res.status === false) {
toastr.error('Policy Dose Not Create', 'Error');
return;
}
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
var message = (policy_PrimaryKey === '') ?
'Policy Additional Rack Rate Added successfully' :
'Policy Additional Rack Rate Added Successfully';
toastr.success(message, 'Success');
$('.close').click();
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}
});
}
});
}
}else{
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning(`Sum Insured Amount does not exist in the Policy Terms.`);
}
}).catch(function(error) {
console.error('Error checking policy terms:', error);
// Handle error if necessary
console.log(`Error checking policy terms: ${error}`);
});
});
@ -2936,126 +2961,123 @@ function checkTermsSISameAsRackRateSI(input) {
}
function checkPolicyTermsSI(callback) {
function checkPolicyTermsSI(callback) {
console.log('checkPolicyTermsSI function called');
console.log('r function called');
var id = $('#additional_grid')[0];
var id = $('#additional_grid')[0];
var container = $('#additional_grid_content_input');
var val = 0;
var val = 0;
if (val == 0) {
id = $('#grid')[0];
container = $('#grid_content_input');
}
console.log(id);
console.log(container);
var siInputs = 0;
var siInputs = null;
if (id.value === '2') {
siInputs = container.find('input[name="gpa_si"]');
} else if (id.value === '3') {
siInputs = container.find('input[name="3_si[]"]');
} else if (id.value === '4') {
siInputs = container.find('input[name="4_si[]"]');
} else if (id.value === '5') {
siInputs = container.find('input[name="5_si[]"]');
} else if (id.value === '6') {
siInputs = container.find('input[name="6_si[]"]');
} else if (id.value === '7') {
siInputs = container.find('input[name="7_si[]"]');
} else if (id.value === '8') {
siInputs = container.find('input[name="8_si[]"]');
} else if (id.value === '9') {
siInputs = container.find('input[name="9_si[]"]');
} else if (id.value === '10') {
siInputs = container.find('input[name="10_si[]"]');
} else if (id.value === '11') {
siInputs = container.find('input[name="11_si[]"]');
} else if (id.value === '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[]"]');
}
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="9_si[]"]');
break;
case '10':
siInputs = container.find('input[name="10_si[]"]');
break;
case '11':
siInputs = container.find('input[name="11_si[]"]');
break;
default:
siInputs = [];
}
console.log('siInputs', siInputs);
var client_policy_id = $('#client_policy_id').val();
console.log('client_policy_id', client_policy_id)
console.log('client_policy_id', client_policy_id);
var url = '<?php echo base_url('util/getPolicyTerms/') ?>' + client_policy_id;
var arrayLength = 0;
console.log('url', url);
$.ajax({
url: url,
type: 'GET',
dataType: 'json',
success: function(response) {
console.log(response);
console.log(response.data);
var array1 = response.data;
var array2 = [];
var policy_terms_si = response.data;
var rack_rate_si = [];
siInputs.each(function() {
var input = $(this).val();
array2.push(input.replace(/,/g, ''));
rack_rate_si.push(input.replace(/,/g, ''));
});
console.log('array1', array1)
console.log('array2', array2)
console.log('policy_terms_si', policy_terms_si);
console.log('rack_rate_si', rack_rate_si);
let new_array = [];
function intersection(arr1, arr2) {
return arr1.filter(value => arr2.includes(value));
rack_rate_si.forEach(element => {
if (!policy_terms_si.includes(element)) {
new_array.push(element);
}
});
console.log('filtered array', new_array);
var arrayLength = new_array.length;
console.log('arrayLength', arrayLength);
if (arrayLength > 0) {
callback(true);
} else {
callback(false);
}
var commonElements = intersection(array1, array2);
function removeCommonElements(arr, common) {
return arr.filter(value => !common.includes(value));
}
array1 = removeCommonElements(array1, commonElements);
array2 = removeCommonElements(array2, commonElements);
console.log('array1', array1)
console.log('array2', array2)
// var result = array1.concat(array2);
var result = array1;
console.log('result', result)
arrayLength = result.length;
console.log('arrayLength', arrayLength)
if (arrayLength > 0) {
callback(true);
} else {
callback(false);
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
toastr.error(`Failed to retrieve Policy Terms. Error: ${error}`);
console.log(xhr.responseText);
console.log(status, error);
console.log(`Failed to retrieve Policy Terms. Error: ${error}`);
callback(false);
}
});
}
</script>