FEAT_RFQ_NONEB_PRE_FINAL
This commit is contained in:
parent
b313309e00
commit
89db5cf085
@ -404,6 +404,7 @@ $routes->group("leads", ["filter" => "authMVC"], function ($routes) {
|
||||
|
||||
$routes->group("rfq", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->post("create", "LeadsController::createRFQ");
|
||||
$routes->post("savePolicyInfo", "LeadsController::savePolicyInfo");
|
||||
$routes->post("createQCR", "LeadsController::createQCR");
|
||||
$routes->get("list/(:any)", "LeadsController::viewRFQ/$1");
|
||||
$routes->get("nonEB","LeadsController::rfqNonEB");
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
22
app/Models/OccupancyMasterModel.php
Normal file
22
app/Models/OccupancyMasterModel.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class OccupancyMasterModel extends Model
|
||||
{
|
||||
protected $table = 'occupancy_master';
|
||||
protected $allowedFields = [
|
||||
'id',
|
||||
'iib_code',
|
||||
'section',
|
||||
'description',
|
||||
'iib_loss_rate',
|
||||
'created_by',
|
||||
'created_at',
|
||||
'is_active'
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
@ -17,6 +17,7 @@ class RFQModel extends Model
|
||||
'type',
|
||||
'lead_id',
|
||||
'json',
|
||||
"registration_json",
|
||||
'created_at',
|
||||
'created_by',
|
||||
'updated_at',
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -215,7 +215,7 @@
|
||||
<div class="form-row" id="input_for_row">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
||||
<button type="submit" class="btn btn-primary" onclick="constructURL(1)">Send Mail</button>
|
||||
</div>
|
||||
@ -243,12 +243,12 @@
|
||||
<select class="form-control" id="to" name="to" required>
|
||||
<?php if (isset($userList)) { ?>
|
||||
<?php foreach ($userList as $user) { ?>
|
||||
<option value="<?= $user['email'];?>">
|
||||
<?= $user['first_name'].' - '.$user['email'];?>
|
||||
<option value="<?= $user['email']; ?>">
|
||||
<?= $user['first_name'] . ' - ' . $user['email']; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
@ -256,12 +256,12 @@
|
||||
<select class="form-control" id="cc" name="cc" required multiple>
|
||||
<?php if (isset($userList)) { ?>
|
||||
<?php foreach ($userList as $user) { ?>
|
||||
<option value="<?= $user['id'];?>">
|
||||
<?= $user['first_name'].' - '.$user['email'];?>
|
||||
<option value="<?= $user['id']; ?>">
|
||||
<?= $user['first_name'] . ' - ' . $user['email']; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
@ -278,7 +278,7 @@
|
||||
</div>
|
||||
<br>
|
||||
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
||||
<button type="submit" class="btn btn-primary" onclick="constructURL(2)">Send Mail</button>
|
||||
<button type="submit" class="btn btn-primary" onclick="constructURL(2)">Send Mail</button>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
@ -300,7 +300,7 @@
|
||||
|
||||
<!-- For display perpose placement alredy submited text display -->
|
||||
<div class="form-group col-md-12">
|
||||
<label><span id="alert_msg"class="text-danger"></span></label>
|
||||
<label><span id="alert_msg" class="text-danger"></span></label>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
@ -335,16 +335,16 @@
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="proposals"> Proposals/Insurer <span id="base_danger"class="text-danger">*</span></label>
|
||||
<select class="form-control" id="proposals"name="proposals" onchange="getInsurerBranchContacts(this)" required>
|
||||
<option value="" >Select Proposals</option>
|
||||
<label for="proposals"> Proposals/Insurer <span id="base_danger" class="text-danger">*</span></label>
|
||||
<select class="form-control" id="proposals" name="proposals" onchange="getInsurerBranchContacts(this)" required>
|
||||
<option value="">Select Proposals</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="placement_to"> To <span id="base_danger"class="text-danger">*</span></label>
|
||||
<label for="placement_to"> To <span id="base_danger" class="text-danger">*</span></label>
|
||||
<select class="form-control" id="placement_to" name="placement_to" required>
|
||||
<option value="" >Select To Mail</option>
|
||||
<option value="">Select To Mail</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@ -353,12 +353,12 @@
|
||||
<select class="form-control" id="placement_cc" name="placement_cc" required multiple>
|
||||
<?php if (isset($userList)) { ?>
|
||||
<?php foreach ($userList as $user) { ?>
|
||||
<option value="<?= $user['id'];?>">
|
||||
<?= $user['first_name'].' - '.$user['email'];?>
|
||||
<option value="<?= $user['id']; ?>">
|
||||
<?= $user['first_name'] . ' - ' . $user['email']; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
@ -403,11 +403,18 @@
|
||||
}
|
||||
};
|
||||
var suggestions = {};
|
||||
var storedData = JSON.parse(localStorage.getItem('policyData'));
|
||||
var policySummary;
|
||||
if (!$.isEmptyObject(storedData)) {
|
||||
policySummary = addPolicySummaryTable(storedData);
|
||||
var policyInformationData = <?= isset($rfq_data['registration_json']) ? json_encode($rfq_data['registration_json'], JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT) : '""' ?>;
|
||||
var storedData = {};
|
||||
console.log("stored data : ", typeof(policyInformationData))
|
||||
|
||||
if (policyInformationData.length) {
|
||||
|
||||
localStorage.setItem('policyData', (policyInformationData));
|
||||
storedData = policyInformationData;
|
||||
}
|
||||
|
||||
var policySummary = [];
|
||||
|
||||
console.log("policy summary is set :", !$.isEmptyObject(policySummary) ? "no" : "yes")
|
||||
$(document).ready(function() {
|
||||
myModal = new bootstrap.Modal(document.getElementById('policyRegisterModel'));
|
||||
@ -482,37 +489,7 @@
|
||||
1: ['Quote asked']
|
||||
}; // Stores quote columns for each proposal
|
||||
|
||||
// Generate a random quote code (e.g., abc123)
|
||||
function generateRandomCode() {
|
||||
const chars = 'abcdefghijklmnopqrstuvwxyz';
|
||||
const nums = '0123456789';
|
||||
return Array.from({
|
||||
length: 3
|
||||
}, () => chars[Math.floor(Math.random() * 26)]).join('') +
|
||||
Array.from({
|
||||
length: 3
|
||||
}, () => nums[Math.floor(Math.random() * 10)]).join('');
|
||||
}
|
||||
|
||||
// Add a new quote column to a specific proposal
|
||||
// function addNewQuote(proposalNumber) {
|
||||
// console.log("this doesnt work");
|
||||
// let increaseBy = 25;
|
||||
// increaseTableWidth(increaseBy)
|
||||
// console.log('ADD NEW QUOTE proposalNumber' + proposalNumber);
|
||||
// console.log('ADD NEW QUOTE overall quotesConfig');
|
||||
// console.log(quotesConfig);
|
||||
// if (!quotesConfig[proposalNumber]) {
|
||||
// quotesConfig[proposalNumber] = ['Quote asked']; // Initialize with default quote
|
||||
// }
|
||||
// const newQuote = generateRandomCode();
|
||||
// quotesConfig[proposalNumber].push(newQuote); // Add new quote to the proposal
|
||||
|
||||
// // Update all tables (parent and child) with the new quote column
|
||||
// updateAllTables(proposalNumber, newQuote);
|
||||
// // hideProposalOptionsForChild();
|
||||
|
||||
// }
|
||||
|
||||
// Update all tables with the new quote column
|
||||
function updateAllTables_old(proposalNumber, newQuote) {
|
||||
@ -722,6 +699,7 @@
|
||||
// console.log('Row id for excess table',rowId);
|
||||
$("#excess .three-dot-menu").hide();
|
||||
moveExcessTableLast();
|
||||
|
||||
}
|
||||
} else {
|
||||
// Handle regular table
|
||||
@ -729,6 +707,9 @@
|
||||
generateTable(childContainer, true, rowId, childTable);
|
||||
// console.log('Row id for excess table', rowId);
|
||||
$(childContainer).find(".three-dot-menu").hide();
|
||||
|
||||
// alert(`${rowId.toUpperCase()}_register`);
|
||||
$(`#${rowId.toUpperCase()}_register`).prop("disabled", false);
|
||||
moveExcessTableLast();
|
||||
}
|
||||
});
|
||||
@ -738,7 +719,10 @@
|
||||
container.appendChild(childContainer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
arrangeTables();
|
||||
alignTableColumn();
|
||||
} else {
|
||||
console.log('UNCHECKED:', rowId);
|
||||
selectedPolicies.delete(rowId);
|
||||
@ -747,6 +731,7 @@
|
||||
regularContainers.forEach(container => {
|
||||
console.log(" contaitner ", container);
|
||||
|
||||
$(`#${rowId.toUpperCase()}_register`).prop("disabled", true);
|
||||
container.remove();
|
||||
});
|
||||
console.log("row id ", rowId);
|
||||
@ -1134,6 +1119,10 @@
|
||||
${newQuote}
|
||||
<span class="three-dot-menu" onclick="showDropdown(event)">⋮</span>
|
||||
<div class="dropdown-content">
|
||||
<button id = "isInsurerSTC" class="sendInsurerClientProposal" onclick = "addOrRemoveIconInsurer(this,event)"
|
||||
style="background-color: rgb(221, 221, 221);">Send to Client <i
|
||||
class="fa fa-check-square"
|
||||
style="color: green; margin-left: 8px; "></i></button>
|
||||
<button onclick="changeInsurer(event, ${proposalNumber}, '${newQuote}')">Change Insurer</button>
|
||||
<button onclick="removeQuote(event, ${proposalNumber}, '${newQuote}')">Remove Quote</button>
|
||||
</div>
|
||||
@ -1183,7 +1172,7 @@
|
||||
const headerRow1 = document.createElement('tr');
|
||||
headerRow1.innerHTML =
|
||||
`
|
||||
${isChildTable ? '<th>S.NO</th>' : '<th><input type="checkbox"></th>'}
|
||||
${isChildTable ? '<th>S.NO</th>' : '<th>Policy</th>'}
|
||||
<th>${tableName}</th>
|
||||
${Object.keys(quotesConfig).map(proposal => `
|
||||
<th data-proposal="${proposal}" colspan="${quotesConfig[proposal].length}">
|
||||
@ -1210,13 +1199,15 @@
|
||||
<th>-</th>
|
||||
${Object.entries(quotesConfig).flatMap(([proposal, codes]) =>
|
||||
codes.map(code => `
|
||||
<th data-proposal="${proposal}" data-quote="${code}">
|
||||
${code}
|
||||
<span class="three-dot-menu" onclick="showDropdown(event)">⋮</span>
|
||||
<div class="dropdown-content">
|
||||
<button onclick="removeQuote(event, ${proposal}, '${code}')">Remove Quote</button>
|
||||
</div>
|
||||
</th>
|
||||
<th data-proposal="${proposal}" data-quote="${code}"
|
||||
class="${code !== 'Quote asked' ? 'insurer_proposal' : ''}">
|
||||
${code}
|
||||
<span class="three-dot-menu" onclick="showDropdown(event)">⋮</span>
|
||||
<div class="dropdown-content">
|
||||
<button onclick="removeQuote(event, ${proposal}, '${code}')">Remove Quote</button>
|
||||
</div>
|
||||
</th>
|
||||
|
||||
`)
|
||||
).join('')}
|
||||
<th>-</th>`;
|
||||
@ -1258,7 +1249,7 @@
|
||||
<input type="checkbox" class="sno-checkbox">
|
||||
${policy.name}
|
||||
${policy.name === 'Fire' || policy.name === 'Burglary' ?
|
||||
`<br><button class = "btn btn-primary btn-sm" onclick = "getPolicyInfo()" class="policy-link" data-policy-name="${policy.name}">Register</button>` :
|
||||
`<br><button id = '${policy.name.toUpperCase()}_register' class = "btn btn-primary btn-sm" onclick = "getPolicyInfo('${policy.name}')" class="policy-link" data-policy-name="${policy.name}" disabled>Register</button>` :
|
||||
''}
|
||||
</td>
|
||||
<td contenteditable="true">${desc}</td>
|
||||
@ -1299,13 +1290,14 @@
|
||||
suggestions[rowID] = row_fields[rowID].answer_type;
|
||||
if (answer_type == 'dropdown') {
|
||||
default_answers_array = row_fields[rowID].default_answer;
|
||||
|
||||
console.log("default ans array : ", typeof(default_answers_array))
|
||||
// createDropdown(default_answers_array);
|
||||
default_value = default_answers_array[0].key;
|
||||
default_answer = default_answers_array[0].display_value;
|
||||
|
||||
} else {
|
||||
default_answers_array = row_fields[rowID].default_answer ? row_fields[rowID].default_answer : "-";
|
||||
console.log("default ans array else: ", default_answers_array)
|
||||
// console.log("defaultansetgoa : ",default_answers_array);
|
||||
default_value = default_answers_array;
|
||||
default_answer = default_answers_array;
|
||||
@ -1321,15 +1313,43 @@
|
||||
${isChildTable
|
||||
? `<td>${SNO}</td>`
|
||||
: `<td rowspan = "${policy.description.length}"><input type="checkbox" class="sno-checkbox">${policy.name}${policy.name == 'Fire' || policy.name == 'Burglary'
|
||||
? `<br><button class = "btn btn-primary btn-sm" onclick = "getPolicyInfo()" class="policy-link" data-policy-name="${policy.name}">Register</a>`
|
||||
? `<br><button id = '${policy.name.toUpperCase()}_register' class = "btn btn-primary btn-sm" onclick = "getPolicyInfo('${policy.name}')" class="policy-link" data-policy-name="${policy.name}" disabled>Register</a>`
|
||||
: ""}</td>`
|
||||
}
|
||||
|
||||
<td contenteditable="true">${tableData ? policy_question : policy.description}</td>
|
||||
${Object.values(quotesConfig).flatMap(codes =>
|
||||
codes.map(() => `<td onblur="setValueForHiddenField(this,'${answer_type}')" onclick = "getAnswer('${tableID}','${rowID}')" contenteditable="true">${tableData ? (default_value === '-' ? `${default_value} <input type="hidden" value='${default_value}' />` : `${default_answer} <input type="hidden" value='${JSON.stringify(default_answers_array[0])}' />`)
|
||||
: policy.quote_asked}</td>`)
|
||||
).join('')}
|
||||
codes.map((_, colIndex) => {
|
||||
// Get the subheader (assuming it's the second <tr> inside <thead>)
|
||||
let subHeaderTh = document.querySelector(`thead tr:nth-child(2) th:nth-child(${colIndex + 1})`);
|
||||
let subHeaderText = subHeaderTh ? subHeaderTh.textContent.trim() : '';
|
||||
|
||||
// Check if subheader is NOT "Quote asked"
|
||||
let className = subHeaderText !== "Quote asked" && subHeaderText != "-" ? "insurer_proposal" : "";
|
||||
let defaultJsonString = typeof default_answers_array == "object" ? JSON.stringify(default_answers_array[0]) : String(default_answers_array);
|
||||
|
||||
// console.log("defaultJsonString", defaultJsonString);
|
||||
// console.log("defaultJsonString type", typeof defaultJsonString);
|
||||
// console.log("defaultJsonString string", String(defaultJsonString));
|
||||
|
||||
|
||||
|
||||
return `<td class="${className}" onblur="setValueForHiddenField(this,'${answer_type}')"
|
||||
onclick="getAnswer('${tableID}','${rowID}')"
|
||||
contenteditable="true">
|
||||
|
||||
${tableData ?
|
||||
(default_value === '-' ?
|
||||
`${default_value} <input type="hidden" value="${default_value}" />`
|
||||
: `${default_answer} <input type="hidden" value='${defaultJsonString}' />`
|
||||
)
|
||||
: policy.quote_asked
|
||||
}
|
||||
|
||||
</td>`;
|
||||
})
|
||||
).join('')}
|
||||
|
||||
<td>
|
||||
${isChildTable ? `
|
||||
<input id = "qcrCheckbox" name = "qcr" checked type="checkbox" class="qcr-checkbox"> <label for = "qcrCheckbox">QCR</label>
|
||||
@ -1474,6 +1494,23 @@
|
||||
console.log("inside if conditoon");
|
||||
localStorage.setItem('allTablesJsonData', JSON.stringify(rfq_data));
|
||||
jsonToTables();
|
||||
if (!$.isEmptyObject(storedData)) {
|
||||
console.log("DATA FROM DB : ", JSON.parse(storedData));
|
||||
let data = JSON.parse(storedData);
|
||||
Object.keys(data).forEach(key => {
|
||||
|
||||
policySummary[key] = addPolicySummaryTable(data[key], key);
|
||||
|
||||
prependTable(policySummary[key],key);
|
||||
|
||||
|
||||
});
|
||||
|
||||
// console.log("policy summary : ",child_table_data[key])
|
||||
|
||||
console.log("generate policy summary : ", policySummary);
|
||||
|
||||
}
|
||||
// generateTable(document.getElementById('tablesContainer'));
|
||||
// console.log("polices Length ", policies.length);
|
||||
|
||||
@ -1783,18 +1820,37 @@
|
||||
function getPolicyInfo(policyName) {
|
||||
console.log("anchor link clicked ", policyName);
|
||||
|
||||
if (!myModal) {
|
||||
myModal = new bootstrap.Modal(document.getElementById('policyRegisterModel'));
|
||||
console.log("inside if condition");
|
||||
}
|
||||
|
||||
myModal = new bootstrap.Modal(document.getElementById('policyRegisterModel'));
|
||||
console.log("inside if condition");
|
||||
|
||||
var leadID = $("#lead_id").val();
|
||||
|
||||
$("#policyName").val(policyName);
|
||||
$("#leadID").val(leadID);
|
||||
$("#multilocation_type_div").hide();
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
// Add 'show active' to the 'product-selection' tab
|
||||
$("#policy_register_forms .tab-pane.show.active").removeClass("active show");
|
||||
|
||||
// Add 'show active' to the 'product-selection' tab
|
||||
$("#product-selection").addClass("active show");
|
||||
hideAndShowBurglary();
|
||||
|
||||
storedPolicyData = JSON.parse(localStorage.getItem('policyData'));
|
||||
if (!$.isEmptyObject(storedPolicyData)) {
|
||||
// alert("not empty");
|
||||
prepareDataForEdit(storedPolicyData);
|
||||
}
|
||||
myModal.show();
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}
|
||||
|
||||
function addPolicySummaryTable(storedData) {
|
||||
function addPolicySummaryTable(storedData, policyName) {
|
||||
// alert(policyName);
|
||||
var locationCount = storedData.locations.length;
|
||||
var tableRowContent = [];
|
||||
|
||||
@ -1804,7 +1860,7 @@
|
||||
|
||||
tableRowContent.push({
|
||||
table_type: "new",
|
||||
table_id: "fire_summary_" + locationIndex,
|
||||
table_id: `${policyName}_summary_` + locationIndex,
|
||||
table_editable: true,
|
||||
table_name: "Risk Location " + locationIndex + "- " +
|
||||
storedData.locations[i].policyRisk['occupancy'] + "- " +
|
||||
@ -1914,15 +1970,17 @@
|
||||
console.log("save button clicked");
|
||||
leadJson = tablesToJson();
|
||||
console.log("json from function ", leadJson);
|
||||
saveRFQTODB(leadJson);
|
||||
var policyJson = localStorage.getItem("policyData") ?? null;
|
||||
saveRFQTODB(leadJson, policyJson);
|
||||
}
|
||||
|
||||
function saveRFQTODB(tableJSON) {
|
||||
function saveRFQTODB(tableJSON, policyJson) {
|
||||
|
||||
var formData = {
|
||||
lead_id: $("#lead_id").val(),
|
||||
json: JSON.stringify(tableJSON),
|
||||
submit_type: "RFQ"
|
||||
submit_type: "RFQ",
|
||||
registration_json: policyJson
|
||||
}
|
||||
|
||||
var url = '<?= base_url('rfq/create') ?>';
|
||||
@ -1935,6 +1993,8 @@
|
||||
method: "POST",
|
||||
success: function(response) {
|
||||
if (response.status == true) {
|
||||
localStorage.removeItem('policyData');
|
||||
|
||||
toastr.success(response.message, "Success");
|
||||
// window.location.reload();
|
||||
} else {
|
||||
@ -1942,7 +2002,7 @@
|
||||
}
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
// window.location.reload();
|
||||
window.location.reload();
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
$('.loader').fadeOut();
|
||||
@ -1955,8 +2015,6 @@
|
||||
|
||||
function prepareOverallData() {
|
||||
const overAllData = {};
|
||||
// console.log("Policy Configuration Data : ", policyConfig);
|
||||
// Iterate through each proposal in quotesConfig
|
||||
Object.entries(policyConfig).forEach(([proposalNumber, insurers]) => {
|
||||
const proposalKey = `Proposal ${proposalNumber}`;
|
||||
overAllData[proposalKey] = {
|
||||
@ -1965,7 +2023,6 @@
|
||||
insurers: []
|
||||
};
|
||||
|
||||
// Get QCR/STC status from proposal header
|
||||
const proposalHeader = document.querySelector(`th[data-proposal="${proposalNumber}"]`);
|
||||
if (proposalHeader) {
|
||||
const qcrSelected = proposalHeader.querySelector('.qcrProposal .fa-check-square') !== null;
|
||||
@ -1975,13 +2032,25 @@
|
||||
}
|
||||
console.log("Insurers Found", insurers);
|
||||
|
||||
// Get unique insurers from quotesConfig (stored during addNewQuote)
|
||||
const uniqueInsurers = [];
|
||||
insurers.forEach(insurer => {
|
||||
if (typeof insurer === 'object' && insurer.id) { // Check if stored properly id:dataId,
|
||||
|
||||
if (typeof insurer === 'object' && insurer.id) {
|
||||
let stcInsurerSelected = false;
|
||||
const insurerHeaders = document.querySelectorAll(`th[data-quote="${insurer.insurerName}"]`);
|
||||
insurerHeaders.forEach(header => {
|
||||
const headerProposalCount = header.getAttribute("data-proposal");
|
||||
if (headerProposalCount == proposalNumber) {
|
||||
console.log("Found the subheader we are searching");
|
||||
if (header.querySelector('.sendInsurerClientProposal .fa-check-square') !== null) {
|
||||
stcInsurerSelected = true;
|
||||
}
|
||||
console.log("STC selected for insurer:", stcInsurerSelected);
|
||||
}
|
||||
});
|
||||
uniqueInsurers.push({
|
||||
ins_name: insurer.insurerName,
|
||||
qcr: 1,
|
||||
stc: rfq_or_qcr == 1 ? 1 : stcInsurerSelected ? 1 : 0,
|
||||
display_name: insurer.insurerName,
|
||||
id: insurer.id
|
||||
});
|
||||
@ -1994,6 +2063,7 @@
|
||||
return overAllData;
|
||||
}
|
||||
|
||||
|
||||
function getTextExcludingButton(cell) {
|
||||
return Array.from(cell.childNodes)
|
||||
.filter(node => node.nodeType === Node.TEXT_NODE) // Get only text nodes
|
||||
@ -2039,7 +2109,7 @@
|
||||
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);
|
||||
console.log("HEader : ", header.innerText == " " ? header.innerText.trim() : headerText);
|
||||
headers.push({
|
||||
// parentHeader: header.innerText.replace('⋮', '').split('\n')[0].replace(/:.*/, '').trim(),
|
||||
parentHeader: headerText,
|
||||
@ -2242,6 +2312,17 @@
|
||||
// child_table_data[rowData.rowID]
|
||||
}
|
||||
|
||||
function getTotalCount(proposalDataArray) {
|
||||
let proposals = proposalDataArray.proposal_data.over_all_column_data;
|
||||
|
||||
let proposalCount = Object.keys(proposals).length; // Count proposals
|
||||
let insurerCount = Object.values(proposals).reduce((sum, proposal) => {
|
||||
return sum + (proposal.insurers ? proposal.insurers.length : 0);
|
||||
}, 0); // Count insurers across all proposals
|
||||
|
||||
return proposalCount + insurerCount;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function jsonToTables() {
|
||||
@ -2270,7 +2351,15 @@
|
||||
console.log("proposal count : ", proposalCount);
|
||||
console.log("proposal count quotes config ... : ", proposalDataArray.proposal_data.over_all_column_data);
|
||||
|
||||
var totalCount = getTotalCount(proposalDataArray);
|
||||
let increaseBy = proposalCount * 150;
|
||||
if (rfq_or_qcr == 1) {
|
||||
console.log("inside if ")
|
||||
increaseBy = proposalCount * 150;
|
||||
} else if (rfq_or_qcr == 2) {
|
||||
increaseBy = totalCount * 150;
|
||||
}
|
||||
|
||||
console.log("trying to find checkbox data : : : ", increaseBy);
|
||||
|
||||
|
||||
@ -2400,6 +2489,7 @@
|
||||
const headerRow1 = document.createElement('tr');
|
||||
const headerRow2 = document.createElement('tr');
|
||||
var overallColumnDataProposal = proposal_data.proposal_data.over_all_column_data;
|
||||
var matchedKey = "";
|
||||
headers.forEach(header => {
|
||||
// Parent header
|
||||
const th1 = document.createElement('th');
|
||||
@ -2408,7 +2498,7 @@
|
||||
var headerName = header.parentHeader;
|
||||
console.log("header name : ", th1.textContent.trim());
|
||||
console.log("over all column data : ", over_all_column_data)
|
||||
let matchedKey = Object.keys(overallColumnDataProposal).find(key => headerName.startsWith(key));
|
||||
matchedKey = Object.keys(overallColumnDataProposal).find(key => headerName.startsWith(key));
|
||||
if (matchedKey) {
|
||||
console.log("something wrong : ", overallColumnDataProposal[matchedKey]);
|
||||
var headerCheckBoxProperties = overallColumnDataProposal[matchedKey];
|
||||
@ -2441,14 +2531,22 @@
|
||||
header.subHeaders.forEach(subHeader => {
|
||||
const th2 = document.createElement('th');
|
||||
if (header.parentHeader.startsWith("Proposal")) {
|
||||
var insurers = overallColumnDataProposal[matchedKey].insurers;
|
||||
const matchedInsurer = insurers.find(ins => ins.ins_name == subHeader);
|
||||
|
||||
if (subHeader != "Quote asked") {
|
||||
console.log("trying to find something : ", matchedInsurer.stc);
|
||||
|
||||
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 id = "isInsurerSTC" class="sendInsurerClientProposal" onclick = "addOrRemoveIconInsurer(this,event)"
|
||||
style="background-color: rgb(221, 221, 221);">Send to Client ${matchedInsurer.stc == 1 ? `<i
|
||||
class="fa fa-check-square"
|
||||
style="color: green; margin-left: 8px; "></i>`: ""} </button>
|
||||
<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>
|
||||
@ -2487,7 +2585,7 @@
|
||||
}
|
||||
// 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>`
|
||||
? `<br><button id = '${cellData.SNO.toUpperCase()}_register' class = "btn btn-primary btn-sm" onclick = "getPolicyInfo('${cellData.SNO}')" class="policy-link" data-policy-name="${cellData.SNO}" ${value == "Checked" ? "" :"disabled"} >Register</a>`
|
||||
: ""}`;
|
||||
}
|
||||
if (typeof value === 'string' && value.startsWith('{')) {
|
||||
@ -2913,25 +3011,67 @@
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function prependTable(policyJson,policyName) {
|
||||
|
||||
// alert("hi");
|
||||
console.log("table to prepened : ", policyJson);
|
||||
let parentDiv = document.querySelector(`div[data-parent-row=${policyName}]`);
|
||||
// let newTable = document.createElement("table");
|
||||
|
||||
if (parentDiv){
|
||||
|
||||
let tables = Array.from(parentDiv.querySelectorAll("table"));
|
||||
|
||||
tables.forEach(table => {
|
||||
if (table.id.includes("summary")) {
|
||||
table.remove(); // Move summary table to the top
|
||||
}
|
||||
});
|
||||
|
||||
policyJson.slice().reverse().forEach(childTable => {
|
||||
generateTable(parentDiv, true, policyName, childTable);
|
||||
});
|
||||
|
||||
|
||||
moveSummaryTableToTop(policyName);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function moveSummaryTableToTop(policyName) {
|
||||
|
||||
let parentDiv = document.querySelector(`div[data-parent-row="${policyName}"]`);
|
||||
if (!parentDiv) return; // Exit if no such div exists
|
||||
|
||||
let tables = Array.from(parentDiv.querySelectorAll("table"));
|
||||
|
||||
tables.forEach(table => {
|
||||
if (table.id.includes("summary")) {
|
||||
parentDiv.prepend(table); // Move summary table to the top
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<!-- Export Excel and Mail Script -->
|
||||
<script>
|
||||
|
||||
var proposalDataForDropDown = {};
|
||||
|
||||
const editorConfig = {
|
||||
buttons: [
|
||||
"bold",
|
||||
"italic",
|
||||
"strikethrough",
|
||||
"|",
|
||||
"superscript",
|
||||
"subscript",
|
||||
"|",
|
||||
"align",
|
||||
"fontsize",
|
||||
"|",
|
||||
"bold",
|
||||
"italic",
|
||||
"strikethrough",
|
||||
"|",
|
||||
"superscript",
|
||||
"subscript",
|
||||
"|",
|
||||
"align",
|
||||
"fontsize",
|
||||
"|",
|
||||
"source" // Add the "source" button for editing HTML
|
||||
],
|
||||
fontsize: ["8px", "10px", "12px", "14px", "16px", "18px", "20px", "22px", "24px"], // Font sizes in pixels
|
||||
@ -2946,7 +3086,7 @@
|
||||
placeholder: "Start typing here...", // Optional placeholder text
|
||||
};
|
||||
|
||||
$(document).ready(function(){
|
||||
$(document).ready(function() {
|
||||
|
||||
const path = window.location.pathname; // Get the current URL path
|
||||
const segments = path.split('/'); // Split the path into segments
|
||||
@ -2958,7 +3098,7 @@
|
||||
|
||||
let excel_url = '<?= base_url('leads/exportQCRandRFQ/') ?>' + lead_id + '/' + rfq_type + '/' + 2
|
||||
console.log(excel_url, excel_url);
|
||||
|
||||
|
||||
$('#submitExcel').attr('data-url', excel_url);
|
||||
|
||||
$('#cc').select2({
|
||||
@ -2989,10 +3129,10 @@
|
||||
|
||||
if (placementLeadData) {
|
||||
placementLeadData = JSON.parse(placementLeadData);
|
||||
let txt = 'The data has already been sent to the insurer '
|
||||
+ placementLeadData.insurer_name
|
||||
+ ' and the proposal is '
|
||||
+ placementLeadData.proposel_name + '.';
|
||||
let txt = 'The data has already been sent to the insurer ' +
|
||||
placementLeadData.insurer_name +
|
||||
' and the proposal is ' +
|
||||
placementLeadData.proposel_name + '.';
|
||||
$('#alert_msg').text(txt);
|
||||
} else {
|
||||
$('#alert_msg').text('');
|
||||
@ -3013,34 +3153,34 @@
|
||||
|
||||
})
|
||||
|
||||
function checkTheTableDataChanged(redirect_type){
|
||||
function checkTheTableDataChanged(redirect_type) {
|
||||
|
||||
|
||||
if(redirect_type == 1){
|
||||
if (redirect_type == 1) {
|
||||
//BACK BUTTON
|
||||
window.location.href="<?= base_url("leads/list")?>"
|
||||
window.location.href = "<?= base_url("leads/list") ?>"
|
||||
|
||||
}else if(redirect_type == 2){
|
||||
} else if (redirect_type == 2) {
|
||||
//EXCEL EXPORT
|
||||
let url = $('#submitExcel').data('url');
|
||||
window.location.href = url;
|
||||
|
||||
}else if(redirect_type == 3){
|
||||
} else if (redirect_type == 3) {
|
||||
//INSURER OR CLIENT MAIL SEND
|
||||
showModal(1);
|
||||
|
||||
}else if(redirect_type == 4){
|
||||
} else if (redirect_type == 4) {
|
||||
//INTERNAL MAIL SEND
|
||||
showModal(2);
|
||||
|
||||
}else if(redirect_type == 5){
|
||||
} else if (redirect_type == 5) {
|
||||
//PROCCED TO QCR
|
||||
// submitQCRData();
|
||||
let lead_id = $('#lead_id').val();
|
||||
let url = '<?= base_url('rfq/list/') ?>' + lead_id + '/' + 2;
|
||||
window.location.href = url;
|
||||
|
||||
}else if(redirect_type == 6){
|
||||
} else if (redirect_type == 6) {
|
||||
//INTERNAL MAIL SEND
|
||||
showModal(3);
|
||||
|
||||
@ -3049,18 +3189,18 @@
|
||||
|
||||
function showModal(mail_type) {
|
||||
|
||||
if(mail_type == 1){
|
||||
if (mail_type == 1) {
|
||||
|
||||
insurerAndClientMailPopUp()
|
||||
|
||||
}else if(mail_type == 2){
|
||||
} else if (mail_type == 2) {
|
||||
|
||||
var myModal = new bootstrap.Modal(document.getElementById('internal_mail_modal'));
|
||||
myModal.show();
|
||||
|
||||
// getMailContent('internal_mail_content');
|
||||
|
||||
}else if(mail_type == 3){
|
||||
} else if (mail_type == 3) {
|
||||
|
||||
placementMailPopUp()
|
||||
// getMailContent('placement_mail_content');
|
||||
@ -3069,7 +3209,7 @@
|
||||
|
||||
}
|
||||
|
||||
function insurerAndClientMailPopUp(){
|
||||
function insurerAndClientMailPopUp() {
|
||||
|
||||
var url = '';
|
||||
var lead_id = $('#lead_id').val();
|
||||
@ -3164,7 +3304,7 @@
|
||||
`;
|
||||
}
|
||||
|
||||
if(user_role_id == 1 || user_role_id == 5){
|
||||
if (user_role_id == 1 || user_role_id == 5) {
|
||||
|
||||
html += `
|
||||
|
||||
@ -3173,8 +3313,8 @@
|
||||
<select class="form-control" id="client_cc" name="client_cc" required multiple>
|
||||
<?php if (isset($userList)) { ?>
|
||||
<?php foreach ($userList as $user) { ?>
|
||||
<option value="<?= $user['id'];?>">
|
||||
<?= $user['first_name'].' - '.$user['email'];?>
|
||||
<option value="<?= $user['id']; ?>">
|
||||
<?= $user['first_name'] . ' - ' . $user['email']; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
@ -3186,8 +3326,8 @@
|
||||
<select class="form-control" id="client_bcc" name="client_bcc" required multiple>
|
||||
<?php if (isset($userList)) { ?>
|
||||
<?php foreach ($userList as $user) { ?>
|
||||
<option value="<?= $user['id'];?>">
|
||||
<?= $user['first_name'].' - '.$user['email'];?>
|
||||
<option value="<?= $user['id']; ?>">
|
||||
<?= $user['first_name'] . ' - ' . $user['email']; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
@ -3235,8 +3375,8 @@
|
||||
<select class="form-control" id="client_cc" name="client_cc" required multiple>
|
||||
<?php if (isset($userList)) { ?>
|
||||
<?php foreach ($userList as $user) { ?>
|
||||
<option value="<?= $user['id'];?>">
|
||||
<?= $user['first_name'].' - '.$user['email'];?>
|
||||
<option value="<?= $user['id']; ?>">
|
||||
<?= $user['first_name'] . ' - ' . $user['email']; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
@ -3248,8 +3388,8 @@
|
||||
<select class="form-control" id="client_bcc" name="client_bcc" required multiple>
|
||||
<?php if (isset($userList)) { ?>
|
||||
<?php foreach ($userList as $user) { ?>
|
||||
<option value="<?= $user['id'];?>">
|
||||
<?= $user['first_name'].' - '.$user['email'];?>
|
||||
<option value="<?= $user['id']; ?>">
|
||||
<?= $user['first_name'] . ' - ' . $user['email']; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
@ -3271,7 +3411,7 @@
|
||||
<label for="insurer_and_client_mail_content">Mail Content</label>
|
||||
<textarea id="insurer_and_client_mail_content" class="form-control" name="insurer_and_client_mail_content" rows="3"><?= isset($mail_content) ? $mail_content : " " ?></textarea>
|
||||
</div>
|
||||
`;
|
||||
`;
|
||||
|
||||
$('#input_for_row').append(html);
|
||||
|
||||
@ -3310,11 +3450,11 @@
|
||||
|
||||
function constructURL(url_type) {
|
||||
|
||||
if(url_type == 1){
|
||||
if (url_type == 1) {
|
||||
constructURL_ForInsurerAndClientMailSend()
|
||||
}else if(url_type == 2){
|
||||
} else if (url_type == 2) {
|
||||
constructURL_ForInternalMailSend()
|
||||
}else if(url_type == 3){
|
||||
} else if (url_type == 3) {
|
||||
|
||||
Swal.fire({
|
||||
title: "Do you want to place the proposal data?",
|
||||
@ -3327,7 +3467,7 @@
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
constructURL_ForPlacementMailSend()
|
||||
}else{
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
@ -3499,19 +3639,19 @@
|
||||
|
||||
$('#to').select2({
|
||||
placeholder: 'Select To Mail',
|
||||
});
|
||||
});
|
||||
$('#cc').val('').select2({
|
||||
placeholder : 'select CC Mail'
|
||||
});
|
||||
placeholder: 'select CC Mail'
|
||||
});
|
||||
// $('#subject').val('');
|
||||
$('#proposals').val('');
|
||||
$('#proposals').val('');
|
||||
$('#placement_to').val('').select2({
|
||||
placeholder : 'select To Mail'
|
||||
});
|
||||
placeholder: 'select To Mail'
|
||||
});
|
||||
$('#placement_cc').val('').select2({
|
||||
placeholder : 'select CC Mail'
|
||||
});
|
||||
$('#placement_subject').val('');
|
||||
placeholder: 'select CC Mail'
|
||||
});
|
||||
$('#placement_subject').val('');
|
||||
|
||||
$("textarea.select2-search__field").attr('rows', '1');
|
||||
$("textarea.select2-search__field").css('resize', 'none');
|
||||
@ -3521,7 +3661,7 @@
|
||||
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
|
||||
}
|
||||
|
||||
function getInsurerBranchContacts(input){
|
||||
function getInsurerBranchContacts(input) {
|
||||
|
||||
let insurer_and_branch = $(input).val();
|
||||
console.log('insurer_and_branch', insurer_and_branch);
|
||||
@ -3537,9 +3677,9 @@
|
||||
console.log(res)
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
if(res.status == false){
|
||||
if (res.status == false) {
|
||||
toastr.warning(res.message, 'WARNING')
|
||||
}else{
|
||||
} else {
|
||||
appendInsurerContact(res.data)
|
||||
}
|
||||
},
|
||||
@ -3565,33 +3705,53 @@
|
||||
$.each(data, function(index, item) {
|
||||
var option = $('<option>', {
|
||||
value: item.id,
|
||||
text: item.contact_person_email
|
||||
text: item.contact_person_email
|
||||
});
|
||||
$('#placement_to').append(option);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$('.close').click(function(){
|
||||
$('.close').click(function() {
|
||||
|
||||
$('#to').select2({
|
||||
placeholder: 'Select To Mail',
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$('#cc').val('').select2({
|
||||
placeholder : 'select CC Mail'
|
||||
});
|
||||
placeholder: 'select CC Mail'
|
||||
});
|
||||
// $('#subject').val('');
|
||||
$('#proposals').val('');
|
||||
$('#proposals').val('');
|
||||
$('#placement_to').val('').select2({
|
||||
placeholder : 'select To Mail'
|
||||
});
|
||||
placeholder: 'select To Mail'
|
||||
});
|
||||
$('#placement_cc').val('').select2({
|
||||
placeholder : 'select CC Mail'
|
||||
});
|
||||
$('#placement_subject').val('');
|
||||
placeholder: 'select CC Mail'
|
||||
});
|
||||
$('#placement_subject').val('');
|
||||
|
||||
$("textarea.select2-search__field").attr('rows', '1');
|
||||
$("textarea.select2-search__field").css('resize', 'none');
|
||||
})
|
||||
|
||||
|
||||
function addOrRemoveIconInsurer(element, event) {
|
||||
event.stopPropagation(); // Prevent event bubbling
|
||||
|
||||
// Find the button inside the dropdown (or use `element` directly)
|
||||
const stcButton = element.closest('.dropdown-content') ?
|
||||
element.closest('.dropdown-content').querySelector('.sendInsurerClientProposal') :
|
||||
element;
|
||||
|
||||
// Check if the icon already exists
|
||||
let icon = stcButton.querySelector("i.fa-check-square");
|
||||
|
||||
if (icon) {
|
||||
// Remove the icon if it already exists
|
||||
icon.remove();
|
||||
} else {
|
||||
// Create and append the check icon
|
||||
createIcon(stcButton);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user