FIX_PROPOSAL_CHANGE

This commit is contained in:
Srinivas-Saravanan 2025-05-09 09:24:21 +05:30
parent 481a9c430c
commit 387d0d1c3e
2 changed files with 60 additions and 67 deletions

View File

@ -655,12 +655,18 @@
}else{ }else{
// alert("you got ir"); // alert("you got ir");
policyRiskAddress.forEach(function() { console.log("increment2",increment2);
// console.log("increment count is ", increment2) console.log("policyRiskAddress.length",policyRiskAddress.length);
addHTMLInputForRiskSplitUP(); if (increment2 <= policyRiskAddress.length) {
validatePolicyBasedOnProductSelection(); policyRiskAddress.forEach(function() {
hideAndShowBurglary(); // console.log("increment count is ", increment2)
}) addHTMLInputForRiskSplitUP();
validatePolicyBasedOnProductSelection();
hideAndShowBurglary();
})
}else {
alert("fdg");
}
} }
} else { } else {
if (contianertoCheck.innerHTML == "") { if (contianertoCheck.innerHTML == "") {
@ -714,7 +720,8 @@
const newRowRisk = document.createElement("div"); const newRowRisk = document.createElement("div");
// // console.log("Risk Split Up for address : ", policyRiskAddress.length) // // console.log("Risk Split Up for address : ", policyRiskAddress.length)
// policyRiskAddress // policyRiskAddress
console.log(increment2);
console.log(policyRiskAddress[increment2-1])
newRowRisk.innerHTML += ` newRowRisk.innerHTML += `
<h5 class = "fire">Fire <?= isset($product) ? $product : "" ?> Details</h5> <h5 class = "fire">Fire <?= isset($product) ? $product : "" ?> Details</h5>
<h5>Risk Split Up for Address : ${policyRiskAddress[increment2-1].address1} ${policyRiskAddress[increment2-1].address2}</h5> <h5>Risk Split Up for Address : ${policyRiskAddress[increment2-1].address1} ${policyRiskAddress[increment2-1].address2}</h5>
@ -1043,7 +1050,7 @@
$('[class*="single_location"]').show(); $('[class*="single_location"]').show();
$("#locationNoDIV").hide(); $("#locationNoDIV").hide();
$("#location_no").removeAttr("required", false); $("#location_no").removeAttr("required", false);
$('[class*="duplicate-btn"]').hide(); // $('[class*="duplicate-btn"]').hide();
$("[id^='select_location']").hide(); $("[id^='select_location']").hide();
$('[id^="select_location"]').hide().prev('label').hide(); $('[id^="select_location"]').hide().prev('label').hide();
$("[id^='select_location']").removeAttr('required', false); $("[id^='select_location']").removeAttr('required', false);

View File

@ -1056,6 +1056,7 @@
newQuoteHeader.textContent = "Liability Limit"; newQuoteHeader.textContent = "Liability Limit";
} }
newQuoteHeader.style.backgroundColor = randomColor; newQuoteHeader.style.backgroundColor = randomColor;
newQuoteHeader.setAttribute('data-proposal', proposalCount);
headerRow2.insertBefore(newQuoteHeader, headerRow2.querySelector('th:last-child')); headerRow2.insertBefore(newQuoteHeader, headerRow2.querySelector('th:last-child'));
// Add new cells to all rows // Add new cells to all rows
@ -1108,6 +1109,8 @@
hideProposalOptionsForChild(); hideProposalOptionsForChild();
showOrHideFieldsBasedOnRFQorQCR(); showOrHideFieldsBasedOnRFQorQCR();
// styleTableColumns(); // styleTableColumns();
monitorTableChanges();
}); });
// ################################################################################# // #################################################################################
@ -4968,71 +4971,54 @@
} }
function monitorTableChanges() { function monitorTableChanges() {
console.log("monitoring table changes"); console.log("monitoring table changes");
var proposalValue = ""; const table = document.querySelector("table");
// Get the first table if (!table) return;
const table = document.querySelector("table");
if (!table) return;
// Get the first row in the tbody const firstRow = table.querySelector("tbody tr");
const firstRow = table.querySelector("tbody tr"); if (!firstRow) return;
if (!firstRow) return;
// console.log("firstRow : ",firstRow); const cells = firstRow.querySelectorAll("td");
const headerRow1 = table.querySelector("thead tr:nth-child(1)");
const headerRow2 = table.querySelector("thead tr:nth-child(2)");
if (!headerRow1 || !headerRow2) return;
// Get all cells in the first row const mainHeaders = headerRow1.querySelectorAll("th");
const cells = firstRow.querySelectorAll("td"); const subHeaders = headerRow2.querySelectorAll("th");
// Get header rows to identify which columns are "Sum Insured"
const headerRow1 = table.querySelector("thead tr:nth-child(1)");
const headerRow2 = table.querySelector("thead tr:nth-child(2)");
if (!headerRow1 || !headerRow2) return;
// console.log("headerRow1 : ",headerRow1); subHeaders.forEach((subHeader, index) => {
// console.log("headerRow2 : ",headerRow2); const subHeaderText = subHeader.textContent.trim();
// Find which column is the "Sum Insured" column const mainHeaderText = mainHeaders[index]?.textContent.trim();
let sumInsuredColumnIndex = -1;
const subHeaders = headerRow2.querySelectorAll("th"); // Check if subheader is "Sum Insured" and main header starts with "Proposal" or "Exis"
if (subHeaderText === "Sum Insured" && /^(Proposal|Exis)/i.test(mainHeaderText)) {
subHeaders.forEach((th, index) => { const proposalValue = subHeader.getAttribute("data-proposal");
if (th.textContent.trim() === "Sum Insured") {
proposalValue = th.getAttribute("data-proposal"); if (index < cells.length) {
sumInsuredColumnIndex = index; const cell = cells[index];
let previousValue = "";
cell.addEventListener("focus", function () {
previousValue = this.textContent.trim();
});
cell.addEventListener("blur", function () {
const newValue = this.textContent.trim();
if (newValue !== previousValue) {
tdChanged = true;
changedNewSI = newValue;
$("#policySI").val(newValue);
console.log("new Value proposalValue", changedNewSI);
console.log("proposalValue",proposalValue);
updateAddON(newValue, proposalValue);
console.log("Sum Insured value changed to:", newValue);
}
});
} }
});
// console.log("sumInsuredColumnIndex : ",sumInsuredColumnIndex);
if (sumInsuredColumnIndex === -1) return;
// Check if we have a cell at that index
if (cells.length > sumInsuredColumnIndex) {
console.log("It is there");
const sumInsuredCell = cells[sumInsuredColumnIndex];
let previousValue = "";
// Add event listener for changes
sumInsuredCell.addEventListener("focus", function () {
previousValue = this.textContent.trim();
});
sumInsuredCell.addEventListener("blur", function () {
const newValue = this.textContent.trim();
if (newValue !== previousValue) {
tdChanged = true;
changedNewSI = newValue;
$("#policySI").val(newValue);
console.log("new Value",changedNewSI);
// alert(newValue);
updateAddON(newValue,proposalValue);
console.log("Sum Insured value changed to:", newValue);
}
});
}else{
console.log("Sum Insured column not found");
} }
} });
}
function updateAddON(newValue,proposalValue = null) { function updateAddON(newValue,proposalValue = null) {
console.log("Function called"); console.log("Function called");