FIX_RFQ_PROPOSAL_COUNT

This commit is contained in:
Srinivas-Saravanan 2025-03-27 13:14:22 +05:30
parent 1c11c9e13e
commit 3b6733e3bb

View File

@ -481,10 +481,19 @@
var rfq_or_qcr = 1; var rfq_or_qcr = 1;
var proposalDataForDropDown = {}; var proposalDataForDropDown = {};
var lead_type = "<?= $lead_data['lead_type'] ?>";
// alert(lead_type);
var rollover_or_renewal = "";
if (lead_type != 1){
rollover_or_renewal = lead_type == 2 ? "Existing Renewal" : "Existing Roll Over";
}
var policyConfig = { var policyConfig = {
1: ['Quote asked'] 1: ['Quote asked']
}; };
let myModal; let myModal;
var over_all_column_data = { var over_all_column_data = {
"Proposal 1": { "Proposal 1": {
@ -638,7 +647,10 @@
// console.log('removeProposal'); // console.log('removeProposal');
console.log(quotesConfig); console.log(quotesConfig);
if (!quotesConfig[proposalNumber]) return; // If proposal doesn't exist, exit 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");
return;
}
// Remove all child columns for the proposal // Remove all child columns for the proposal
const tables = document.querySelectorAll('table'); const tables = document.querySelectorAll('table');
tables.forEach(table => { tables.forEach(table => {
@ -1574,6 +1586,7 @@
// console.log("Subheader th: colinded : ",colIndex); // console.log("Subheader th: colinded : ",colIndex);
// Get the subheader (assuming it's the second <tr> inside <thead>) // Get the subheader (assuming it's the second <tr> inside <thead>)
let subHeaderThList = [...document.querySelectorAll("thead tr:nth-child(2) th")]; let subHeaderThList = [...document.querySelectorAll("thead tr:nth-child(2) th")];
console.log("subHeaderThList", subHeaderThList);
// Filter <th> elements that have a valid 'data-proposal' attribute // Filter <th> elements that have a valid 'data-proposal' attribute
let validSubHeaders = subHeaderThList.filter(th => { let validSubHeaders = subHeaderThList.filter(th => {
@ -1583,18 +1596,23 @@
}); });
// console.log("Subheader th: subHeaderThList",subHeaderThList); console.log("Subheader th: validSubHeaders",validSubHeaders);
// let validSubHeaders = subHeaderThList.filter(th => th.hasAttribute("data-proposal")); // 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);
let subHeaderTh = validSubHeaders.find(th => th.textContent.trim());
console.log("Subheader th: codeValue",codeValue);
console.log("Subheader th: subHeaderTh",subHeaderTh);
// if (subHeaderTh.classList.contains("insurer_proposal")) { // if (subHeaderTh.classList.contains("insurer_proposal")) {
// alert(subHeaderTh); // alert(subHeaderTh);
// } // }
let subHeaderText = subHeaderTh ? subHeaderTh.textContent.trim() : ''; let subHeaderText = subHeaderTh ? subHeaderTh.textContent.trim() : '';
// console.log("Subheader th: ",subHeaderText); console.log("Subheader th: below code",subHeaderText);
// Check if subheader is NOT "Quote asked" // Check if subheader is NOT "Quote asked"
let className = subHeaderText !== "Quote asked" && subHeaderText != "-" ? "insurer_proposal" : ""; let className = !subHeaderText.startsWith("Quote asked") && subHeaderText != "-" ?
"insurer_proposal" : "";
console.log("className", className);
// alert(subHeaderText); // alert(subHeaderText);
let defaultJsonString = typeof default_answers_array == "object" ? JSON.stringify(default_answers_array[0]) : String(default_answers_array); let defaultJsonString = typeof default_answers_array == "object" ? JSON.stringify(default_answers_array[0]) : String(default_answers_array);
@ -2699,11 +2717,12 @@
} }
function addSuggestion(rowData) { function addSuggestion(rowData) {
// console.log("child table data ", rowData); console.log("child table data rowData", rowData);
// console.log("child table data ", rowData.row_id); console.log("child table data rowData.id", rowData.row_id);
// console.log("child table data ", child_table_data[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]; var table_data = child_table_data[rowData.row_id];
table_data.forEach(table => { table_data.forEach(table => {
table.table_row_contents.forEach(row => { table.table_row_contents.forEach(row => {
const key = Object.keys(row)[0]; // Get the first key in the row object const key = Object.keys(row)[0]; // Get the first key in the row object
@ -2743,13 +2762,16 @@
let keys = Object.keys(quotesConfig); let keys = Object.keys(quotesConfig);
let lastKey = keys[keys.length - 1]; let lastKey = keys[keys.length - 1];
proposalCount = lastKey; proposalCount = lastKey;
proposalCountForTableINcrease = keys.length;
console.log(proposalCount); console.log(proposalCount);
// Calculate width increase // Calculate width increase
let increaseBy = rfq_or_qcr == 2 ? let increaseBy = rfq_or_qcr == 2 ?
getTotalCount(proposalDataArray) * 150 : getTotalCount(proposalDataArray) * 150 :
proposalCount * 150; proposalCountForTableINcrease * 150;
console.log("Quotes COnfig : ",quotesConfig);
console.log("policy COnfig :", policyConfig);
// // console.log("trying to find checkbox data : : : ", increaseBy); // // console.log("trying to find checkbox data : : : ", increaseBy);
@ -2833,12 +2855,21 @@
// td.onclick = () => getAnswer(table.id, tr.id); // td.onclick = () => getAnswer(table.id, tr.id);
td.innerHTML = processCellContent(cellData.input_value, rowData, cellData.display_content); 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")) { if (cellData.parentth.startsWith("Proposal") || cellData.parentth.startsWith("Existing")) {
if (lead_type == 1){
td.onclick = () => getAnswer(table.id, tr.id); td.onclick = () => getAnswer(table.id, tr.id);
if (cellData.subth != "Quote asked") { if (cellData.subth != "Quote asked") {
td.onclick = () => getAnswer(table.id, tr.id); td.onclick = () => getAnswer(table.id, tr.id);
td.classList.add("insurer_proposal"); td.classList.add("insurer_proposal");
} }
}else{
if (cellData.subth != "Quote asked") {
td.classList.add("insurer_proposal");
}
}
} }
td.contentEditable = true; td.contentEditable = true;
@ -2929,11 +2960,29 @@
// Parent header // Parent header
const th1 = document.createElement('th'); const th1 = document.createElement('th');
th1.textContent = header.parentHeader; th1.textContent = header.parentHeader;
if (header.parentHeader.startsWith('Proposal')) { if (header.parentHeader.startsWith('Proposal') || header.parentHeader.startsWith("Existing")) {
if (lead_type == 1){
var headerName = header.parentHeader; var headerName = header.parentHeader;
// console.log("header name : ", th1.textContent.trim()); }else{
// console.log("over all column data : ", over_all_column_data) var headerName = rollover_or_renewal;
}
if (lead_type == 1){
matchedKey = Object.keys(overallColumnDataProposal).find(key => headerName.startsWith(key)); matchedKey = Object.keys(overallColumnDataProposal).find(key => headerName.startsWith(key));
}else{
if (header.parentHeader.startsWith("Proposal")){
var tempHeader = header.parentHeader;
matchedKey = Object.keys(overallColumnDataProposal).find(key => tempHeader.startsWith(key));
}else{
matchedKey = Object.keys(overallColumnDataProposal).find(key => headerName.startsWith(key));
}
}
if (matchedKey) { if (matchedKey) {
// console.log("something wrong : ", overallColumnDataProposal[matchedKey]); // console.log("something wrong : ", overallColumnDataProposal[matchedKey]);
var headerCheckBoxProperties = overallColumnDataProposal[matchedKey]; var headerCheckBoxProperties = overallColumnDataProposal[matchedKey];
@ -2965,7 +3014,7 @@
// Sub headers // Sub headers
header.subHeaders.forEach(subHeader => { header.subHeaders.forEach(subHeader => {
const th2 = document.createElement('th'); const th2 = document.createElement('th');
if (header.parentHeader.startsWith("Proposal")) { if (header.parentHeader.startsWith("Proposal") || header.parentHeader.startsWith("Existing")) {
var insurers = overallColumnDataProposal[matchedKey].insurers; var insurers = overallColumnDataProposal[matchedKey].insurers;
const matchedInsurer = insurers.find(ins => ins.ins_name == subHeader); const matchedInsurer = insurers.find(ins => ins.ins_name == subHeader);
@ -3379,7 +3428,7 @@
cell.attr("contenteditable", "false"); cell.attr("contenteditable", "false");
removeOnClickFromColumnCells(cell); removeOnClickFromColumnCells(cell);
if (!cell.text().trim().startsWith("Proposal")){ if (!cell.text().trim().startsWith("Proposal") && !cell.text().trim().startsWith("Existing")){
cell.addClass("readonly-select"); cell.addClass("readonly-select");
} }
} else if (rfq_or_qcr == 1) { } else if (rfq_or_qcr == 1) {