FIX_AUTO_SAVE_TERMS : RV
This commit is contained in:
parent
98bc8f1006
commit
329680c2fe
@ -2423,6 +2423,7 @@ class ClientController extends AdminController
|
|||||||
|
|
||||||
// echo "<pre>";
|
// echo "<pre>";
|
||||||
// print_r($this->request->getPost());die;
|
// print_r($this->request->getPost());die;
|
||||||
|
$this->myLogger->logme('error', "post data : " . json_encode($this->request->getPost() ?? []));
|
||||||
$this->myLogger->logme('error', 'Terms CREATE function called');
|
$this->myLogger->logme('error', 'Terms CREATE function called');
|
||||||
|
|
||||||
/*** Client Policy Table Primary Key(ID) ***/
|
/*** Client Policy Table Primary Key(ID) ***/
|
||||||
@ -2624,7 +2625,7 @@ class ClientController extends AdminController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$data['enrollment_display_key'] = $this->enrollmentGMCDisplayValueTransform();
|
$data['enrollment_display_key'] = $this->enrollmentGMCDisplayValueTransform();
|
||||||
|
$this->myLogger->logme('error', "contructed post data : " . json_encode($data ?? []));
|
||||||
// print_r($data);die;
|
// print_r($data);die;
|
||||||
|
|
||||||
$jsonData = json_encode($data);
|
$jsonData = json_encode($data);
|
||||||
|
|||||||
@ -4947,7 +4947,7 @@ class LeadsController extends BaseController
|
|||||||
|
|
||||||
// Start table with clean styling
|
// Start table with clean styling
|
||||||
$html .= "<h3 style='color: #333; font-weight: 500; margin-bottom: 15px;'>{$category}</h3>";
|
$html .= "<h3 style='color: #333; font-weight: 500; margin-bottom: 15px;'>{$category}</h3>";
|
||||||
$html .= "<table style='width: 100%; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 14px;color:black;'>";
|
$html .= "<table data-custom-table-css='table' style='width: 100%; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 14px;'>";
|
||||||
|
|
||||||
// Table header with light background
|
// Table header with light background
|
||||||
$html .= "<tr>";
|
$html .= "<tr>";
|
||||||
|
|||||||
@ -775,8 +775,34 @@
|
|||||||
|
|
||||||
console.log('autoSaveOtherTerms function called');
|
console.log('autoSaveOtherTerms function called');
|
||||||
|
|
||||||
var formData = new FormData($('#otherPolicyTerms')[0]);
|
// var formData = new FormData($('#otherPolicyTerms')[0]);
|
||||||
console.log("formData", formData);
|
// console.log("formData", formData);
|
||||||
|
|
||||||
|
var form = $('#otherPolicyTerms')[0];
|
||||||
|
if (!form) {
|
||||||
|
console.error("Form #otherPolicyTerms not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if form has any data before proceeding
|
||||||
|
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 (value && value.toString().trim() !== '') {
|
||||||
|
hasData = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasData) {
|
||||||
|
console.warn("Form data is empty, skipping auto-save");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var policy_form_action = '<?= base_url("client/terms/other_terms") ?>';
|
var policy_form_action = '<?= base_url("client/terms/other_terms") ?>';
|
||||||
console.log("policy_form_action", policy_form_action);
|
console.log("policy_form_action", policy_form_action);
|
||||||
@ -809,9 +835,9 @@
|
|||||||
// Append the JSON string to the FormData object
|
// Append the JSON string to the FormData object
|
||||||
formData.append('policy_terms', jsonString);
|
formData.append('policy_terms', jsonString);
|
||||||
|
|
||||||
formData.forEach((value, key) => {
|
// formData.forEach((value, key) => {
|
||||||
console.log(key + ': ' + value);
|
// console.log(key + ': ' + value);
|
||||||
});
|
// });
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
data: formData,
|
data: formData,
|
||||||
|
|||||||
@ -1943,6 +1943,34 @@
|
|||||||
|
|
||||||
console.log("autoSaveGmcTerms function called");
|
console.log("autoSaveGmcTerms function called");
|
||||||
|
|
||||||
|
// Add form validation before proceeding
|
||||||
|
var form = $('#policyJsonForm')[0];
|
||||||
|
if (!form) {
|
||||||
|
console.error("Form #policyJsonForm not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if form has any data before proceeding
|
||||||
|
var formData = new FormData(form);
|
||||||
|
var hasData = false;
|
||||||
|
|
||||||
|
console.log("form entries : ", formData.entries());
|
||||||
|
|
||||||
|
for (let [key, value] of formData.entries()) {
|
||||||
|
console.log("Key:", key, "Value:", value);
|
||||||
|
if(key == "sum_insured"){
|
||||||
|
if (value && value.toString().trim() !== '') {
|
||||||
|
hasData = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasData) {
|
||||||
|
console.warn("Form data is empty, skipping auto-save");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var specialConditions = [];
|
var specialConditions = [];
|
||||||
|
|
||||||
$(".removeDom").each(function() {
|
$(".removeDom").each(function() {
|
||||||
@ -1957,19 +1985,15 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("specialConditions", specialConditions);
|
console.log("specialConditions", specialConditions);
|
||||||
|
|
||||||
var formData = new FormData($('#policyJsonForm')[0]);
|
// var formData = new FormData($('#policyJsonForm')[0]);
|
||||||
console.log("formData", formData);
|
|
||||||
|
|
||||||
var policy_form_action = '<?= base_url("client/policy/policyGMCTerms") ?>';
|
var policy_form_action = '<?= base_url("client/policy/policyGMCTerms") ?>';
|
||||||
console.log("policy_form_action", policy_form_action);
|
console.log("policy_form_action", policy_form_action);
|
||||||
|
|
||||||
formData.append("special_condition_display_value", JSON.stringify(specialConditions));
|
formData.append("special_condition_display_value", JSON.stringify(specialConditions));
|
||||||
// console.log('formData', formData);
|
|
||||||
formData.forEach((value, key) => {
|
|
||||||
// console.log(key + ':', value);
|
|
||||||
});
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
data: formData,
|
data: formData,
|
||||||
|
|||||||
@ -617,45 +617,77 @@
|
|||||||
|
|
||||||
let gpaJsonObjectForSpecialCondition = JSON.parse(res.data);
|
let gpaJsonObjectForSpecialCondition = JSON.parse(res.data);
|
||||||
Object.keys(gpaJsonObjectForSpecialCondition).forEach(function(key) {
|
Object.keys(gpaJsonObjectForSpecialCondition).forEach(function(key) {
|
||||||
if (key.includes("gpa_special_condition_label") || key.includes(
|
|
||||||
"gpa_special_condition_input")) {
|
// if (key.includes("gpa_special_condition_label") || key.includes("gpa_special_condition_input")) {
|
||||||
|
|
||||||
|
// if (key.includes("gpa_special_condition_label")) {
|
||||||
|
// for (let index = 0; index <
|
||||||
|
// gpaJsonObjectForSpecialCondition[key].length; index++) {
|
||||||
|
// specialConditionForGPA();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// let elements = document.getElementsByName(`${key}[]`);
|
||||||
|
|
||||||
|
// if (elements) {
|
||||||
|
// elements.forEach((element, index) => {
|
||||||
|
|
||||||
|
// if (gpaJsonObjectForSpecialCondition[key][
|
||||||
|
// index
|
||||||
|
// ] == undefined) {
|
||||||
|
// element.value = " ";
|
||||||
|
// } else {
|
||||||
|
// element.value =
|
||||||
|
// gpaJsonObjectForSpecialCondition[key][
|
||||||
|
// index
|
||||||
|
// ];
|
||||||
|
|
||||||
|
// if (key.includes("gpa_special_condition_label")) {
|
||||||
|
// let checkbox = $(element).closest('.form-group').find('input[name="gpa_special_condition_display[]"]');
|
||||||
|
// console.log("First element:", element);
|
||||||
|
|
||||||
|
// if (checkbox.length) {
|
||||||
|
// console.log("Checkbox found:", checkbox);
|
||||||
|
|
||||||
|
// // Correct way to set the 'id' attribute
|
||||||
|
// let formattedValue = gpaJsonObjectForSpecialCondition[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("gpa_special_condition_label") || key.includes("gpa_special_condition_input")) {
|
||||||
|
|
||||||
if (key.includes("gpa_special_condition_label")) {
|
if (key.includes("gpa_special_condition_label")) {
|
||||||
for (let index = 0; index <
|
let count = gpaJsonObjectForSpecialCondition[key]?.length || 0;
|
||||||
gpaJsonObjectForSpecialCondition[key].length; index++) {
|
for (let i = 0; i < count; i++) {
|
||||||
specialConditionForGPA();
|
specialConditionForGPA(); // Called once per label entry
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let elements = document.getElementsByName(`${key}[]`);
|
let elements = document.getElementsByName(`${key}[]`);
|
||||||
|
|
||||||
if (elements) {
|
if (elements && elements.length) {
|
||||||
elements.forEach((element, index) => {
|
Array.from(elements).forEach((element, index) => {
|
||||||
|
let value = gpaJsonObjectForSpecialCondition[key]?.[index] || "";
|
||||||
|
|
||||||
if (gpaJsonObjectForSpecialCondition[key][
|
element.value = value;
|
||||||
index
|
|
||||||
] == undefined) {
|
|
||||||
element.value = " ";
|
|
||||||
} else {
|
|
||||||
element.value =
|
|
||||||
gpaJsonObjectForSpecialCondition[key][
|
|
||||||
index
|
|
||||||
];
|
|
||||||
|
|
||||||
if (key.includes("gpa_special_condition_label")) {
|
if (key.includes("gpa_special_condition_label")) {
|
||||||
let checkbox = $(element).closest('.form-group').find('input[name="gpa_special_condition_display[]"]');
|
let checkbox = $(element).closest('.form-group')
|
||||||
console.log("First element:", element);
|
.find('input[name="gpa_special_condition_display[]"]');
|
||||||
|
|
||||||
if (checkbox.length) {
|
if (checkbox.length) {
|
||||||
console.log("Checkbox found:", checkbox);
|
let formattedValue = value.replace(/[\s\-\/,&]+/g, '').toLowerCase();
|
||||||
|
|
||||||
// Correct way to set the 'id' attribute
|
|
||||||
let formattedValue = gpaJsonObjectForSpecialCondition[key][index].replace(/[\s\-\/,&]+/g, '').toLowerCase();
|
|
||||||
console.log('formattedValue', formattedValue);
|
|
||||||
checkbox.attr('id', formattedValue + '_display');
|
checkbox.attr('id', formattedValue + '_display');
|
||||||
|
|
||||||
console.log("Updated Checkbox:", checkbox);
|
|
||||||
} else {
|
|
||||||
console.log("Checkbox not found for:", element);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1051,6 +1083,32 @@
|
|||||||
|
|
||||||
console.log('autoSaveGpaTerms function called');
|
console.log('autoSaveGpaTerms function called');
|
||||||
|
|
||||||
|
var form = $('#policyGPATerms')[0];
|
||||||
|
if (!form) {
|
||||||
|
console.error("Form #policyGPATerms not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if form has any data before proceeding
|
||||||
|
var formData = new FormData(form);
|
||||||
|
var hasData = false;
|
||||||
|
|
||||||
|
|
||||||
|
for (let [key, value] of formData.entries()) {
|
||||||
|
console.log("Key:", key, "Value:", value);
|
||||||
|
if(key == "sumInsured2"){
|
||||||
|
if (value && value.toString().trim() !== '') {
|
||||||
|
hasData = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasData) {
|
||||||
|
console.warn("Form data is empty, skipping auto-save");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var specialConditions = [];
|
var specialConditions = [];
|
||||||
|
|
||||||
$(".removeDom").each(function () {
|
$(".removeDom").each(function () {
|
||||||
@ -1063,12 +1121,9 @@
|
|||||||
specialConditions.push({ [label]: input });
|
specialConditions.push({ [label]: input });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("gpa_specialConditions", specialConditions);
|
console.log("gpa_specialConditions", specialConditions);
|
||||||
|
|
||||||
var formData = new FormData($('#policyGPATerms')[0]);
|
// var formData = new FormData($('#policyGPATerms')[0]);
|
||||||
console.log("formData", formData);
|
|
||||||
|
|
||||||
var policy_form_action = '<?= base_url("client/terms/gpa_create") ?>';
|
var policy_form_action = '<?= base_url("client/terms/gpa_create") ?>';
|
||||||
console.log("policy_form_action", policy_form_action);
|
console.log("policy_form_action", policy_form_action);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user