Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
149a70e5d1
@ -425,10 +425,10 @@
|
||||
}
|
||||
// console.log("form from : ", formDataSplitUp);
|
||||
|
||||
if (productSelectionData.multipleProduct == 'on') {
|
||||
let selectionType = productSelectionData.multilocation_type;
|
||||
// if (productSelectionData.multipleProduct == 'on') {
|
||||
// let selectionType = productSelectionData.multilocation_type;
|
||||
|
||||
if (selectionType == 'multiFloater') {
|
||||
// if (selectionType == 'multiFloater') {
|
||||
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 findMaterial = [...document.querySelectorAll('[id^="finishedStock_"]')].map(el => Number(el.value) || 0);
|
||||
@ -456,16 +456,16 @@
|
||||
return false;
|
||||
}
|
||||
// console.log("Total SI: ", totalSI);
|
||||
} else {
|
||||
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 findMaterial = [...document.querySelectorAll('[id^="finishedStock_"]')].map(el => Number(el.value) || 0);
|
||||
// } else {
|
||||
// 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 findMaterial = [...document.querySelectorAll('[id^="finishedStock_"]')].map(el => Number(el.value) || 0);
|
||||
|
||||
totalSI = InProcess.reduce((acc, val) => acc + val, 0) +
|
||||
rawMaterial.reduce((acc, val) => acc + val, 0) +
|
||||
findMaterial.reduce((acc, val) => acc + val, 0);
|
||||
}
|
||||
}
|
||||
// totalSI = InProcess.reduce((acc, val) => acc + val, 0) +
|
||||
// rawMaterial.reduce((acc, val) => acc + val, 0) +
|
||||
// findMaterial.reduce((acc, val) => acc + val, 0);
|
||||
// }
|
||||
// }
|
||||
|
||||
// console.log("Form is trying to submit : ", formDataSplitUp);
|
||||
|
||||
@ -655,13 +655,34 @@
|
||||
|
||||
}else{
|
||||
// alert("you got ir");
|
||||
policyRiskAddress.forEach(function() {
|
||||
// console.log("increment count is ", increment2)
|
||||
addHTMLInputForRiskSplitUP();
|
||||
validatePolicyBasedOnProductSelection();
|
||||
hideAndShowBurglary();
|
||||
})
|
||||
}
|
||||
console.log("increment2",increment2);
|
||||
console.log("policyRiskAddress.length",policyRiskAddress.length);
|
||||
|
||||
policyRiskAddress.forEach(function() {
|
||||
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 {
|
||||
if (contianertoCheck.innerHTML == "") {
|
||||
addHTMLInputForRiskSplitUpWarninig();
|
||||
@ -714,7 +735,8 @@
|
||||
const newRowRisk = document.createElement("div");
|
||||
// // console.log("Risk Split Up for address : ", policyRiskAddress.length)
|
||||
// policyRiskAddress
|
||||
|
||||
console.log(increment2);
|
||||
console.log(policyRiskAddress[increment2-1])
|
||||
newRowRisk.innerHTML += `
|
||||
<h5 class = "fire">Fire <?= isset($product) ? $product : "" ?> Details</h5>
|
||||
<h5>Risk Split Up for Address : ${policyRiskAddress[increment2-1].address1} ${policyRiskAddress[increment2-1].address2}</h5>
|
||||
@ -1043,7 +1065,7 @@
|
||||
$('[class*="single_location"]').show();
|
||||
$("#locationNoDIV").hide();
|
||||
$("#location_no").removeAttr("required", false);
|
||||
$('[class*="duplicate-btn"]').hide();
|
||||
// $('[class*="duplicate-btn"]').hide();
|
||||
$("[id^='select_location']").hide();
|
||||
$('[id^="select_location"]').hide().prev('label').hide();
|
||||
$("[id^='select_location']").removeAttr('required', false);
|
||||
|
||||
@ -1056,6 +1056,7 @@
|
||||
newQuoteHeader.textContent = "Liability Limit";
|
||||
}
|
||||
newQuoteHeader.style.backgroundColor = randomColor;
|
||||
newQuoteHeader.setAttribute('data-proposal', proposalCount);
|
||||
headerRow2.insertBefore(newQuoteHeader, headerRow2.querySelector('th:last-child'));
|
||||
|
||||
// Add new cells to all rows
|
||||
@ -1108,6 +1109,8 @@
|
||||
hideProposalOptionsForChild();
|
||||
showOrHideFieldsBasedOnRFQorQCR();
|
||||
// styleTableColumns();
|
||||
|
||||
monitorTableChanges();
|
||||
});
|
||||
|
||||
// #################################################################################
|
||||
@ -4972,71 +4975,54 @@
|
||||
}
|
||||
|
||||
function monitorTableChanges() {
|
||||
console.log("monitoring table changes");
|
||||
var proposalValue = "";
|
||||
// Get the first table
|
||||
const table = document.querySelector("table");
|
||||
if (!table) return;
|
||||
console.log("monitoring table changes");
|
||||
const table = document.querySelector("table");
|
||||
if (!table) return;
|
||||
|
||||
// Get the first row in the tbody
|
||||
const firstRow = table.querySelector("tbody tr");
|
||||
if (!firstRow) return;
|
||||
const firstRow = table.querySelector("tbody tr");
|
||||
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 cells = firstRow.querySelectorAll("td");
|
||||
|
||||
// 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;
|
||||
const mainHeaders = headerRow1.querySelectorAll("th");
|
||||
const subHeaders = headerRow2.querySelectorAll("th");
|
||||
|
||||
// console.log("headerRow1 : ",headerRow1);
|
||||
// console.log("headerRow2 : ",headerRow2);
|
||||
// Find which column is the "Sum Insured" column
|
||||
let sumInsuredColumnIndex = -1;
|
||||
const subHeaders = headerRow2.querySelectorAll("th");
|
||||
|
||||
subHeaders.forEach((th, index) => {
|
||||
if (th.textContent.trim() === "Sum Insured") {
|
||||
proposalValue = th.getAttribute("data-proposal");
|
||||
sumInsuredColumnIndex = index;
|
||||
subHeaders.forEach((subHeader, index) => {
|
||||
const subHeaderText = subHeader.textContent.trim();
|
||||
const mainHeaderText = mainHeaders[index]?.textContent.trim();
|
||||
|
||||
// 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");
|
||||
|
||||
if (index < cells.length) {
|
||||
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) {
|
||||
console.log("Function called");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user