FIX_QCR_AND_STC_SRI
This commit is contained in:
parent
45eeef869b
commit
076f40499b
@ -583,7 +583,8 @@ class LeadsController extends BaseController
|
||||
|
||||
$data['policies'] = json_decode($data['question_json'], true)['policies'];
|
||||
$data["child_table_data"] = json_decode($data['question_json'], true)['child_table_data'];
|
||||
// dd($data);
|
||||
// $data['lead_register_data'] = json_decode($data['lead_data']['custom_fields']);
|
||||
// dd($data['lead_register_data']);
|
||||
$data['client_type'] = $this->clientType;
|
||||
$this->loadLayout('view_rfq_non_eb', $data);
|
||||
|
||||
|
||||
@ -32,11 +32,11 @@
|
||||
<!-- Product selection Tab -->
|
||||
<div class="tab-pane fade show active" id="product-selection">
|
||||
<form id="productSelectionForm" class="parsley-examples" enctype="multipart/form-data">
|
||||
<div class="row">
|
||||
<div class="form-group col-md-3">
|
||||
<button type="button" class="btn btn-primary" id="getDataFromLead" onclick="assignLeadData()">Get Data From Lead</button>
|
||||
<div class="row">
|
||||
<div class="form-group col-md-3">
|
||||
<button type="button" class="btn btn-primary" id="getDataFromLead" onclick="assignLeadData()">Get Data From Lead</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group col-md-3">
|
||||
<label>Select Buisness Type<span class="text-danger">*</span></label>
|
||||
@ -64,7 +64,7 @@
|
||||
<div class="row">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="client_type">Client Type<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="client_type" name="client_type" >
|
||||
<select class="form-control" id="client_type" name="client_type">
|
||||
<option value="">Select Client type</option>
|
||||
<?php
|
||||
if (isset($client_type) && count($client_type)) {
|
||||
@ -77,7 +77,7 @@
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="buisnessNature">Nature of Buisness</label>
|
||||
<input type="text" class="form-control" id="buisnessNature"/>
|
||||
<input type="text" class="form-control" id="buisnessNature" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -123,8 +123,11 @@
|
||||
<label for="pan_number">PAN Number</label>
|
||||
<input type="text" id="pan_number" name="pan_number" class="form-control" />
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<input type="checkbox" id="dataFromLead" name="dataFromLead" class="form-check-input" />
|
||||
<div class="form-group col-md-3" style="
|
||||
padding-left: 40px;
|
||||
padding-top: 34px;
|
||||
">
|
||||
<input onclick="checkandassignLeadData()" type="checkbox" id="dataFromLead" name="dataFromLead" class="form-check-input" />
|
||||
<label for="dataFromLead">Get Data From Leads</label>
|
||||
</div>
|
||||
</div>
|
||||
@ -159,7 +162,7 @@
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="policy_term">Policy Term<span class="text-danger">*</span></label>
|
||||
<select id="policy_term" name="policy_term" class="form-control" >
|
||||
<select id="policy_term" name="policy_term" class="form-control">
|
||||
<option value="">Select</option>
|
||||
<option value="1_month">1 Months</option>
|
||||
<option value="2_month">2 Months</option>
|
||||
@ -179,7 +182,7 @@
|
||||
</div>
|
||||
<div id="locationNoDIV" class="form-group col-md-3">
|
||||
<label for="location_no">No of location<span class="text-danger">*</span></label>
|
||||
<select id="location_no" name="location_no" class="form-control" >
|
||||
<select id="location_no" name="location_no" class="form-control">
|
||||
<option value="1">1</option>
|
||||
<option value="2">2</option>
|
||||
<option value="3">3</option>
|
||||
@ -264,11 +267,11 @@
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var storedData = JSON.parse(localStorage.getItem('policyData'));
|
||||
var storedPolicyData = JSON.parse(localStorage.getItem('policyData'));
|
||||
$(document).ready(function() {
|
||||
// console.log("Stored date Found : ",storedData.length);
|
||||
if (!$.isEmptyObject(storedData)) {
|
||||
prepareDataForEdit(storedData);
|
||||
// console.log("Stored date Found : ",storedPolicyData.length);
|
||||
if (!$.isEmptyObject(storedPolicyData)) {
|
||||
prepareDataForEdit(storedPolicyData);
|
||||
} else {
|
||||
console.log("inside else trying to open product sleection tab");
|
||||
// const productSelectionTab = new bootstrap.Tab(document.getElementById);
|
||||
@ -346,7 +349,7 @@
|
||||
|
||||
var policyRiskSplitUpData = {};
|
||||
$(document).ready(function() {
|
||||
if ($.isEmptyObject(storedData)) {
|
||||
if ($.isEmptyObject(storedPolicyData)) {
|
||||
$('#multilocation_type_div').hide();
|
||||
}
|
||||
// When a business-type checkbox changes, handle exclusive selection
|
||||
@ -546,6 +549,7 @@
|
||||
if (e.target.id === 'policy-details-tab') {
|
||||
if (Object.keys(productSelectionData).length > 0) {
|
||||
$("#policy-details").show();
|
||||
|
||||
// validatePolicyBasedOnProductSelection();
|
||||
} else {
|
||||
$("#policy-details").hide();
|
||||
@ -1061,9 +1065,9 @@
|
||||
console.log("Policy data saved to local storage. : ", policyData);
|
||||
}
|
||||
|
||||
function loadPolicyDataBack(storedData) {
|
||||
if (storedData) {
|
||||
var parsedData = storedData;
|
||||
function loadPolicyDataBack(storedPolicyData) {
|
||||
if (storedPolicyData) {
|
||||
var parsedData = storedPolicyData;
|
||||
|
||||
// Assign back to original variables
|
||||
productSelectionData = parsedData.productSelection;
|
||||
@ -1086,6 +1090,7 @@
|
||||
|
||||
|
||||
function prepareDataForEdit(data) {
|
||||
// alert("something wrong");
|
||||
loadPolicyDataBack(data);
|
||||
// Populate Product Selection
|
||||
$('#singleProduct').prop('checked', data.productSelection.singleProduct === 'on');
|
||||
@ -1163,11 +1168,48 @@
|
||||
|
||||
}
|
||||
|
||||
function assignLeadData(){
|
||||
const lead_data = '<?= json_encode($lead_data['custom_fields']) ?>';
|
||||
|
||||
if (lead_data){
|
||||
console.log("Lead Data : ",lead_data);
|
||||
function checkandassignLeadData() {
|
||||
|
||||
var checkedStatus = $("#dataFromLead").is(":checked") ? true : false;
|
||||
|
||||
if (checkedStatus) {
|
||||
assignLeadData();
|
||||
}
|
||||
}
|
||||
|
||||
function assignLeadData() {
|
||||
const lead_data = <?= json_encode(json_decode($lead_data['custom_fields'])) ?>;
|
||||
var client_type = <?= isset($lead_data['client_type']) ? $lead_data
|
||||
['client_type'] : "" ?>;
|
||||
var mobile = <?= isset($lead_data['client_type']) ? $lead_data
|
||||
['client_type'] : "" ?>;
|
||||
var email = <?= isset($lead_data['client_type']) ? $lead_data
|
||||
['client_type'] : "" ?>;
|
||||
var panNo = <?= isset($lead_data['client_type']) ? $lead_data
|
||||
['client_type'] : "" ?>;
|
||||
console.log("client_type : ".client_type);
|
||||
if (lead_data) {
|
||||
// lead_data = JSON.parse(lead_data);
|
||||
console.log("Lead Data : ", typeof(lead_data));
|
||||
|
||||
if (lead_data.risk_location == "Single") {
|
||||
|
||||
console.log("single ");
|
||||
$("#singleProduct").prop("checked", true).trigger("change");
|
||||
|
||||
} else {
|
||||
|
||||
$("#multipleProduct").prop("checked", true).trigger("change");
|
||||
|
||||
if (lead_data.risk_location == "multi_with_floter") {
|
||||
$("#multilocation_type").val("multiFloater").trigger("change");
|
||||
} else {
|
||||
$("#multilocation_type").val("multiLocation").trigger("change");
|
||||
}
|
||||
}
|
||||
|
||||
$("#client_type").val(client_type).trigger("change");
|
||||
$("#address1").val(lead_data.address);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -198,7 +198,7 @@
|
||||
'insurers': []
|
||||
}
|
||||
};
|
||||
const suggestions = {};
|
||||
var suggestions = {};
|
||||
var storedData = JSON.parse(localStorage.getItem('policyData'));
|
||||
var policySummary;
|
||||
if (!$.isEmptyObject(storedData)) {
|
||||
@ -398,6 +398,8 @@
|
||||
|
||||
// Remove the proposal from quotesConfig
|
||||
delete quotesConfig[proposalNumber];
|
||||
|
||||
delete policyConfig[proposalNumber];
|
||||
}
|
||||
|
||||
// Add a new row
|
||||
@ -720,7 +722,7 @@
|
||||
quotesConfig[proposalNumber].push(newQuote);
|
||||
console.log("add Quotes config", quotesConfig);
|
||||
updateAllTables(proposalNumber, insurerName);
|
||||
|
||||
|
||||
var proposalName = `Proposal ${proposalNumber}`;
|
||||
const proposalHeader = document.querySelector(`th[data-proposal="${proposalNumber}"]`);
|
||||
if (proposalHeader) {
|
||||
@ -740,11 +742,11 @@
|
||||
quotesConfig[proposalNumber].push(newQuote);
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -862,8 +864,10 @@
|
||||
console.log("quote index ", quoteIndex);
|
||||
if (quoteIndex !== -1) {
|
||||
quotesConfig[proposalNumber].splice(quoteIndex, 1);
|
||||
policyConfig[proposalNumber].splice(quoteIndex, 1);
|
||||
if (quotesConfig[proposalNumber].length === 0) {
|
||||
delete quotesConfig[proposalNumber];
|
||||
delete policyConfig[proposalNumber];
|
||||
}
|
||||
}
|
||||
|
||||
@ -939,11 +943,11 @@
|
||||
insertPosition += quotesConfig[i]?.length || 0;
|
||||
}
|
||||
insertPosition += quotesConfig[proposalNumber].length - 1;
|
||||
console.log("Header insert position : ",insertPosition);
|
||||
console.log("Header insert position : ",newQuoteHeader.outerHTML);
|
||||
console.log("Header insert position : ",headerRow2.children[insertPosition].outerHTML);
|
||||
console.log("Header insert position : ",quotesConfig[proposalNumber].length);
|
||||
console.log("Header insert position : ",proposalHeader);
|
||||
console.log("Header insert position : ", insertPosition);
|
||||
console.log("Header insert position : ", newQuoteHeader.outerHTML);
|
||||
console.log("Header insert position : ", headerRow2.children[insertPosition].outerHTML);
|
||||
console.log("Header insert position : ", quotesConfig[proposalNumber].length);
|
||||
console.log("Header insert position : ", proposalHeader);
|
||||
// Update headers
|
||||
headerRow2.insertBefore(newQuoteHeader, headerRow2.children[insertPosition]);
|
||||
if (proposalHeader) proposalHeader.colSpan = quotesConfig[proposalNumber].length;
|
||||
@ -952,8 +956,8 @@
|
||||
table.querySelectorAll('tbody tr').forEach(row => {
|
||||
const lastCell = row.querySelector(`td:nth-child(${insertPosition})`);
|
||||
const newCell = lastCell.cloneNode(true);
|
||||
console.log("Header insert position lasr cell: ",lastCell.outerHTML)
|
||||
console.log("Header insert position new cell: ",newCell.outerHTML)
|
||||
console.log("Header insert position lasr cell: ", lastCell.outerHTML)
|
||||
console.log("Header insert position new cell: ", newCell.outerHTML)
|
||||
newCell.contentEditable = true;
|
||||
newCell.onclick = () => getAnswer(table.id, row.id);
|
||||
row.insertBefore(newCell, row.children[insertPosition]);
|
||||
@ -1085,7 +1089,7 @@
|
||||
var policy_question = row_fields[rowID].display_value;
|
||||
var answer_type = row_fields[rowID].answer_type;
|
||||
var tableID = tableData?.table_id ?? null;
|
||||
// console.log('table id ', tableID);
|
||||
console.log('row fields : ', row_fields);
|
||||
var SNO = getSNO(tableID);
|
||||
if (tableData) {
|
||||
suggestions[rowID] = row_fields[rowID].answer_type;
|
||||
@ -1267,7 +1271,7 @@
|
||||
localStorage.setItem('allTablesJsonData', JSON.stringify(rfq_data));
|
||||
jsonToTables();
|
||||
// generateTable(document.getElementById('tablesContainer'));
|
||||
console.log("polices Length ", policies.length);
|
||||
// console.log("polices Length ", policies.length);
|
||||
|
||||
} else {
|
||||
generateTable(document.getElementById('tablesContainer'));
|
||||
@ -1511,27 +1515,49 @@
|
||||
|
||||
function addOrRemoveIcon(element, event) {
|
||||
event.stopPropagation();
|
||||
let icon = element.querySelector('.fa-check-square');
|
||||
|
||||
// Get the parent dropdown to access both buttons reliably
|
||||
const dropdown = element.closest('.dropdown-content');
|
||||
const qcrButton = dropdown.querySelector('.qcrProposal');
|
||||
const stcButton = dropdown.querySelector('.sendClientProposal');
|
||||
|
||||
// Get current icons
|
||||
let qcrIcon = qcrButton.querySelector('.fa-check-square');
|
||||
let stcIcon = stcButton.querySelector('.fa-check-square');
|
||||
|
||||
// If clicked on QCR button
|
||||
if (element.classList.contains('qcrProposal')) {
|
||||
var client_proposal_element = document.querySelector('.sendClientProposal');
|
||||
var icon2 = client_proposal_element.querySelector('.fa-check-square');
|
||||
if (icon) {
|
||||
if (icon2) {
|
||||
client_proposal_element.removeChild(icon2);
|
||||
if (!qcrIcon) {
|
||||
// QCR being checked: add icon to both
|
||||
createIcon(qcrButton);
|
||||
if (!stcIcon) {
|
||||
createIcon(stcButton);
|
||||
}
|
||||
} else {
|
||||
if (!icon2) {
|
||||
createIcon(client_proposal_element);
|
||||
// QCR being unchecked: remove icon from both
|
||||
qcrButton.removeChild(qcrIcon);
|
||||
if (stcIcon) {
|
||||
stcButton.removeChild(stcIcon);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!icon) {
|
||||
createIcon(element);
|
||||
// console.log("checkbox added");
|
||||
} else {
|
||||
element.removeChild(icon);
|
||||
// console.log("checkbox removed");
|
||||
// If clicked on Send to Client button
|
||||
else if (element.classList.contains('sendClientProposal')) {
|
||||
if (!stcIcon) {
|
||||
// STC being checked: must ensure QCR is checked first
|
||||
if (!qcrIcon) {
|
||||
createIcon(qcrButton); // Ensure QCR is checked
|
||||
}
|
||||
createIcon(stcButton);
|
||||
} else {
|
||||
// STC being unchecked: only remove STC icon
|
||||
stcButton.removeChild(stcIcon);
|
||||
// QCR remains unchanged
|
||||
}
|
||||
}
|
||||
|
||||
// Update your data model or save state if needed
|
||||
// updateHeaderCheckBoxProperties();
|
||||
}
|
||||
|
||||
function createIcon(element) {
|
||||
@ -1712,6 +1738,7 @@
|
||||
}
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
// window.location.reload();
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
$('.loader').fadeOut();
|
||||
@ -1751,8 +1778,6 @@
|
||||
|
||||
uniqueInsurers.push({
|
||||
ins_name: insurer.insurerName,
|
||||
qcr: 1,
|
||||
stc: 1,
|
||||
display_name: insurer.insurerName,
|
||||
id: insurer.id
|
||||
});
|
||||
@ -1789,17 +1814,34 @@
|
||||
|
||||
let headerIndex = 0;
|
||||
parentHeaders.forEach(header => {
|
||||
const colspan = parseInt(header.getAttribute('colspan')) || 1;
|
||||
console.log("Found header ", header);
|
||||
if (header.innerText.trim().startsWith("Proposal")) {
|
||||
var policyNumber = header.getAttribute("data-proposal");
|
||||
var colspan = parseInt(quotesConfig[policyNumber].length);
|
||||
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);
|
||||
for (let i = 0; i < colspan; i++) {
|
||||
subHeaderArray.push(subHeaders[headerIndex].innerText.replace('⋮', '').trim());
|
||||
const subheaderHTML = subHeaders[headerIndex].innerHTML;
|
||||
const subheaderText = subheaderHTML.replace(/<span class="three-dot-menu"[\s\S]*?<\/div>/g, '').trim();
|
||||
subHeaderArray.push(subheaderText);
|
||||
headerIndex++;
|
||||
}
|
||||
console.log("HEader : ", header.innerText.replace('⋮', '').split('\n')[0].replace(/:.*/, '').trim());
|
||||
console.log("inside save colspn : ", colspan);
|
||||
const headerHTML = header.innerHTML;
|
||||
const headerText = headerHTML.replace(/<span class="three-dot-menu"[\s\S]*?<\/div>/g, '').trim();
|
||||
console.log("processing sub header array : ", subHeaderArray);
|
||||
console.log("HEader : ", headerText);
|
||||
headers.push({
|
||||
parentHeader: header.innerText.replace('⋮', '').split('\n')[0].replace(/:.*/, '').trim(),
|
||||
// parentHeader: header.innerText.replace('⋮', '').split('\n')[0].replace(/:.*/, '').trim(),
|
||||
parentHeader: headerText,
|
||||
subHeaders: subHeaderArray
|
||||
});
|
||||
console.log("processing sub header array : ", headers);
|
||||
});
|
||||
|
||||
// Process each row in the current table
|
||||
@ -1846,14 +1888,15 @@
|
||||
|
||||
if (input.type === "checkbox") {
|
||||
content = input.checked ? "Checked" : "Not Checked"; // Handling checkboxes
|
||||
display_value = input.checked ? "Checked" : "Not Checked";
|
||||
display_content = input.checked ? "Checked" : "Not Checked";
|
||||
} else {
|
||||
content = input.value; // Handling other input types like text, select, textarea
|
||||
display_value = cell.innerText.trim();
|
||||
display_content = cell.innerText.trim();
|
||||
console.log("processing sub header array : ", content);
|
||||
}
|
||||
} else {
|
||||
content = cell.innerText.trim(); // If no input is found, use the cell's text
|
||||
display_value = cell.innerText.trim();
|
||||
display_content = cell.innerText.trim();
|
||||
|
||||
}
|
||||
}
|
||||
@ -1864,7 +1907,7 @@
|
||||
subth: subHeader,
|
||||
// value: cell.innerText,
|
||||
input_value: content,
|
||||
display_value: display_value,
|
||||
display_content: display_content,
|
||||
rowspan: cell.rowSpan
|
||||
});
|
||||
|
||||
@ -1873,7 +1916,7 @@
|
||||
});
|
||||
|
||||
data.push(rowData);
|
||||
console.log("data gets pushed here ", data);
|
||||
// console.log("processing sub header array : ",content);
|
||||
});
|
||||
tablePolicyName = [...selectedPolicies].find(policy => tableId.startsWith(policy)) || null;
|
||||
console.log(selectedPolicies);
|
||||
@ -1975,6 +2018,24 @@
|
||||
return quotesConfiguration;
|
||||
}
|
||||
|
||||
function addSuggestion(rowData) {
|
||||
console.log("child table data ", rowData);
|
||||
console.log("child table data ", rowData.row_id);
|
||||
console.log("child table data ", child_table_data[rowData.row_id]);
|
||||
|
||||
var table_data = child_table_data[rowData.row_id];
|
||||
table_data.forEach(table => {
|
||||
table.table_row_contents.forEach(row => {
|
||||
const key = Object.keys(row)[0]; // Get the first key in the row object
|
||||
const answerType = row[key].answer_type; // Get the answer_type
|
||||
suggestions[key] = answerType; // Store in suggestions object
|
||||
});
|
||||
});
|
||||
|
||||
console.log("child table data ", suggestions);
|
||||
// child_table_data[rowData.rowID]
|
||||
}
|
||||
|
||||
|
||||
|
||||
function jsonToTables() {
|
||||
@ -2006,6 +2067,9 @@
|
||||
let increaseBy = proposalCount * 150;
|
||||
console.log("trying to find checkbox data : : : ", increaseBy);
|
||||
|
||||
|
||||
suggestions = {};
|
||||
|
||||
// Group tables by policy name
|
||||
const policyTables = {};
|
||||
|
||||
@ -2062,7 +2126,7 @@
|
||||
}
|
||||
// Handle regular cells
|
||||
else {
|
||||
td.innerHTML = processCellContent(cellData.input_value, rowData,cellData.display_value);
|
||||
td.innerHTML = processCellContent(cellData.input_value, rowData, cellData.display_content);
|
||||
if (cellData.parentth.startsWith("Proposal")) {
|
||||
td.onclick = () => getAnswer(table.id, tr.id);
|
||||
if (cellData.subth != "Quote asked") {
|
||||
@ -2148,7 +2212,7 @@
|
||||
${header.parentHeader}
|
||||
<span class="three-dot-menu" >⋮</span>
|
||||
<div class="dropdown-content">
|
||||
<button id = "isQCR" onclick = "addOrRemoveIcon(this,event)"class="qcrProposal" style="background-color: rgb(221, 221, 221);">QCR ${headerCheckBoxProperties['qcr'] == 1 ? `<i
|
||||
<button id = "isQCR" onclick = "addOrRemoveIcon(this,event)" class="qcrProposal" style="background-color: rgb(221, 221, 221);">QCR ${headerCheckBoxProperties['qcr'] == 1 ? `<i
|
||||
class="fa fa-check-square"
|
||||
style="color: green; margin-left: 8px; "></i> `:"" }</button>
|
||||
<button id = "isSTC" class="sendClientProposal" onclick = "addOrRemoveIcon(this,event)"
|
||||
@ -2170,20 +2234,28 @@
|
||||
// Sub headers
|
||||
header.subHeaders.forEach(subHeader => {
|
||||
const th2 = document.createElement('th');
|
||||
if (header.parentHeader.startsWith("Proposal") && subHeader != "Quote asked") {
|
||||
console.log("this is the subheader : ", subHeader);
|
||||
th2.classList.add("insurer_proposal");
|
||||
th2.innerHTML = `
|
||||
if (header.parentHeader.startsWith("Proposal")) {
|
||||
|
||||
if (subHeader != "Quote asked") {
|
||||
console.log("this is the subheader : ", subHeader);
|
||||
th2.classList.add("insurer_proposal");
|
||||
th2.innerHTML = `
|
||||
${subHeader}
|
||||
<span class="three-dot-menu">⋮</span>
|
||||
<div class="dropdown-content">
|
||||
<button onclick="changeInsurer(event, ${header.parentHeader.split(' ')[1]}, '${subHeader}')">Change Insurer</button>
|
||||
<button onclick="removeQuote(event, ${header.parentHeader.split(' ')[1]}, '${subHeader}')">Remove Quote</button>
|
||||
</div>
|
||||
`;
|
||||
`;
|
||||
} else {
|
||||
th2.textContent = subHeader;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
@ -2200,9 +2272,13 @@
|
||||
}
|
||||
|
||||
// Helper to process cell content
|
||||
function processCellContent(value, cellData = null,displayValue) {
|
||||
function processCellContent(value, cellData = null, displayValue) {
|
||||
|
||||
if (value.startsWith('Check') || value.startsWith('Not')) {
|
||||
|
||||
if (value == "Checked") {
|
||||
addSuggestion(cellData);
|
||||
}
|
||||
// console.log("insude the function value ", value);
|
||||
return `<input type="checkbox" ${value == "Checked" ? "checked" :""} class = "sno-checkbox" /> ${cellData.SNO} ${cellData.SNO == 'Fire' || cellData.SNO == 'Burglary'
|
||||
? `<br><button class = "btn btn-primary btn-sm" onclick = "getPolicyInfo()" class="policy-link" data-policy-name="${cellData.SNO}">Register</a>`
|
||||
@ -2241,7 +2317,7 @@
|
||||
// Three-dot menu handlers
|
||||
document.querySelectorAll('.three-dot-menu').forEach(menu => {
|
||||
menu.addEventListener('click', showDropdown);
|
||||
console.log("event listener called ");
|
||||
// console.log("event listener called ");
|
||||
});
|
||||
|
||||
// Policy link handlers
|
||||
@ -2321,8 +2397,9 @@
|
||||
};
|
||||
|
||||
var proposal = getProposalsWithQCRZero(overallData);
|
||||
|
||||
console.log("column to hide : ", proposal);
|
||||
proposal.forEach(function(prop) {
|
||||
console.log("column prop : ", prop);
|
||||
hideColumn(prop);
|
||||
})
|
||||
|
||||
@ -2332,51 +2409,50 @@
|
||||
console.log(`Hiding column: ${columnName}`);
|
||||
|
||||
document.querySelectorAll("table").forEach(table => {
|
||||
let headers = table.querySelectorAll("th");
|
||||
let rows = table.querySelectorAll("tr");
|
||||
// 1. Find the main proposal header in the first header row
|
||||
const mainHeaderRow = table.querySelector('thead tr:first-child');
|
||||
let proposalHeader = null;
|
||||
let proposalColspan = 1;
|
||||
let startColumnIndex = -1;
|
||||
|
||||
let columnIndex = -1;
|
||||
|
||||
// Find the column index based on header text
|
||||
headers.forEach((header, index) => {
|
||||
if (header.textContent.trim().startsWith(columnName)) {
|
||||
columnIndex = index;
|
||||
header.style.display = "none"; // Hide header
|
||||
// Find the header matching the columnName and its position
|
||||
Array.from(mainHeaderRow.children).forEach((th, index) => {
|
||||
if (th.textContent.trim().startsWith(columnName)) {
|
||||
proposalHeader = th;
|
||||
proposalColspan = parseInt(th.getAttribute('colspan')) || 1;
|
||||
startColumnIndex = index; // Starting index of the proposal header
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
if (columnIndex === -1) {
|
||||
console.log(`Column "${columnName}" not found in any table.`);
|
||||
if (!proposalHeader) {
|
||||
console.log(`Column "${columnName}" not found.`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Hide corresponding cells while respecting colspan & rowspan
|
||||
rows.forEach(row => {
|
||||
let cells = Array.from(row.children);
|
||||
let cellIndex = 0;
|
||||
// 2. Hide the main proposal header
|
||||
proposalHeader.style.display = "none";
|
||||
|
||||
for (let cell of cells) {
|
||||
let colSpan = cell.colSpan || 1;
|
||||
let rowSpan = cell.rowSpan || 1;
|
||||
// 3. Find and hide all subheaders under this proposal
|
||||
const subHeaderRow = table.querySelector('thead tr:last-child');
|
||||
const subHeaders = Array.from(subHeaderRow.children);
|
||||
|
||||
if (cellIndex === columnIndex) {
|
||||
if (colSpan > 1) {
|
||||
cell.colSpan--; // Reduce colspan instead of hiding
|
||||
} else {
|
||||
cell.style.display = "none"; // Hide the cell
|
||||
}
|
||||
}
|
||||
// Calculate range of subheaders to hide (same colspan as proposal header)
|
||||
const endColumnIndex = startColumnIndex + proposalColspan - 1;
|
||||
for (let i = startColumnIndex; i <= endColumnIndex; i++) {
|
||||
if (subHeaders[i]) subHeaders[i].style.display = "none";
|
||||
}
|
||||
|
||||
cellIndex += colSpan; // Move to the next column index
|
||||
// 4. Hide corresponding cells in all data rows
|
||||
table.querySelectorAll('tbody tr').forEach(row => {
|
||||
const cells = Array.from(row.children);
|
||||
for (let i = startColumnIndex; i <= endColumnIndex; i++) {
|
||||
if (cells[i]) cells[i].style.display = "none";
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function hideNonQCRRows() {
|
||||
console.log("hideNonQCRRows function called");
|
||||
// Select all tables
|
||||
@ -2538,78 +2614,89 @@
|
||||
|
||||
function contentNonEditableInsurerAdded(overallcolumnData) {
|
||||
let insNames = [];
|
||||
|
||||
Object.entries(overallcolumnData).forEach(([proposalKey, proposalValue]) => {
|
||||
if (proposalValue.insurers.length > 0) {
|
||||
insNames.push(proposalKey); // Push proposal key if insurers are present
|
||||
}
|
||||
});
|
||||
|
||||
console.log("overall column Data : ", insNames);
|
||||
console.log("Insurer names to make non-editable:", insNames);
|
||||
|
||||
$("table").each(function() {
|
||||
var table = $(this);
|
||||
var mainHeaderRow = table.find("tr:first-child"); // First row as main header
|
||||
|
||||
var targetColumnIndexes = new Set();
|
||||
var colIndexTracker = [];
|
||||
|
||||
// Step 1: Create a mapping of visual index to column header text
|
||||
var headerMapping = [];
|
||||
var visualIndex = 0;
|
||||
|
||||
// Step 1: Find columns where the header matches `insNames`
|
||||
mainHeaderRow.children("th, td").each(function(actualIndex) {
|
||||
colIndexTracker[visualIndex] = actualIndex;
|
||||
|
||||
mainHeaderRow.children("th, td").each(function() {
|
||||
var cellText = $(this).text().trim();
|
||||
// console.log("order : ",cellText);
|
||||
if (insNames.some(ins => cellText.startsWith(ins))) {
|
||||
targetColumnIndexes.add(visualIndex);
|
||||
var colspan = parseInt($(this).attr("colspan") || 1, 10);
|
||||
|
||||
// Store the header text at this visual index
|
||||
for (var i = 0; i < colspan; i++) {
|
||||
headerMapping[visualIndex + i] = cellText;
|
||||
}
|
||||
|
||||
visualIndex += parseInt($(this).attr("colspan") || 1, 10);
|
||||
// Check if this column matches any insurer name
|
||||
if (insNames.some(ins => cellText.startsWith(ins))) {
|
||||
for (var i = 0; i < colspan; i++) {
|
||||
targetColumnIndexes.add(visualIndex + i);
|
||||
}
|
||||
}
|
||||
|
||||
visualIndex += colspan;
|
||||
});
|
||||
// console.log("order fro header : ",targetColumnIndexes);
|
||||
|
||||
console.log("Target column indexes:", Array.from(targetColumnIndexes));
|
||||
|
||||
if (targetColumnIndexes.size === 0) return; // If no matching column is found, exit
|
||||
|
||||
var rowSpans = {};
|
||||
|
||||
// Step 2: Iterate through rows and set cells as non-editable
|
||||
table.find("tr").each(function() {
|
||||
table.find("tr").each(function(rowIndex) {
|
||||
var row = $(this);
|
||||
var currentVisualIndex = 0;
|
||||
|
||||
row.children("td, th").each(function(actualIndex) {
|
||||
while (rowSpans[currentVisualIndex]) {
|
||||
currentVisualIndex++; // Skip row-spanned columns
|
||||
row.children("td, th").each(function() {
|
||||
// Skip cells that are covered by rowspans from previous rows
|
||||
while (rowSpans[currentVisualIndex] > 0) {
|
||||
rowSpans[currentVisualIndex]--;
|
||||
currentVisualIndex++;
|
||||
}
|
||||
|
||||
var cell = $(this);
|
||||
var actualColIndex = colIndexTracker[currentVisualIndex];
|
||||
var cellColspan = parseInt(cell.attr("colspan") || 1, 10);
|
||||
var cellRowspan = parseInt(cell.attr("rowspan") || 1, 10);
|
||||
// console.log("order actualcol index : ",actualColIndex);
|
||||
if (targetColumnIndexes.has(actualColIndex)) {
|
||||
// console.log("inside if conditon order");
|
||||
|
||||
// Check if any of the columns this cell spans are in our target set
|
||||
let makeNonEditable = false;
|
||||
for (let i = 0; i < cellColspan; i++) {
|
||||
if (targetColumnIndexes.has(currentVisualIndex + i)) {
|
||||
makeNonEditable = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (makeNonEditable) {
|
||||
cell.attr("contenteditable", "false");
|
||||
removeOnClickFromColumnCells(cell);
|
||||
}
|
||||
|
||||
// Track rowspan
|
||||
// Track rowspan for future rows
|
||||
if (cellRowspan > 1) {
|
||||
for (var i = 0; i < cellColspan; i++) {
|
||||
rowSpans[currentVisualIndex + i] = (rowSpans[currentVisualIndex + i] || 0) + (cellRowspan - 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Move to the next visual position
|
||||
currentVisualIndex += cellColspan;
|
||||
});
|
||||
|
||||
// Reduce rowspan count for the next row
|
||||
Object.keys(rowSpans).forEach(function(key) {
|
||||
if (rowSpans[key] > 0) {
|
||||
rowSpans[key]--;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user