diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 53de23a7..6c491bf9 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -4737,12 +4737,12 @@ class ClientController extends AdminController // echo "File does not exist."; // } - // $data = $this->leadsModel->where('leads.id', 115)->where('leads.is_active', 1)->first(); - // $RFQdata = $RFQModel->getRFQTableDataWithLeadIDAndType(115, 2); - // Kint::dump($RFQdata['json']); - // $returnData = $LeadsController->getPlacementJson($data); - // $this->clientPolicyModel->where('id', 6050)->set('placement_json', $returnData)->update(); - // dd($returnData); + $data = $this->leadsModel->where('leads.id', 125)->where('leads.is_active', 1)->first(); + $RFQdata = $RFQModel->getRFQTableDataWithLeadIDAndType(125, 2); + Kint::dump($RFQdata['json']); + $returnData = $LeadsController->getPlacementJson($data); + $this->clientPolicyModel->where('id', 6050)->set('placement_json', $returnData)->update(); + dd($returnData); } diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index c9f6a26a..a858ff7d 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -549,7 +549,7 @@ class LeadsController extends BaseController // dd($lead_data); - if ($lead_data['lead_type'] == 2) { + if ($lead_data['lead_type'] != 1) { $client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $lead_data['source_policy_id'])->first(); $data['policy_terms'] = $client_policy_data['policy_terms']; } @@ -576,7 +576,7 @@ class LeadsController extends BaseController $data['subject'] = $this->transformMailContent($lead_data, $subject, $data['page_name']); - // dd($data); + if ($data['lead_data']['lead_form_type'] == 1) { $this->loadLayout('view_rfq.php', $data); @@ -585,7 +585,7 @@ class LeadsController extends BaseController $data['occupancy'] = $this->occupancyModel->findAll(); // dd($data['occupancy']); - if($lead_data['lead_type'] == 2){ + if($lead_data['lead_type'] != 1 && $data['rfq_count'] == 0){ $client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $lead_data['source_policy_id'])->first(); $data['rfq_data']['json'] = $client_policy_data['placement_json']; } @@ -597,6 +597,7 @@ class LeadsController extends BaseController // $data['lead_register_data'] = json_decode($data['lead_data']['custom_fields']); // dd($data['lead_register_data']); + // dd($data); $data['client_type'] = $this->clientType; $data['buisness_type'] = $this->buisnessType; $this->loadLayout('view_rfq_non_eb', $data); diff --git a/app/Views/view_rfq_non_eb.php b/app/Views/view_rfq_non_eb.php index da988735..d30969de 100644 --- a/app/Views/view_rfq_non_eb.php +++ b/app/Views/view_rfq_non_eb.php @@ -29,6 +29,14 @@ } + table thead tr:nth-child(1) th { + background-color: #bfe0e2; + border: 1px solid #007bff; + } + table thead tr:nth-child(2) th { + background-color: #bfe0e2; + border: 1px solid #007bff; + } /* Apply styles to the first column, accounting for rowspan */ @@ -484,11 +492,15 @@ var lead_type = ""; // alert(lead_type); var rollover_or_renewal = ""; + + var rfq_count = ""; + // alert(rfq_count); if (lead_type != 1){ rollover_or_renewal = lead_type == 2 ? "Existing Renewal" : "Existing Roll Over"; } + // alert(rollover_or_renewal); var policyConfig = { 1: ['Quote asked'] @@ -505,7 +517,7 @@ var suggestions = {}; var policyInformationData = ; var storedData = {}; - // console.log("stored data : ", typeof(policyInformationData)) + // // console.log("stored data : ", typeof(policyInformationData)) if (policyInformationData.length) { @@ -515,16 +527,16 @@ var policySummary = []; - // console.log("policy summary is set :", !$.isEmptyObject(policySummary) ? "no" : "yes") + // // console.log("policy summary is set :", !$.isEmptyObject(policySummary) ? "no" : "yes") $(document).ready(function() { myModal = new bootstrap.Modal(document.getElementById('policyRegisterModel')); }); var tableCount = 0; const policies = ; - // console.log('policies', policies); + // // console.log('policies', policies); const child_table_data = ; - // console.log('child_table_data', child_table_data); + // // console.log('child_table_data', child_table_data); const policyOrder = [{ 'fire': { @@ -586,7 +598,7 @@ let selectedPolicies = new Set(); let proposalCount = 1; - // console.log("Proposal count changed", proposalCount); + // // console.log("Proposal count changed", proposalCount); let quotesConfig = { 1: ['Quote asked'] }; // Stores quote columns for each proposal @@ -613,7 +625,7 @@ } insertPosition += quotesConfig[proposalNumber].length - 1; let table_id = table.id ? table.id : 'parent'; - // console.log('insert position of ' + table.id + ' - ' + insertPosition); + // // console.log('insert position of ' + table.id + ' - ' + insertPosition); // Add new quote sub-header const newQuoteHeader = document.createElement('th'); newQuoteHeader.textContent = newQuote; @@ -632,20 +644,27 @@ // Show dropdown menu function showDropdown(event) { - // console.log("dropdown function triggered"); + // // console.log("dropdown function triggered"); const dropdown = event.target.nextElementSibling; - // console.log(dropdown); + // // console.log(dropdown); dropdown.style.display = dropdown.style.display === 'block' ? 'none' : 'block'; event.stopPropagation(); } // Remove a proposal column function removeProposal(proposalNumber) { - let startIndex = 0; - console.log("Remove Proposal : startIndex 1 ",startIndex); - // console.log('removeProposal'); - console.log(quotesConfig); + // alert(proposalNumber); + var rowIdCount = {}; + + let startIndex = 0; + // console.log("Remove Proposal startIndex : ",startIndex); + // console.log("Remove Proposal proposalNumber : ",proposalNumber); + + + // // console.log('removeProposal'); + // console.log("quotesConfig",quotesConfig); + if (!quotesConfig[proposalNumber]) return; // If proposal doesn't exist, exit if(Object.keys(quotesConfig).length == 1){ toastr.warning("You cannot Delete All the Proposals","Warning"); @@ -654,42 +673,80 @@ // Remove all child columns for the proposal const tables = document.querySelectorAll('table'); tables.forEach(table => { + const headerRow1 = table.querySelector('thead tr:first-child'); const headerRow2 = table.querySelector('thead tr:last-child'); // Find the proposal header and calculate its colspan const proposalHeader = headerRow1.querySelector(`th[data-proposal="${proposalNumber}"]`); if (proposalHeader) { - console.log("Remove Proposal : quotesConfig ",quotesConfig[proposalNumber]); - console.log("Remove Proposal : proposalHeader ",proposalHeader); + // console.log("Remove Proposal : quotesConfig ",quotesConfig[proposalNumber]); + // console.log("Remove Proposal : proposalHeader ",proposalHeader); if (rfq_or_qcr == 1){ var colspan = parseInt(quotesConfig[proposalNumber].length); }else{ var colspan = parseInt(proposalHeader.getAttribute('colspan'), 10); } - console.log("Remove Proposal : colspan ",colspan); + // console.log("Remove Proposal : colspan ",colspan); // Remove the proposal header proposalHeader.remove(); // Remove corresponding sub-headers in the second header row const subHeaders = headerRow2.querySelectorAll(`th`); startIndex = 2; // Start after the first two columns (checkbox and Particulars) - console.log("Remove Proposal : startIndex 2",startIndex); - for (let i = 1; i < proposalNumber; i++) { - startIndex += quotesConfig[i]?.length || 0; - console.log("Remove Proposal : startIndex 3",startIndex); + // console.log("Remove Proposal : startIndex 2",startIndex); + // if (lead_type != 1){ + // proposalNumber = proposalNumber + 1; + // }else{ + + // } + if (lead_type != 1){ + for (let i = 0; i < proposalNumber; i++) { + // // console.log("quotesConfig[i] be", quotesConfig[i]) + // // console.log("quotesConfig[i] length", quotesConfig[i]?.length) + + + startIndex += quotesConfig[i]?.length || 0; + + + // console.log("quotesConfig[i] after", quotesConfig[i]); + // console.log("Remove Proposal : startIndex 3",startIndex); + } + }else{ + for (let i = 1; i < proposalNumber; i++) { + // // console.log("quotesConfig[i] be", quotesConfig[i]) + // // console.log("quotesConfig[i] length", quotesConfig[i]?.length) + + + startIndex += quotesConfig[i]?.length || 0; + + + // console.log("quotesConfig[i] after", quotesConfig[i]); + // console.log("Remove Proposal : startIndex 3",startIndex); + } } + for (let i = 0; i < colspan; i++) { - console.log("Remove Proposal : colspan ",colspan); - console.log("Remove Proposal : startIndex 4",startIndex) + // console.log("Remove Proposal : colspan ",colspan); + // console.log("Remove Proposal : startIndex 4",startIndex) headerRow2.removeChild(headerRow2.children[startIndex]); } // Remove corresponding cells in all rows table.querySelectorAll('tbody tr').forEach(row => { for (let i = 0; i < colspan; i++) { - row.removeChild(row.children[startIndex]); + var rowId = row.id; + if (rowIdCount[rowId] === undefined) { + rowIdCount[rowId] = 0; + } else { + rowIdCount[rowId]++; + } + // console.log("rowIdCount[rowId]", rowIdCount[rowId]); + newStartIndex = rowIdCount[rowId] > 0 ? startIndex-1 : startIndex; + // console.log("newStartIndex", newStartIndex) + row.removeChild(row.children[newStartIndex]); + } }); } @@ -699,21 +756,22 @@ delete quotesConfig[proposalNumber]; delete policyConfig[proposalNumber]; - // console.log("DELETE INSURE : policyConfig",policyConfig); - // console.log("DELETE INSURE : quotesConfig",quotesConfig); + // // console.log("DELETE INSURE : policyConfig",policyConfig); + // // console.log("DELETE INSURE : quotesConfig",quotesConfig); // alert(quotesConfig); // alert(policyConfig) + // console.log('End of the functions') } // Add a new row function addRow(event, element) { - // console.log(' event ', element); + // // console.log(' event ', element); const button = event.target; const row = button.closest('tr'); const table = row.closest('table'); const newRow = row.cloneNode(true); - // console.log("old Row ", row); + // // console.log("old Row ", row); // return false; var tableID = table.id; @@ -721,7 +779,7 @@ // Clear input values and generate new IDs newRow.querySelectorAll('td').forEach((td, index) => { if (index === 0) { - // console.log("Trying to set sno"); + // // console.log("Trying to set sno"); td.innerHTML = ""; td.innerHTML = `${nextSNO}`; } @@ -738,7 +796,7 @@ const row = button.closest('tr'); const table = row.closest('table'); if (row && row.parentElement.children.length > 1) { - // console.log("Row Removed"); + // // console.log("Row Removed"); row.remove(); updateSNO(table.id); } @@ -746,23 +804,23 @@ //function to hide all the 3 dot actions for the child table function hideProposalOptionsForChild() { - // // console.log('function called'); + // // // console.log('function called'); const parentTable = document.querySelector("table"); const tables = document.querySelectorAll('table'); - // // console.log('parentTable : ',parentTable); + // // // console.log('parentTable : ',parentTable); tables.forEach(table => { if (table !== parentTable) { // Hide .three-dot-menu in all other tables $(table).find(".three-dot-menu").hide(); - // // console.log("hided 3 dot menu in the table",table); + // // // console.log("hided 3 dot menu in the table",table); } }); } document.addEventListener("change", function(event) { const checkbox = event.target; if (checkbox.classList.contains("qcr-checkbox")) { - // // console.log("QCR checkbox change detected"); + // // // console.log("QCR checkbox change detected"); // Get the row containing the checkbox const row = checkbox.closest('tr'); @@ -776,15 +834,15 @@ // Optionally, you can trigger any additional logic here if (checkbox.checked) { - // // console.log("QCR checkbox is checked, client-checkbox is also checked"); + // // // console.log("QCR checkbox is checked, client-checkbox is also checked"); } else { - // // console.log("QCR checkbox is unchecked, client-checkbox is also unchecked"); + // // // console.log("QCR checkbox is unchecked, client-checkbox is also unchecked"); } } else { - // console.warn("No client-checkbox found in the same row"); + // // console.warn("No client-checkbox found in the same row"); } } else if (checkbox.classList.contains("client-checkbox")) { - // console.log("trying to change"); + // // console.log("trying to change"); const row = checkbox.closest('tr'); const qcrCheckbox = row.querySelector('.qcr-checkbox'); @@ -809,7 +867,7 @@ child_table_data[rowId]?.forEach(childTable => { if (childTable.table_type == "append") { var tableName = childTable.table_id; - // console.log("table name ", tableName); + // // console.log("table name ", tableName); // Handle excess table const excessContainer = document.createElement('div'); excessContainer.setAttribute('data-parent-row', tableName); @@ -819,7 +877,7 @@ if (result) { generateTable(excessContainer, true, rowId, childTable); container.appendChild(excessContainer); - // // console.log('Row id for excess table',rowId); + // // // console.log('Row id for excess table',rowId); $("#excess .three-dot-menu").hide(); moveExcessTableLast(); } @@ -827,7 +885,7 @@ // Handle regular table childContainer.setAttribute('data-parent-row', rowId); generateTable(childContainer, true, rowId, childTable); - // // console.log('Row id for excess table', rowId); + // // // console.log('Row id for excess table', rowId); $(childContainer).find(".three-dot-menu").hide(); // alert(`${rowId.toUpperCase()}_register`); @@ -845,17 +903,17 @@ arrangeTables(); alignTableColumn(); } else { - // console.log('UNCHECKED:', rowId); + // // console.log('UNCHECKED:', rowId); selectedPolicies.delete(rowId); // Remove regular child tables const regularContainers = container.querySelectorAll(`div[data-parent-row="${rowId}"]:not([data-excess-container])`); regularContainers.forEach(container => { - // console.log(" contaitner ", container); + // // console.log(" contaitner ", container); $(`#${rowId.toUpperCase()}_register`).prop("disabled", true); container.remove(); }); - // console.log("row id ", rowId); + // // console.log("row id ", rowId); // Handle excess table rows const excessTable = document.getElementById('excess'); if (excessTable) { @@ -865,7 +923,7 @@ // Check if excess table is empty const remainingRows = excessTable.querySelector('tbody').children; - // // console.log(remainingRows); + // // // console.log(remainingRows); if (remainingRows.length === 0) { // Remove the entire excess table container // const excessContainer = excessTable.closest('div[data-excess-container]'); @@ -881,7 +939,7 @@ } } } else if (checkbox.classList.contains("qcr-checkbox")) { - // console.log("QCR checkbox change detected"); + // // console.log("QCR checkbox change detected"); // Get the row containing the checkbox const row = checkbox.closest('tr'); @@ -895,20 +953,20 @@ // Optionally, you can trigger any additional logic here if (checkbox.checked) { - // console.log("QCR checkbox is checked, client-checkbox is also checked"); + // // console.log("QCR checkbox is checked, client-checkbox is also checked"); } else { - // console.log("QCR checkbox is unchecked, client-checkbox is also unchecked"); + // // console.log("QCR checkbox is unchecked, client-checkbox is also unchecked"); } } else { - console.warn("No client-checkbox found in the same row"); + // console.warn("No client-checkbox found in the same row"); } } }); // Add a new proposal document.getElementById('addProposal').addEventListener('click', () => { - // console.log("proposal count before ", proposalCount); + // // console.log("proposal count before ", proposalCount); proposalCount++; - // console.log("proposal count after ", proposalCount); + // // console.log("proposal count after ", proposalCount); quotesConfig[proposalCount] = ['Quote asked']; policyConfig[proposalCount] = ['Quote asked']; @@ -982,9 +1040,9 @@ targetCell = cells[cells.length - 1]; } - // console.log("ADD PROPOSAL : targetCell", targetCell); + // // console.log("ADD PROPOSAL : targetCell", targetCell); const newCell = targetCell.cloneNode(true); - // console.log("ADD PROPOSAL : newCell", newCell); + // // console.log("ADD PROPOSAL : newCell", newCell); newCell.contentEditable = true; newCell.onclick = () => getAnswer(table.id, row.id); @@ -993,6 +1051,9 @@ }); }); + // console.log(quotesConfig); + // console.log(policyConfig); + hideProposalOptionsForChild(); showOrHideFieldsBasedOnRFQorQCR(); // styleTableColumns(); @@ -1001,7 +1062,7 @@ // ################################################################################# function addNewQuote(proposalNumber) { - // console.log("add new Quote start : ", quotesConfig); + // // console.log("add new Quote start : ", quotesConfig); const insurers = ; selectInsurer(insurers).then(result => { insurer = result.selectedInsurer; @@ -1012,16 +1073,16 @@ let increaseBy = 100; increaseTableWidth(increaseBy); - // // console.log("Selected Insurer:", insurerName); - // // console.log("Entered Version:", version); - // // console.log("Entered data id:", dataId); - // console.log("add new Quote : ", proposalNumber); - // console.log("add new Quote : ", quotesConfig); - // console.log("Add new quote insurer name : ", insurerName); + // // // console.log("Selected Insurer:", insurerName); + // // // console.log("Entered Version:", version); + // // // console.log("Entered data id:", dataId); + // // console.log("add new Quote : ", proposalNumber); + // // console.log("add new Quote : ", quotesConfig); + // // console.log("Add new quote insurer name : ", insurerName); if (!quotesConfig[proposalNumber]) return; - // console.log("add new quote ", quotesConfig[proposalNumber]); + // // console.log("add new quote ", quotesConfig[proposalNumber]); if (quotesConfig[proposalNumber].includes(insurerName)) { - // console.log("add new quote is duplicate"); + // // console.log("add new quote is duplicate"); Swal.fire({ title: "Insurer Dublicate Found?", text: "Do you want version control!", @@ -1041,7 +1102,7 @@ for (let i = 0; i < quotesConfig[proposalNumber].length; i++) { if (quotesConfig[proposalNumber][i].startsWith(baseInsurerName)) { count++; - // console.log("add count ", count); + // // console.log("add count ", count); } } @@ -1049,12 +1110,12 @@ if (version === "") { insurerName = `${baseInsurerName} v${count + 1}`; version = count + 1; - // console.log("add inurer name ", insurerName); + // // console.log("add inurer name ", insurerName); } else { // If user already specified version, append count to make it unique insurerName = `${baseInsurerName} v${version}_${count + 1}`; version = `${version}_${count + 1}`; - // console.log("add inurer name else", insurerName); + // // console.log("add inurer name else", insurerName); } var insurerDetails = { @@ -1065,7 +1126,7 @@ policyConfig[proposalNumber].push(insurerDetails); const newQuote = insurerName; quotesConfig[proposalNumber].push(newQuote); - // console.log("add Quotes config", quotesConfig); + // // console.log("add Quotes config", quotesConfig); updateAllTables(proposalNumber, insurerName); var proposalName = `Proposal ${proposalNumber}`; @@ -1085,13 +1146,13 @@ policyConfig[proposalNumber].push(insurerDetails); const newQuote = insurerName; quotesConfig[proposalNumber].push(newQuote); - // console.log("add Quotes config", quotesConfig); + // // console.log("add Quotes config", quotesConfig); updateAllTables(proposalNumber, insurerName); var proposalName = `Proposal ${proposalNumber}`; const proposalHeader = document.querySelector(`th[data-proposal="${proposalNumber}"]`); if (proposalHeader) { - // console.log("Proposal heade length : ", quotesConfig[proposalNumber].length) + // // console.log("Proposal heade length : ", quotesConfig[proposalNumber].length) proposalHeader.colSpan = quotesConfig[proposalNumber].length; } } @@ -1108,7 +1169,7 @@ function changeInsurer(event, proposalNumber, currentInsurer) { // Stop event propagation event.stopPropagation(); - // console.log("insurer change function called ", quotesConfig[proposalNumber]); + // // console.log("insurer change function called ", quotesConfig[proposalNumber]); if (!quotesConfig[proposalNumber]) return; const insurers = ; @@ -1125,24 +1186,24 @@ newInsurerName = `${newInsurerName}-${newversion.trim()}`.replace(/\s+/g, ''); } - // console.log('insurer newInsurerName', newInsurerName); - // console.log('insurer newversion', newversion); + // // console.log('insurer newInsurerName', newInsurerName); + // // console.log('insurer newversion', newversion); if (newInsurerName) { - // // console.log("insurer inside new insurer name : ",headerRow2); + // // // console.log("insurer inside new insurer name : ",headerRow2); // Update all tables with the new insurer document.querySelectorAll('table').forEach(table => { const headerRow2 = table.querySelector('thead tr:last-child'); - // console.log("insurer inside ", headerRow2); + // // console.log("insurer inside ", headerRow2); // Find the header cells that match our criteria Array.from(headerRow2.children).forEach(th => { // Check if this cell contains our insurer and proposal - // console.log("insurer proposal number : ", proposalNumber); - // console.log("insurer header proposal number : ", th); + // // console.log("insurer proposal number : ", proposalNumber); + // // console.log("insurer header proposal number : ", th); if (th.getAttribute('data-proposal') === proposalNumber.toString()) { // Get the first text node (the insurer name part) let content = th.innerHTML; - // console.log("insurer inside ", content); + // // console.log("insurer inside ", content); // Only replace the exact insurer name, not any menu text if (content.includes(currentInsurer)) { // Create a regex to match just the insurer name @@ -1166,10 +1227,10 @@ // Generate new quote code based on new insurer const newQuoteCode = oldQuoteCode.replace(currentInsurer, newInsurerName); quotesConfig[proposalNumber][quoteIndex] = newQuoteCode; - // console.log("Existing policy data ", policyConfig[proposalNumber][quoteIndex]); + // // console.log("Existing policy data ", policyConfig[proposalNumber][quoteIndex]); policyConfig[proposalNumber][quoteIndex] = insurerDetailsChange; - // console.log("quote index ", quoteIndex); - // console.log("changed like this ", insurerDetailsChange); + // // console.log("quote index ", quoteIndex); + // // console.log("changed like this ", insurerDetailsChange); // Update data-quote attribute th.setAttribute('data-quote', newQuoteCode); } @@ -1203,11 +1264,13 @@ function removeQuote(event, proposalNumber, quoteCode) { event.stopPropagation(); + var rowIdCount = {}; + if (!quotesConfig[proposalNumber]) return; // Remove quote from config const quoteIndex = quotesConfig[proposalNumber].indexOf(quoteCode); - // console.log("quote index ", quoteIndex); + // // console.log("quote index ", quoteIndex); if (quoteIndex !== -1) { quotesConfig[proposalNumber].splice(quoteIndex, 1); policyConfig[proposalNumber].splice(quoteIndex, 1); @@ -1227,19 +1290,19 @@ th.textContent.includes(quoteCode) && th.getAttribute('data-proposal') === proposalNumber.toString() ); - // console.log("quote target index ", targetIndex); + // // console.log("quote target index ", targetIndex); if (targetIndex !== -1) { - // console.log("quote target index inside if", targetIndex); + // // console.log("quote target index inside if", targetIndex); // Remove from header row 2 headerRow2.removeChild(headerRow2.children[targetIndex]); // Update proposal header colspan const proposalHeader = headerRow1.querySelector(`th[data-proposal="${proposalNumber}"]`); - // console.log("quote target index inside if proposal header", proposalHeader); + // // console.log("quote target index inside if proposal header", proposalHeader); if (proposalHeader) { const newColspan = parseInt(proposalHeader.colSpan) - 1; - // console.log("Quote new colspan : ", newColspan); + // // console.log("Quote new colspan : ", newColspan); if (newColspan > 0) { proposalHeader.colSpan = newColspan; } else { @@ -1250,10 +1313,21 @@ // Remove from data rows table.querySelectorAll('tbody tr').forEach(row => { const cellIndex = targetIndex; // No need to add 2 since we're using children array - // console.log("quote target index inside if proposal header", cellIndex); + // console.log("quote target index", cellIndex); + + var rowId = row.id; + if (rowIdCount[rowId] === undefined) { + rowIdCount[rowId] = 0; + } else { + rowIdCount[rowId]++; + } + // console.log("rowIdCount[rowId]", rowIdCount[rowId]); + newStartIndex = rowIdCount[rowId] > 0 ? cellIndex-1 : cellIndex; + // console.log("quote target index inside if proposal header", newStartIndex); + if (row.children[cellIndex]) { - row.removeChild(row.children[cellIndex]); - // console.log("quote target index inside if proposal header", row); + row.removeChild(row.children[newStartIndex]); + // // console.log("quote target index inside if proposal header", row); } }); @@ -1262,17 +1336,17 @@ } function updateAllTables(proposalNumber, newQuote) { - + // alert(proposalNumber); document.querySelectorAll('table').forEach(table => { const headerRow1 = table.querySelector('thead tr:first-child'); const headerRow2 = table.querySelector('thead tr:last-child'); - // console.log('headerRow2 data', headerRow2); - // console.log('headerRow2 headerRow2.children', headerRow2.children); + // // console.log('headerRow2 data', headerRow2); + // // console.log('headerRow2 headerRow2.children', headerRow2.children); const proposalHeader = headerRow1.querySelector(`th[data-proposal="${proposalNumber}"]`); - // console.log("Proposal Header : ", proposalNumber); + console.log("Proposal proposalNumber : ", proposalNumber); // Create new quote header const newQuoteHeader = document.createElement('th'); newQuoteHeader.innerHTML = ` @@ -1292,25 +1366,31 @@ // Calculate header insert position let insertPosition = 2; - for (let i = 1; i < proposalNumber; i++) { - insertPosition += quotesConfig[i]?.length || 0; + if (lead_type == 1){ + for (let i = 1; i < proposalNumber; i++) { + insertPosition += quotesConfig[i]?.length || 0; + } + }else{ + for (let i = 0; i < proposalNumber; i++) { + insertPosition += quotesConfig[i]?.length || 0; + } } + insertPosition += quotesConfig[proposalNumber].length - 1; - // console.log("Header insert position : ", insertPosition); + // // console.log("Header insert position : ", insertPosition); if (headerRow2.children[insertPosition - 1]) { let referenceChild = headerRow2.children[insertPosition - 1]; // Get the target child - // console.log("referenceChild", referenceChild); + // // console.log("referenceChild", referenceChild); let computedStyle = window.getComputedStyle(referenceChild); - // console.log("computedStyle", computedStyle); + // // console.log("computedStyle", computedStyle); // Copy all computed styles - for (let prop of computedStyle) { - // console.log("prop", prop); - newQuoteHeader.style[prop] = computedStyle.getPropertyValue(prop); - } + let backgroundColor = computedStyle.getPropertyValue("background-color"); + newQuoteHeader.style.backgroundColor = backgroundColor; + } headerRow2.insertBefore(newQuoteHeader, headerRow2.children[insertPosition]); @@ -1452,7 +1532,7 @@ } tableName = tableData ? tableData.table_name : "Particulars"; - // // console.log("table Name ",tableName); + // // // console.log("table Name ",tableName); // Header setup const thead = document.createElement('thead'); const headerRow1 = document.createElement('tr'); @@ -1493,11 +1573,11 @@ thead.append(headerRow1, headerRow2); table.appendChild(thead); let latestWidth = $("table").last().width(); - // // console.log('Latest width', latestWidth); + // // // console.log('Latest width', latestWidth); if (tableData) { - // // console.log("table ",$(table)); + // // // console.log("table ",$(table)); $(table).width(latestWidth); // Convert to jQuery object using $(table) - // // console.log('table data',tableData); + // // // console.log('table data',tableData); } @@ -1583,42 +1663,42 @@ ${Object.values(quotesConfig).flatMap(codes => codes.map((codeValue, colIndex) => { - // console.log("Subheader th: colinded : ",colIndex); + // // console.log("Subheader th: colinded : ",colIndex); // Get the subheader (assuming it's the second inside ) let subHeaderThList = [...document.querySelectorAll("thead tr:nth-child(2) th")]; - console.log("subHeaderThList", subHeaderThList); + // // console.log("subHeaderThList", subHeaderThList); // Filter elements that have a valid 'data-proposal' attribute let validSubHeaders = subHeaderThList.filter(th => { let dataProposal = th.getAttribute("data-proposal"); - // console.log("Subheader th: dataProposal : ",dataProposal); + // // console.log("Subheader th: dataProposal : ",dataProposal); return dataProposal !== null && dataProposal !== undefined && dataProposal.trim() !== ""; }); - console.log("Subheader th: validSubHeaders",validSubHeaders); + // // console.log("Subheader th: validSubHeaders",validSubHeaders); // let validSubHeaders = subHeaderThList.filter(th => th.hasAttribute("data-proposal")); - // console.log("Subheader th: validSubHeaders",validSubHeaders); + // // console.log("Subheader th: validSubHeaders",validSubHeaders); let subHeaderTh = validSubHeaders.find(th => th.textContent.trim()); - console.log("Subheader th: codeValue",codeValue); - console.log("Subheader th: subHeaderTh",subHeaderTh); + // // console.log("Subheader th: codeValue",codeValue); + // // console.log("Subheader th: subHeaderTh",subHeaderTh); // if (subHeaderTh.classList.contains("insurer_proposal")) { // alert(subHeaderTh); // } let subHeaderText = subHeaderTh ? subHeaderTh.textContent.trim() : ''; - console.log("Subheader th: below code",subHeaderText); + // // console.log("Subheader th: below code",subHeaderText); // Check if subheader is NOT "Quote asked" let className = !subHeaderText.startsWith("Quote asked") && subHeaderText != "-" ? "insurer_proposal" : ""; - console.log("className", className); + // console.log("className", className); // alert(subHeaderText); let defaultJsonString = typeof default_answers_array == "object" ? JSON.stringify(default_answers_array[0]) : String(default_answers_array); - // // console.log("defaultJsonString", defaultJsonString); - // // console.log("defaultJsonString type", typeof defaultJsonString); - // // console.log("defaultJsonString string", String(defaultJsonString)); + // // // console.log("defaultJsonString", defaultJsonString); + // // // console.log("defaultJsonString type", typeof defaultJsonString); + // // // console.log("defaultJsonString string", String(defaultJsonString)); @@ -1672,7 +1752,7 @@ if (excessTable) { // If table exists, append new rows to it const tbody = excessTable.querySelector('tbody'); - // // console.log("table data ",tableData); + // // // console.log("table data ",tableData); // Add new rows from tableData tableData.table_row_contents.forEach((rowData, index) => { let rowID = Object.keys(rowData)[0]; @@ -1687,36 +1767,36 @@ ${question} ${Object.values(quotesConfig).flatMap(codes => codes.map((codeValue, colIndex) => { - // console.log("Subheader th: colinded : ",colIndex); + // // console.log("Subheader th: colinded : ",colIndex); // Get the subheader (assuming it's the second inside ) let subHeaderThList = [...document.querySelectorAll("thead tr:nth-child(2) th")]; // Filter elements that have a valid 'data-proposal' attribute let validSubHeaders = subHeaderThList.filter(th => { let dataProposal = th.getAttribute("data-proposal"); - // console.log("Subheader th: dataProposal : ",dataProposal); + // // console.log("Subheader th: dataProposal : ",dataProposal); return dataProposal !== null && dataProposal !== undefined && dataProposal.trim() !== ""; }); - // console.log("Subheader th: subHeaderThList",subHeaderThList); + // // console.log("Subheader th: subHeaderThList",subHeaderThList); // let validSubHeaders = subHeaderThList.filter(th => th.hasAttribute("data-proposal")); - // console.log("Subheader th: validSubHeaders",validSubHeaders); + // // console.log("Subheader th: validSubHeaders",validSubHeaders); let subHeaderTh = validSubHeaders.find(th => th.textContent.trim() === codeValue) || null; - // console.log("Subheader th: subHeaderTh",subHeaderTh); + // // console.log("Subheader th: subHeaderTh",subHeaderTh); // if (subHeaderTh.classList.contains("insurer_proposal")) { // alert(subHeaderTh); // } let subHeaderText = subHeaderTh ? subHeaderTh.textContent.trim() : ''; - // console.log("Subheader th: ",subHeaderText); + // // console.log("Subheader th: ",subHeaderText); // Check if subheader is NOT "Quote asked" let className = subHeaderText !== "Quote asked" && subHeaderText != "-" ? "insurer_proposal" : ""; // alert(subHeaderText); let defaultJsonString = typeof default_answers_array == "object" ? JSON.stringify(default_answers_array[0]) : String(default_answers_array); - // // console.log("defaultJsonString", defaultJsonString); - // // console.log("defaultJsonString type", typeof defaultJsonString); - // // console.log("defaultJsonString string", String(defaultJsonString)); + // // // console.log("defaultJsonString", defaultJsonString); + // // // console.log("defaultJsonString type", typeof defaultJsonString); + // // // console.log("defaultJsonString string", String(defaultJsonString)); @@ -1753,7 +1833,7 @@ } // Initialize the parent table document.addEventListener('DOMContentLoaded', () => { - // // console.log("bjnglfkrg ", rfq_data.length); + // // // console.log("bjnglfkrg ", rfq_data.length); const url = window.location.pathname; // Get the path (e.g., "/nhance/rfq/list/75/1") const segments = url.split("/"); // Split by "/" segments[segments.length - 1] = "1"; // Change the last segment @@ -1762,13 +1842,14 @@ history.pushState(null, "", newUrl); // Change the URL without reloading if (rfq_data.length) { - // console.log("inside if conditoon"); + // // console.log("inside if conditoon"); localStorage.setItem('allTablesJsonData', JSON.stringify(rfq_data)); jsonToTables(); + styleTableColumns(); proposalDataForDropDown = rfq_data[rfq_data.length - 1].proposal_data; - // console.log("proposalDataForDropDown", proposalDataForDropDown); + // // console.log("proposalDataForDropDown", proposalDataForDropDown); if (!$.isEmptyObject(storedData)) { - // console.log("DATA FROM DB : ", JSON.parse(storedData)); + // // console.log("DATA FROM DB : ", JSON.parse(storedData)); let data = JSON.parse(storedData); Object.keys(data).forEach(key => { @@ -1779,23 +1860,23 @@ }); - // // console.log("policy summary : ",child_table_data[key]) + // // // console.log("policy summary : ",child_table_data[key]) - // console.log("generate policy summary : ", policySummary); + // // console.log("generate policy summary : ", policySummary); styleTableColumns(); } // generateTable(document.getElementById('tablesContainer')); - // // console.log("polices Length ", policies.length); + // // // console.log("polices Length ", policies.length); } else { generateTable(document.getElementById('tablesContainer')); styleTableColumns(); - // console.log("polices Length ", policies.length); + // // console.log("polices Length ", policies.length); if (policies.length == 1) { setTimeout(() => { $(".sno-checkbox").each(function() { - // console.log("time completed function called"); + // // console.log("time completed function called"); $(".sno-checkbox").prop("checked", true); this.dispatchEvent(new Event("change", { bubbles: true @@ -1818,25 +1899,28 @@ function getAnswer(table_id, rowID) { event.stopPropagation(); - // console.log("Function called", table_id); + // alert(); + // // console.log("Function called"); + + // // console.log("Function called", table_id); var policy = table_id.split('_').slice(0, -1).join('_'); // var policy = 'policy_' + table; - // console.log('policy ', rowID); + // // console.log('policy ', rowID); Object.entries(child_table_data).forEach(([key, value]) => { if (key == policy) { var table_data = value; - // // console.log("table data ",table_data); + // // // console.log("table data ",table_data); // Loop through all available table data (removing hardcoded [0]) table_data.forEach(table => { var table_row = table['table_row_contents']; - // // console.log("table Row ",table_row); + // // // console.log("table Row ",table_row); Object.entries(table_row).forEach(([key, value]) => { var question_id = Object.keys(value)[0]; - // // console.log("Question ID : ",question_id," row ID : ",rowID); + // // // console.log("Question ID : ",question_id," row ID : ",rowID); if (question_id == rowID) { let questionData = value[question_id]; - // console.log("question data", questionData); + // // console.log("question data", questionData); if (questionData.answer_type == 'dropdown') { var answerAndValues = questionData.answers; @@ -1853,7 +1937,7 @@ function createDropdown(answerAndValues) { - // // console.log(answerAndValues); + // // // console.log(answerAndValues); const originalTd = event.target; const dropdown = document.createElement("div"); dropdown.classList.add("simple-dropdown"); @@ -1906,7 +1990,7 @@ const overallContainer = document.getElementById('allTableContainer'); if (!excessTable) { - // console.log("Excess table not found."); + // // console.log("Excess table not found."); return; } @@ -1962,9 +2046,9 @@ } function updateSNO(tableID) { - // console.log("Function Called Update Sno"); + // // console.log("Function Called Update Sno"); const table = document.getElementById(tableID); - // console.log("table : ", table); + // // console.log("table : ", table); if (!table) return; const rows = table.querySelectorAll("tbody tr"); @@ -1986,17 +2070,17 @@ $('.table-collapsible-bar').each(function() { let currentWidth = ($(this).width()); - // // console.log('table width ', typeof (currentWidth)); + // // // console.log('table width ', typeof (currentWidth)); let increaseTableWidth = (currentWidth + increaseBy); - // // console.log(increaseTableWidth); + // // // console.log(increaseTableWidth); $(this).width(currentWidth + increaseBy); }); - // // console.log("function called tablewidth increase"); + // // // console.log("function called tablewidth increase"); $("table").each(function() { let currentWidth = ($(this).width()); - // // console.log('table width ', typeof(currentWidth)); + // // // console.log('table width ', typeof(currentWidth)); let increaseTableWidth = (currentWidth + increaseBy); - // // console.log(increaseTableWidth); + // // // console.log(increaseTableWidth); $(this).width(currentWidth + increaseBy); }); } @@ -2005,7 +2089,7 @@ // Target the container const container = document.getElementById('tablesContainer'); if (!container) { - console.error('Error: tablesContainer not found'); + // console.error('Error: tablesContainer not found'); return; } @@ -2028,7 +2112,7 @@ const selectedContainers = containerArray.filter(container => selectedPolicies.has(container.policyName) ); - // // console.log('container selected ',selectedContainers); + // // // console.log('container selected ',selectedContainers); // Sort by priority selectedContainers.sort((a, b) => a.priority - b.priority); @@ -2041,11 +2125,11 @@ function setValueForHiddenField(element, answer_type) { // alert("hi"); if (answer_type != 'dropdown') { - // // console.log(element); + // // // console.log(element); const hiddenInput = element.querySelector("input[type='hidden']"); const updatedText = element.textContent.trim(); var updated_Text = element.textContent.trim(); - // // console.log('updated text ',updated); + // // // console.log('updated text ',updated); if (hiddenInput) { hiddenValue = updated_Text; @@ -2053,9 +2137,9 @@ // Convert it back to a JSON string and set the value hiddenInput.value = JSON.stringify(hiddenValue); - // console.log("Updated Hidden Input Value:", hiddenInput.value); + // // console.log("Updated Hidden Input Value:", hiddenInput.value); } else { - console.warn("No hidden input found inside the element."); + // console.warn("No hidden input found inside the element."); } } checkCellValueAndHighlight(); @@ -2126,11 +2210,11 @@ }); function getPolicyInfo(policyName) { - // console.log("anchor link clicked ", policyName); + // // console.log("anchor link clicked ", policyName); myModal = new bootstrap.Modal(document.getElementById('policyRegisterModel')); - // console.log("inside if condition"); + // // console.log("inside if condition"); var leadID = $("#lead_id").val(); let policy = policies.find(p => p.name === policyName); @@ -2211,13 +2295,13 @@ } var policySummary = tableRowContent; - // console.log("policy summary ", policySummary); + // // console.log("policy summary ", policySummary); return policySummary; } async function selectInsurer(insurers) { - // console.log("Async function called"); + // // console.log("Async function called"); // Build the HTML for the Select2 dropdown and the input text field const selectHTML = `
@@ -2278,9 +2362,9 @@ } function saveRFQ() { - // console.log("save button clicked"); + // // console.log("save button clicked"); leadJson = tablesToJson(); - // console.log("json from function ", leadJson); + // // console.log("json from function ", leadJson); var policyJson = localStorage.getItem("policyData") ?? null; saveRFQTODB(leadJson, policyJson); } @@ -2310,7 +2394,7 @@ localStorage.removeItem('policyData'); toastr.success(response.message, "Success"); - // console.log(rfq_data.length); + // // console.log(rfq_data.length); $('.actionBtns').show(); if (rfq_or_qcr == 2) { @@ -2329,16 +2413,25 @@ error: function(xhr, status, error) { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - console.error(xhr.responseText); - console.error(status, error); + // console.error(xhr.responseText); + // console.error(status, error); } }) } function prepareOverallData() { + var proposalKey = ""; const overAllData = {}; Object.entries(policyConfig).forEach(([proposalNumber, insurers]) => { - const proposalKey = `Proposal ${proposalNumber}`; + if (lead_type == 1){ + proposalKey = `Proposal ${proposalNumber}`; + }else{ + if (proposalNumber == 0){ + proposalKey = `${rollover_or_renewal} ${proposalNumber}`; + }else{ + proposalKey = `Proposal ${proposalNumber}`; + } + } overAllData[proposalKey] = { qcr: 0, stc: 0, @@ -2352,7 +2445,7 @@ overAllData[proposalKey].qcr = qcrSelected ? 1 : 0; overAllData[proposalKey].stc = stcSelected ? 1 : 0; } - // console.log("Insurers Found", insurers); + // // console.log("Insurers Found", insurers); const uniqueInsurers = []; insurers.forEach(insurer => { @@ -2362,11 +2455,11 @@ insurerHeaders.forEach(header => { const headerProposalCount = header.getAttribute("data-proposal"); if (headerProposalCount == proposalNumber) { - // console.log("Found the subheader we are searching"); + // // console.log("Found the subheader we are searching"); if (header.querySelector('.sendInsurerClientProposal .fa-check-square') !== null) { stcInsurerSelected = true; } - // console.log("STC selected for insurer:", stcInsurerSelected); + // // console.log("STC selected for insurer:", stcInsurerSelected); } }); uniqueInsurers.push({ @@ -2378,10 +2471,10 @@ }); } }); - // console.log("Unique Insurers Found", uniqueInsurers); + // // console.log("Unique Insurers Found", uniqueInsurers); overAllData[proposalKey].insurers = Array.from(uniqueInsurers.values()); }); - // console.log("overalll data created is ", overAllData); + // // console.log("overalll data created is ", overAllData); return overAllData; } @@ -2402,7 +2495,7 @@ var headers = []; const data = []; const tableId = table.id; // Ensure each table has a unique ID - // // console.log('Processing table:', tableId); + // // // console.log('Processing table:', tableId); // Get parent headers and subheaders for the current table const parentHeaders = table.querySelectorAll('thead tr:nth-child(1) th'); @@ -2410,34 +2503,34 @@ let headerIndex = 0; parentHeaders.forEach(header => { - // console.log("Found header ", header); - if (header.innerText.trim().startsWith("Proposal")) { + // // console.log("Found header ", header); + if (header.innerText.trim().startsWith("Proposal") || header.innerText.trim().startsWith("Existing")) { var policyNumber = header.getAttribute("data-proposal"); var colspan = parseInt(quotesConfig[policyNumber].length); - // console.log("Found header true colspan : ", colspan); + // // console.log("Found header true colspan : ", colspan); } else { var colspan = parseInt(header.getAttribute('colspan')) || 1; } const subHeaderArray = []; // console.log("processing save function header : ", header); - // // console.log("processing save colspn : ",colspan); + // // // console.log("processing save colspn : ",colspan); for (let i = 0; i < colspan; i++) { const subheaderHTML = subHeaders[headerIndex].innerHTML; const subheaderText = subheaderHTML.replace(//g, '').trim(); subHeaderArray.push(subheaderText); headerIndex++; } - // console.log("inside save colspn : ", colspan); + // // console.log("inside save colspn : ", colspan); const headerHTML = header.innerHTML; const headerText = headerHTML.replace(//g, '').trim(); // console.log("processing sub header array : ", subHeaderArray); - // console.log("HEader : ", header.innerText == " " ? header.innerText.trim() : headerText); + // // console.log("HEader : ", header.innerText == " " ? header.innerText.trim() : headerText); headers.push({ // parentHeader: header.innerText.replace('⋮', '').split('\n')[0].replace(/:.*/, '').trim(), parentHeader: headerText, subHeaders: subHeaderArray }); - // console.log("processing sub header array : ", headers); + // // console.log("processing sub header array : ", headers); }); // Process each row in the current table @@ -2447,11 +2540,11 @@ let rowIdForRemoveFirstIndex = ""; rows.forEach(row => { const rowId = row.id; - // console.log("row id : ", rowId); - // console.log("Suggestions :", suggestions); + // // console.log("row id : ", rowId); + // // console.log("Suggestions :", suggestions); const inputType = suggestions[rowId]?.answer_type || 'text'; // Default to 'text' if undefined const cells = row.querySelectorAll('td'); - // // console.log("row id going to submit us ", ); + // // // console.log("row id going to submit us ", ); const rowData = { SNO: cells[0] ? getTextExcludingButton(cells[0]) : '', items: cells[1]?.innerText || '', @@ -2459,11 +2552,11 @@ data: [] }; if (tableId == "excess") { - // console.log("row Trying to set : ", row); - // console.log("row Trying to set : ", row.outerHTML); + // // console.log("row Trying to set : ", row); + // // console.log("row Trying to set : ", row.outerHTML); rowData['parentPolicy'] = row.getAttribute("data-excess-row-parent") } - // console.log("Row data foint to submit ", rowData); + // // console.log("Row data foint to submit ", rowData); let dataIndex = 0; if (rowIdCount[rowId] === undefined) { rowIdCount[rowId] = 0; @@ -2471,15 +2564,15 @@ rowIdCount[rowId]++; } const occurrence = rowIdCount[rowId]; - // console.log("NEw Method : rowIdCount",rowIdCount) - // console.log("NEw Method : occurrence",occurrence) + // // console.log("NEw Method : rowIdCount",rowIdCount) + // // console.log("NEw Method : occurrence",occurrence) let rowspan_row_id = ''; if (occurrence > 0) { var headers2 = headers; headers2 = headers2.filter((header, index) => !(index === 0 && header.parentHeader === "Policy")); - // console.log("Header 2 ",headers2); + // // console.log("Header 2 ",headers2); headers2.forEach((header2, TableDataHeaderIndex) => { header2.subHeaders.forEach(subHeader => { @@ -2490,7 +2583,7 @@ if (inputType === "text" && header2.parentHeader === 'Action') { const qcrInput = cell.querySelector('input[name="qcr"]'); const clientInput = cell.querySelector('input[name="stc"]'); - // console.log("QCR INPUT : ", qcrInput); + // // console.log("QCR INPUT : ", qcrInput); content = { qcr: qcrInput?.checked ? 1 : 0, @@ -2499,7 +2592,7 @@ } else { const input = cell.querySelector('input, select, textarea'); if (input) { - // console.log("Input type:", input.type); + // // console.log("Input type:", input.type); if (input.type === "checkbox") { content = input.checked ? "Checked" : "Not Checked"; // Handling checkboxes @@ -2507,7 +2600,7 @@ } else { content = input.value; // Handling other input types like text, select, textarea display_content = cell.innerText.trim(); - // console.log("processing sub header array : ", content); + // // console.log("processing sub header array : ", content); } } else { content = cell.innerText.trim(); // If no input is found, use the cell's text @@ -2536,11 +2629,11 @@ // let parentThDataText; // if (headers[TableDataHeaderIndex + headerIndexOffset]) { // parentThDataText = headers[TableDataHeaderIndex + headerIndexOffset].parentHeader; - // // console.log("NEw Method : parentThDataText",parentThDataText) + // // // console.log("NEw Method : parentThDataText",parentThDataText) // } else { // parentThDataText = header.parentHeader; // Fallback if there are no more headers // } - // // console.log(`Row ${rowId} occurrence ${occurrence} using header: `, parentThDataText); + // // // console.log(`Row ${rowId} occurrence ${occurrence} using header: `, parentThDataText); header.subHeaders.forEach(subHeader => { @@ -2551,7 +2644,7 @@ if (inputType === "text" && header.parentHeader === 'Action') { const qcrInput = cell.querySelector('input[name="qcr"]'); const clientInput = cell.querySelector('input[name="stc"]'); - // console.log("QCR INPUT : ", qcrInput); + // // console.log("QCR INPUT : ", qcrInput); content = { qcr: qcrInput?.checked ? 1 : 0, @@ -2560,7 +2653,7 @@ } else { const input = cell.querySelector('input, select, textarea'); if (input) { - // console.log("Input type:", input.type); + // // console.log("Input type:", input.type); if (input.type === "checkbox") { content = input.checked ? "Checked" : "Not Checked"; // Handling checkboxes @@ -2568,7 +2661,7 @@ } else { content = input.value; // Handling other input types like text, select, textarea display_content = cell.innerText.trim(); - // console.log("processing sub header array : ", content); + // // console.log("processing sub header array : ", content); } } else { content = cell.innerText.trim(); // If no input is found, use the cell's text @@ -2581,14 +2674,14 @@ // if(rowId == rowspan_row_id){ // parentThDataText = rowspan_row_id == rowId ? headers[TableDataHeaderIndex + 1].parentHeader : header.parentHeader; - // // console.log('rowspan_row_id parentThDataText', parentThDataText); - // // console.log('rowspan_row_id', rowspan_row_id); + // // // console.log('rowspan_row_id parentThDataText', parentThDataText); + // // // console.log('rowspan_row_id', rowspan_row_id); // rowspan_row_id = rowspan_row_id - 1; - // // console.log('rowspan_row_id after decrement', rowspan_row_id); + // // // console.log('rowspan_row_id after decrement', rowspan_row_id); // } - // // console.log("trying to find what this is ",cell); + // // // console.log("trying to find what this is ",cell); rowData.data.push({ parentth: header.parentHeader, subth: subHeader, @@ -2603,11 +2696,11 @@ }); data.push(rowData); - // // console.log("processing sub header array : ",content); + // // // console.log("processing sub header array : ",content); }); tablePolicyName = [...selectedPolicies].find(policy => tableId.startsWith(policy)) || null; - // console.log(selectedPolicies); - // console.log(tablePolicyName); + // // console.log(selectedPolicies); + // // console.log(tablePolicyName); // Get table-specific over_all_column_data (adjust based on your data structure) @@ -2631,7 +2724,7 @@ }); // Save all tables' data to localStorage localStorage.setItem('allTablesJsonData', JSON.stringify(allTablesData)); - // console.log('All tables data saved:', allTablesData); + // // console.log('All tables data saved:', allTablesData); // toastr.success("RFQ Saved Successfully", "SUCCESS"); // If needed, reconstruct tables from JSON (implement jsonToTable accordingly) @@ -2645,7 +2738,7 @@ segments[segments.length - 1] = "2"; // Change the last segment const newUrl = segments.join("/"); // Rebuild the URL - // console.log('newUrl', newUrl) + // // console.log('newUrl', newUrl) history.pushState(null, "", newUrl); // Change the URL without reloading @@ -2669,9 +2762,19 @@ Object.entries(overAllColumnData).forEach(([proposalKey, proposalData]) => { // Extract proposal number from the key (ensuring it's properly extracted) let match = proposalKey.match(/\d+/); // Extracts the number from "Proposal X" - let proposalNumber = match ? match[0] : undefined; + let proposalNumber = ""; + if (lead_type == 1){ + proposalNumber = match ? match[0] : undefined; + }else{ + if (rfq_count == 0){ + proposalNumber = 0; + }else{ + // alert(proposalData); + proposalNumber = match ? match[0] : undefined; + } + } - if (!proposalNumber) return; // Skip if extraction fails + // if (!proposalNumber) return; // Skip if extraction fails // Initialize with "Quote asked" result[proposalNumber] = ["Quote asked"]; @@ -2696,15 +2799,22 @@ function setQuotesConfig(overallColumnData) { let quotesConfiguration = {}; // Stores the transformed output let index = 1; // Keeps track of proposal index - // console.log(overallColumnData); + // // console.log(overallColumnData); Object.keys(overallColumnData).forEach((proposalKey) => { let parts = proposalKey.split(" "); let lastNumber = parseInt(parts[parts.length - 1], 10); - index = lastNumber; - // console.log(proposalKey); - // console.log(index); - // console.log(value); + + if (lead_type == 1){ + index = lastNumber; + }else{ + if (rfq_count == 0){ + index = 0; + }else{ + index = lastNumber; + } + } + let proposal = overallColumnData[proposalKey]; let insurersList = proposal.insurers.map(ins => ins.ins_name); // Extract insurer names @@ -2717,9 +2827,9 @@ } function addSuggestion(rowData) { - console.log("child table data rowData", rowData); - console.log("child table data rowData.id", rowData.row_id); - console.log("child table data child_table_data", child_table_data[rowData.row_id]); + // // console.log("child table data rowData", rowData); + // // console.log("child table data rowData.id", rowData.row_id); + // // console.log("child table data child_table_data", child_table_data[rowData.row_id]); var table_data = child_table_data[rowData.row_id]; @@ -2731,7 +2841,7 @@ }); }); - // console.log("child table data ", suggestions); + // // console.log("child table data ", suggestions); // child_table_data[rowData.rowID] } @@ -2761,18 +2871,28 @@ quotesConfig = setQuotesConfig(proposalDataArray.proposal_data.over_all_column_data); let keys = Object.keys(quotesConfig); let lastKey = keys[keys.length - 1]; - proposalCount = lastKey; + if (lead_type == 1){ + proposalCount = lastKey; + }else{ + if (rfq_count == 0){ + proposalCount = 0; + }else{ + proposalCount = keys.length-1; + } + } + + proposalCountForTableINcrease = keys.length; - console.log(proposalCount); + // console.log(proposalCount); // Calculate width increase let increaseBy = rfq_or_qcr == 2 ? getTotalCount(proposalDataArray) * 150 : proposalCountForTableINcrease * 150; - console.log("Quotes COnfig : ",quotesConfig); - console.log("policy COnfig :", policyConfig); - // // console.log("trying to find checkbox data : : : ", increaseBy); + // console.log("Quotes COnfig : ",quotesConfig); + // console.log("policy COnfig :", policyConfig); + // // // console.log("trying to find checkbox data : : : ", increaseBy); suggestions = {}; @@ -2854,7 +2974,7 @@ else { // td.onclick = () => getAnswer(table.id, tr.id); td.innerHTML = processCellContent(cellData.input_value, rowData, cellData.display_content); - // console.log("DEBUG ISSUE : ",cellData.parentth) + // // console.log("DEBUG ISSUE : ",cellData.parentth) if (cellData.parentth.startsWith("Proposal") || cellData.parentth.startsWith("Existing")) { if (lead_type == 1){ @@ -2864,8 +2984,9 @@ td.classList.add("insurer_proposal"); } }else{ - + td.onclick = () => getAnswer(table.id, tr.id); if (cellData.subth != "Quote asked") { + td.onclick = () => getAnswer(table.id, tr.id); td.classList.add("insurer_proposal"); } } @@ -2956,40 +3077,70 @@ const headerRow2 = document.createElement('tr'); var overallColumnDataProposal = proposal_data.proposal_data.over_all_column_data; var matchedKey = ""; + var headerName = ''; headers.forEach(header => { // Parent header const th1 = document.createElement('th'); th1.textContent = header.parentHeader; if (header.parentHeader.startsWith('Proposal') || header.parentHeader.startsWith("Existing")) { if (lead_type == 1){ - var headerName = header.parentHeader; + headerName = header.parentHeader; }else{ - var headerName = rollover_or_renewal; - } + if (rfq_count == 0){ + headerName = rollover_or_renewal; + }else{ + headerName = header.parentHeader; + } + } + var proposalHTMLNumber = ""; + console.log("Header Name : ",header.parentHeader); + // alert(headerName); if (lead_type == 1){ + console.log("Header Name lead type 1 : ",header.parentHeader); matchedKey = Object.keys(overallColumnDataProposal).find(key => headerName.startsWith(key)); + proposalHTMLNumber = header.parentHeader.split(' ')[1]; }else{ + console.log("Header Name lead type not 1 : ",header.parentHeader); + + if (rfq_count == 0 && header.parentHeader.startsWith("Proposal")){ + console.log("Header Name lead type not 1 proposal: ",header.parentHeader); - if (header.parentHeader.startsWith("Proposal")){ var tempHeader = header.parentHeader; matchedKey = Object.keys(overallColumnDataProposal).find(key => tempHeader.startsWith(key)); + proposalHTMLNumber = 0; + }else{ - matchedKey = Object.keys(overallColumnDataProposal).find(key => headerName.startsWith(key)); + + console.log("Header Name lead type not 1 noy proposal: ",header.parentHeader); + + if (header.parentHeader.startsWith("Existing")){ + var tempHeader2 = lead_type == 2 ?"Existing Renewal 0":"Existing Roll Over 0"; + matchedKey = Object.keys(overallColumnDataProposal).find(key => tempHeader2.startsWith(key)); + proposalHTMLNumber = 0; + // alert(tempHeader2); + }else if (header.parentHeader.startsWith("Proposal")){ + matchedKey = Object.keys(overallColumnDataProposal).find(key => headerName.startsWith(key)); + proposalHTMLNumber = header.parentHeader.split(' ')[1]; + } + + // alert(matchedKey); } } if (matchedKey) { - // console.log("something wrong : ", overallColumnDataProposal[matchedKey]); + // // console.log("something wrong : ", overallColumnDataProposal[matchedKey]); var headerCheckBoxProperties = overallColumnDataProposal[matchedKey]; + // // console.log("something wrong :headerCheckBoxProperties ", headerCheckBoxProperties); } + th1.innerHTML = ` - ${header.parentHeader} + ${headerName} `; th1.colSpan = header.subHeaders.length; - // // console.log("insurer data proposal set : ",th1); // See the element's attributes in the console + // // // console.log("insurer data proposal set : ",th1); // See the element's attributes in the // console } headerRow1.appendChild(th1); - // // console.log("this is the header : ", header); + // // // console.log("this is the header : ", header); // Sub headers header.subHeaders.forEach(subHeader => { const th2 = document.createElement('th'); if (header.parentHeader.startsWith("Proposal") || header.parentHeader.startsWith("Existing")) { var insurers = overallColumnDataProposal[matchedKey].insurers; + // // console.log("trying to find something :header.parentHeader ", header.parentHeader); + // // console.log("trying to find something :insurers ", insurers); + // // console.log("trying to find : subHeader",subHeader) const matchedInsurer = insurers.find(ins => ins.ins_name == subHeader); + if (subHeader != "Quote asked") { - // console.log("trying to find something : ", matchedInsurer.stc); + // // console.log("trying to find something : matchedInsurer", matchedInsurer); + // // console.log("trying to find something :matchedInsurer stc ", matchedInsurer.stc); + // // console.log("trying to find something : ", matchedInsurer.stc); - // console.log("this is the subheader : ", subHeader); - // console.log("debug 2: ", subHeader, "parent header : ", header.parentHeader); + // // console.log("this is the subheader : ", subHeader); + // // console.log("debug 2: ", subHeader, "parent header : ", header.parentHeader); th2.classList.add("insurer_proposal"); th2.innerHTML = ` ${subHeader} @@ -3032,19 +3189,34 @@ style="background-color: rgb(221, 221, 221);">Send to Client ${matchedInsurer.stc == 1 ? ``: ""} - - + +
`; } else { th2.textContent = subHeader; } + if (lead_type == 1){ + + th1.setAttribute('data-proposal', header.parentHeader.split(' ')[1]); + th2.setAttribute('data-proposal', header.parentHeader.split(' ')[1]); - th2.setAttribute('data-proposal', header.parentHeader.split(' ')[1]); + }else{ + if (headerName.startsWith("Existing")){ + th1.setAttribute('data-proposal',0); + th2.setAttribute('data-proposal',0); + + }else{ + th1.setAttribute('data-proposal', header.parentHeader.split(' ')[1]); + th2.setAttribute('data-proposal', header.parentHeader.split(' ')[1]); + + } + + } th2.setAttribute("data-quote", subHeader); - th1.setAttribute('data-proposal', header.parentHeader.split(' ')[1]); - // // console.log("header insert position ",th1.getAttribute()) + + // // // console.log("header insert position ",th1.getAttribute()) } else { th2.textContent = subHeader; @@ -3068,7 +3240,7 @@ if (value == "Checked") { addSuggestion(cellData); } - // // console.log("insude the function value ", value); + // // // console.log("insude the function value ", value); return ` ${cellData.SNO} ${cellData.SNO == 'Fire' || cellData.SNO == 'Burglary' ? `