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']; $insurer_id = $client_policy_data['insurer_id'];
$client_id = $client_policy_data['client_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'])) { 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'); $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(); ->findAll();
$client_policy_list = $this->clientPolicyModel->getPolicyTypeForPolicyBinding($client_id); $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'])); // $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 = new \DateTime($client_policy_data['policy_end_date']);
$fromDate->modify('+1 year'); $fromDate->modify('+1 year');
@ -2606,18 +2608,16 @@ class ClientController extends AdminController
'special_condition_input' => true, 'special_condition_input' => true,
'multiple_sum_insured' => true, 'multiple_sum_insured' => true,
]; ];
foreach ($fields as $field => $needsCleanup) {
$value = $this->request->getPost($field);
// $data = []; if ($value !== null && $value !== '') {
$data[$field] = $needsCleanup ? str_replace(',', '', $value) : $value;
// foreach ($fields as $field => $needsCleanup) { }else{
// $value = $this->request->getPost($field); $data[$field] = $value;
}
// if ($value !== null && $value !== '') { }
// $data[$field] = $needsCleanup ? str_replace(',', '', $value) : $value;
// }else{
// $data[$field] = $value;
// }
// }
$data['enrollment_display_key'] = $this->enrollmentGMCDisplayValueTransform(); $data['enrollment_display_key'] = $this->enrollmentGMCDisplayValueTransform();
@ -2949,25 +2949,25 @@ class ClientController extends AdminController
'air_ambulance' 'air_ambulance'
]; ];
// // Remove commas and assign if present // Remove commas and assign if present
// foreach ($fieldsWithCommaRemoval as $field) { foreach ($fieldsWithCommaRemoval as $field) {
// $value = $this->request->getPost($field); $value = $this->request->getPost($field);
// if ($value !== null) { if ($value !== null) {
// $data[$field] = str_replace(',', '', $value); $data[$field] = str_replace(',', '', $value);
// }else{ }else{
// $data[$field] = $value; $data[$field] = $value;
// } }
// } }
// // Direct assign if present // Direct assign if present
// foreach ($fieldsWithoutCommaRemoval as $field) { foreach ($fieldsWithoutCommaRemoval as $field) {
// $value = $this->request->getPost($field); $value = $this->request->getPost($field);
// if ($value !== null) { if ($value !== null) {
// $data[$field] = $value; $data[$field] = $value;
// }else{ }else{
// $data[$field] = $value; $data[$field] = $value;
// } }
// } }
$data['enrollment_display_key'] = $this->enrollmentGPADisplayValueTransform(); $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); 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 // Get client data
$client_data = $this->clientModel $client_data = $this->clientModel
@ -3605,6 +3605,14 @@ class ClientController extends AdminController
$cd_data = array_merge($cd_data, $client_cd_data); $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)) { if (!empty($cd_data)) {
return $this->respond([ return $this->respond([
'status' => true, 'status' => true,

View File

@ -1136,287 +1136,289 @@
let jsonObject = JSON.parse(response.data); let jsonObject = JSON.parse(response.data);
disableUnwantedTerms(jsonObject); 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") || key.includes("special_condition_input")) {
if (key.includes("special_condition_label")) { if (key.includes("special_condition_label")) {
if (jsonObject[key] && Array.isArray(jsonObject[key])) { if (jsonObject[key] && Array.isArray(jsonObject[key])) {
for (let index = 0; index < jsonObject[key].length; index++) { for (let index = 0; index < jsonObject[key].length; index++) {
specialCondition(); 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 = " ";
} else { } else {
element.value = jsonObject[key][index]; console.warn(`jsonObject[${key}] is not a valid array.`);
}
}
if (key.includes("special_condition_label")) { //console.log('key', key)
let checkbox = $(element).closest('.form-group').find('input[name="special_condition_display[]"]'); let elements = document.getElementsByName(`${key}[]`);
console.log("First element:", element); //console.log(elements)
if (checkbox.length) { if (elements) {
console.log("Checkbox found:", checkbox); 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 if (key.includes("special_condition_label")) {
let formattedValue = jsonObject[key][index].replace(/[\s\-\/,&]+/g, '').toLowerCase(); let checkbox = $(element).closest('.form-group').find('input[name="special_condition_display[]"]');
console.log('formattedValue', formattedValue); console.log("First element:", element);
checkbox.attr('id', formattedValue + '_display');
console.log("Updated Checkbox:", checkbox); if (checkbox.length) {
} else { console.log("Checkbox found:", checkbox);
console.log("Checkbox not found for:", element);
// 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 elements = document.getElementsByName(key);
if (elements && elements.length > 0) {
let checkboxes = document.querySelectorAll( let element = elements[
`input[name="${key}[]"]`); 0]; // Assuming you want to update the first element with the name
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) { if (element.tagName === 'INPUT' && (element.type ===
$('#family_floaters').val('EPORPIL'); 'checkbox' || element.type === 'radio')) {
} 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.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); } else {
if (elements && elements.length > 0) { element.nextElementSibling.checked = element.value;
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 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 { } 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_min_age').val(jsonObject[key].self.min);
$('#self_max_age').val(jsonObject[key].self.max); $('#self_max_age').val(jsonObject[key].self.max);
$('#spouse_min_age').val(jsonObject[key].spouse.min); $('#spouse_min_age').val(jsonObject[key].spouse.min);
$('#spouse_max_age').val(jsonObject[key].spouse.max); $('#spouse_max_age').val(jsonObject[key].spouse.max);
$('#child_min_age').val(jsonObject[key].child.min); $('#child_min_age').val(jsonObject[key].child.min);
$('#child_max_age').val(jsonObject[key].child.max); $('#child_max_age').val(jsonObject[key].child.max);
$('#other_member_min_age').val(jsonObject[key].elders.min); $('#other_member_min_age').val(jsonObject[key].elders.min);
$('#other_member_max_age').val(jsonObject[key].elders.max); $('#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) { // if (jsonObject[key].self == 0) {
// $('#is_payable_employee_for_self').prop('checked', // $('#is_payable_employee_for_self').prop('checked',
// false); // false);
// } else { // } else {
// $('#is_payable_employee_for_self').prop('checked', // $('#is_payable_employee_for_self').prop('checked',
// true); // true);
// } // }
// if (jsonObject[key].spouse == 0) { // if (jsonObject[key].spouse == 0) {
// $('#is_payable_employee_for_spouse').prop('checked', // $('#is_payable_employee_for_spouse').prop('checked',
// false); // false);
// } else { // } else {
// $('#is_payable_employee_for_spouse').prop('checked', // $('#is_payable_employee_for_spouse').prop('checked',
// true); // true);
// } // }
// if (jsonObject[key].childern == 0) { // if (jsonObject[key].childern == 0) {
// $('#is_payable_employee_for_child').prop('checked', // $('#is_payable_employee_for_child').prop('checked',
// false); // false);
// } else { // } else {
// $('#is_payable_employee_for_child').prop('checked', // $('#is_payable_employee_for_child').prop('checked',
// true); // true);
// } // }
// // if (jsonObject[key].elders == 0) { // // if (jsonObject[key].elders == 0) {
// // $('#is_payable_employee_for_elders').prop('checked', // // $('#is_payable_employee_for_elders').prop('checked',
// // false); // // false);
// // } else { // // } else {
// // $('#is_payable_employee_for_elders').prop('checked', // // $('#is_payable_employee_for_elders').prop('checked',
// // true); // // true);
// // } // // }
// } // }
// } // }
if (key.includes("enrollment_display_key") && key != "") { if (key.includes("enrollment_display_key") && key != "") {
console.log('enrollment_display_key'); console.log('enrollment_display_key');
console.log(jsonObject[key]); console.log(jsonObject[key]);
processJsonObject(jsonObject); processJsonObject(jsonObject);
} }
}); });
}
} }
$("#sum_insured").trigger("keyup"); $("#sum_insured").trigger("keyup");
@ -1886,36 +1888,40 @@
} }
function disableUnwantedTerms(jsonObject) { function disableUnwantedTerms(jsonObject) {
// alert("Disabling unwanted terms");
fields.forEach(function(key) { console.log("Disabling unwanted terms");
// If key NOT in jsonObject, then hide and disable its associated elements console.log("jsonObject : ", jsonObject);
if (!jsonObject.hasOwnProperty(key)) {
const elements = document.getElementsByName(key);
elements.forEach(element => { if(jsonObject){
element.style.display = "none"; fields.forEach(function(key) {
element.disabled = true; // 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}"]`); elements.forEach(element => {
if (label) { element.style.display = "none";
label.style.display = "none"; element.disabled = true;
}
const displayElement = document.getElementById(`${element.id}_display`); const label = document.querySelector(`label[for="${element.id}"]`);
if (displayElement) { if (label) {
displayElement.checked = false; label.style.display = "none";
displayElement.disabled = true; }
displayElement.style.display = "none";
}
const rowDiv = element.closest('.row'); const displayElement = document.getElementById(`${element.id}_display`);
if (rowDiv) { if (displayElement) {
rowDiv.style.display = "none"; displayElement.checked = false;
} displayElement.disabled = true;
displayElement.style.display = "none";
}
const rowDiv = element.closest('.row');
if (rowDiv) {
rowDiv.style.display = "none";
}
});
}
}); });
} }
});
} }
function autoSaveGmcTerms() function autoSaveGmcTerms()