FEAT_RFQ_NONEB_NEW_CHANGES
This commit is contained in:
parent
b542913153
commit
5828bc707a
@ -100,7 +100,9 @@ class LeadsController extends BaseController
|
||||
$this->issuer = [1 => 'JIBS', 2 => 'Nhance'];
|
||||
$this->clientType = [1 => 'Group', 2 => 'Individual'];
|
||||
$this->leadType = [1 => 'Fresh', 2 => 'Renewal', 3 => 'Roll Over'];
|
||||
$this->buisnessType = [1 => 'Industrial', 2 => 'Non Industrial'];
|
||||
$data = $this->kycEntityTypeModel->where('is_active', 1)->findAll();
|
||||
$this->buisnessType = array_column($data, 'name', 'id');
|
||||
// $this->buisnessType = [1 => 'Public Sector', 2 => 'Private Sector',3=> 'Trust',4 => 'Proprietorship',5 => 'Partnership',6 => 'Private',7 => 'Individual'];
|
||||
$this->leadsStatus = [
|
||||
'queued' => 'In-Queued',
|
||||
'qcr_sent' => 'QCR sent',
|
||||
@ -730,9 +732,11 @@ class LeadsController extends BaseController
|
||||
$data['product'] = $this->leadsModel->select("policy_type.policy_type")->join('policy_type', 'leads.policy_type_id = policy_type.id')->where('leads.id', $id)->first()['policy_type'];
|
||||
// $data['lead_register_data'] = json_decode($data['lead_data']['custom_fields']);
|
||||
// dd($data['lead_register_data']);
|
||||
// $data['entity_type'] = $this->kycEntityTypeModel->where('is_active', 1)->findAll();
|
||||
$data['buisness_type'] = $this->buisnessType;
|
||||
|
||||
// dd($data);
|
||||
$data['client_type'] = $this->clientType;
|
||||
$data['buisness_type'] = $this->buisnessType;
|
||||
$this->loadLayout('view_rfq_non_eb', $data);
|
||||
}
|
||||
}
|
||||
@ -2076,6 +2080,7 @@ class LeadsController extends BaseController
|
||||
->where('leads.id', $lead_id)
|
||||
->first();
|
||||
|
||||
// log_message('error', 'Lead Data' . json_encode($lead_data));
|
||||
// print_r($lead_data ); die;
|
||||
|
||||
$cc_mails = [];
|
||||
@ -2236,9 +2241,9 @@ class LeadsController extends BaseController
|
||||
foreach ($recipient_data as $recipient) {
|
||||
|
||||
$message = $original_message;
|
||||
$message = str_replace("{{RECIPIENT_NAME}}", $recipient['name'], $message);
|
||||
$message = str_replace("{{CLIENT_NAME}}", $lead_data['client_name'], $message);
|
||||
$message = str_replace("{{POLICY_LONG_NAME}}", $lead_data['long_name'], $message);
|
||||
$message = str_replace("{{RECIPIENT_NAME}}", $recipient['name'] != "" ? $recipient['name'] :" ", $message);
|
||||
$message = str_replace("{{CLIENT_NAME}}", $lead_data['client_name'] != "" ? $lead_data['client_name'] : "", $message);
|
||||
$message = str_replace("{{POLICY_LONG_NAME}}",$lead_data['long_name'] != ""? $lead_data['long_name'] : "", $message);
|
||||
$message = str_replace("{{POLICY_START_DATE}}", change_date_format($lead_data['policy_start_date'], 'Y-m-d', 'd-m-Y'), $message);
|
||||
$message = str_replace("{{DURATION}}", calculate_days_bw_dates($lead_data['policy_end_date'] ?? "", $lead_data['policy_start_date'] ?? "")->days, $message) ?? '--';
|
||||
|
||||
@ -2809,7 +2814,7 @@ class LeadsController extends BaseController
|
||||
$value = $cellData['display_content'] ?? '';
|
||||
|
||||
// Skip unwanted keys
|
||||
if (in_array($parentth, ['SNO', 'Particulars', 'Action']) || $subth === 'Quote Asked') {
|
||||
if (in_array($parentth, ['SNO', 'Particulars', 'Action']) || $subth === 'Sum Insured' || $subth === 'Fidelity Limit') {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -3217,11 +3222,11 @@ class LeadsController extends BaseController
|
||||
$sheet->getColumnDimension('B')->setWidth($maxWidthA * 1.2);
|
||||
$sheet->getColumnDimension('C')->setWidth($maxWidthB * 1.2);
|
||||
|
||||
$rowNumber += 2;
|
||||
$rowNumber += 1;
|
||||
//Policy Registration
|
||||
if (!empty($policy_registration_data)) {
|
||||
foreach ($policy_registration_data as $key => $value) {
|
||||
|
||||
// kint::dump($value);
|
||||
$startRow = $rowNumber; // Track where the block starts
|
||||
|
||||
// Title Row
|
||||
@ -3308,6 +3313,24 @@ class LeadsController extends BaseController
|
||||
$rowNumber++;
|
||||
}
|
||||
|
||||
if (isset($value['policyDetails']) && !empty($value['policyDetails'])) {
|
||||
// Type of Business
|
||||
$sheet->mergeCells("A{$rowNumber}:B{$rowNumber}");
|
||||
$sheet->setCellValue("A{$rowNumber}", "Terrorism");
|
||||
$sheet->setCellValue("C{$rowNumber}", ucfirst($value['policyDetails']['terrorism'] ?? 'No'));
|
||||
|
||||
$sheet->getStyle("A{$rowNumber}")->applyFromArray([
|
||||
'font' => ['bold' => true],
|
||||
'alignment' => [
|
||||
'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
|
||||
'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER,
|
||||
],
|
||||
]);
|
||||
|
||||
$rowNumber++;
|
||||
|
||||
}
|
||||
|
||||
$endRow = $rowNumber - 1; // Block ends at previous row
|
||||
|
||||
// Apply border to the whole block
|
||||
@ -3320,8 +3343,9 @@ class LeadsController extends BaseController
|
||||
],
|
||||
]);
|
||||
|
||||
$rowNumber += 2; // Add space before the next block
|
||||
$rowNumber += 1; // Add space before the next block
|
||||
}
|
||||
// die();
|
||||
}
|
||||
|
||||
//Table Data
|
||||
@ -3425,6 +3449,18 @@ class LeadsController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
// For the subheader row, merge B and C and set the value
|
||||
$sheet->setCellValue("B{$subHeaderRow}", "Sum Insured");
|
||||
$sheet->mergeCells("B{$subHeaderRow}:C{$subHeaderRow}");
|
||||
$sheet->getStyle("B{$subHeaderRow}:C{$subHeaderRow}")->applyFromArray([
|
||||
'font' => ['bold' => true],
|
||||
'alignment' => [
|
||||
'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
|
||||
'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER,
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
// Apply border to the header range
|
||||
$prevColumn4 = $this->getPreviousColumn($columnLetter);
|
||||
$headerRange = "A{$rowNumber}:" . "{$prevColumn4}" . "{$subHeaderRow}";
|
||||
@ -3441,7 +3477,9 @@ class LeadsController extends BaseController
|
||||
$sheet->getRowDimension($rowNumber)->setRowHeight(25); // Header row height
|
||||
$sheet->getRowDimension($subHeaderRow)->setRowHeight(20); // Subheader row height
|
||||
|
||||
$rowNumber = $subHeaderRow + 2;
|
||||
// $rowNumber = $subHeaderRow + 2;
|
||||
$rowNumber = $subHeaderRow + 1;
|
||||
|
||||
$column_data = $data['table_data']['data'];
|
||||
// dd($column_data);
|
||||
$serial_no = 1;
|
||||
@ -3729,7 +3767,7 @@ class LeadsController extends BaseController
|
||||
$row['data'] = array_filter(
|
||||
$row['data'],
|
||||
function ($item) {
|
||||
return in_array($item['subth'], ['Quote asked', '-']);
|
||||
return in_array($item['subth'], ['Sum Insured', '-',"Liability Limit"]);
|
||||
}
|
||||
);
|
||||
|
||||
@ -3818,7 +3856,7 @@ class LeadsController extends BaseController
|
||||
if ($subHeader === $insurer) {
|
||||
$headerData[] = [
|
||||
'parentHeader' => $header['parentHeader'],
|
||||
'subHeaders' => ['Quote asked', $subHeader]
|
||||
'subHeaders' => ['Sum Insured', $subHeader]
|
||||
];
|
||||
break 2; // Exit both loops after match is found
|
||||
}
|
||||
@ -3851,8 +3889,8 @@ class LeadsController extends BaseController
|
||||
$filteredData[] = $item;
|
||||
}
|
||||
|
||||
// Include Proposal with Quote Asked
|
||||
if ($item['parentth'] === $proposal && $item['subth'] === "Quote asked") {
|
||||
// Include Proposal with Sum Insured
|
||||
if ($item['parentth'] === $proposal && ($item['subth'] === "Sum Insured" || $item['subth'] === "Liability Limit")) {
|
||||
$filteredData[] = $item;
|
||||
}
|
||||
|
||||
|
||||
@ -884,7 +884,7 @@
|
||||
<?php
|
||||
if (isset($policy_type) && count($policy_type)) {
|
||||
foreach ($policy_type as $value) {
|
||||
if ($value['allocg'] != "Non-EB") {
|
||||
if ($value['allocg'] != "Non-EB" && $value['allocg'] != "Marine") {
|
||||
echo "<option value='" . $value['id'] . "'>" . $value['policy_type'] . "</option>";
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,11 +217,11 @@
|
||||
<div class="text-right">
|
||||
<button type="submit" id="riskSplitup" class="btn btn-primary">Validate and Add Risk Split up</button>
|
||||
</div>
|
||||
<div class="row">
|
||||
<!-- <div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<button type="submit" id="submitPolicyRisk" class="btn btn-primary">Submit For Validation</button>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@ -579,11 +579,12 @@
|
||||
policyRiskAddress = groupedData;
|
||||
console.log("Grouped Data as Objects: ", policyRiskAddress);
|
||||
|
||||
if (productSelectionData.singleProduct == 'on') {
|
||||
savePolicyDataLocal();
|
||||
} else {
|
||||
// if (productSelectionData.singleProduct == 'on') {
|
||||
// savePolicyDataLocal();
|
||||
// } else {
|
||||
riskSplitup();
|
||||
}
|
||||
// }
|
||||
|
||||
});
|
||||
|
||||
$("#policyDetailsForm").submit(function(event) {
|
||||
@ -652,6 +653,14 @@
|
||||
hideAndShowBurglary();
|
||||
})
|
||||
|
||||
}else{
|
||||
// alert("you got ir");
|
||||
policyRiskAddress.forEach(function() {
|
||||
// console.log("increment count is ", increment2)
|
||||
addHTMLInputForRiskSplitUP();
|
||||
validatePolicyBasedOnProductSelection();
|
||||
hideAndShowBurglary();
|
||||
})
|
||||
}
|
||||
} else {
|
||||
if (contianertoCheck.innerHTML == "") {
|
||||
@ -713,23 +722,23 @@
|
||||
<div class = "row">
|
||||
<div class="form-group col-md-4 multi_location_company">
|
||||
<label for="building_${increment2}">Building</label>
|
||||
<input type="text" id="building_${increment2}" name="building[]" class="form-control multi_location_company " />
|
||||
<input type="number" id="building_${increment2}" name="building[]" class="form-control multi_location_company " />
|
||||
</div>
|
||||
<div class="form-group col-md-4 multi_location_company ">
|
||||
<div class="form-group col-md-4 multi_location_company ">
|
||||
<label for="content_${increment2}">Content</label>
|
||||
<input type="text" id="content_${increment2}" name="content[]" class="form-control multi_location_company " />
|
||||
<input type="number" id="content_${increment2}" name="content[]" class="form-control multi_location_company " />
|
||||
</div>
|
||||
<div class="form-group col-md-4 multi_location_company ">
|
||||
<label for="furniture_${increment2}">Furniture/Office Equipment</label>
|
||||
<input type="text" id="furniture_${increment2}" name="furniture[]" class="form-control multi_location_company " />
|
||||
<input type="number" id="furniture_${increment2}" name="furniture[]" class="form-control multi_location_company " />
|
||||
</div>
|
||||
<div class="form-group col-md-4 multi_location_company ">
|
||||
<label for="plantAndMachinery_${increment2}">Plant and Machinery</label>
|
||||
<input type="text" id="plantAndMachinery_${increment2}" name="plant_and_machinery[]" class="form-control multi_location_company " />
|
||||
<input type="number" id="plantAndMachinery_${increment2}" name="plant_and_machinery[]" class="form-control multi_location_company " />
|
||||
</div>
|
||||
<div class="form-group col-md-4 multi_location_company">
|
||||
<label for="electricalFittings_${increment2}">Electrical Fittings</label>
|
||||
<input type="text" id="electricalFittings_${increment2}" name="electrical_fittings[]" class="form-control multi_location_company "/>
|
||||
<input type="number" id="electricalFittings_${increment2}" name="electrical_fittings[]" class="form-control multi_location_company "/>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
@ -872,7 +881,7 @@
|
||||
|
||||
<div class="dt-switch-wrapper col-md-4 common_location_occupancy d-flex align-items-center">
|
||||
<div class="custom-control custom-switch d-flex justify-content-center">
|
||||
<input type="checkbox" class="custom-control-input" id="isBasement_${increment}" onchange="hideShowBasement(${increment})">
|
||||
<input type="checkbox" class="custom-control-input" id="isBasement_${increment}" onchange="hideShowBasement(this)">
|
||||
<label class="custom-control-label" for="isBasement_${increment}">Basement</label>
|
||||
</div>
|
||||
</div>
|
||||
@ -920,26 +929,13 @@
|
||||
|
||||
`;
|
||||
|
||||
// newRow2.innerHTML += `
|
||||
// <div class = "row">
|
||||
// <div class="col-md-12 text-right">
|
||||
// <button type ="submit" id="riskSplitup" class="btn btn-primary">Validate and Add Risk Split up</button>
|
||||
// </div>
|
||||
// </div>
|
||||
// <div class = "row">
|
||||
// <div class="col-md-12 text-right">
|
||||
// <button type ="submit" id="submitPolicyRisk" class="btn btn-primary">Submit For Validation</button>
|
||||
// </div>
|
||||
// </div>
|
||||
|
||||
// `;
|
||||
|
||||
container.appendChild(newRow);
|
||||
// container.appendChild(newRow2);
|
||||
|
||||
const selectElement = document.getElementById(`select_location_${increment}`);
|
||||
selectElement.innerHTML = "";
|
||||
for (let i = 1; i <= policyDetailsData.location_no; i++) {
|
||||
console.log("location no : ", policyDetailsData.location_no);
|
||||
const option = document.createElement('option');
|
||||
option.value = `Location ${i}`;
|
||||
option.textContent = `Location ${i}`;
|
||||
@ -957,37 +953,33 @@
|
||||
});
|
||||
|
||||
|
||||
$(document).on('click', '.duplicate-btn', function() {
|
||||
|
||||
|
||||
// console.log("button is clicked");
|
||||
// console.log("increment cout ", increment);
|
||||
|
||||
$(document).on('click', '.duplicate-btn', function () {
|
||||
|
||||
if (policyDetailsData.location_no >= increment) {
|
||||
const $rowToClone = $(this).closest('.form-row');
|
||||
|
||||
// Destroy Select2 for the current and previous occupancy fields
|
||||
$(`#occupancy_${increment}`).select2('destroy');
|
||||
$(`#occupancy_${increment - 1}`).select2('destroy');
|
||||
|
||||
// Clone the row
|
||||
const $clone = $rowToClone.clone();
|
||||
|
||||
$clone.find('.select2-hidden-accessible').each(function() {
|
||||
// Clean up select2 artifacts from the clone
|
||||
$clone.find('.select2-hidden-accessible').each(function () {
|
||||
$(this).select2('destroy');
|
||||
});
|
||||
|
||||
$clone.find('.select2-container').remove();
|
||||
|
||||
// Increment the counter
|
||||
|
||||
|
||||
// Update all IDs and reset values in the clone
|
||||
$clone.find('[id]').each(function() {
|
||||
// Update all IDs in the clone
|
||||
$clone.find('[id]').each(function () {
|
||||
const oldId = $(this).attr('id');
|
||||
const newId = oldId.replace(/_(\d+)$/, `_${increment}`);
|
||||
$(this).attr('id', newId);
|
||||
});
|
||||
|
||||
// Update labels to match new IDs
|
||||
$clone.find('label').each(function() {
|
||||
// Update all labels
|
||||
$clone.find('label').each(function () {
|
||||
const oldFor = $(this).attr('for');
|
||||
if (oldFor) {
|
||||
const newFor = oldFor.replace(/_(\d+)$/, `_${increment}`);
|
||||
@ -998,18 +990,35 @@
|
||||
// Insert the cloned row after the original
|
||||
$clone.insertAfter($rowToClone);
|
||||
|
||||
let selectedLocation = $(`#select_location_${increment}`).val();
|
||||
$(`#select_location_${increment} option[value="${selectedLocation}"]`).remove();
|
||||
$(`#occupancy_${increment}`).select2();
|
||||
// Refill and update the select_location dropdown
|
||||
const selectElement = document.getElementById(`select_location_${increment}`);
|
||||
selectElement.innerHTML = "";
|
||||
for (let i = 1; i <= policyDetailsData.location_no; i++) {
|
||||
const option = document.createElement('option');
|
||||
option.value = `Location ${i}`;
|
||||
option.textContent = `Location ${i}`;
|
||||
selectElement.appendChild(option);
|
||||
}
|
||||
|
||||
for (let i = 1;i<increment;i++){
|
||||
|
||||
let selectedLocation = $(`#select_location_${i}`).val();
|
||||
$(`#select_location_${increment} option[value="${selectedLocation}"]`).remove();
|
||||
|
||||
}
|
||||
|
||||
// Re-initialize Select2 for both fields
|
||||
$(`#occupancy_${increment - 1}`).select2(); // previous
|
||||
$(`#occupancy_${increment}`).select2(); // current
|
||||
$(`#iibCode_${increment}`).val(""); // current
|
||||
increment++;
|
||||
|
||||
} else {
|
||||
toastr.error("Maximum no of allowed locations reached", "Error")
|
||||
toastr.error("Maximum number of allowed locations reached", "Error");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
})
|
||||
|
||||
function addOrRemoveAdd() {
|
||||
// console.log("chceck box clicked");
|
||||
if ($("#sameAsCommunicationAddress").is(":checked")) {
|
||||
@ -1039,10 +1048,10 @@
|
||||
$('[id^="select_location"]').hide().prev('label').hide();
|
||||
$("[id^='select_location']").removeAttr('required', false);
|
||||
// $('[class*="single_location_occupancy"]').hide().removeAttr("required", false);
|
||||
$('[class*="multi_location_company"]').hide().removeAttr('required');
|
||||
$("#riskSplitup").hide();
|
||||
// $('[class*="multi_location_company"]').hide().removeAttr('required');
|
||||
// $("#riskSplitup").hide();
|
||||
$("#submitPolicyRisk").show();
|
||||
$("#risksplitupTab").hide();
|
||||
// $("#risksplitupTab").hide();
|
||||
// $('[class*="multiLocationOccupancy"]').hide().removeAttr('required', false);
|
||||
// $('[class*="multiLocationOccupancyWithoutFloater"]').hide().removeAttr('required', false);
|
||||
|
||||
@ -1155,6 +1164,8 @@
|
||||
}
|
||||
|
||||
function savePolicyDataLocal() {
|
||||
|
||||
isSaved = false;
|
||||
// Generate the JSON structure using the registerPolicyData function
|
||||
var policyData = registerPolicyData();
|
||||
|
||||
@ -1187,6 +1198,7 @@
|
||||
$('.loader-mask').fadeIn();
|
||||
toastr.success("Policy Information Collected ", "SUCCESS");
|
||||
closeModal();
|
||||
changeTerrorism(Number($("#policySI").val()));
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
// console.log("Updated policy data in localStorage:", existingData);
|
||||
@ -1386,6 +1398,7 @@
|
||||
var mobile = <?= isset($lead_data['contact_person_mobile']) ? $lead_data['contact_person_mobile'] : "" ?>;
|
||||
var contact_email = "<?= isset($lead_data['contact_person_email']) ? $lead_data['contact_person_email'] : "" ?>";
|
||||
var panNo = <?= isset($lead_data['client_type']) ? $lead_data['client_type'] : "" ?>;
|
||||
var buisnessType = <?= isset($lead_data['entity_type_id']) ? $lead_data['entity_type_id'] : "" ?>;
|
||||
// console.log("client_type : ".client_type);
|
||||
if (lead_data) {
|
||||
// lead_data = JSON.parse(lead_data);
|
||||
@ -1407,11 +1420,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$("#client_type").val(client_type).trigger("change");
|
||||
$("#insured_name").val(clientName);
|
||||
$("#address1").val(lead_data.address);
|
||||
$("#pin_code").val(lead_data.pincode);
|
||||
$("#mobile").val(mobile);
|
||||
$("#email").val(contact_email);
|
||||
console.log("buisness type : ", buisnessType);
|
||||
$("#type_of_buisness").val(buisnessType);
|
||||
// var policy_type = lead_data.policy_type_id;
|
||||
}
|
||||
}
|
||||
@ -1544,23 +1561,26 @@
|
||||
}
|
||||
|
||||
|
||||
function hideShowBasement(incrementFromBasement) {
|
||||
let isBasement = $(`#isBasement_${incrementFromBasement}`).is(":checked");
|
||||
function hideShowBasement(element) {
|
||||
let elementID = element.id;
|
||||
let increment = elementID.split("_").pop();
|
||||
|
||||
let isBasement = $(`#isBasement_${increment}`).is(":checked");
|
||||
|
||||
// Get the label associated with the input
|
||||
let label = $(`label[for='basementSI_${incrementFromBasement}']`);
|
||||
let label = $(`label[for='basementSI_${increment}']`);
|
||||
|
||||
if (isBasement) {
|
||||
$(`#basementSI_${incrementFromBasement}`).parent().show();
|
||||
$(`#basementSI_${incrementFromBasement}`).prop("required", "required");
|
||||
$(`#basementSI_${increment}`).parent().show();
|
||||
$(`#basementSI_${increment}`).prop("required", "required");
|
||||
|
||||
// Add * if not already there
|
||||
if (label.find(".text-danger").length === 0) {
|
||||
label.append('<span class="text-danger">*</span>');
|
||||
}
|
||||
} else {
|
||||
$(`#basementSI_${incrementFromBasement}`).parent().hide();
|
||||
$(`#basementSI_${incrementFromBasement}`).removeAttr("required");
|
||||
$(`#basementSI_${increment}`).parent().hide();
|
||||
$(`#basementSI_${increment}`).removeAttr("required");
|
||||
|
||||
// Remove * if exists
|
||||
label.find(".text-danger").remove();
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<?php foreach ($multi_file_data as $file) : ?>
|
||||
<div class="form-check">
|
||||
|
||||
<input type="checkbox" class="form-check-input multi_file_attachment" id="file_<?= $file['id'] ?>" name="selected_attachment_files[]" value="<?= $file['id'] ?>" checked>
|
||||
<input type="checkbox" class="form-check-input multi_file_attachment" id="file_<?= $file['id'] ?>" name="selected_attachment_files[]" value="<?= $file['id'] ?>">
|
||||
<label class="form-check-label" for="file_<?= $file['id'] ?>">
|
||||
<?= htmlspecialchars($file['docs_name']) ?> - <?= htmlspecialchars($file['file_name']) ?>
|
||||
</label>
|
||||
|
||||
@ -20,7 +20,11 @@
|
||||
</div>
|
||||
|
||||
<!-- Address -->
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Address</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
|
||||
</div>
|
||||
|
||||
@ -20,7 +20,11 @@
|
||||
</div>
|
||||
|
||||
<!-- Address -->
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Address</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
|
||||
</div>
|
||||
|
||||
@ -20,7 +20,11 @@
|
||||
</div>
|
||||
|
||||
<!-- Address -->
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Address</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
|
||||
</div>
|
||||
|
||||
@ -68,7 +68,11 @@
|
||||
</div>
|
||||
|
||||
<!-- Address -->
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Address:</label>
|
||||
<textarea class="form-control" id="address" name="address"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
|
||||
</div>
|
||||
|
||||
@ -81,7 +81,11 @@
|
||||
</div>
|
||||
|
||||
<!-- Communication Address -->
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Communication Address</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
|
||||
</div>
|
||||
|
||||
@ -68,7 +68,11 @@
|
||||
</div>
|
||||
|
||||
<!-- Address -->
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Address</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
|
||||
</div>
|
||||
|
||||
@ -14,7 +14,11 @@
|
||||
</div>
|
||||
|
||||
<!-- Address of the Insured -->
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Address of the Insured</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
|
||||
</div>
|
||||
|
||||
@ -35,7 +35,11 @@
|
||||
</div>
|
||||
|
||||
<!-- Address of the Insured -->
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Address of the Insured</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
|
||||
</div>
|
||||
|
||||
@ -35,7 +35,11 @@
|
||||
</div>
|
||||
|
||||
<!-- Address of the Insured -->
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Address of the Insured</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="1"></textarea>
|
||||
</div>
|
||||
|
||||
@ -178,7 +178,11 @@
|
||||
</div>
|
||||
|
||||
<!-- Address -->
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Address</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="1">value="<?= isset($lead_edit_data['address']) ? $lead_edit_data['address'] : '' ?>"</textarea>
|
||||
</div>
|
||||
|
||||
@ -67,7 +67,11 @@
|
||||
</div>
|
||||
|
||||
<!-- Communication Address -->
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Communication Address</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
|
||||
</div>
|
||||
|
||||
@ -27,6 +27,10 @@
|
||||
</div>
|
||||
|
||||
<!-- Address -->
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="address">Address</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
|
||||
|
||||
@ -35,7 +35,11 @@
|
||||
</div>
|
||||
|
||||
<!-- Communication Address -->
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Communication Address</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
|
||||
</div>
|
||||
|
||||
@ -33,7 +33,11 @@
|
||||
</div>
|
||||
|
||||
<!-- Communication Address -->
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pinCode">Pin Code</label>
|
||||
<input type="text" class="form-control" id="pinCode" name="pincode" value="<?= isset($lead_edit_data['pincode']) ? htmlspecialchars($lead_edit_data['pincode']) : ''; ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="address">Communication Address</label>
|
||||
<textarea class="form-control" id="address" name="address" rows="1"><?= isset($lead_edit_data['address']) ? htmlspecialchars($lead_edit_data['address']) : ''; ?></textarea>
|
||||
</div>
|
||||
|
||||
@ -516,10 +516,13 @@
|
||||
</div><!-- /.modal -->
|
||||
|
||||
<script>
|
||||
|
||||
var isSaved = true;
|
||||
// var randomColor = 'hsl(' + Math.random() * 360 + ', 100%, 93%)';
|
||||
var rfq_data = <?= isset($rfq_data['json']) ? json_encode($rfq_data['json'], JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT) : '""' ?>;
|
||||
rfq_data = rfq_data ? JSON.parse(rfq_data) : {}; // Convert to object if not already
|
||||
|
||||
var policySI = "";
|
||||
var rfq_or_qcr = 1;
|
||||
var proposalDataForDropDown = {};
|
||||
var lead_type = "<?= $lead_data['lead_type'] ?>";
|
||||
@ -547,6 +550,9 @@
|
||||
'insurers': []
|
||||
}
|
||||
};
|
||||
|
||||
var tdChanged = false;
|
||||
var changedNewSI = "";
|
||||
var suggestions = {};
|
||||
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 = {};
|
||||
@ -564,6 +570,7 @@
|
||||
// // console.log("policy summary is set :", !$.isEmptyObject(policySummary) ? "no" : "yes")
|
||||
$(document).ready(function() {
|
||||
myModal = new bootstrap.Modal(document.getElementById('policyRegisterModel'));
|
||||
// monitorTableChanges();
|
||||
});
|
||||
var tableCount = 0;
|
||||
const policies = <?= json_encode($policies) ?>;
|
||||
@ -688,6 +695,7 @@
|
||||
// Remove a proposal column
|
||||
function removeProposal(proposalNumber) {
|
||||
|
||||
isSaved = false;
|
||||
// alert(proposalNumber);
|
||||
var rowIdCount = {};
|
||||
|
||||
@ -801,6 +809,7 @@
|
||||
function addRow(event, element) {
|
||||
|
||||
// // console.log(' event ', element);
|
||||
isSaved = false;
|
||||
const button = event.target;
|
||||
const row = button.closest('tr');
|
||||
const table = row.closest('table');
|
||||
@ -826,6 +835,7 @@
|
||||
|
||||
// Remove a row
|
||||
function removeRow(event) {
|
||||
isSaved = false;
|
||||
const button = event.target;
|
||||
const row = button.closest('tr');
|
||||
const table = row.closest('table');
|
||||
@ -1000,6 +1010,7 @@
|
||||
document.getElementById('addProposal').addEventListener('click', () => {
|
||||
// // console.log("proposal count before ", proposalCount);
|
||||
proposalCount++;
|
||||
isSaved = false;
|
||||
// // console.log("proposal count after ", proposalCount);
|
||||
|
||||
quotesConfig[proposalCount] = ['Sum Insured'];
|
||||
@ -1037,7 +1048,13 @@
|
||||
|
||||
// Add new quote sub-header
|
||||
const newQuoteHeader = document.createElement('th');
|
||||
newQuoteHeader.textContent = 'Sum Insured';
|
||||
if (table.id != "public_liability_addOnCoverage"){
|
||||
|
||||
newQuoteHeader.textContent = 'Sum Insured';
|
||||
|
||||
}else{
|
||||
newQuoteHeader.textContent = "Liability Limit";
|
||||
}
|
||||
newQuoteHeader.style.backgroundColor = randomColor;
|
||||
headerRow2.insertBefore(newQuoteHeader, headerRow2.querySelector('th:last-child'));
|
||||
|
||||
@ -1586,19 +1603,26 @@
|
||||
</th>
|
||||
`).join('')}
|
||||
<th>Action</th>`;
|
||||
|
||||
console.log("quotesConfig",quotesConfig);
|
||||
const headerRow2 = document.createElement('tr');
|
||||
headerRow2.innerHTML = `
|
||||
<th>-</th>
|
||||
<th>-</th>
|
||||
${Object.entries(quotesConfig).flatMap(([proposal, codes]) =>
|
||||
|
||||
${Object.entries(quotesConfig).flatMap(([proposal, codes]) =>
|
||||
// codes.map(code => `
|
||||
// <th data-proposal="${proposal}" data-quote="${code}" class="${code !== 'Sum Insured' && code !== "Liability Limit" ? 'insurer_proposal' : ''}">
|
||||
// ${table.id == "public_liability_addOnCoverage" ? "Liability Limit" : 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('')}
|
||||
codes.map(code => `
|
||||
<th data-proposal="${proposal}" data-quote="${code}" class="${code !== 'Sum Insured' ? '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 data-proposal="${proposal}" data-quote="${code}" class="${code !== 'Sum Insured' && code !== "Liability Limit" ? 'insurer_proposal' : ''}">
|
||||
${table.id == "public_liability_addOnCoverage" ? "Liability Limit" : code}
|
||||
</th>
|
||||
`)
|
||||
).join('')}
|
||||
@ -1724,7 +1748,7 @@
|
||||
let subHeaderText = subHeaderTh ? subHeaderTh.textContent.trim() : '';
|
||||
// // console.log("Subheader th: below code",subHeaderText);
|
||||
// Check if subheader is NOT "Sum Insured"
|
||||
let className = !subHeaderText.startsWith("Sum Insured") && subHeaderText != "-" ?
|
||||
let className = !subHeaderText.startsWith("Sum Insured") && subHeaderText != "-" && !subHeaderText.startsWith("Liability Limit")?
|
||||
"insurer_proposal" : "";
|
||||
// console.log("className", className);
|
||||
// alert(subHeaderText);
|
||||
@ -1776,6 +1800,17 @@
|
||||
tableContainer.appendChild(collapsibleBar);
|
||||
tableContainer.appendChild(tableContent);
|
||||
container.appendChild(tableContainer);
|
||||
monitorTableChanges();
|
||||
|
||||
if (changedNewSI != null && changedNewSI != ""){
|
||||
|
||||
console.log("Changed new SI",changedNewSI);
|
||||
setTimeout(function() {
|
||||
updateAddON(changedNewSI)
|
||||
}, 500);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1827,7 +1862,7 @@
|
||||
|
||||
let subHeaderText = subHeaderTh ? subHeaderTh.textContent.trim() : '';
|
||||
// Check if subheader is NOT "Sum Insured"
|
||||
let className = !subHeaderText.startsWith("Sum Insured") && subHeaderText != "-" ?
|
||||
let className = !subHeaderText.startsWith("Sum Insured") && subHeaderText != "-" && !subHeaderText.startsWith("Liability Limit")?
|
||||
"insurer_proposal" : ""; // alert(subHeaderText);
|
||||
let defaultJsonString = typeof default_answers_array == "object" ? JSON.stringify(default_answers_array[0]) : String(default_answers_array);
|
||||
|
||||
@ -1863,10 +1898,12 @@
|
||||
});
|
||||
moveExcessTableLast();
|
||||
styleTableColumns();
|
||||
monitorTableChanges()
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
// Initialize the parent table
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
@ -1883,6 +1920,7 @@
|
||||
localStorage.setItem('allTablesJsonData', JSON.stringify(rfq_data));
|
||||
jsonToTables();
|
||||
styleTableColumns();
|
||||
monitorTableChanges();
|
||||
proposalDataForDropDown = rfq_data[rfq_data.length - 1].proposal_data;
|
||||
// // console.log("proposalDataForDropDown", proposalDataForDropDown);
|
||||
if (!$.isEmptyObject(storedData)) {
|
||||
@ -2190,6 +2228,7 @@
|
||||
}
|
||||
|
||||
function addOrRemoveIcon(element, event) {
|
||||
isSaved = false;
|
||||
event.stopPropagation();
|
||||
|
||||
// Get the parent dropdown to access both buttons reliably
|
||||
@ -2257,16 +2296,20 @@
|
||||
// // console.log("anchor link clicked ", policyName);
|
||||
|
||||
|
||||
myModal = new bootstrap.Modal(document.getElementById('policyRegisterModel'));
|
||||
myModal = new bootstrap.Modal(document.getElementById('policyRegisterModel'),{
|
||||
backdrop: 'static',
|
||||
keyboard: false
|
||||
});
|
||||
// // console.log("inside if condition");
|
||||
|
||||
var leadID = $("#lead_id").val();
|
||||
let policy = policies.find(p => p.name === policyName);
|
||||
// alert(policy.quote_asked[0]);
|
||||
// var policySI = policies[]
|
||||
|
||||
policySI = rfq_count == 0 && !tdChanged ? policy.quote_asked[0] : (changedNewSI) != "" && changedNewSI != 0? changedNewSI : policy.quote_asked[0];
|
||||
console.log("policy si",policySI,"rfq ount ",rfq_count,"tdchanged ",tdChanged,"changedNewSI",changedNewSI);
|
||||
$("#policyName").val(policyName);
|
||||
$("#policySI").val(policy.quote_asked[0]);
|
||||
$("#policySI").val(policySI);
|
||||
$("#leadID").val(leadID);
|
||||
$("#multilocation_type_div").hide();
|
||||
$('.loader').fadeIn();
|
||||
@ -2296,7 +2339,68 @@
|
||||
|
||||
// Loop through each location and generate the summary rows dynamically
|
||||
for (let i = 0; i < locationCount; i++) {
|
||||
let locationIndex = i + 1; // To make it 1-based instead of 0-based
|
||||
let locationIndex = i + 1;
|
||||
|
||||
let rowContents = [
|
||||
{
|
||||
[`fire_plantMachineries_${locationIndex}`]: {
|
||||
"display_value": "Plant & Machineries and Accessories",
|
||||
"answer_type": "free-text",
|
||||
"default_answer": storedData.locations[i].policyRiskSplitUp?.plant_and_machinery || ""
|
||||
}
|
||||
},
|
||||
{
|
||||
[`fire_electricalFittings_${locationIndex}`]: {
|
||||
"display_value": "Electronic Equipments and Accessories",
|
||||
"answer_type": "free-text",
|
||||
"default_answer": storedData.locations[i].policyRiskSplitUp?.electrical_fittings || ""
|
||||
}
|
||||
},
|
||||
{
|
||||
[`fire_furnitureFittings_${locationIndex}`]: {
|
||||
"display_value": "FFF (Furniture, Fixtures & Fittings)",
|
||||
"answer_type": "free-text",
|
||||
"default_answer": storedData.locations[i].policyRiskSplitUp?.furniture || ""
|
||||
}
|
||||
},
|
||||
{
|
||||
[`fire_content_${locationIndex}`]: {
|
||||
"display_value": "Other Contents Related to Insured",
|
||||
"answer_type": "free-text",
|
||||
"default_answer": storedData.locations[i].policyRiskSplitUp?.content || ""
|
||||
}
|
||||
},
|
||||
{
|
||||
[`fire_content_${locationIndex}`]: {
|
||||
"display_value": "Stock",
|
||||
"answer_type": "free-text",
|
||||
"default_answer": storedData.locations[i].policyRiskSplitUp?.finished_stock || ""
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
// ✅ Keep the structure, add extra only if value is present
|
||||
const riskSplit = storedData.locations[i].policyRiskSplitUp || {};
|
||||
|
||||
if (riskSplit.stock_in_process) {
|
||||
rowContents.push({
|
||||
[`fire_content_${locationIndex}`]: {
|
||||
"display_value": "Stock In Process",
|
||||
"answer_type": "free-text",
|
||||
"default_answer": riskSplit.stock_in_process
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (riskSplit.raw_material) {
|
||||
rowContents.push({
|
||||
[`fire_content_${locationIndex}`]: {
|
||||
"display_value": "Raw Materials",
|
||||
"answer_type": "free-text",
|
||||
"default_answer": riskSplit.raw_material
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
tableRowContent.push({
|
||||
table_type: "new",
|
||||
@ -2306,40 +2410,12 @@
|
||||
storedData.locations[i].policyRisk['occupancy'] + "- " +
|
||||
storedData.locations[i].policyRisk['address1'] + " " +
|
||||
storedData.locations[i].policyRisk['address2'],
|
||||
table_row_contents: [{
|
||||
[`fire_plantMachineries_${locationIndex}`]: {
|
||||
"display_value": "Plant & Machineries and Accessories",
|
||||
"answer_type": "free-text",
|
||||
"default_answer": storedData.locations[i].policyRiskSplitUp?.plantAndMachinery || ""
|
||||
}
|
||||
},
|
||||
{
|
||||
[`fire_electricalFittings_${locationIndex}`]: {
|
||||
"display_value": "Electronic Equipments and Accessories",
|
||||
"answer_type": "free-text",
|
||||
"default_answer": storedData.locations[i].policyRiskSplitUp?.electricalFittings || ""
|
||||
}
|
||||
},
|
||||
{
|
||||
[`fire_furnitureFittings_${locationIndex}`]: {
|
||||
"display_value": "FFF (Furniture, Fixtures & Fittings)",
|
||||
"answer_type": "free-text",
|
||||
"default_answer": storedData.locations[i].policyRiskSplitUp?.furniture || ""
|
||||
}
|
||||
},
|
||||
{
|
||||
[`fire_content_${locationIndex}`]: {
|
||||
"display_value": "Other Contents Related to Insured",
|
||||
"answer_type": "free-text",
|
||||
"default_answer": storedData.locations[i].policyRiskSplitUp?.content || ""
|
||||
}
|
||||
}
|
||||
]
|
||||
table_row_contents: rowContents
|
||||
});
|
||||
}
|
||||
|
||||
var policySummary = tableRowContent;
|
||||
// // console.log("policy summary ", policySummary);
|
||||
console.log("policy summary ", policySummary);
|
||||
return policySummary;
|
||||
}
|
||||
|
||||
@ -2406,6 +2482,8 @@
|
||||
}
|
||||
|
||||
function saveRFQ() {
|
||||
// alert("Function Called");
|
||||
isSaved = true;
|
||||
// // console.log("save button clicked");
|
||||
leadJson = tablesToJson();
|
||||
// // console.log("json from function ", leadJson);
|
||||
@ -2775,8 +2853,13 @@
|
||||
return allTablesData;
|
||||
}
|
||||
|
||||
function openQCR() {
|
||||
async function openQCR() {
|
||||
|
||||
if (!isSaved){
|
||||
const proceed = await confirmUnsavedChanges();
|
||||
// if (!proceed) {}
|
||||
// return;
|
||||
}
|
||||
const url = window.location.pathname; // Get the path (e.g., "/nhance/rfq/list/75/1")
|
||||
const segments = url.split("/"); // Split by "/"
|
||||
segments[segments.length - 1] = "2"; // Change the last segment
|
||||
@ -2987,13 +3070,14 @@
|
||||
|
||||
// Create body
|
||||
const tbody = document.createElement('tbody');
|
||||
var cellCount = 0;
|
||||
tableEntry.table_data.data.forEach((rowData, rowDataIndex) => {
|
||||
const tr = document.createElement('tr');
|
||||
tr.id = rowData.row_id;
|
||||
if (tableEntry.tableId === "excess" && rowData.parentPolicy) {
|
||||
tr.setAttribute('data-excess-row-parent', rowData.parentPolicy);
|
||||
}
|
||||
|
||||
|
||||
// Process each cell
|
||||
rowData.data.forEach((cellData, cellIndex) => {
|
||||
const td = document.createElement(cellIndex === 0 ? 'td' : 'td');
|
||||
@ -3032,19 +3116,28 @@
|
||||
|
||||
if (lead_type == 1){
|
||||
td.onclick = () => getAnswer(table.id, tr.id);
|
||||
if (cellData.subth != "Sum Insured") {
|
||||
if (cellData.subth != "Sum Insured" && cellData.subth != "Liability Limit") {
|
||||
td.onclick = () => getAnswer(table.id, tr.id);
|
||||
td.classList.add("insurer_proposal");
|
||||
}
|
||||
}else{
|
||||
td.onclick = () => getAnswer(table.id, tr.id);
|
||||
if (cellData.subth != "Sum Insured") {
|
||||
if (cellData.subth != "Sum Insured" && cellData.subth != "Liability Limit") {
|
||||
td.onclick = () => getAnswer(table.id, tr.id);
|
||||
td.classList.add("insurer_proposal");
|
||||
}
|
||||
}
|
||||
|
||||
if (cellData.subth == "Sum Insured" && cellData.parentth == "Proposal 1" && table.id == "" && cellCount === 0){
|
||||
console.log("cell count : ",cellCount)
|
||||
changedNewSI = cellData.input_value;
|
||||
console.log("changed new si from jsontotables",changedNewSI);
|
||||
$("#policySI").val(changedNewSI);
|
||||
cellCount = cellCount + 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
td.contentEditable = true;
|
||||
|
||||
@ -3246,8 +3339,8 @@
|
||||
const matchedInsurer = insurers.find(ins => ins.ins_name == subHeader);
|
||||
|
||||
|
||||
if (subHeader != "Sum Insured") {
|
||||
// // console.log("trying to find something : matchedInsurer", matchedInsurer);
|
||||
if (subHeader != "Sum Insured" && subHeader != "Liability Limit") {
|
||||
console.log("trying to find something : matchedInsurer", subHeader);
|
||||
// // console.log("trying to find something :matchedInsurer stc ", matchedInsurer.stc);
|
||||
// // console.log("trying to find something : ", matchedInsurer.stc);
|
||||
|
||||
@ -3656,7 +3749,7 @@
|
||||
subHeaderRow.children("th, td").each(function(actualIndex) {
|
||||
colIndexTracker[visualIndex] = actualIndex;
|
||||
|
||||
if ($(this).text().trim() === "Sum Insured") {
|
||||
if ($(this).text().trim() === "Sum Insured" || $(this).text().trim() === "Liability Limit") {
|
||||
targetColumnIndexes.push(visualIndex);
|
||||
}
|
||||
|
||||
@ -4238,8 +4331,13 @@
|
||||
|
||||
})
|
||||
|
||||
function checkTheTableDataChanged(redirect_type) {
|
||||
async function checkTheTableDataChanged(redirect_type) {
|
||||
|
||||
if (!isSaved){
|
||||
const proceed = await confirmUnsavedChanges();
|
||||
// if (!proceed) {}
|
||||
// return;
|
||||
}
|
||||
|
||||
if (redirect_type == 1) {
|
||||
//BACK BUTTON
|
||||
@ -4868,4 +4966,229 @@
|
||||
createIcon(stcButton);
|
||||
}
|
||||
}
|
||||
|
||||
function monitorTableChanges() {
|
||||
console.log("monitoring table changes");
|
||||
var proposalValue = "";
|
||||
// Get the first table
|
||||
const table = document.querySelector("table");
|
||||
if (!table) return;
|
||||
|
||||
// Get the first row in the tbody
|
||||
const firstRow = table.querySelector("tbody tr");
|
||||
if (!firstRow) return;
|
||||
|
||||
// console.log("firstRow : ",firstRow);
|
||||
|
||||
// Get all cells in the first row
|
||||
const cells = firstRow.querySelectorAll("td");
|
||||
|
||||
// Get header rows to identify which columns are "Sum Insured"
|
||||
const headerRow1 = table.querySelector("thead tr:nth-child(1)");
|
||||
const headerRow2 = table.querySelector("thead tr:nth-child(2)");
|
||||
|
||||
if (!headerRow1 || !headerRow2) return;
|
||||
|
||||
// console.log("headerRow1 : ",headerRow1);
|
||||
// console.log("headerRow2 : ",headerRow2);
|
||||
// Find which column is the "Sum Insured" column
|
||||
let sumInsuredColumnIndex = -1;
|
||||
const subHeaders = headerRow2.querySelectorAll("th");
|
||||
|
||||
subHeaders.forEach((th, index) => {
|
||||
if (th.textContent.trim() === "Sum Insured") {
|
||||
proposalValue = th.getAttribute("data-proposal");
|
||||
sumInsuredColumnIndex = index;
|
||||
}
|
||||
});
|
||||
|
||||
// console.log("sumInsuredColumnIndex : ",sumInsuredColumnIndex);
|
||||
|
||||
if (sumInsuredColumnIndex === -1) return;
|
||||
|
||||
// Check if we have a cell at that index
|
||||
if (cells.length > sumInsuredColumnIndex) {
|
||||
console.log("It is there");
|
||||
const sumInsuredCell = cells[sumInsuredColumnIndex];
|
||||
|
||||
let previousValue = "";
|
||||
// Add event listener for changes
|
||||
sumInsuredCell.addEventListener("focus", function () {
|
||||
previousValue = this.textContent.trim();
|
||||
});
|
||||
|
||||
sumInsuredCell.addEventListener("blur", function () {
|
||||
const newValue = this.textContent.trim();
|
||||
if (newValue !== previousValue) {
|
||||
tdChanged = true;
|
||||
changedNewSI = newValue;
|
||||
$("#policySI").val(newValue);
|
||||
console.log("new Value",changedNewSI);
|
||||
// alert(newValue);
|
||||
updateAddON(newValue,proposalValue);
|
||||
console.log("Sum Insured value changed to:", newValue);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
console.log("Sum Insured column not found");
|
||||
}
|
||||
}
|
||||
|
||||
function updateAddON(newValue,proposalValue = null) {
|
||||
console.log("Function called");
|
||||
var table = document.getElementById("fire_addOnCoverage");
|
||||
|
||||
console.log("table : ",table);
|
||||
if (!table) return;
|
||||
|
||||
const thead = table.querySelector("thead");
|
||||
const tbody = table.querySelector("tbody");
|
||||
|
||||
if (!thead || !tbody) return;
|
||||
|
||||
const topHeaderCells = thead.rows[0].cells;
|
||||
const subHeaderCells = thead.rows[1].cells;
|
||||
|
||||
let targetIndexes = [];
|
||||
|
||||
// Find indexes of columns with the required headers
|
||||
for (let i = 0; i < topHeaderCells.length; i++) {
|
||||
const topHeaderText = topHeaderCells[i].textContent.trim();
|
||||
const subHeaderText = subHeaderCells[i] ? subHeaderCells[i].textContent.trim() : "";
|
||||
|
||||
const subheaderProposalValue = subHeaderCells[i]?.getAttribute("data-proposal");
|
||||
console.log("subheaderProposalValue : ",subheaderProposalValue);
|
||||
console.log("proposalValue : ",proposalValue);
|
||||
|
||||
if (proposalValue != "" && proposalValue != null){
|
||||
|
||||
if (subheaderProposalValue !== proposalValue) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((topHeaderText.startsWith("Pro") || topHeaderText.startsWith("Exis")) && subHeaderText === "Sum Insured") {
|
||||
targetIndexes.push(i);
|
||||
}
|
||||
}
|
||||
|
||||
// Loop through the first 3 rows of tbody and update the matching cells
|
||||
for (let rowIndex = 0; rowIndex < Math.min(3, tbody.rows.length); rowIndex++) {
|
||||
const row = tbody.rows[rowIndex];
|
||||
targetIndexes.forEach(colIndex => {
|
||||
if (row.cells[colIndex]) {
|
||||
console.log("Found row to update")
|
||||
if (['fire_stfi', 'fire_eq'].includes(row.id)) {
|
||||
row.cells[colIndex].textContent = newValue;
|
||||
}
|
||||
|
||||
if (row.id == "fire_terrorism"){
|
||||
if (storedPolicyData){
|
||||
|
||||
console.log("storedPolicyData : ",storedPolicyData);
|
||||
var is_terrorism = storedPolicyData.fire.policyDetails.terrorism;
|
||||
|
||||
console.log("is terrorism",is_terrorism);
|
||||
if (is_terrorism == "yes"){
|
||||
row.cells[colIndex].textContent = `Yes, ${newValue}`;
|
||||
}else{
|
||||
row.cells[colIndex].textContent = "No"
|
||||
|
||||
}
|
||||
}else{
|
||||
row.cells[colIndex].textContent = "No"
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function changeTerrorism(newValue){
|
||||
|
||||
storedPolicyData = JSON.parse(localStorage.getItem('policyData'));
|
||||
|
||||
console.log("Stroredpolicy data : ",storedPolicyData);
|
||||
|
||||
console.log("Change terrorism Function Called");
|
||||
var table = document.getElementById("fire_addOnCoverage");
|
||||
if (!table) return;
|
||||
|
||||
const thead = table.querySelector("thead");
|
||||
const tbody = table.querySelector("tbody");
|
||||
|
||||
if (!thead || !tbody) return;
|
||||
|
||||
const topHeaderCells = thead.rows[0].cells;
|
||||
const subHeaderCells = thead.rows[1].cells;
|
||||
|
||||
let targetIndexes = [];
|
||||
|
||||
// Find indexes of columns with the required headers
|
||||
for (let i = 0; i < topHeaderCells.length; i++) {
|
||||
const topHeaderText = topHeaderCells[i].textContent.trim();
|
||||
const subHeaderText = subHeaderCells[i] ? subHeaderCells[i].textContent.trim() : "";
|
||||
|
||||
|
||||
if ((topHeaderText.startsWith("Pro") || topHeaderText.startsWith("Exis")) && subHeaderText === "Sum Insured") {
|
||||
targetIndexes.push(i);
|
||||
}
|
||||
}
|
||||
|
||||
// Loop through the first 3 rows of tbody and update the matching cells
|
||||
for (let rowIndex = 0; rowIndex < Math.min(3, tbody.rows.length); rowIndex++) {
|
||||
const row = tbody.rows[rowIndex];
|
||||
targetIndexes.forEach(colIndex => {
|
||||
if (row.cells[colIndex]) {
|
||||
|
||||
if (row.id == "fire_terrorism"){
|
||||
console.log("Found the row");
|
||||
if (storedPolicyData){
|
||||
|
||||
console.log("storedPolicyData : ",storedPolicyData);
|
||||
var is_terrorism = storedPolicyData.fire.policyDetails.terrorism;
|
||||
updateAddON(newValue);
|
||||
if (is_terrorism == "yes"){
|
||||
row.cells[colIndex].textContent = `Yes, ${newValue}`;
|
||||
}else{
|
||||
row.cells[colIndex].textContent = "No"
|
||||
|
||||
}
|
||||
}else{
|
||||
row.cells[colIndex].textContent = "No"
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('input', function (e) {
|
||||
if (e.target.matches('td[contenteditable]')) {
|
||||
isSaved = false;
|
||||
// alert("status changed");
|
||||
}
|
||||
});
|
||||
|
||||
async function confirmUnsavedChanges() {
|
||||
|
||||
const result = await Swal.fire({
|
||||
title: 'Unsaved changes',
|
||||
text: 'Please save your changes before continuing.',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Save Now',
|
||||
cancelButtonText: 'Cancel'
|
||||
});
|
||||
|
||||
if (result.isConfirmed) {
|
||||
saveRFQ();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user