From 387d0d1c3efe8d0c27b46febcbdead98f3e118c2 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Fri, 9 May 2025 09:24:21 +0530 Subject: [PATCH] FIX_PROPOSAL_CHANGE --- app/Views/policyRegisterModel.php | 23 ++++--- app/Views/view_rfq_non_eb.php | 104 +++++++++++++----------------- 2 files changed, 60 insertions(+), 67 deletions(-) diff --git a/app/Views/policyRegisterModel.php b/app/Views/policyRegisterModel.php index f9b1ee91..c5f41032 100644 --- a/app/Views/policyRegisterModel.php +++ b/app/Views/policyRegisterModel.php @@ -655,12 +655,18 @@ }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); + if (increment2 <= policyRiskAddress.length) { + policyRiskAddress.forEach(function() { + // console.log("increment count is ", increment2) + addHTMLInputForRiskSplitUP(); + validatePolicyBasedOnProductSelection(); + hideAndShowBurglary(); + }) + }else { + alert("fdg"); + } } } else { if (contianertoCheck.innerHTML == "") { @@ -714,7 +720,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 += `
Fire Details
Risk Split Up for Address : ${policyRiskAddress[increment2-1].address1} ${policyRiskAddress[increment2-1].address2}
@@ -1043,7 +1050,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); diff --git a/app/Views/view_rfq_non_eb.php b/app/Views/view_rfq_non_eb.php index e0abbc8c..508961e8 100644 --- a/app/Views/view_rfq_non_eb.php +++ b/app/Views/view_rfq_non_eb.php @@ -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(); }); // ################################################################################# @@ -4968,71 +4971,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");