FIX_BUG : RV

This commit is contained in:
VENKATESHWARAN 2025-08-07 10:48:56 +05:30
parent e006d76a99
commit 71d0e4dbf8
2 changed files with 306 additions and 292 deletions

View File

@ -2180,6 +2180,7 @@ class ClientController extends AdminController
$insurer_id = $client_policy_data['insurer_id'];
$client_id = $client_policy_data['client_id'];
$insurer_branch_id = $client_policy_data['insurer_branch_id'];
if (!empty($client_policy_data['policy_start_date'])) {
$client_policy_data['source_policy_start_date'] = change_date_format($client_policy_data['policy_start_date'], 'Y-m-d', 'd/m/Y');
@ -2200,7 +2201,8 @@ class ClientController extends AdminController
->findAll();
$client_policy_list = $this->clientPolicyModel->getPolicyTypeForPolicyBinding($client_id);
$cd_data = $this->CDMasterModel->where('client_id', $client_id)->where('insurer_id', $insurer_id)->where('is_active', 1)->findAll();
// $cd_data = $this->CDMasterModel->where('client_id', $client_id)->where('insurer_id', $insurer_id)->where('is_active', 1)->findAll();
$cd_data = $this->get_cd_ac($client_id, $insurer_id, $insurer_branch_id, "internal");
// $client_policy_data['policy_end_date'] = date('d/m/Y', strtotime($client_policy_data['policy_end_date']));
$fromDate = new \DateTime($client_policy_data['policy_end_date']);
$fromDate->modify('+1 year');
@ -2606,18 +2608,16 @@ class ClientController extends AdminController
'special_condition_input' => true,
'multiple_sum_insured' => true,
];
foreach ($fields as $field => $needsCleanup) {
$value = $this->request->getPost($field);
// $data = [];
// foreach ($fields as $field => $needsCleanup) {
// $value = $this->request->getPost($field);
// if ($value !== null && $value !== '') {
// $data[$field] = $needsCleanup ? str_replace(',', '', $value) : $value;
// }else{
// $data[$field] = $value;
// }
// }
if ($value !== null && $value !== '') {
$data[$field] = $needsCleanup ? str_replace(',', '', $value) : $value;
}else{
$data[$field] = $value;
}
}
$data['enrollment_display_key'] = $this->enrollmentGMCDisplayValueTransform();
@ -2949,25 +2949,25 @@ class ClientController extends AdminController
'air_ambulance'
];
// // Remove commas and assign if present
// foreach ($fieldsWithCommaRemoval as $field) {
// $value = $this->request->getPost($field);
// if ($value !== null) {
// $data[$field] = str_replace(',', '', $value);
// }else{
// $data[$field] = $value;
// }
// }
// Remove commas and assign if present
foreach ($fieldsWithCommaRemoval as $field) {
$value = $this->request->getPost($field);
if ($value !== null) {
$data[$field] = str_replace(',', '', $value);
}else{
$data[$field] = $value;
}
}
// // Direct assign if present
// foreach ($fieldsWithoutCommaRemoval as $field) {
// $value = $this->request->getPost($field);
// if ($value !== null) {
// $data[$field] = $value;
// }else{
// $data[$field] = $value;
// }
// }
// Direct assign if present
foreach ($fieldsWithoutCommaRemoval as $field) {
$value = $this->request->getPost($field);
if ($value !== null) {
$data[$field] = $value;
}else{
$data[$field] = $value;
}
}
$data['enrollment_display_key'] = $this->enrollmentGPADisplayValueTransform();
@ -3573,7 +3573,7 @@ class ClientController extends AdminController
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Additionaly Rack Rate Data Remove Successfully'], 200);
}
public function get_cd_ac($client_id, $insurer_id, $insurer_branch_id)
public function get_cd_ac($client_id, $insurer_id, $insurer_branch_id, $return_type = null)
{
// Get client data
$client_data = $this->clientModel
@ -3605,6 +3605,14 @@ class ClientController extends AdminController
$cd_data = array_merge($cd_data, $client_cd_data);
if($return_type == "internal"){
if(!empty($cd_data)){
return $cd_data;
}else{
return [];
}
}
if (!empty($cd_data)) {
return $this->respond([
'status' => true,

View File

@ -1136,287 +1136,289 @@
let jsonObject = JSON.parse(response.data);
disableUnwantedTerms(jsonObject);
Object.keys(jsonObject).forEach(function(key) {
if(jsonObject){
Object.keys(jsonObject).forEach(function(key) {
if (key.includes("special_condition_label") || key.includes("special_condition_input")) {
if (key.includes("special_condition_label")) {
if (jsonObject[key] && Array.isArray(jsonObject[key])) {
for (let index = 0; index < jsonObject[key].length; index++) {
specialCondition();
}
} else {
console.warn(`jsonObject[${key}] is not a valid array.`);
}
}
//console.log('key', key)
let elements = document.getElementsByName(`${key}[]`);
//console.log(elements)
if (elements) {
elements.forEach((element, index) => {
//console.log()
if (jsonObject[key][index] == undefined) {
element.value = " ";
if (key.includes("special_condition_label") || key.includes("special_condition_input")) {
if (key.includes("special_condition_label")) {
if (jsonObject[key] && Array.isArray(jsonObject[key])) {
for (let index = 0; index < jsonObject[key].length; index++) {
specialCondition();
}
} else {
element.value = jsonObject[key][index];
console.warn(`jsonObject[${key}] is not a valid array.`);
}
}
if (key.includes("special_condition_label")) {
let checkbox = $(element).closest('.form-group').find('input[name="special_condition_display[]"]');
console.log("First element:", element);
//console.log('key', key)
let elements = document.getElementsByName(`${key}[]`);
//console.log(elements)
if (checkbox.length) {
console.log("Checkbox found:", checkbox);
if (elements) {
elements.forEach((element, index) => {
//console.log()
if (jsonObject[key][index] == undefined) {
element.value = " ";
} else {
element.value = jsonObject[key][index];
// Correct way to set the 'id' attribute
let formattedValue = jsonObject[key][index].replace(/[\s\-\/,&]+/g, '').toLowerCase();
console.log('formattedValue', formattedValue);
checkbox.attr('id', formattedValue + '_display');
if (key.includes("special_condition_label")) {
let checkbox = $(element).closest('.form-group').find('input[name="special_condition_display[]"]');
console.log("First element:", element);
console.log("Updated Checkbox:", checkbox);
} else {
console.log("Checkbox not found for:", element);
if (checkbox.length) {
console.log("Checkbox found:", checkbox);
// Correct way to set the 'id' attribute
let formattedValue = jsonObject[key][index].replace(/[\s\-\/,&]+/g, '').toLowerCase();
console.log('formattedValue', formattedValue);
checkbox.attr('id', formattedValue + '_display');
console.log("Updated Checkbox:", checkbox);
} else {
console.log("Checkbox not found for:", element);
}
}
}
}
});
}
}
// if (key.includes("multiple_sum_insured")) {
// jsonObject[key].forEach((value, index) => {
// appendGMCSIAddMore(value);
// });
// }
if (key.includes("multiple_sum_insured") && key != "") {
if (Array.isArray(jsonObject[key])) {
jsonObject[key].forEach((value, index) => {
appendGMCSIAddMore(value);
});
} else {
console.log(`${key} is not an array.`);
}
}
if (key === "family_floater") {
if (jsonObject[key] === "Floater") {
setTimeout(() => {
$("#familyFloaterYes").prop("checked", true);
}, 100); // delay in milliseconds
} else {
$("#familyFloaterNo").prop("checked", true);
}
});
}
}
// if (key.includes("multiple_sum_insured")) {
// jsonObject[key].forEach((value, index) => {
// appendGMCSIAddMore(value);
// });
// }
if (key.includes("multiple_sum_insured") && key != "") {
if (Array.isArray(jsonObject[key])) {
jsonObject[key].forEach((value, index) => {
appendGMCSIAddMore(value);
});
} else {
console.log(`${key} is not an array.`);
}
}
if (key === "family_floater") {
if (jsonObject[key] === "Floater") {
setTimeout(() => {
$("#familyFloaterYes").prop("checked", true);
}, 100); // delay in milliseconds
} else {
$("#familyFloaterNo").prop("checked", true);
}
if (key.includes("family_floaters")) {
let checkboxes = document.querySelectorAll(
`input[name="${key}[]"]`);
if (jsonObject[key]) {
console.log(jsonObject[key]);
if (jsonObject[key].childrens) {
$('#children').val(jsonObject[key].childrens);
}
if (jsonObject[key].self == 0) {
$('#self').prop('checked', false);
}
if (jsonObject[key].spouse == 0) {
$('#spouse').prop('checked', false);
} else {
$('#spouse').prop('checked', true);
}
if (jsonObject[key]['either-parents-pil'] == 1) {
$('#family_floaters').val('EPORPIL');
} else if (jsonObject[key].parents == 1 && jsonObject[key][
'parents-in-law'
] == 1) {
$('#family_floaters').val('2EPORPIL');
} else if (jsonObject[key].parents == 2 && jsonObject[key][
'parents-in-law'
] == 2) {
$('#family_floaters').val('4EPORPIL');
} else if (jsonObject[key].parents == 1) {
$('#family_floaters').val('1P');
} else if (jsonObject[key].parents == 2) {
$('#family_floaters').val('2P');
} else if (jsonObject[key]['parents-in-law'] == 1) {
$('#family_floaters').val('1PIL');
} else if (jsonObject[key]['parents-in-law'] == 2) {
$('#family_floaters').val('2PIL');
} else if (jsonObject[key]['either-parents-pil'] == 2) {
$('#family_floaters').val('2EPORPIL');
}
}
}
if (key.includes("family_floaters")) {
let checkboxes = document.querySelectorAll(
`input[name="${key}[]"]`);
if (jsonObject[key]) {
console.log(jsonObject[key]);
if (jsonObject[key].childrens) {
$('#children').val(jsonObject[key].childrens);
}
if (jsonObject[key].self == 0) {
$('#self').prop('checked', false);
}
if (jsonObject[key].spouse == 0) {
$('#spouse').prop('checked', false);
} else {
$('#spouse').prop('checked', true);
}
let elements = document.getElementsByName(key);
if (elements && elements.length > 0) {
let element = elements[
0]; // Assuming you want to update the first element with the name
if (jsonObject[key]['either-parents-pil'] == 1) {
$('#family_floaters').val('EPORPIL');
} else if (jsonObject[key].parents == 1 && jsonObject[key][
'parents-in-law'
] == 1) {
$('#family_floaters').val('2EPORPIL');
} else if (jsonObject[key].parents == 2 && jsonObject[key][
'parents-in-law'
] == 2) {
$('#family_floaters').val('4EPORPIL');
} else if (jsonObject[key].parents == 1) {
$('#family_floaters').val('1P');
} else if (jsonObject[key].parents == 2) {
$('#family_floaters').val('2P');
} else if (jsonObject[key]['parents-in-law'] == 1) {
$('#family_floaters').val('1PIL');
} else if (jsonObject[key]['parents-in-law'] == 2) {
$('#family_floaters').val('2PIL');
} else if (jsonObject[key]['either-parents-pil'] == 2) {
$('#family_floaters').val('2EPORPIL');
}
}
if (element.tagName === 'INPUT' && (element.type ===
'checkbox' || element.type === 'radio')) {
}
if (element.type === 'checkbox') {
element.checked = jsonObject[key] ===
'1'; // Assuming jsonObject[key] is '1' or '0' for checkbox
} else if (element.type === 'radio') {
if (element.value === jsonObject[key]) {
element.checked = element.value === jsonObject[key];
if (element.name === "family_floater") {
element.parentElement.nextElementSibling.style
.display = '';
element.parentElement.parentElement
.parentElement.nextElementSibling.style
.display = '';
// alert('family floater');
} else if (element.name ===
"waiverofpreexistingdiseases") {
element.parentElement.parentElement
.nextElementSibling.style.display = '';
element.parentElement.parentElement
.nextElementSibling.nextElementSibling.style
.display = '';
element.parentElement.parentElement
.nextElementSibling.nextElementSibling
.nextElementSibling.style.display = '';
element.parentElement.parentElement
.nextElementSibling.nextElementSibling
.nextElementSibling.nextElementSibling.style
.display = '';
} else if (element.name === "ayudhtreatmentcover") {
element.parentElement.parentElement
.nextElementSibling.style.display = '';
} else if (element.name === "ailmentcapping") {
element.parentElement.parentElement
.nextElementSibling.style.display = '';
} else if (element.name === "copayzonewisecopay") {
element.parentElement.parentElement
.nextElementSibling.style.display = '';
} else if (element.name === "cataract") {
element.parentElement.parentElement
.nextElementSibling.style.display = '';
}
let elements = document.getElementsByName(key);
if (elements && elements.length > 0) {
let element = elements[
0]; // Assuming you want to update the first element with the name
if (element.tagName === 'INPUT' && (element.type ===
'checkbox' || element.type === 'radio')) {
if (element.type === 'checkbox') {
element.checked = jsonObject[key] ===
'1'; // Assuming jsonObject[key] is '1' or '0' for checkbox
} else if (element.type === 'radio') {
if (element.value === jsonObject[key]) {
element.checked = element.value === jsonObject[key];
if (element.name === "family_floater") {
element.parentElement.nextElementSibling.style
.display = '';
element.parentElement.parentElement
.parentElement.nextElementSibling.style
.display = '';
// alert('family floater');
} else if (element.name ===
"waiverofpreexistingdiseases") {
element.parentElement.parentElement
.nextElementSibling.style.display = '';
element.parentElement.parentElement
.nextElementSibling.nextElementSibling.style
.display = '';
element.parentElement.parentElement
.nextElementSibling.nextElementSibling
.nextElementSibling.style.display = '';
element.parentElement.parentElement
.nextElementSibling.nextElementSibling
.nextElementSibling.nextElementSibling.style
.display = '';
} else if (element.name === "ayudhtreatmentcover") {
element.parentElement.parentElement
.nextElementSibling.style.display = '';
} else if (element.name === "ailmentcapping") {
element.parentElement.parentElement
.nextElementSibling.style.display = '';
} else if (element.name === "copayzonewisecopay") {
element.parentElement.parentElement
.nextElementSibling.style.display = '';
} else if (element.name === "cataract") {
element.parentElement.parentElement
.nextElementSibling.style.display = '';
} else {
element.nextElementSibling.checked = element.value;
}
}
} else if (key === "Wellness" || key ===
"additionalsicknessbenefit") {
let wysiwygElement = element.previousElementSibling
.querySelector('.jodit-wysiwyg');
if (wysiwygElement) {
let pTag = wysiwygElement.querySelector(
'p'); // Find the <p> tag inside the wysiwyg element
if (pTag) {
// pTag.innerHTML = ''; // Clear the content inside the <p> tag
pTag.innerHTML = jsonObject[
key]; // Add your new content inside the <p> tag
}
}
console.log(jsonObject[key]);
} else {
console.log(jsonObject[key]);
if (jsonObject[key] === undefined || jsonObject[key] === "" || jsonObject[key] === null) {
element.value = " ";
} else {
element.nextElementSibling.checked = element.value;
element.value = jsonObject[key];
}
}
} else if (key === "Wellness" || key ===
"additionalsicknessbenefit") {
let wysiwygElement = element.previousElementSibling
.querySelector('.jodit-wysiwyg');
if (wysiwygElement) {
let pTag = wysiwygElement.querySelector(
'p'); // Find the <p> tag inside the wysiwyg element
if (pTag) {
// pTag.innerHTML = ''; // Clear the content inside the <p> tag
pTag.innerHTML = jsonObject[
key]; // Add your new content inside the <p> tag
}
}
console.log(jsonObject[key]);
} else {
console.log(jsonObject[key]);
if (jsonObject[key] === undefined || jsonObject[key] === "" || jsonObject[key] === null) {
element.value = " ";
} else {
element.value = jsonObject[key];
}
}
}
if (key.includes("age_ratio")) {
if (key.includes("age_ratio")) {
$('#self_min_age').val(jsonObject[key].self.min);
$('#self_max_age').val(jsonObject[key].self.max);
$('#self_min_age').val(jsonObject[key].self.min);
$('#self_max_age').val(jsonObject[key].self.max);
$('#spouse_min_age').val(jsonObject[key].spouse.min);
$('#spouse_max_age').val(jsonObject[key].spouse.max);
$('#spouse_min_age').val(jsonObject[key].spouse.min);
$('#spouse_max_age').val(jsonObject[key].spouse.max);
$('#child_min_age').val(jsonObject[key].child.min);
$('#child_max_age').val(jsonObject[key].child.max);
$('#child_min_age').val(jsonObject[key].child.min);
$('#child_max_age').val(jsonObject[key].child.max);
$('#other_member_min_age').val(jsonObject[key].elders.min);
$('#other_member_max_age').val(jsonObject[key].elders.max);
}
$('#other_member_min_age').val(jsonObject[key].elders.min);
$('#other_member_max_age').val(jsonObject[key].elders.max);
}
// if (key.includes("is_payable_employee")) {
// if (key.includes("is_payable_employee")) {
// if (jsonObject[key]) {
// if (jsonObject[key]) {
// if (jsonObject[key].self == 0) {
// $('#is_payable_employee_for_self').prop('checked',
// false);
// } else {
// $('#is_payable_employee_for_self').prop('checked',
// true);
// }
// if (jsonObject[key].self == 0) {
// $('#is_payable_employee_for_self').prop('checked',
// false);
// } else {
// $('#is_payable_employee_for_self').prop('checked',
// true);
// }
// if (jsonObject[key].spouse == 0) {
// $('#is_payable_employee_for_spouse').prop('checked',
// false);
// } else {
// $('#is_payable_employee_for_spouse').prop('checked',
// true);
// }
// if (jsonObject[key].spouse == 0) {
// $('#is_payable_employee_for_spouse').prop('checked',
// false);
// } else {
// $('#is_payable_employee_for_spouse').prop('checked',
// true);
// }
// if (jsonObject[key].childern == 0) {
// $('#is_payable_employee_for_child').prop('checked',
// false);
// } else {
// $('#is_payable_employee_for_child').prop('checked',
// true);
// }
// if (jsonObject[key].childern == 0) {
// $('#is_payable_employee_for_child').prop('checked',
// false);
// } else {
// $('#is_payable_employee_for_child').prop('checked',
// true);
// }
// // if (jsonObject[key].elders == 0) {
// // $('#is_payable_employee_for_elders').prop('checked',
// // false);
// // } else {
// // $('#is_payable_employee_for_elders').prop('checked',
// // true);
// // }
// // if (jsonObject[key].elders == 0) {
// // $('#is_payable_employee_for_elders').prop('checked',
// // false);
// // } else {
// // $('#is_payable_employee_for_elders').prop('checked',
// // true);
// // }
// }
// }
// }
// }
if (key.includes("enrollment_display_key") && key != "") {
if (key.includes("enrollment_display_key") && key != "") {
console.log('enrollment_display_key');
console.log(jsonObject[key]);
console.log('enrollment_display_key');
console.log(jsonObject[key]);
processJsonObject(jsonObject);
}
processJsonObject(jsonObject);
}
});
});
}
}
$("#sum_insured").trigger("keyup");
@ -1886,36 +1888,40 @@
}
function disableUnwantedTerms(jsonObject) {
// alert("Disabling unwanted terms");
fields.forEach(function(key) {
// If key NOT in jsonObject, then hide and disable its associated elements
if (!jsonObject.hasOwnProperty(key)) {
const elements = document.getElementsByName(key);
console.log("Disabling unwanted terms");
console.log("jsonObject : ", jsonObject);
elements.forEach(element => {
element.style.display = "none";
element.disabled = true;
if(jsonObject){
fields.forEach(function(key) {
// If key NOT in jsonObject, then hide and disable its associated elements
if (!jsonObject?.hasOwnProperty(key)) {
const elements = document.getElementsByName(key);
const label = document.querySelector(`label[for="${element.id}"]`);
if (label) {
label.style.display = "none";
}
elements.forEach(element => {
element.style.display = "none";
element.disabled = true;
const displayElement = document.getElementById(`${element.id}_display`);
if (displayElement) {
displayElement.checked = false;
displayElement.disabled = true;
displayElement.style.display = "none";
}
const label = document.querySelector(`label[for="${element.id}"]`);
if (label) {
label.style.display = "none";
}
const rowDiv = element.closest('.row');
if (rowDiv) {
rowDiv.style.display = "none";
}
const displayElement = document.getElementById(`${element.id}_display`);
if (displayElement) {
displayElement.checked = false;
displayElement.disabled = true;
displayElement.style.display = "none";
}
const rowDiv = element.closest('.row');
if (rowDiv) {
rowDiv.style.display = "none";
}
});
}
});
}
});
}
function autoSaveGmcTerms()