Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
1d71166bf5
@ -394,7 +394,7 @@ class EmployeeServiceController extends AdminController
|
||||
'is_mandatory' => true,
|
||||
'data_type' => 'str',
|
||||
'format' => null,
|
||||
'allowed_values' => ['name', 'dob', 'relationship']
|
||||
'allowed_values' => ['name', 'dob', 'relationship', 'email_corporate']
|
||||
],
|
||||
'value' => [
|
||||
'col_idx' => 4,
|
||||
|
||||
@ -1273,8 +1273,8 @@ class LeadsController extends BaseController
|
||||
'Total Lives' => $rfq_data['incept_no_of_lives'],
|
||||
|
||||
'Period of Insurance ' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d-m-Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d-m-Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
|
||||
'Insurer' => $rfq_data['insurer_name'] ?? " - ",
|
||||
'TPA' => $rfq_data['tpa_name'] ?? " - ",
|
||||
// 'Insurer' => $rfq_data['insurer_name'] ?? " - ",
|
||||
// 'TPA' => $rfq_data['tpa_name'] ?? " - ",
|
||||
// 'Policy Run Days' => $rfq_data['policy_run_days'],
|
||||
];
|
||||
} else if (in_array($rfq_data['policy_type_id'], [1, 6, 7])) {
|
||||
@ -1344,6 +1344,7 @@ class LeadsController extends BaseController
|
||||
$sheetName = 'Worksheet';
|
||||
if ($type == 2) {
|
||||
$sheetName = 'QCR';
|
||||
// $propsal_and_insurer = "Proposal 1-ICICIPRU-ICICI001";
|
||||
$data = $this->convertJsonForQCR($data, $type);
|
||||
if ($propsal_and_insurer !== null) {
|
||||
list($proposal_key, $insurer_key) = explode('-', $propsal_and_insurer, 2);
|
||||
@ -1485,9 +1486,16 @@ class LeadsController extends BaseController
|
||||
|
||||
$columnLetter = 'A';
|
||||
$header_actual_count = 0;
|
||||
$headerIndex = 0;
|
||||
foreach ($headers as $header) {
|
||||
// Kint::dump($header);
|
||||
|
||||
if($is_placement == true){
|
||||
//for placement proposal only
|
||||
$nxt_ro = $rowNumber + 1;
|
||||
$sheet->mergeCells("C{$rowNumber}:C{$nxt_ro}");
|
||||
}
|
||||
|
||||
if (in_array($header['parentHeader'], ['Item Key', 'Action'])) {
|
||||
continue;
|
||||
}
|
||||
@ -1499,10 +1507,18 @@ class LeadsController extends BaseController
|
||||
if ($header['parentHeader'] === 'Sno') {
|
||||
$header['parentHeader'] = 'S.No.';
|
||||
$sheet->getColumnDimension('A')->setWidth(10);
|
||||
|
||||
//merge the 2 row cells of the S.No.
|
||||
$nxt_ro = $rowNumber + 1;
|
||||
$sheet->mergeCells("{$columnLetter}{$rowNumber}:{$columnLetter}{$nxt_ro}");
|
||||
}
|
||||
|
||||
if ($header['parentHeader'] === 'Particulars') {
|
||||
$sheet->getColumnDimension('B')->setWidth(35);
|
||||
|
||||
//merge the 2 row cells of the particulars
|
||||
$nxt_ro = $rowNumber + 1;
|
||||
$sheet->mergeCells("{$columnLetter}{$rowNumber}:{$columnLetter}{$nxt_ro}");
|
||||
}
|
||||
|
||||
$startColumn = $columnLetter; // Start of the current header range
|
||||
@ -1512,9 +1528,12 @@ class LeadsController extends BaseController
|
||||
$sheet->setCellValue("{$startColumn}{$rowNumber}", "Terms");
|
||||
} else {
|
||||
if(in_array($header['parentHeader'], ["Existing Renewal", "Existing Rollover"])){
|
||||
$sheet->setCellValue("{$startColumn}{$rowNumber}", "Terms");
|
||||
}else{
|
||||
$sheet->setCellValue("{$startColumn}{$rowNumber}", "Existing Terms");
|
||||
}else if(in_array($header['parentHeader'], ["Particulars", "S.No."])){
|
||||
$sheet->setCellValue("{$startColumn}{$rowNumber}", $header['parentHeader']);
|
||||
}else{
|
||||
$headerIndex = $headerIndex + 1;
|
||||
$sheet->setCellValue("{$startColumn}{$rowNumber}", "Proposal Terms " . $headerIndex);
|
||||
}
|
||||
}
|
||||
$sheet->getStyle("{$startColumn}{$rowNumber}")->applyFromArray([
|
||||
@ -1585,9 +1604,9 @@ class LeadsController extends BaseController
|
||||
$sheet->getRowDimension($subHeaderRow)->setRowHeight(20); // Subheader row height
|
||||
|
||||
if ($is_placement == true) {
|
||||
$rowNumber = $subHeaderRow;
|
||||
$rowNumber = $subHeaderRow + 1;
|
||||
} else {
|
||||
$rowNumber = $subHeaderRow + 2;
|
||||
$rowNumber = $subHeaderRow + 1;
|
||||
}
|
||||
|
||||
// dd($rowNumber);
|
||||
@ -1629,6 +1648,7 @@ class LeadsController extends BaseController
|
||||
//premium data
|
||||
if ($type == 2) {
|
||||
|
||||
if($is_placement == true){$columnLetterForPremium = "B";}else{$columnLetterForPremium = "C";}
|
||||
$rowNumber += 2;
|
||||
|
||||
// Add premium data
|
||||
@ -1636,19 +1656,26 @@ class LeadsController extends BaseController
|
||||
// $labelArray = ["Premium", "GST (%)", "GST Amount (₹)", "Total"];
|
||||
$labelArray = ["Premium", "GST Amount (₹)", "Total"];
|
||||
$premiumData = $data['premium_data']['data'];
|
||||
// dd($premiumData);
|
||||
// $premium = [$labelArray[0]];
|
||||
// $gst = [$labelArray[1]];
|
||||
// $gstAmt = [$labelArray[1]];
|
||||
// $total = [$labelArray[2]];
|
||||
|
||||
if($is_placement == true){
|
||||
$premium[] = $labelArray[0];
|
||||
$gstAmt[] = $labelArray[1];
|
||||
$total[] = $labelArray[2];
|
||||
}
|
||||
|
||||
foreach ($premiumData as $proposal => $insurers) {
|
||||
if ($proposal != 'Particulars') {
|
||||
foreach ($insurers as $insurer => $values) {
|
||||
if($insurer == 'Quote Asked'){
|
||||
$premium[] = $labelArray[0];
|
||||
$premium[] = count($insurers ?? []) > 1 ? $labelArray[0] : "";
|
||||
// $gst[] = "";
|
||||
$gstAmt[] = $labelArray[1];
|
||||
$total[] = $labelArray[2];
|
||||
$gstAmt[] = count($insurers ?? []) > 1 ? $labelArray[1] : "";
|
||||
$total[] = count($insurers ?? []) > 1 ? $labelArray[2] : "";
|
||||
}else{
|
||||
$premium[] = formatIndianCurrency($values[$labelArray[0]]);
|
||||
// $gst[] = $values[$labelArray[1]];
|
||||
@ -1659,8 +1686,10 @@ class LeadsController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
// dd([$premium, $gstAmt, $total]); die;
|
||||
|
||||
foreach ([$premium, $gstAmt, $total] as $index => $rowData) {
|
||||
$columnLetter = 'C';
|
||||
$columnLetter = $columnLetterForPremium;
|
||||
foreach ($rowData as $key => $value) {
|
||||
$sheet->setCellValue("{$columnLetter}{$rowNumber}", $value);
|
||||
if (in_array($value, $labelArray)) {
|
||||
@ -1677,8 +1706,8 @@ class LeadsController extends BaseController
|
||||
$prevColumn3 = $this->getPreviousColumn($columnLetter, 2);
|
||||
}
|
||||
|
||||
$premiumRange = "C" . ($rowNumber - 3) . ":" . "{$prevColumn3}" . ($rowNumber - 1);
|
||||
// dd($premiumRange);
|
||||
$premiumRange = $columnLetterForPremium . ($rowNumber - 3) . ":" . "{$prevColumn3}" . ($rowNumber - 1);
|
||||
// dd($prevColumn3, $premiumRange, $this->getPreviousColumn($columnLetter, 2), $columnLetter, $rowNumber);
|
||||
|
||||
$sheet->getStyle($premiumRange)->applyFromArray([
|
||||
'borders' => [
|
||||
|
||||
@ -29,12 +29,45 @@
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.table th[contenteditable],
|
||||
/* .table th[contenteditable],
|
||||
.table td[contenteditable] {
|
||||
border: 1px solid #007bff;
|
||||
outline: none;
|
||||
} */
|
||||
|
||||
#rfqTable th:nth-child(-n+3),
|
||||
#rfqTable td:nth-child(-n+3) {
|
||||
border: none;
|
||||
}
|
||||
|
||||
#rfqTable th:nth-child(-n+3),
|
||||
#rfqTable td:nth-child(-n+3) {
|
||||
border: 3px solid snow;
|
||||
}
|
||||
|
||||
#rfqTable th:nth-child(n+4),
|
||||
#rfqTable td:nth-child(n+4) {
|
||||
border: 2px solid #007bff;
|
||||
/* outline: none; */
|
||||
}
|
||||
|
||||
#rfqTable thead th {
|
||||
border-bottom: none !important;
|
||||
}
|
||||
|
||||
/* Apply border to all columns */
|
||||
#rfqTable_for_calc th,
|
||||
#rfqTable_for_calc td {
|
||||
border: 2px solid #007bff;
|
||||
}
|
||||
|
||||
/* Remove border from first 2 and last column */
|
||||
#rfqTable_for_calc th:nth-child(-n+2),
|
||||
#rfqTable_for_calc td:nth-child(-n+2),
|
||||
#rfqTable_for_calc th:last-child,
|
||||
#rfqTable_for_calc td:last-child {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.table th,
|
||||
.table td {
|
||||
@ -196,11 +229,15 @@
|
||||
color: #666;
|
||||
}
|
||||
|
||||
table th.action,
|
||||
/* table th.action,
|
||||
table th.disableborder,
|
||||
table td.action,
|
||||
table td.disableborder {
|
||||
border: none !important;
|
||||
} */
|
||||
|
||||
.no-border {
|
||||
border: none !important;
|
||||
}
|
||||
|
||||
</style>
|
||||
@ -244,10 +281,10 @@
|
||||
<table id="rfqTable" class="table table-bordered mt-3">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="sticky">Sno</th>
|
||||
<th class="hidden">Item Key</th>
|
||||
<th class="sticky">Particulars</th>
|
||||
<th contenteditable="false" id="first_proposel_title" >Proposal 1
|
||||
<th class="sticky no-border" style="border-right: 3px solid snow !important; border-left: 3px solid snow !important; border-top: 3px solid snow !important; min-width: 72px !important;"><span class="key_name" style="display: none;">Sno</span><span class="display_name">S.No.</span></th>
|
||||
<th class="hidden no-border" style="border-right: 2px solid snow !important;">Item Key</th>
|
||||
<th class="sticky no-border" style="border-top: 3px solid snow !important; border-right: 3px solid snow !important;">Particulars</th>
|
||||
<th contenteditable="false" id="first_proposel_title" ><span class="key_name" style="display: none;">Proposal 1</span><span class="display_name">Proposal Coverage 1</span>
|
||||
<span class="dropdown" onclick="showThreeDottedMenu(event)">
|
||||
<button class="dropbtn">⋮</button>
|
||||
<div class="dropdown-content">
|
||||
@ -267,16 +304,16 @@
|
||||
<th class="action">Action</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="sticky"> - </th>
|
||||
<th class="hidden"> - </th>
|
||||
<th class="sticky"> - </th>
|
||||
<th colspan="X" style="background-color: inherit;">Quote Asked</th>
|
||||
<th class="sticky no-border" style="color: rgb(191, 224, 226); border-right: 3px solid snow !important; border-left: 3px solid snow !important; min-width: 72px !important;"> - </th>
|
||||
<th class="hidden no-border" style="color: #bfe0e2; border-right: 2px solid snow !important;"> - </th>
|
||||
<th class="sticky no-border" style="color: rgb(191, 224, 226); border-bottom: 3px solid snow !important; border-right: 3px solid snow !important;"> - </th>
|
||||
<th colspan="X" style="background-color: inherit;"><span class="key_name" style="display: none;">Quote Asked</span><span class="display_name">Quote Asked</span></th>
|
||||
<th class="action"> - </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="sno">1</td>
|
||||
<td class="sno" style="min-width: 72px !important;">1</td>
|
||||
<td class="hidden"></td>
|
||||
<td contenteditable="true" class="particulars sticky"></td>
|
||||
<td contenteditable="true" class="editablecolumns"></td>
|
||||
@ -299,7 +336,6 @@
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- end col -->
|
||||
@ -647,6 +683,7 @@
|
||||
var jsonDataForHide = null;
|
||||
var multi_file_data = [];
|
||||
var totalSumAssuredData = [];
|
||||
var snoColumnWidth = "72px";
|
||||
|
||||
const editorConfig = {
|
||||
buttons: [
|
||||
@ -1200,10 +1237,13 @@ function addSuggestionsToTable() {
|
||||
console.log('leadType', leadType);
|
||||
|
||||
let renewal_or_rollover = "Proposal 1";
|
||||
let renewal_or_rollover_display_name = "Proposal Coverage 1";
|
||||
if (leadType == 2) {
|
||||
renewal_or_rollover = "Existing Renewal";
|
||||
renewal_or_rollover_display_name = "Existing Coverage";
|
||||
} else if (leadType == 3) {
|
||||
renewal_or_rollover = "Existing Rollover";
|
||||
renewal_or_rollover_display_name = "Existing Coverage";
|
||||
}
|
||||
|
||||
over_all_column_data = {
|
||||
@ -1219,7 +1259,7 @@ function addSuggestionsToTable() {
|
||||
|
||||
|
||||
$('#first_proposel_title').html(`
|
||||
${renewal_or_rollover}
|
||||
<span class="key_name" style="display: none;">${renewal_or_rollover}</span><span class="display_name">${renewal_or_rollover_display_name}</span>
|
||||
<span class="dropdown" onclick="showThreeDottedMenu(event)">
|
||||
<button class="dropbtn">⋮</button>
|
||||
<div class="dropdown-content">
|
||||
@ -1269,6 +1309,7 @@ function addSuggestionsToTable() {
|
||||
const snoCell = newRow.insertCell(0);
|
||||
snoCell.classList.add('sno');
|
||||
snoCell.innerText = tbody[0].rows.length;
|
||||
snoCell.style.setProperty('min-width', snoColumnWidth, 'important');
|
||||
|
||||
const hiddenCell = newRow.insertCell(1);
|
||||
hiddenCell.classList.add('hidden');
|
||||
@ -1482,29 +1523,39 @@ addQuoteButton.addEventListener('click', function() {
|
||||
const newQuoteHeader = document.createElement('th');
|
||||
newQuoteHeader.colspan = 1;
|
||||
newQuoteHeader.setAttribute('data-colspan', 1)
|
||||
|
||||
const quoteCount = headerRow.cells.length - 4;
|
||||
console.log('quoteCount', quoteCount);
|
||||
console.log('quoteCount', headerRow.cells);
|
||||
console.log('quoteCount', headerRow.cells);
|
||||
console.log('quoteCount headerRow.cells', headerRow.cells);
|
||||
|
||||
|
||||
const lastCellIndex = headerRow.cells.length - 1;
|
||||
const secondLastCellValue = headerRow.cells[lastCellIndex - 1].textContent.trim();
|
||||
console.log('lastCellIndex : ', lastCellIndex);
|
||||
|
||||
// const secondLastCellValue = headerRow.cells[lastCellIndex - 1].textContent.trim();
|
||||
let secondLastCellValue = headerRow.cells[lastCellIndex - 1];
|
||||
console.log('SecondLastCellValue Instance : ', secondLastCellValue);
|
||||
|
||||
secondLastCellValue = (secondLastCellValue.querySelector('.key_name')?.innerText || '').trim();
|
||||
console.log('SecondLastCellValue Text: ', secondLastCellValue);
|
||||
|
||||
// Split the second last cell's value and get the last part
|
||||
const lastPart = secondLastCellValue?.split(" ")[1]?.trim() ?? "0";
|
||||
console.log('lastPart : ', lastPart);
|
||||
|
||||
// Check if lastPart is a valid number; if not, default to 0
|
||||
const proposalNumber = isNaN(Number(lastPart)) ? 0 : Number(lastPart);
|
||||
|
||||
|
||||
console.log("proposalNumber:", proposalNumber);
|
||||
|
||||
proposal_colum_count = proposalNumber + 1;
|
||||
console.log("proposal_colum_count:", proposal_colum_count);
|
||||
|
||||
// proposal_colum_count = proposal_colum_count + 1;
|
||||
var new_proposal_name = `Proposal ${proposal_colum_count}`;
|
||||
newQuoteHeader.innerHTML = `${new_proposal_name} <span class="dropdown" onclick="showThreeDottedMenu(event)">
|
||||
let new_proposal_name = `Proposal ${proposal_colum_count}`;
|
||||
let new_proposal_name_display_name = "Proposal Coverage " + (proposal_colum_count);
|
||||
|
||||
newQuoteHeader.innerHTML = `
|
||||
<span class="key_name" style="display: none;">${new_proposal_name}</span><span class="display_name">${new_proposal_name_display_name}</span>
|
||||
<span class="dropdown" onclick="showThreeDottedMenu(event)">
|
||||
<button class="dropbtn">⋮</button>
|
||||
<div class="dropdown-content">
|
||||
<!-- <a href="#" class="addInsurer">Add Insurer</a> -->
|
||||
@ -1531,7 +1582,10 @@ addQuoteButton.addEventListener('click', function() {
|
||||
if (i == 1) {
|
||||
// Create a new <th> element
|
||||
const newHeaderCell = document.createElement('th');
|
||||
newHeaderCell.innerHTML = ` Quote Asked `;
|
||||
// newHeaderCell.innerHTML = ` Quote Asked `;
|
||||
let subHeaderKeyName = "Quote Asked";
|
||||
let subHeaderDisplayName = "Quote Asked";
|
||||
newHeaderCell.innerHTML = `<span class="key_name" style="display: none;">${subHeaderKeyName}</span><span class="display_name">${subHeaderDisplayName}</span>`;
|
||||
newHeaderCell.style.backgroundColor = randomColor;
|
||||
// Insert the <th> element at the desired position
|
||||
rfqTable.rows[i].insertBefore(newHeaderCell, rfqTable.rows[i].cells[secondHeaderRow.cells.length - 1]);
|
||||
@ -1959,9 +2013,18 @@ function addInsurer(event) {
|
||||
if (insurerName) {
|
||||
|
||||
const closestTh = event.target.closest('th');
|
||||
console.log("closestTh", closestTh);
|
||||
|
||||
let colIndex = closestTh.cellIndex;
|
||||
console.log("colIndex", colIndex);
|
||||
|
||||
let columnText = closestTh.innerText;
|
||||
let proposal_name = columnText.split('⋮')[0].trim();
|
||||
console.log("columnText", columnText);
|
||||
|
||||
// let proposal_name = columnText.split('⋮')[0].trim();
|
||||
let proposal_name = (closestTh.querySelector('.key_name')?.innerText || '').trim();
|
||||
console.log("proposal_name", proposal_name);
|
||||
|
||||
|
||||
if (!checkExistingInsurer(proposal_name, insurerName)) {
|
||||
|
||||
@ -1977,8 +2040,8 @@ function addInsurer(event) {
|
||||
if (result.isConfirmed) {
|
||||
|
||||
let insurer_index = checkExistingInsurerIndex(proposal_name, insurerName);
|
||||
// console.log('insurer_index', insurer_index);
|
||||
// console.log('insurerName', insurerName);
|
||||
console.log('insurer_index', insurer_index);
|
||||
console.log('insurerName', insurerName);
|
||||
let modifiedInsurerName = constructInsurerNameWithVersion(proposal_name, insurerName);
|
||||
console.log('modifiedInsurerName', modifiedInsurerName);
|
||||
addInsurerData(event, modifiedInsurerName, dataId, insurer_index)
|
||||
@ -2006,7 +2069,9 @@ function addInsurerData(event, insurerName, dataId, nextIndex = null) {
|
||||
let colIndex = closestTh.cellIndex;
|
||||
// console.log('column index of first table', colIndex);
|
||||
let columnText = closestTh.innerText;
|
||||
let proposal_name = columnText.split('⋮')[0].trim();
|
||||
// let proposal_name = columnText.split('⋮')[0].trim();
|
||||
let proposal_name = (closestTh.querySelector('.key_name')?.innerText || '').trim();
|
||||
console.log("proposal_name", proposal_name);
|
||||
|
||||
let rfqTable = document.getElementById('rfqTable');
|
||||
const headerRow = rfqTable.rows[1];
|
||||
@ -2461,14 +2526,17 @@ function showThreeDottedMenu(event) {
|
||||
|
||||
function checkExistingInsurer(proposal_name, insurer_name) {
|
||||
|
||||
console.log("checkExistingInsurer function called");
|
||||
|
||||
proposal_name = proposal_name.trim(proposal_name);
|
||||
// console.log('proposal_name - ' + proposal_name);
|
||||
// console.log(over_all_column_data[proposal_name]);
|
||||
console.log('proposal_name - ' + proposal_name);
|
||||
console.log("over_all_column_data", over_all_column_data);
|
||||
console.log("over_all_column_data[proposal_name]", over_all_column_data[proposal_name]);
|
||||
// console.log('insurer_name - ' + insurer_name);
|
||||
|
||||
if (over_all_column_data[proposal_name]) {
|
||||
let tempInsurerList = over_all_column_data[proposal_name].insurers;
|
||||
// console.log('tempInsurerList', tempInsurerList);
|
||||
console.log('tempInsurerList', tempInsurerList);
|
||||
if (!tempInsurerList.length) {
|
||||
return true;
|
||||
}
|
||||
@ -2481,6 +2549,7 @@ function checkExistingInsurer(proposal_name, insurer_name) {
|
||||
function checkExistingInsurerIndex(proposal_name, insurer_name) {
|
||||
|
||||
console.log('#####################################################');
|
||||
console.log("checkExistingInsurerIndex function called");
|
||||
|
||||
proposal_name = proposal_name.trim();
|
||||
|
||||
@ -2548,8 +2617,11 @@ function checkExistingInsurerIndex(proposal_name, insurer_name) {
|
||||
function pushInsurerInArray(proposal_name, insurer_arr) {
|
||||
|
||||
console.log('pushInsurerInArray function called');
|
||||
|
||||
proposal_name = proposal_name.trim();
|
||||
console.log("proposal_name", proposal_name);
|
||||
console.log("over_all_column_data", over_all_column_data);
|
||||
console.log("over_all_column_data[proposal_name]", over_all_column_data[proposal_name]);
|
||||
|
||||
if (over_all_column_data[proposal_name]) {
|
||||
over_all_column_data[proposal_name].insurers.push(insurer_arr);
|
||||
console.log('new insurer added in golbal variable');
|
||||
@ -2580,10 +2652,10 @@ function popInsurerInArray(proposal_name, insurerName) {
|
||||
|
||||
function changeInsurer(event) {
|
||||
|
||||
console.log('changeInsurer function called');
|
||||
console.log('change insure event', event);
|
||||
|
||||
let proposal_name = getParentHeaderTh(event);
|
||||
console.log('proposel Name', proposal_name)
|
||||
console.log('proposel Name', proposal_name);
|
||||
|
||||
if(proposal_name == null || proposal_name == ""){
|
||||
toastr.warning("Could not change the insurer", "WARNING")
|
||||
@ -2603,12 +2675,14 @@ function changeInsurer(event) {
|
||||
newInsurerName = `${newInsurerName}-${newversion.trim()}`.replace(/\s+/g, '');
|
||||
}
|
||||
|
||||
console.log('newInsurerName', newInsurerName)
|
||||
console.log('newversion', newversion)
|
||||
console.log('newInsurerName', newInsurerName);
|
||||
console.log('newversion', newversion);
|
||||
console.log("dataId", dataId);
|
||||
|
||||
|
||||
const closestTh = event.target.closest('th');
|
||||
let oldInsurerName = closestTh.innerText.split('⋮')[0].trim();
|
||||
console.log(oldInsurerName + ' - ' + newInsurerName);
|
||||
console.log("old and new insure name" , oldInsurerName + ' - ' + newInsurerName);
|
||||
|
||||
|
||||
if (!checkExistingInsurer(proposal_name, newInsurerName) && oldInsurerName != newInsurerName) {
|
||||
@ -2624,9 +2698,10 @@ function changeInsurer(event) {
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
|
||||
console.log("dataId", dataId);
|
||||
let modifiedInsurerName = constructInsurerNameWithVersion(proposal_name, newInsurerName);
|
||||
console.log('modifiedInsurerName', modifiedInsurerName);
|
||||
changeInsurerData(event, modifiedInsurerName, dataId)
|
||||
changeInsurerData(event, modifiedInsurerName, dataId);
|
||||
|
||||
}else{
|
||||
return false;
|
||||
@ -2634,7 +2709,7 @@ function changeInsurer(event) {
|
||||
});
|
||||
|
||||
}else{
|
||||
changeInsurerData(event, newInsurerName)
|
||||
changeInsurerData(event, newInsurerName, dataId);
|
||||
}
|
||||
|
||||
|
||||
@ -2643,6 +2718,10 @@ function changeInsurer(event) {
|
||||
|
||||
function changeInsurerData(event, newInsurerName, dataId){
|
||||
|
||||
console.log("changeInsurerData function called")
|
||||
console.log("newInsurerName", newInsurerName)
|
||||
console.log("dataId", dataId)
|
||||
|
||||
if (newInsurerName) {
|
||||
|
||||
const closestTh = event.target.closest('th');
|
||||
@ -2680,9 +2759,12 @@ function changeInsurerData(event, newInsurerName, dataId){
|
||||
}
|
||||
}
|
||||
|
||||
changeInsurerForPremiumTable(event, newInsurerName, subThIndex)
|
||||
changeInsurerForPremiumTable(event, newInsurerName, subThIndex);
|
||||
|
||||
let proposal_name = parentTh.innerText.split('⋮')[0].trim();
|
||||
// let proposal_name = parentTh.innerText.split('⋮')[0].trim();
|
||||
let proposal_name = (parentTh.querySelector('.key_name')?.innerText || '').trim();
|
||||
console.log("proposal_name", proposal_name);
|
||||
console.log("over_all_column_data[proposal_name]", over_all_column_data[proposal_name]);
|
||||
|
||||
if (over_all_column_data[proposal_name]) {
|
||||
// let tempInsurerList = over_all_column_data[proposal_name].insurers;
|
||||
@ -2704,6 +2786,8 @@ function changeInsurerData(event, newInsurerName, dataId){
|
||||
|
||||
isFormDataModified = true; // if any value changeing in the table to set true
|
||||
|
||||
console.log("over_all_column_data", over_all_column_data);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2750,9 +2834,10 @@ function getParentHeaderTh(event) {
|
||||
const colspan = parseInt(th.getAttribute('colspan')) || 1;
|
||||
|
||||
if (actualColIndex >= colSpanCounter && actualColIndex < colSpanCounter + colspan) {
|
||||
let proposelName = th.innerText.split('⋮')[0].trim();
|
||||
console.log("Parent TH Proposel innerText:", proposelName);
|
||||
console.log("Parent TH Proposel textContent:", th.textContent.trim());
|
||||
// let proposelName = th.innerText.split('⋮')[0].trim();
|
||||
let proposelName = (th.querySelector('.key_name')?.innerText || '').trim();
|
||||
console.log("Parent TH Proposal innerText:", proposelName);
|
||||
console.log("Parent TH Proposal textContent:", th.textContent.trim());
|
||||
return proposelName;
|
||||
}
|
||||
|
||||
@ -3398,13 +3483,24 @@ function placementMailPopUp() {
|
||||
// Clear existing options
|
||||
selectElement.innerHTML = '<option value="">Select Proposals</option>';
|
||||
|
||||
let loopindex = 1;
|
||||
// Loop through the proposal data and append options
|
||||
for (const [proposalKey, proposalValue] of Object.entries(proposalDataForDropDown.over_all_column_data)) {
|
||||
proposalValue.insurers.forEach(insurer => {
|
||||
const option = document.createElement('option');
|
||||
option.value = insurer.id;
|
||||
option.setAttribute("data-id", `${proposalKey}-${insurer.display_name}`);
|
||||
option.textContent = `${proposalKey} - ${insurer.display_name}`;
|
||||
|
||||
let ProposelDisplayName = "Proposal Coverage"
|
||||
if(proposalKey == "Existing Renewal" || proposalKey == "Existing Rollover"){
|
||||
ProposelDisplayName = "Existing Coverage"
|
||||
}else{
|
||||
ProposelDisplayName = "Proposal Coverage " + loopindex;
|
||||
loopindex ++
|
||||
}
|
||||
|
||||
option.textContent = `${ProposelDisplayName} - ${insurer.display_name}`;
|
||||
|
||||
selectElement.appendChild(option);
|
||||
});
|
||||
}
|
||||
@ -4249,6 +4345,7 @@ function tableToJson() {
|
||||
const parentHeaders = table.querySelectorAll('thead tr:nth-child(1) th');
|
||||
const subHeaders = table.querySelectorAll('thead tr:nth-child(2) th');
|
||||
|
||||
const last_index = parentHeaders.length - 1;
|
||||
let headerIndex = 0;
|
||||
parentHeaders.forEach((header, index) => {
|
||||
|
||||
@ -4260,9 +4357,18 @@ function tableToJson() {
|
||||
headerIndex++;
|
||||
}
|
||||
|
||||
let parentHeaderValue;
|
||||
if (headerIndex < 3 || headerIndex == last_index) {
|
||||
parentHeaderValue = header.innerText.replace('⋮', '').trim();
|
||||
} else {
|
||||
parentHeaderValue = (header.querySelector('.key_name')?.innerText || '').trim();
|
||||
}
|
||||
|
||||
console.log("parentHeaderValue", parentHeaderValue)
|
||||
|
||||
headers.push({
|
||||
// parentHeader: header.innerText,
|
||||
parentHeader: header.innerText.replace('⋮', '').trim(),
|
||||
parentHeader: parentHeaderValue,
|
||||
subHeaders: subHeaderArray
|
||||
});
|
||||
});
|
||||
@ -4432,6 +4538,7 @@ function jsonToTable(json) {
|
||||
let randomColor = 'hsl(' + Math.random() * 360 + ', 100%, 93%)';
|
||||
|
||||
var proposel_count = 0;
|
||||
var proposel_count_for_title = 1;
|
||||
var proposel_color_count = [];
|
||||
|
||||
let remove_proposel_name = [];
|
||||
@ -4471,8 +4578,18 @@ function jsonToTable(json) {
|
||||
`<i class="fa fa-check-square" style="color: green; margin-left: 8px;"></i>` : '';
|
||||
|
||||
|
||||
let renewal_or_rollover = header.parentHeader;
|
||||
let renewal_or_rollover_display_name = "Proposal Coverage " + (proposel_count_for_title);
|
||||
|
||||
parentTh.innerHTML = `${header.parentHeader} <span class="dropdown" onclick="showThreeDottedMenu(event)">
|
||||
if(["Existing Renewal", "Existing Rollover"].includes(header.parentHeader)){
|
||||
renewal_or_rollover_display_name = "Existing Coverage";
|
||||
}else{
|
||||
proposel_count_for_title ++ ;
|
||||
}
|
||||
|
||||
parentTh.innerHTML = `
|
||||
<span class="key_name" style="display: none;">${renewal_or_rollover}</span><span class="display_name">${renewal_or_rollover_display_name}</span>
|
||||
<span class="dropdown" onclick="showThreeDottedMenu(event)">
|
||||
<button class="dropbtn">⋮</button>
|
||||
<div class="dropdown-content">
|
||||
<a href="#" class="addInsurer">Add Insurer</a>
|
||||
@ -4490,20 +4607,35 @@ function jsonToTable(json) {
|
||||
}
|
||||
|
||||
} else {
|
||||
parentTh.innerText = header.parentHeader;
|
||||
if(["Sno"].includes(header.parentHeader)){
|
||||
let snoKeyName = header.parentHeader;
|
||||
let snoDisplayName = "S.No.";
|
||||
parentTh.innerHTML = ` <span class="key_name" style="display: none;">${snoKeyName}</span><span class="display_name">${snoDisplayName}</span>`;
|
||||
}else{
|
||||
parentTh.innerText = header.parentHeader;
|
||||
}
|
||||
}
|
||||
|
||||
// Hide column if header is "Item Key"
|
||||
if (header.parentHeader === "Item Key") {
|
||||
parentTh.classList.add('hidden');
|
||||
parentTh.classList.add('hidden', 'no-border');
|
||||
parentTh.style.borderRight = '2px solid snow';
|
||||
parentTh.style.setProperty('border-right', '2px solid snow', 'important');
|
||||
}
|
||||
|
||||
if (header.parentHeader === "Particulars") {
|
||||
parentTh.classList.add('sticky');
|
||||
parentTh.classList.add('sticky', 'no-border');
|
||||
parentTh.style.setProperty('border-top', '3px solid snow', 'important');
|
||||
parentTh.style.setProperty('border-right', '3px solid snow', 'important');
|
||||
|
||||
}
|
||||
|
||||
if (header.parentHeader === "Sno") {
|
||||
parentTh.classList.add('sticky');
|
||||
parentTh.classList.add('sticky', 'no-border');
|
||||
parentTh.style.setProperty('border-right', '3px solid snow', 'important');
|
||||
parentTh.style.setProperty('border-left', '3px solid snow', 'important');
|
||||
parentTh.style.setProperty('border-top', '3px solid snow', 'important');
|
||||
parentTh.style.setProperty('min-width', snoColumnWidth, 'important');
|
||||
}
|
||||
|
||||
if (RFQ_or_QCR == 2) {
|
||||
@ -4525,19 +4657,28 @@ function jsonToTable(json) {
|
||||
|
||||
// Hide if parent header is "Item Key"
|
||||
if (header.parentHeader === "Item Key") {
|
||||
subTh.classList.add('hidden');
|
||||
subTh.classList.add('hidden', 'no-border');
|
||||
subTh.style.color = '#bfe0e2';
|
||||
subTh.style.setProperty('border-right', '2px solid snow', 'important');
|
||||
}
|
||||
|
||||
if (header.parentHeader === "Particulars") {
|
||||
subTh.classList.add('sticky');
|
||||
subTh.classList.add('sticky', 'no-border');
|
||||
subTh.style.color = '#bfe0e2';
|
||||
subTh.style.setProperty('border-bottom', '3px solid snow', 'important');
|
||||
subTh.style.setProperty('border-right', '3px solid snow', 'important');
|
||||
}
|
||||
|
||||
if (header.parentHeader === "Sno") {
|
||||
subTh.classList.add('sticky');
|
||||
subTh.classList.add('sticky', 'no-border');
|
||||
subTh.style.color = '#bfe0e2';
|
||||
subTh.style.setProperty('border-right', '3px solid snow', 'important');
|
||||
subTh.style.setProperty('border-left', '3px solid snow', 'important');
|
||||
subTh.style.setProperty('min-width', snoColumnWidth, 'important');
|
||||
}
|
||||
|
||||
// Add dropdown menu only if subHeader is not "Quote Asked" or "-"
|
||||
if (!["Quote Asked", "-"].includes(subHeader)) {
|
||||
if (!["Quote Asked", "-", ""].includes(subHeader)) {
|
||||
|
||||
// Set default values for dropdown data
|
||||
let dropdownDataQCRForInsurer = '';
|
||||
@ -4547,7 +4688,7 @@ function jsonToTable(json) {
|
||||
let checkDropdownDataSTCForInsurer = '';
|
||||
|
||||
// Check if header is allowed to have insurer data
|
||||
if (!["Sno", "Item Key", "Particulars", "Action"].includes(header.parentHeader)) {
|
||||
if (!["Sno", "Item Key", "Particulars", "Action", ""].includes(header.parentHeader)) {
|
||||
|
||||
const insurerData = proposels[header.parentHeader]?.insurers[index - 1] || {};
|
||||
|
||||
@ -4585,10 +4726,16 @@ function jsonToTable(json) {
|
||||
}
|
||||
|
||||
} else {
|
||||
subTh.innerText = subHeader;
|
||||
|
||||
if(!["-"].includes(subHeader)){
|
||||
let subHeaderDisplayName = subHeader;
|
||||
subTh.innerHTML = `<span class="key_name" style="display: none;">${subHeader}</span><span class="display_name">${subHeaderDisplayName}</span>`;
|
||||
}else{
|
||||
subTh.innerText = subHeader;
|
||||
}
|
||||
}
|
||||
|
||||
if (!["-"].includes(subHeader) && proposel_count > 1) {
|
||||
if (!["-", ""].includes(subHeader) && proposel_count > 1) {
|
||||
subTh.style.backgroundColor = randomColor;
|
||||
}
|
||||
|
||||
@ -4616,8 +4763,7 @@ function jsonToTable(json) {
|
||||
});
|
||||
});
|
||||
|
||||
console.log('remove_proposel_name', remove_proposel_name);
|
||||
|
||||
// console.log('remove_proposel_name', remove_proposel_name);
|
||||
// console.log('proposel_color_count', proposel_color_count);
|
||||
|
||||
thead.appendChild(parentHeaderRow);
|
||||
@ -4635,6 +4781,7 @@ function jsonToTable(json) {
|
||||
const snoTd = document.createElement('td');
|
||||
snoTd.classList.add('sno');
|
||||
snoTd.innerText = rowIndex + 1;
|
||||
snoTd.style.setProperty('min-width', snoColumnWidth, 'important');
|
||||
row.appendChild(snoTd);
|
||||
|
||||
// Hidden Item Key column
|
||||
@ -4661,6 +4808,10 @@ function jsonToTable(json) {
|
||||
|
||||
const td = document.createElement('td');
|
||||
|
||||
if(rowData.SNO == "1"){
|
||||
td.style.setProperty('border-top', '2px solid #007bff', 'important');
|
||||
}
|
||||
|
||||
if (dataEntry.parentth === "Action") {
|
||||
td.classList.add('action');
|
||||
const qcrChecked = dataEntry.input_value?.qcr ? "checked" : "";
|
||||
@ -4780,6 +4931,7 @@ function populateTable(json) {
|
||||
const headerRow2 = document.createElement("tr");
|
||||
|
||||
var proposels = json.proposal_data.over_all_column_data;
|
||||
let proposel_count = 1;
|
||||
|
||||
// Iterate over the headers to create thead
|
||||
json.table_data.headers.forEach(header => {
|
||||
@ -4790,16 +4942,42 @@ function populateTable(json) {
|
||||
if (!["Item Key"].includes(header.parentHeader)) {
|
||||
// console.log(header.parentHeader);
|
||||
|
||||
// if(header.subHeaders.length == 1){
|
||||
// console.log('header.subHeaders.length', header.subHeaders.length)
|
||||
// if(!["Sno", "Particulars", "Action"].includes(header.parentHeader)){
|
||||
// console.log('returned ............', header.parentHeader);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
// Create the parent header
|
||||
const th = document.createElement("th");
|
||||
th.textContent = header.parentHeader;
|
||||
let calc_renewal_or_rollover = header.parentHeader;
|
||||
let calc_renewal_or_rollover_display_name = "Proposal Coverage " + (proposel_count);
|
||||
|
||||
if(["Sno", "Particulars", "Action"].includes(header.parentHeader)){
|
||||
th.textContent = header.parentHeader;
|
||||
}else{
|
||||
th.innerHTML = `<span class="key_name" style="display: none;">${calc_renewal_or_rollover}</span><span class="display_name">${calc_renewal_or_rollover_display_name}</span>`
|
||||
proposel_count ++
|
||||
}
|
||||
|
||||
if (header.parentHeader === "Particulars") {
|
||||
th.classList.add('sticky');
|
||||
th.classList.add('sticky', 'no-border');
|
||||
th.style.color = '#fff';
|
||||
th.style.backgroundColor = '#fff';
|
||||
// th.style.borderRight = '2px solid snow';
|
||||
// th.style.setProperty('border-right', '2px solid snow', 'important');
|
||||
}
|
||||
|
||||
if (header.parentHeader === "Sno") {
|
||||
th.classList.add('sticky');
|
||||
th.classList.add('sticky', 'no-border');
|
||||
th.style.color = '#fff';
|
||||
th.style.backgroundColor = '#fff';
|
||||
th.style.setProperty('min-width', snoColumnWidth, 'important');
|
||||
// th.style.color = "#bfe0e2";
|
||||
// th.style.borderRight = '2px solid snow';
|
||||
// th.style.setProperty('border-right', '2px solid snow', 'important');
|
||||
}
|
||||
|
||||
if (header.parentHeader === "Action") {
|
||||
@ -4808,14 +4986,23 @@ function populateTable(json) {
|
||||
}
|
||||
|
||||
if(header.parentHeader !== 'Particulars' && header.parentHeader !== 'Sno' && header.parentHeader !== "Action"){
|
||||
th.style.backgroundColor = randomColor;
|
||||
// th.style.backgroundColor = randomColor;
|
||||
}
|
||||
|
||||
if (header.parentHeader === "Particulars") {
|
||||
th.classList.add('readonly-select');
|
||||
// th.style.color = "#bfe0e2";
|
||||
}
|
||||
|
||||
// Calculate colspan based on the number of subheaders
|
||||
const subHeaderCount = header.subHeaders.length;
|
||||
// const subHeaderCount = (header.subHeaders.length) - 1;
|
||||
console.log("subHeaderCount : ", subHeaderCount);
|
||||
|
||||
if (subHeaderCount > 0) {
|
||||
th.setAttribute("colspan", subHeaderCount);
|
||||
} else {
|
||||
th.setAttribute("rowspan", 2); // No subheaders, span both rows
|
||||
th.setAttribute("colspan", 1);
|
||||
}
|
||||
|
||||
if (RFQ_or_QCR == 2) {
|
||||
@ -4831,14 +5018,31 @@ function populateTable(json) {
|
||||
// Create and append subheaders to the second row
|
||||
header.subHeaders.forEach(subHeader => {
|
||||
const subTh = document.createElement("th");
|
||||
subTh.textContent = subHeader;
|
||||
|
||||
if(subHeader == "Quote Asked"){
|
||||
let subHeaderKeyName = subHeader
|
||||
let subHeaderDisplayName = "Particulars"
|
||||
subTh.innerHTML = `<span class="key_name" style="display: none;">${subHeaderKeyName}</span><span class="display_name">${subHeaderDisplayName}</span>`;
|
||||
}else{
|
||||
subTh.textContent = subHeader;
|
||||
}
|
||||
|
||||
if (header.parentHeader === "Particulars") {
|
||||
subTh.classList.add('sticky');
|
||||
subTh.classList.add('sticky', 'no-border');
|
||||
subTh.style.color = '#fff';
|
||||
subTh.style.backgroundColor = '#fff';
|
||||
// subTh.style.borderRight = '2px solid snow';
|
||||
// subTh.style.setProperty('border-right', '2px solid snow', 'important');
|
||||
// subTh.style.setProperty('border-bottom', '2px solid snow', 'important');
|
||||
}
|
||||
|
||||
if (header.parentHeader === "Sno") {
|
||||
subTh.classList.add('sticky');
|
||||
subTh.classList.add('sticky', 'no-border');
|
||||
subTh.style.color = '#fff';
|
||||
subTh.style.backgroundColor = '#fff';
|
||||
subTh.style.setProperty('min-width', snoColumnWidth, 'important');
|
||||
// subTh.style.borderRight = '2px solid snow';
|
||||
// subTh.style.setProperty('border-right', '2px solid snow', 'important');
|
||||
}
|
||||
|
||||
if (header.parentHeader === "Action") {
|
||||
@ -4847,7 +5051,12 @@ function populateTable(json) {
|
||||
}
|
||||
|
||||
if(header.parentHeader != "Particulars" && header.parentHeader !== 'Sno' && header.parentHeader !== "Action"){
|
||||
subTh.style.backgroundColor = randomColor;
|
||||
// subTh.style.backgroundColor = randomColor;
|
||||
}
|
||||
|
||||
if (header.parentHeader === "Particulars") {
|
||||
subTh.classList.add('readonly-select');
|
||||
subTh.textContent = " ";
|
||||
}
|
||||
|
||||
//for QCR hidden fields
|
||||
@ -4877,30 +5086,49 @@ function populateTable(json) {
|
||||
|
||||
rowLabels.forEach((label, rowIndex) => {
|
||||
|
||||
console.log("rowLabels", rowLabels);
|
||||
const tr = document.createElement("tr");
|
||||
|
||||
// First column: Serial No
|
||||
const tdFirst = document.createElement("td");
|
||||
tdFirst.textContent = rowIndex + 1;
|
||||
tdFirst.className = "sticky";
|
||||
tdFirst.className = "sticky readonly-select";
|
||||
// tdFirst.style.color = "#bfe0e2";
|
||||
tdFirst.style.color = "#fff";
|
||||
tdFirst.style.backgroundColor = "#fff";
|
||||
tdFirst.style.border = "none";
|
||||
tdFirst.style.setProperty('min-width', snoColumnWidth, 'important');
|
||||
tr.appendChild(tdFirst);
|
||||
|
||||
// Second column: Row label
|
||||
const tdLabel = document.createElement("td");
|
||||
tdLabel.textContent = label;
|
||||
tdLabel.className = "sticky";
|
||||
// tdLabel.style.color = "#bfe0e2";
|
||||
tdLabel.style.color = "#fff";
|
||||
tdLabel.style.backgroundColor = "#fff";
|
||||
tdLabel.style.border = "none";
|
||||
tdLabel.className = "sticky readonly-select";
|
||||
tr.appendChild(tdLabel);
|
||||
|
||||
console.log("before header loop");
|
||||
// Create a td for each subheader
|
||||
json.table_data.headers.forEach((header, headerIndexForCalc) => {
|
||||
if (!["Item Key", "Sno", "Particulars"].includes(header.parentHeader)) {
|
||||
|
||||
// if(header.subHeaders.length == 1){
|
||||
// console.log('DATA header.subHeaders.length', header.subHeaders.length)
|
||||
// if(!["Action"].includes(header.parentHeader)){
|
||||
// console.log('DATA returned ............', header.parentHeader);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
header.subHeaders.forEach((value, index) => {
|
||||
|
||||
|
||||
// if(value != '-'){
|
||||
const td = document.createElement("td");
|
||||
|
||||
if(label == "Total") {
|
||||
console.log();
|
||||
td.setAttribute("contenteditable", false);
|
||||
td.classList.add('readonly-select')
|
||||
}else{
|
||||
@ -4919,6 +5147,13 @@ function populateTable(json) {
|
||||
label.toLowerCase().replace(/\s+/g, '').replace(/[%₹()]/g, '')
|
||||
);
|
||||
|
||||
|
||||
// if(value == "Quote Asked"){
|
||||
// td.setAttribute("contenteditable", false);
|
||||
// // td.classList.add('hidden');
|
||||
// // td.style.color = randomColor;
|
||||
// }
|
||||
|
||||
if(RFQ_or_QCR == 2){
|
||||
if (proposels[header.parentHeader] && proposels[header.parentHeader].qcr !== undefined) {
|
||||
if(proposels[header.parentHeader].qcr == 0 || proposels[header.parentHeader].qcr == false){
|
||||
@ -4928,14 +5163,21 @@ function populateTable(json) {
|
||||
}
|
||||
|
||||
// td.id = `${label.toLowerCase()}`;
|
||||
console.log('child table', header.parentHeader);
|
||||
td.textContent = json.premium_data?.data?.[header.parentHeader]?.[value]?.[label] || "";
|
||||
// console.log('child table', header.parentHeader);
|
||||
if(value == "Quote Asked"){
|
||||
td.setAttribute("contenteditable", false);
|
||||
td.textContent = label;
|
||||
}else{
|
||||
td.textContent = json.premium_data?.data?.[header.parentHeader]?.[value]?.[label] || "";
|
||||
}
|
||||
tr.appendChild(td);
|
||||
// }
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
console.log("After header loop");
|
||||
// Add the row to tbody
|
||||
tbody.appendChild(tr);
|
||||
});
|
||||
@ -4966,17 +5208,39 @@ function generateJSONFromTable() {
|
||||
console.log('headerRows 0', headerRows[1].length);
|
||||
|
||||
// Extract parent headers
|
||||
headerRows[0].querySelectorAll("th").forEach((th, index) => {
|
||||
if (index > 0) parentHeaders.push(th.textContent.trim());
|
||||
// headerRows[0].querySelectorAll("th").forEach((th, index) => {
|
||||
// if (index > 0) parentHeaders.push(th.textContent.trim());
|
||||
// });
|
||||
const headerThs = headerRows[0].querySelectorAll("th");
|
||||
const last_index = headerThs.length - 1;
|
||||
console.log("last_index", last_index);
|
||||
|
||||
headerThs.forEach((th, index) => {
|
||||
let parentHeaderValue;
|
||||
|
||||
// Skip index 0 if not needed
|
||||
if (index > 0) {
|
||||
// For index 1 or last column, use full text
|
||||
if (index < 2 || index === last_index) {
|
||||
parentHeaderValue = th.textContent.trim();
|
||||
} else {
|
||||
parentHeaderValue = (th.querySelector('.key_name')?.innerText || '').trim();
|
||||
}
|
||||
|
||||
console.log("parentHeaderValue", parentHeaderValue);
|
||||
parentHeaders.push(parentHeaderValue);
|
||||
}
|
||||
});
|
||||
|
||||
// Calculate how many subheaders belong to each parent header using `colspan`
|
||||
let currentParentIndex = 0;
|
||||
let remainingColspan = 0;
|
||||
let secondHeaderIndex = 0;
|
||||
|
||||
headerRows[1].querySelectorAll("th").forEach((th, index) => {
|
||||
|
||||
if (index > 0) { // Skip the first column if it's for row labels
|
||||
const subHeaderText = th.textContent.trim();
|
||||
const subHeaderText = th.querySelector('.key_name')?.innerText || th.textContent.trim();
|
||||
|
||||
// If no remainingColspan, move to the next parent header
|
||||
if (remainingColspan === 0) {
|
||||
@ -4992,8 +5256,10 @@ function generateJSONFromTable() {
|
||||
|
||||
// Decrease remainingColspan as a subheader is assigned
|
||||
remainingColspan--;
|
||||
secondHeaderIndex++;
|
||||
}
|
||||
});
|
||||
secondHeaderIndex = 0;
|
||||
|
||||
// Initialize the structure for all parent headers and subheaders
|
||||
parentHeaders.forEach(parent => {
|
||||
@ -5059,6 +5325,7 @@ function addInsurerDataForPremiumTable(event, insurerName, proposal_name) {
|
||||
let parentTh = rfqTable.querySelector('thead tr th:nth-child(' + (colIndex + 1) + ')');
|
||||
let columnIndextoCopyData = totalColspan - parentTh.colSpan;
|
||||
parentTh.colSpan += 1;
|
||||
console.log("columnIndextoCopyData", columnIndextoCopyData);
|
||||
|
||||
// Determine the position for inserting the column
|
||||
let insertPosition = totalColspan; // Default to inserting at the end of the current insurer's columns
|
||||
@ -5088,7 +5355,7 @@ function addInsurerDataForPremiumTable(event, insurerName, proposal_name) {
|
||||
);
|
||||
|
||||
// newCell.classList.add('editablecolumns');
|
||||
newCell.innerHTML = rfqTable.rows[i].cells[columnIndextoCopyData].innerHTML;
|
||||
// newCell.innerHTML = rfqTable.rows[i].cells[columnIndextoCopyData].innerHTML; //do not remove this
|
||||
// newCell.style.backgroundColor = parentTh.style.backgroundColor;
|
||||
labelIncrement++
|
||||
}
|
||||
@ -5474,7 +5741,8 @@ function appendMultiFileData(data) {
|
||||
|
||||
async function submitData(input) {
|
||||
|
||||
console.log(over_all_column_data);
|
||||
console.log("The submit function called RFQ and QCR");
|
||||
console.log("over_all_column_data", over_all_column_data);
|
||||
|
||||
try {
|
||||
// Show loader if necessary
|
||||
@ -5485,6 +5753,8 @@ function appendMultiFileData(data) {
|
||||
const jsonData = await tableToJsonForFormSubmit();
|
||||
console.log(jsonData);
|
||||
|
||||
// return;
|
||||
|
||||
// Create a FormData object
|
||||
const formData = new FormData();
|
||||
let lead_id = $('#lead_id').val();
|
||||
@ -5619,7 +5889,7 @@ function appendMultiFileData(data) {
|
||||
|
||||
async function tableToJsonForFormSubmit() {
|
||||
|
||||
// console.log('tableToJsonForFormSubmit function clled');
|
||||
console.log('tableToJsonForFormSubmit function clled');
|
||||
|
||||
return new Promise((resolve) => {
|
||||
|
||||
@ -5639,13 +5909,16 @@ function appendMultiFileData(data) {
|
||||
|
||||
// console.log('parentHeaders length', parentHeaders.length);
|
||||
// console.log('subHeaders length', subHeaders.length);
|
||||
|
||||
|
||||
const last_index = parentHeaders.length - 1;
|
||||
console.log("last_index", last_index)
|
||||
let headerIndex = 0;
|
||||
parentHeaders.forEach((header) => {
|
||||
let headerIndex1 = 0;
|
||||
let secondHeaderIndex = 0;
|
||||
parentHeaders.forEach((header, FirstHeaderRowIndex) => {
|
||||
|
||||
// console.log('header names', header);
|
||||
// console.log('header header.innerText', header.innerText);
|
||||
|
||||
// const colspan = header.getAttribute('colspan') || 4;
|
||||
|
||||
let colspan = 1;
|
||||
@ -5656,24 +5929,57 @@ function appendMultiFileData(data) {
|
||||
colspan = header.getAttribute('colspan') || 1;
|
||||
}
|
||||
|
||||
|
||||
// console.log('colspan', colspan);
|
||||
const subHeaderArray = [];
|
||||
|
||||
// console.log('headerIndex', headerIndex);
|
||||
for (let i = 0; i < colspan; i++) {
|
||||
// console.log('headerIndex', headerIndex);
|
||||
const cleanedText = subHeaders[headerIndex].textContent.trim().split('⋮')[0].trim();
|
||||
// console.log('cleanedText', cleanedText);
|
||||
// console.log('headerIndex', headerIndex);
|
||||
console.log('headerIndex', headerIndex);
|
||||
// console.log('subHeaders[headerIndex]', subHeaders[headerIndex]);
|
||||
let cleanedText = subHeaders[headerIndex].textContent.trim().split('⋮')[0].trim();
|
||||
if(FirstHeaderRowIndex > 2 && secondHeaderIndex == 0){
|
||||
cleanedText = (subHeaders[headerIndex].querySelector('.key_name')?.innerText || '').trim();
|
||||
}
|
||||
if(headerIndex1 === last_index){
|
||||
cleanedText = "-";
|
||||
}
|
||||
console.log('cleanedText', cleanedText);
|
||||
subHeaderArray.push(cleanedText);
|
||||
headerIndex++;
|
||||
secondHeaderIndex ++;
|
||||
}
|
||||
secondHeaderIndex = 0;
|
||||
|
||||
// let parentHeaderValue;
|
||||
// if (headerIndex1 < 3 || headerIndex1 == last_index) {
|
||||
// if(FirstHeaderRowIndex == 0){
|
||||
// parentHeaderValue = (header.querySelector('.key_name')?.innerText || '').trim();
|
||||
// }else{
|
||||
// parentHeaderValue = header.innerText.trim().split('⋮')[0].trim();
|
||||
// }
|
||||
// } else {
|
||||
// parentHeaderValue = (header.querySelector('.key_name')?.innerText || '').trim();
|
||||
// }
|
||||
|
||||
let parentHeaderValue;
|
||||
|
||||
if (headerIndex1 < 3 || headerIndex1 === last_index) {
|
||||
if (FirstHeaderRowIndex === 0) {
|
||||
parentHeaderValue = (header.querySelector('.key_name')?.innerText || (header.innerText.split('⋮')[0] || '-')).trim() ?? "-";
|
||||
} else {
|
||||
parentHeaderValue = (header.innerText.split('⋮')[0] || '-').trim() ?? "-";
|
||||
}
|
||||
} else {
|
||||
parentHeaderValue = (header.querySelector('.key_name')?.innerText || (header.innerText.split('⋮')[0] || '')).trim() ?? "-";
|
||||
}
|
||||
|
||||
|
||||
headers.push({
|
||||
parentHeader: header.textContent.trim().split('⋮')[0].trim(),
|
||||
parentHeader: parentHeaderValue,
|
||||
subHeaders: subHeaderArray
|
||||
});
|
||||
|
||||
headerIndex1++;
|
||||
});
|
||||
|
||||
// Get the data from table rows
|
||||
@ -5770,6 +6076,7 @@ function appendMultiFileData(data) {
|
||||
jsonData.premium_data = premium_data;
|
||||
// }
|
||||
|
||||
console.log('JSON.stringify(jsonData)', JSON.stringify(jsonData))
|
||||
localStorage.setItem('data', JSON.stringify(jsonData));
|
||||
resolve(jsonData);
|
||||
});
|
||||
@ -5778,6 +6085,7 @@ function appendMultiFileData(data) {
|
||||
async function convertJsonForQCR() {
|
||||
|
||||
var json = await tableToJsonForFormSubmit()
|
||||
console.log("convertJsonForQCR json", json);
|
||||
|
||||
if (json) {
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user