Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
e5ea779aee
@ -239,8 +239,8 @@ class LeadsController extends BaseController
|
||||
$policy_end_date = null;
|
||||
}
|
||||
|
||||
if(!empty($data['incurred_claims_date'][$index])){
|
||||
$incurred_claims_date = change_date_format($data['incurred_claims_date'][$index], 'd/m/Y', 'Y-m-d');
|
||||
if(!empty($data['incurred_claim_date'][$index])){
|
||||
$incurred_claims_date = change_date_format($data['incurred_claim_date'][$index], 'd/m/Y', 'Y-m-d');
|
||||
}else{
|
||||
$incurred_claims_date = null;
|
||||
}
|
||||
@ -371,6 +371,18 @@ class LeadsController extends BaseController
|
||||
$data['policy_end_date'] = null;
|
||||
}
|
||||
|
||||
if (!empty($data['incurred_claims_date'])) {
|
||||
$data['incurred_claims_date'] = change_date_format($data['incurred_claims_date'], 'Y-m-d', 'd/m/Y');
|
||||
} else {
|
||||
$data['incurred_claims_date'] = null;
|
||||
}
|
||||
|
||||
if (!empty($data['premium_date'])) {
|
||||
$data['premium_date'] = change_date_format($data['premium_date'], 'Y-m-d', 'd/m/Y');
|
||||
} else {
|
||||
$data['premium_date'] = null;
|
||||
}
|
||||
|
||||
if ($data) {
|
||||
return $this->respond(['status' => true, 'data' => $data], 200);
|
||||
} else {
|
||||
@ -747,20 +759,25 @@ class LeadsController extends BaseController
|
||||
$rowNumber += 2;
|
||||
|
||||
// Add premium data
|
||||
$labelArray = ["Premium", "GST (%)", "GST Amount (₹)", "Total"];
|
||||
$premiumData = $data['premium_data']['data'];
|
||||
$premium = ['Premium'];
|
||||
$gst = ['GST'];
|
||||
$total = ['Total'];
|
||||
$premium = [$labelArray[0]];
|
||||
$gst = [$labelArray[1]];
|
||||
$gstAmt = [$labelArray[2]];
|
||||
$total = [$labelArray[3]];
|
||||
|
||||
foreach ($premiumData as $proposal => $insurers) {
|
||||
foreach ($insurers as $insurer => $values) {
|
||||
$premium[] = $values['Premium'];
|
||||
$gst[] = $values['GST'];
|
||||
$total[] = $values['Total'];
|
||||
if($proposal != 'Particulars'){
|
||||
foreach ($insurers as $insurer => $values) {
|
||||
$premium[] = $values[$labelArray[0]];
|
||||
$gst[] = $values[$labelArray[1]];
|
||||
$gstAmt[] = $values[$labelArray[2]];
|
||||
$total[] = $values[$labelArray[3]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ([$premium, $gst, $total] as $index => $rowData) {
|
||||
foreach ([$premium, $gst, $gstAmt, $total] as $index => $rowData) {
|
||||
$columnLetter = 'B';
|
||||
foreach ($rowData as $key => $value) {
|
||||
$sheet->setCellValue("{$columnLetter}{$rowNumber}", $value);
|
||||
|
||||
@ -405,7 +405,6 @@ function getLeadsDataForEdit(input) {
|
||||
$('#policy_start_date_1').val(res.data.policy_start_date);
|
||||
$('#policy_end_date_1').val(res.data.policy_end_date);
|
||||
$('#no_of_lives').val(res.data.no_of_lives);
|
||||
$('#incurred_claims').val(res.data.incurred_claims);
|
||||
$('#location').val(res.data.location);
|
||||
|
||||
let increment = 1;
|
||||
@ -430,7 +429,9 @@ function getLeadsDataForEdit(input) {
|
||||
$('#annualised_claims_' + increment).val(res.data.annualised_claims);
|
||||
$('#incurred_claims_ratio_' + increment).val(res.data.incurred_claims_ratio);
|
||||
$('#earned_claims_ratio_' + increment).val(res.data.earned_claims_ratio);
|
||||
$('#incurred_claims_' + increment).val(res.data.incurred_claims);
|
||||
$('#file_name_display').text('Upload File Name : ' + res.data.file_name);
|
||||
// $('#file_name').val(res.data.file_name);
|
||||
|
||||
|
||||
if (res.data.salse_person_id) {
|
||||
@ -887,7 +888,7 @@ function addHTMLInput(check) {
|
||||
newRow7.innerHTML += `
|
||||
<div class="form-group col-md-3">
|
||||
<label for="file_upload">File Upload<span class="text-danger">*</span></label>
|
||||
<input type="file" class="form-control" id="file_name" name="file_name[]" accept=".xls,.xlsx" required>
|
||||
<input type="file" class="form-control" id="file_name_${increment}" name="file_name[]" accept=".xls,.xlsx">
|
||||
<span class="text-danger" id="file_name_display"></span>
|
||||
</div>
|
||||
`;
|
||||
@ -982,7 +983,7 @@ function addHTMLInput(check) {
|
||||
|
||||
console.log('increment', increment);
|
||||
console.log('policy_start_datePicker selectedDates', selectedDates);
|
||||
console.log('policy_start_datePicker incurred_claim_', $("#incurred_claim_" + increment).val());
|
||||
console.log('policy_start_datePicker incurred_claim_date_', $("#incurred_claim_date_" + increment).val());
|
||||
|
||||
// Recalculate policy_run_days if incurred claim date is already selected
|
||||
if ($("#incurred_claim_date_" + increment).val()) {
|
||||
@ -1000,21 +1001,19 @@ function addHTMLInput(check) {
|
||||
var incurred_claim_datepicker = flatpickr("#incurred_claim_date_" + increment, {
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false,
|
||||
onChange: function(selectedDates) {
|
||||
onChange: function (selectedDates) {
|
||||
console.log('Flatpickr instance:', this);
|
||||
console.log('ID of this element:', this.input.id);
|
||||
|
||||
console.log('this object', this);
|
||||
console.log('id of this element:', this.id);
|
||||
// Extract the increment value from the element's ID
|
||||
let increment = this.input.id.split('_').pop();
|
||||
console.log('Extracted increment:', increment);
|
||||
|
||||
let increment = this.element.id.split('_').pop();
|
||||
console.log(increment); // Outputs: 1
|
||||
|
||||
console.log('selectedDates', selectedDates);
|
||||
console.log('policy_start_date_', $("#policy_start_date_" + increment).val());
|
||||
console.log('Selected Dates:', selectedDates);
|
||||
console.log('Policy Start Date:', $("#policy_start_date_" + increment).val());
|
||||
|
||||
// Recalculate policy_run_days if policy start date is already selected
|
||||
if ($("#policy_start_date_" + increment).val()) {
|
||||
|
||||
console.log('selectedDates', selectedDates);
|
||||
calculatePolicyRunDays(increment);
|
||||
}
|
||||
}
|
||||
@ -1063,9 +1062,10 @@ function removeHTMLInput(element)
|
||||
function calculatePolicyRunDays(increment) {
|
||||
|
||||
console.log('calculatePolicyRunDays function called');
|
||||
console.log('increment', increment);
|
||||
|
||||
var policyStartDate = flatpickr.parseDate($("#policy_start_date_" + increment).val(), "d/m/Y");
|
||||
var incurredClaimDate = flatpickr.parseDate($("#incurred_claim_" + increment).val(), "d/m/Y");
|
||||
var incurredClaimDate = flatpickr.parseDate($("#incurred_claim_date_" + increment).val(), "d/m/Y");
|
||||
|
||||
console.log('policyStartDate', policyStartDate)
|
||||
console.log('incurredClaimDate', incurredClaimDate)
|
||||
|
||||
@ -232,7 +232,7 @@
|
||||
<th class="sticky">Sno</th>
|
||||
<th class="hidden">Item Key</th>
|
||||
<th class="sticky">Particulars</th>
|
||||
<th contenteditable="false">Proposal 1
|
||||
<th contenteditable="false" id="first_proposel_title" >Proposal 1
|
||||
<span class="dropdown" onclick="showThreeDottedMenu(event)">
|
||||
<button class="dropbtn">⋮</button>
|
||||
<div class="dropdown-content">
|
||||
@ -667,6 +667,8 @@
|
||||
|
||||
$('#submitData').text('Save RFQ');
|
||||
$('#submitMail').text('Send Insurer Mail');
|
||||
$('#submitPlacement').hide();
|
||||
document.getElementById("second_table")?.remove();
|
||||
|
||||
if(data){
|
||||
$('#submitQCRData').show();
|
||||
@ -674,16 +676,15 @@
|
||||
$('#submitQCRData').hide();
|
||||
$('#submitMail').hide();
|
||||
$('#submitExcel').hide();
|
||||
x }
|
||||
|
||||
$('#submitPlacement').hide();
|
||||
|
||||
if(jsonDataForHide){
|
||||
$('#second_table').hide();
|
||||
}else{
|
||||
document.getElementById("second_table")?.remove();
|
||||
$('#submitInternalMail').hide();
|
||||
}
|
||||
|
||||
// if(jsonDataForHide){
|
||||
// $('#second_table').hide();
|
||||
// }else{
|
||||
// document.getElementById("second_table")?.remove();
|
||||
// }
|
||||
|
||||
}else{
|
||||
|
||||
$('#submitData').text('Save QCR');
|
||||
@ -1029,8 +1030,36 @@ function addSuggestionsToTable() {
|
||||
|
||||
console.log(' addSuggestionsToTable suggestions ', suggestions);
|
||||
console.log(' addSuggestionsToTable suggestions type', typeof suggestions);
|
||||
let leadType = <?= isset($lead_data) && isset($lead_data['lead_type']) ? $lead_data['lead_type'] : 1; ?>;
|
||||
console.log('leadType', leadType);
|
||||
|
||||
let renewal_or_rollover = "Proposal 1";
|
||||
if(leadType == 2){
|
||||
renewal_or_rollover = "Existing Renewal"
|
||||
}else if(leadType == 3){
|
||||
renewal_or_rollover = "Existing Rollover"
|
||||
}
|
||||
|
||||
$('#first_proposel_title').html(`
|
||||
${renewal_or_rollover}
|
||||
<span class="dropdown" onclick="showThreeDottedMenu(event)">
|
||||
<button class="dropbtn">⋮</button>
|
||||
<div class="dropdown-content">
|
||||
<a href="#" class="addInsurer">Add Insurer</a>
|
||||
<a href="#" class="qcrProposal" style="background-color: rgb(221, 221, 221);">
|
||||
QCR <i class="fa fa-check-square" style="color: green; margin-left: 8px;"></i>
|
||||
</a>
|
||||
<a href="#" class="sendClientProposal" style="background-color: rgb(221, 221, 221);">
|
||||
Send to Client <i class="fa fa-check-square" style="color: green; margin-left: 8px;"></i>
|
||||
</a>
|
||||
<a href="#" class="removeProposal">Remove</a>
|
||||
</div>
|
||||
</span>
|
||||
`);
|
||||
|
||||
if (policy_terms && RFQ_or_QCR == 1) {
|
||||
|
||||
|
||||
let special_condition_count = 0;
|
||||
|
||||
if (policy_terms['special_condition_label']) {
|
||||
@ -1074,7 +1103,9 @@ function addSuggestionsToTable() {
|
||||
|
||||
const columnCount = $("#rfqTable thead tr th").length;
|
||||
console.log('columnCount' + columnCount);
|
||||
|
||||
for (let i = 3; i < columnCount - 6; i++) {
|
||||
|
||||
const editableCell = newRow.insertCell(i);
|
||||
editableCell.setAttribute('contenteditable', 'true');
|
||||
editableCell.classList.add('editablecolumns');
|
||||
@ -1093,6 +1124,7 @@ function addSuggestionsToTable() {
|
||||
editableCell.textContent = '';
|
||||
inputBox.value = '';
|
||||
}
|
||||
|
||||
} else if (policy_terms[key] == 0) {
|
||||
if (details.answers[1]) {
|
||||
editableCell.textContent = details.answers[1].display_value || '';
|
||||
@ -1116,14 +1148,30 @@ function addSuggestionsToTable() {
|
||||
|
||||
if (key.startsWith('special_condition')) {
|
||||
|
||||
if(policy_terms['special_condition_label']){
|
||||
editableCell.textContent = policy_terms['special_condition_label'][special_condition_index] + ' - ' + policy_terms['special_condition_input'][special_condition_index];
|
||||
inputBox.value = policy_terms['special_condition_label'][special_condition_index] + '--' + policy_terms['special_condition_input'][special_condition_index];
|
||||
special_condition_index++
|
||||
if(policy_terms.hasOwnProperty('special_condition_label')){
|
||||
|
||||
if(policy_terms['special_condition_label'] != "" && Array.isArray(policy_terms['special_condition_label'])){
|
||||
editableCell.textContent = policy_terms['special_condition_label'][special_condition_index] + ' - ' + policy_terms['special_condition_input'][special_condition_index];
|
||||
inputBox.value = policy_terms['special_condition_label'][special_condition_index] + '--' + policy_terms['special_condition_input'][special_condition_index];
|
||||
special_condition_index++
|
||||
}else{
|
||||
editableCell.textContent = ""
|
||||
inputBox.value = "";
|
||||
special_condition_index++
|
||||
}
|
||||
|
||||
}else{
|
||||
editableCell.textContent = policy_terms['gpa_special_condition_label'][special_condition_index] + ' - ' + policy_terms['gpa_special_condition_input'][special_condition_index];
|
||||
inputBox.value = policy_terms['gpa_special_condition_label'][special_condition_index] + '--' + policy_terms['gpa_special_condition_input'][special_condition_index];
|
||||
special_condition_index++
|
||||
|
||||
|
||||
if(policy_terms['gpa_special_condition_label'] != "" && Array.isArray(policy_terms['gpa_special_condition_label'])){
|
||||
editableCell.textContent = policy_terms['gpa_special_condition_label'][special_condition_index] + ' - ' + policy_terms['gpa_special_condition_input'][special_condition_index];
|
||||
inputBox.value = policy_terms['gpa_special_condition_label'][special_condition_index] + '--' + policy_terms['gpa_special_condition_input'][special_condition_index];
|
||||
special_condition_index++
|
||||
}else{
|
||||
editableCell.textContent = ""
|
||||
inputBox.value = "";
|
||||
special_condition_index++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1216,9 +1264,11 @@ addQuoteButton.addEventListener('click', function() {
|
||||
const secondLastCellValue = headerRow.cells[lastCellIndex - 1].textContent.trim();
|
||||
|
||||
// Split the second last cell's value and get the last part
|
||||
const lastPart = secondLastCellValue.split(" ")[1]?.trim();
|
||||
const lastPart = secondLastCellValue?.split(" ")[1]?.trim() ?? "0";
|
||||
|
||||
// Check if lastPart is a valid number; if not, default to 0
|
||||
const proposalNumber = isNaN(Number(lastPart)) ? 0 : Number(lastPart);
|
||||
|
||||
const proposalNumber = Number(lastPart);
|
||||
|
||||
console.log("proposalNumber:", proposalNumber);
|
||||
|
||||
@ -1336,6 +1386,7 @@ function showSuggestions(input) {
|
||||
function showAnswersSuggestions(input) {
|
||||
|
||||
console.log(input.parentElement.id);
|
||||
console.log(input);
|
||||
//return;
|
||||
var questionItem = input.parentElement.id;
|
||||
|
||||
@ -1451,11 +1502,16 @@ document.addEventListener('click', function(e) {
|
||||
}
|
||||
|
||||
if (e.target.classList.contains('editablecolumns')) {
|
||||
|
||||
// console.log(e.target.innerText);
|
||||
// if(e.target.innerText == '')
|
||||
// {
|
||||
showAnswersSuggestions(e.target);
|
||||
// showAnswersSuggestions(e.target);
|
||||
// }
|
||||
|
||||
if (e.target.isContentEditable) {
|
||||
showAnswersSuggestions(e.target);
|
||||
}
|
||||
}
|
||||
|
||||
//hide currently showing any three dotted menu
|
||||
@ -4136,8 +4192,6 @@ function jsonToTable(json) {
|
||||
// Add subheaders, hiding those under "Item Key"
|
||||
header.subHeaders.forEach((subHeader, index) => {
|
||||
|
||||
|
||||
|
||||
const subTh = document.createElement('th');
|
||||
|
||||
// Hide if parent header is "Item Key"
|
||||
@ -4294,15 +4348,28 @@ function jsonToTable(json) {
|
||||
td.innerText = dataEntry.value || '';
|
||||
|
||||
if(!["Sno", "Item Key", "Particulars", "Action"].includes(dataEntry.parentth)){
|
||||
insurerCountForDisableQuoteAsked = proposels[dataEntry.parentth]['insurers'].length
|
||||
const insurers = proposels[dataEntry?.parentth]?.insurers;
|
||||
insurerCountForDisableQuoteAsked = insurers?.length ?? 0;
|
||||
}
|
||||
|
||||
if(dataEntry.subth === "Quote Asked" && insurerCountForDisableQuoteAsked > 0){
|
||||
td.contentEditable = false;
|
||||
td.classList.add('readonly-select');
|
||||
if(RFQ_or_QCR == 1){
|
||||
//if the page is RFQ than check the insurer after disable the quote asked
|
||||
if(dataEntry.subth === "Quote Asked" && insurerCountForDisableQuoteAsked > 0){
|
||||
td.contentEditable = false;
|
||||
td.classList.add('readonly-select');
|
||||
}else{
|
||||
td.contentEditable = true;
|
||||
td.classList.add('editablecolumns');
|
||||
}
|
||||
}else{
|
||||
td.contentEditable = true;
|
||||
td.classList.add('editablecolumns');
|
||||
//if the page is QCR than disable the quote asked default
|
||||
if(dataEntry.subth === "Quote Asked"){
|
||||
td.contentEditable = false;
|
||||
td.classList.add('readonly-select');
|
||||
}else{
|
||||
td.contentEditable = true;
|
||||
td.classList.add('editablecolumns');
|
||||
}
|
||||
}
|
||||
// end of hide QUOTE ASKED if insurer exist
|
||||
|
||||
@ -4366,11 +4433,12 @@ function jsonToTable(json) {
|
||||
hideQCR()
|
||||
|
||||
isFormDataModified = false;
|
||||
// if(RFQ_or_QCR == 2){
|
||||
if(RFQ_or_QCR == 2){
|
||||
populateTable(json)
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
//Premium Calculation child table
|
||||
function populateTable(json) {
|
||||
|
||||
console.log(json);
|
||||
@ -4382,6 +4450,7 @@ function populateTable(json) {
|
||||
const headerRow1 = document.createElement("tr");
|
||||
const headerRow2 = document.createElement("tr");
|
||||
|
||||
var proposels = json.proposal_data.over_all_column_data;
|
||||
|
||||
// Iterate over the headers to create thead
|
||||
json.table_data.headers.forEach(header => {
|
||||
@ -4415,6 +4484,14 @@ function populateTable(json) {
|
||||
th.setAttribute("rowspan", 2); // No subheaders, span both rows
|
||||
}
|
||||
|
||||
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) {
|
||||
th.classList.add('hidden');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
headerRow1.appendChild(th);
|
||||
|
||||
// Create and append subheaders to the second row
|
||||
@ -4433,6 +4510,15 @@ function populateTable(json) {
|
||||
if(header.parentHeader != "Particulars" && header.parentHeader !== 'Sno'){
|
||||
subTh.style.backgroundColor = randomColor;
|
||||
}
|
||||
|
||||
//for QCR hidden fields
|
||||
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){
|
||||
subTh.classList.add('hidden')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
headerRow2.appendChild(subTh);
|
||||
});
|
||||
@ -4473,12 +4559,28 @@ function populateTable(json) {
|
||||
|
||||
// if(value != '-'){
|
||||
const td = document.createElement("td");
|
||||
td.setAttribute("contenteditable", "true");
|
||||
// td.classList.add('editablecolumnsforcalc')
|
||||
|
||||
if(label == "Total") {
|
||||
console.log();
|
||||
td.setAttribute("contenteditable", false);
|
||||
td.classList.add('readonly-select')
|
||||
}else{
|
||||
td.setAttribute("contenteditable", "true");
|
||||
}
|
||||
|
||||
td.classList.add(
|
||||
'editablecolumnsforcalc',
|
||||
label.toLowerCase().replace(/\s+/g, '').replace(/[%₹()]/g, '')
|
||||
);
|
||||
|
||||
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){
|
||||
td.classList.add('hidden')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// td.id = `${label.toLowerCase()}`;
|
||||
td.textContent = json.premium_data?.data?.[header.parentHeader]?.[value]?.[label] || "";
|
||||
tr.appendChild(td);
|
||||
@ -4588,12 +4690,12 @@ function generateJSONFromTable() {
|
||||
|
||||
function addInsurerDataForPremiumTable(event, insurerName, proposal_name) {
|
||||
|
||||
console.log('########################################################################')
|
||||
console.log('##################### ADD INSURER ###################################################')
|
||||
|
||||
const closestTh = event.target.closest('th');
|
||||
let colIndex = closestTh.cellIndex;
|
||||
console.log('column index of second table', colIndex);
|
||||
colIndex = colIndex -2
|
||||
colIndex = colIndex -1
|
||||
console.log('column index of second table', colIndex);
|
||||
|
||||
let rfqTable = document.getElementById('rfqTable_for_calc');
|
||||
@ -4613,8 +4715,10 @@ function addInsurerDataForPremiumTable(event, insurerName, proposal_name) {
|
||||
|
||||
// Determine the position for inserting the column
|
||||
let insertPosition = totalColspan; // Default to inserting at the end of the current insurer's columns
|
||||
const rowLabels = ["Premium", "GST (%)", "GST Amount (₹)", "Total"];
|
||||
|
||||
// Add a new column to each row
|
||||
let labelIncrement = 0
|
||||
for (let i = 1; i < rfqTable.rows.length; i++) {
|
||||
if (i === 1) {
|
||||
const newHeaderCell = document.createElement('th');
|
||||
@ -4623,13 +4727,27 @@ function addInsurerDataForPremiumTable(event, insurerName, proposal_name) {
|
||||
rfqTable.rows[i].insertBefore(newHeaderCell, rfqTable.rows[i].cells[insertPosition]);
|
||||
} else {
|
||||
const newCell = rfqTable.rows[i].insertCell(insertPosition);
|
||||
newCell.setAttribute('contenteditable', 'true');
|
||||
|
||||
if(rowLabels[labelIncrement] == "Total") {
|
||||
console.log();
|
||||
newCell.setAttribute("contenteditable", false);
|
||||
newCell.classList.add('readonly-select')
|
||||
}else{
|
||||
newCell.setAttribute("contenteditable", "true");
|
||||
}
|
||||
newCell.classList.add(
|
||||
'editablecolumnsforcalc',
|
||||
rowLabels[labelIncrement].toLowerCase().replace(/\s+/g, '').replace(/[%₹()]/g, '')
|
||||
);
|
||||
|
||||
// newCell.classList.add('editablecolumns');
|
||||
newCell.innerHTML = rfqTable.rows[i].cells[columnIndextoCopyData].innerHTML;
|
||||
newCell.style.backgroundColor = parentTh.style.backgroundColor;
|
||||
// newCell.style.backgroundColor = parentTh.style.backgroundColor;
|
||||
labelIncrement++
|
||||
}
|
||||
}
|
||||
|
||||
labelIncrement = 0
|
||||
isFormDataModified = true; // if any value changeing in the table to set true
|
||||
|
||||
console.log('########################################################################')
|
||||
@ -4638,13 +4756,15 @@ function addInsurerDataForPremiumTable(event, insurerName, proposal_name) {
|
||||
|
||||
function copyInsurerDataForPremiumTable(event, insurerName){
|
||||
|
||||
console.log('########## COPPY INSURER ##############')
|
||||
|
||||
const thPosition = getThPosition(event);
|
||||
|
||||
let parentThIndex = null;
|
||||
const closestTh = event.target.closest('th');
|
||||
let colIndex = closestTh.cellIndex;
|
||||
console.log('colIndex', colIndex);
|
||||
colIndex = colIndex - 2;
|
||||
colIndex = colIndex - 1;
|
||||
let columnText = closestTh.innerText;
|
||||
let proposal_name = columnText.split('⋮')[0].trim();
|
||||
let rfqTable = document.getElementById('rfqTable_for_calc');
|
||||
@ -4696,6 +4816,8 @@ function copyInsurerDataForPremiumTable(event, insurerName){
|
||||
// add colspan of current th
|
||||
let parentTh = rfqTable.querySelector('thead tr th:nth-child(' + (parentThIndex + 1) + ')');
|
||||
parentTh.colSpan += 1;
|
||||
|
||||
let labelIncrement = 0;
|
||||
// Add a new column to each row
|
||||
for (let i = 1; i < rfqTable.rows.length; i++) {
|
||||
|
||||
@ -4711,19 +4833,34 @@ function copyInsurerDataForPremiumTable(event, insurerName){
|
||||
|
||||
} else {
|
||||
const newCell = rfqTable.rows[i].insertCell(totalColspan);
|
||||
newCell.setAttribute('contenteditable', 'true');
|
||||
|
||||
if(rowLabels[labelIncrement] == "Total") {
|
||||
console.log();
|
||||
newCell.setAttribute("contenteditable", false);
|
||||
newCell.classList.add('readonly-select')
|
||||
}else{
|
||||
newCell.setAttribute("contenteditable", "true");
|
||||
}
|
||||
newCell.classList.add(
|
||||
'editablecolumnsforcalc',
|
||||
rowLabels[labelIncrement].toLowerCase().replace(/\s+/g, '').replace(/[%₹()]/g, '')
|
||||
);
|
||||
|
||||
// newCell.setAttribute('contenteditable', 'true');
|
||||
newCell.innerHTML = rfqTable.rows[i].cells[colIndex].innerHTML;
|
||||
newCell.style.backgroundColor = parentTh.style.backgroundColor;
|
||||
// newCell.style.backgroundColor = parentTh.style.backgroundColor;
|
||||
labelIncrement++
|
||||
}
|
||||
|
||||
}
|
||||
labelIncrement = 0
|
||||
}
|
||||
|
||||
function changeInsurerForPremiumTable(event, newInsurerName, secondRowIndex) {
|
||||
|
||||
const table = document.getElementById('rfqTable_for_calc');
|
||||
const headerRows = table.querySelectorAll('thead tr');
|
||||
secondRowIndex = secondRowIndex - 2
|
||||
secondRowIndex = secondRowIndex - 1
|
||||
const secondRow = headerRows[1];
|
||||
const thElements = secondRow.querySelectorAll('th');
|
||||
const closestTh = thElements[secondRowIndex];
|
||||
@ -4755,7 +4892,7 @@ function removeInsurerFromPremiumTable(event, secondRowIndex) {
|
||||
console.log('insurerName', insurerName);
|
||||
// let subThIndex = closestTh.cellIndex;
|
||||
// console.log('subThIndex', subThIndex);
|
||||
subThIndex = secondRowIndex - 2
|
||||
subThIndex = secondRowIndex - 1
|
||||
console.log('subThIndex', subThIndex);
|
||||
|
||||
// Get the sub TH from the second header row
|
||||
@ -4806,7 +4943,7 @@ function removeInsurerFromPremiumTable(event, secondRowIndex) {
|
||||
|
||||
function removeProposalForPremiumTable(secondRowIndex) {
|
||||
|
||||
let colIndex = secondRowIndex - 2;
|
||||
let colIndex = secondRowIndex - 1;
|
||||
console.log('colIndex', colIndex);
|
||||
|
||||
const rfqPremiumTable = document.getElementById('rfqTable_for_calc');
|
||||
@ -4919,6 +5056,14 @@ function autoCaluculationForPremiumChildTable(input) {
|
||||
const row = input.closest('tr');
|
||||
console.log('row', row);
|
||||
|
||||
const hasPremiumClass = input.classList.contains('premium');
|
||||
const hasGstClass = input.classList.contains('gst');
|
||||
const hasGstAmtClass = input.classList.contains('gstamount');
|
||||
|
||||
console.log('hasPremiumClass', hasPremiumClass);
|
||||
console.log('hasGstClass', hasGstClass);
|
||||
|
||||
|
||||
// Find the index of the input td
|
||||
const tdIndex = Array.from(row.children).indexOf(input);
|
||||
console.log('tdIndex', tdIndex);
|
||||
@ -4930,22 +5075,43 @@ function autoCaluculationForPremiumChildTable(input) {
|
||||
// Extract values from the corresponding cells in each row
|
||||
const premium = Number(rows[0].children[tdIndex]?.textContent.trim()) || 0;
|
||||
const gst = Number(rows[1].children[tdIndex]?.textContent.trim()) || 0;
|
||||
const gstAmt = Number(rows[2].children[tdIndex]?.textContent.trim()) || 0;
|
||||
|
||||
console.log('premium', premium);
|
||||
console.log('gst', gst);
|
||||
|
||||
|
||||
// Calculate GST Amount and Total
|
||||
const gstAmount = (premium * gst) / 100;
|
||||
const total = premium + gstAmount;
|
||||
if(hasPremiumClass || hasGstClass){
|
||||
|
||||
console.log('Calculated GST Amount:', gstAmount.toFixed(2));
|
||||
console.log('Calculated Total Amount:', total.toFixed(2));
|
||||
const gstAmount = (premium * gst) / 100;
|
||||
const total = premium + gstAmount;
|
||||
|
||||
// Update GST Amount row
|
||||
rows[2].children[tdIndex].textContent = gstAmount.toFixed(2);
|
||||
console.log('Calculated GST Amount:', gstAmount.toFixed(2));
|
||||
console.log('Calculated Total Amount:', total.toFixed(2));
|
||||
|
||||
// Update Total row
|
||||
rows[3].children[tdIndex].textContent = total.toFixed(2);
|
||||
// Update GST Amount row
|
||||
rows[2].children[tdIndex].textContent = gstAmount.toFixed(2);
|
||||
|
||||
// Update Total row
|
||||
rows[3].children[tdIndex].textContent = total.toFixed(2);
|
||||
|
||||
}else if (hasGstAmtClass){
|
||||
|
||||
// Calculate GST percentage based on GST amount and premium
|
||||
const gstPercent = premium > 0 ? (gstAmt / premium) * 100 : 0;
|
||||
const total = premium + gstAmt;
|
||||
|
||||
console.log('Calculated GST Percentage:', gstPercent.toFixed(2));
|
||||
console.log('Calculated Total Amount:', total.toFixed(2));
|
||||
|
||||
// Update GST row with calculated GST percentage
|
||||
rows[1].children[tdIndex].textContent = gstPercent.toFixed(2);
|
||||
|
||||
// Update Total row
|
||||
rows[3].children[tdIndex].textContent = total.toFixed(2);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5101,7 +5267,7 @@ function autoCaluculationForPremiumChildTable(input) {
|
||||
const table = document.getElementById('rfqTable');
|
||||
|
||||
let premium_data = '';
|
||||
if(jsonDataForHide){
|
||||
if(RFQ_or_QCR == 2){
|
||||
premium_data = generateJSONFromTable();
|
||||
console.log('save premium data', premium_data);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user