Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev

This commit is contained in:
VENKATESHWARAN 2025-05-09 14:23:29 +05:30
commit 149a70e5d1
2 changed files with 88 additions and 80 deletions

View File

@ -425,10 +425,10 @@
} }
// console.log("form from : ", formDataSplitUp); // console.log("form from : ", formDataSplitUp);
if (productSelectionData.multipleProduct == 'on') { // if (productSelectionData.multipleProduct == 'on') {
let selectionType = productSelectionData.multilocation_type; // let selectionType = productSelectionData.multilocation_type;
if (selectionType == 'multiFloater') { // if (selectionType == 'multiFloater') {
let InProcess = [...document.querySelectorAll('[id^="stockInProcess_"]')].map(el => Number(el.value) || 0); let InProcess = [...document.querySelectorAll('[id^="stockInProcess_"]')].map(el => Number(el.value) || 0);
let rawMaterial = [...document.querySelectorAll('[id^="rawMaterial_"]')].map(el => Number(el.value) || 0); let rawMaterial = [...document.querySelectorAll('[id^="rawMaterial_"]')].map(el => Number(el.value) || 0);
let findMaterial = [...document.querySelectorAll('[id^="finishedStock_"]')].map(el => Number(el.value) || 0); let findMaterial = [...document.querySelectorAll('[id^="finishedStock_"]')].map(el => Number(el.value) || 0);
@ -456,16 +456,16 @@
return false; return false;
} }
// console.log("Total SI: ", totalSI); // console.log("Total SI: ", totalSI);
} else { // } else {
let InProcess = [...document.querySelectorAll('[id^="stockInProcess_"]')].map(el => Number(el.value) || 0); // let InProcess = [...document.querySelectorAll('[id^="stockInProcess_"]')].map(el => Number(el.value) || 0);
let rawMaterial = [...document.querySelectorAll('[id^="rawMaterial_"]')].map(el => Number(el.value) || 0); // let rawMaterial = [...document.querySelectorAll('[id^="rawMaterial_"]')].map(el => Number(el.value) || 0);
let findMaterial = [...document.querySelectorAll('[id^="finishedStock_"]')].map(el => Number(el.value) || 0); // let findMaterial = [...document.querySelectorAll('[id^="finishedStock_"]')].map(el => Number(el.value) || 0);
totalSI = InProcess.reduce((acc, val) => acc + val, 0) + // totalSI = InProcess.reduce((acc, val) => acc + val, 0) +
rawMaterial.reduce((acc, val) => acc + val, 0) + // rawMaterial.reduce((acc, val) => acc + val, 0) +
findMaterial.reduce((acc, val) => acc + val, 0); // findMaterial.reduce((acc, val) => acc + val, 0);
} // }
} // }
// console.log("Form is trying to submit : ", formDataSplitUp); // console.log("Form is trying to submit : ", formDataSplitUp);
@ -655,13 +655,34 @@
}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();
validatePolicyBasedOnProductSelection(); policyRiskAddress.forEach(function() {
hideAndShowBurglary(); if (increment2 <= policyRiskAddress.length) {
}) // console.log("increment count is ", increment2)
} addHTMLInputForRiskSplitUP();
validatePolicyBasedOnProductSelection();
hideAndShowBurglary();
}
})
// else {
// const container = document.getElementById("addRiskSplitUp");
// container.innerHTML = "";
// increment2 = 1;
// if (increment2 <= policyRiskAddress.length) {
// policyRiskAddress.forEach(function() {
// // console.log("increment count is ", increment2)
// addHTMLInputForRiskSplitUP();
// validatePolicyBasedOnProductSelection();
// hideAndShowBurglary();
// // increment2++;
// })
// // alert("fdg");
// }
// }
}
} else { } else {
if (contianertoCheck.innerHTML == "") { if (contianertoCheck.innerHTML == "") {
addHTMLInputForRiskSplitUpWarninig(); addHTMLInputForRiskSplitUpWarninig();
@ -714,7 +735,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 +1065,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();
}); });
// ################################################################################# // #################################################################################
@ -4972,71 +4975,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" subHeaders.forEach((subHeader, index) => {
const headerRow1 = table.querySelector("thead tr:nth-child(1)"); const subHeaderText = subHeader.textContent.trim();
const headerRow2 = table.querySelector("thead tr:nth-child(2)"); const mainHeaderText = mainHeaders[index]?.textContent.trim();
if (!headerRow1 || !headerRow2) return; // Check if subheader is "Sum Insured" and main header starts with "Proposal" or "Exis"
if (subHeaderText === "Sum Insured" && /^(Proposal|Exis)/i.test(mainHeaderText)) {
const proposalValue = subHeader.getAttribute("data-proposal");
// console.log("headerRow1 : ",headerRow1); if (index < cells.length) {
// console.log("headerRow2 : ",headerRow2); const cell = cells[index];
// Find which column is the "Sum Insured" column let previousValue = "";
let sumInsuredColumnIndex = -1;
const subHeaders = headerRow2.querySelectorAll("th");
subHeaders.forEach((th, index) => { cell.addEventListener("focus", function () {
if (th.textContent.trim() === "Sum Insured") { previousValue = this.textContent.trim();
proposalValue = th.getAttribute("data-proposal"); });
sumInsuredColumnIndex = index;
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");