Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev

This commit is contained in:
VENKATESHWARAN 2025-03-27 13:13:43 +05:30
commit c262733332
2 changed files with 121 additions and 89 deletions

View File

@ -238,19 +238,19 @@
<script> <script>
var totalSI; var totalSI;
var finalData = {}; var finalData = {};
console.log("policyName : ", $('#policyName').val()); // console.log("policyName : ", $('#policyName').val());
var policyName = $('#policyName').val(); var policyName = $('#policyName').val();
const occupancyMaster = <?= json_encode($occupancy) ?>; const occupancyMaster = <?= json_encode($occupancy) ?>;
console.log("Occupancy : ", occupancyMaster); // console.log("Occupancy : ", occupancyMaster);
var storedPolicyData = {}; var storedPolicyData = {};
storedPolicyData = JSON.parse(localStorage.getItem('policyData')); storedPolicyData = JSON.parse(localStorage.getItem('policyData'));
$(document).ready(function() { $(document).ready(function() {
// resetAllform(); // resetAllform();
console.log("Stored date Found : ", typeof(storedPolicyData)); // console.log("Stored date Found : ", typeof(storedPolicyData));
if (!$.isEmptyObject(storedPolicyData)) { if (!$.isEmptyObject(storedPolicyData)) {
// prepareDataForEdit(storedPolicyData); // prepareDataForEdit(storedPolicyData);
} else { } else {
console.log("inside else trying to open product sleection tab"); // console.log("inside else trying to open product sleection tab");
// const productSelectionTab = new bootstrap.Tab(document.getElementById); // const productSelectionTab = new bootstrap.Tab(document.getElementById);
const productSelectionTab = new bootstrap.Tab(document.getElementById('product-selection-tab')); const productSelectionTab = new bootstrap.Tab(document.getElementById('product-selection-tab'));
productSelectionTab.show(); productSelectionTab.show();
@ -306,22 +306,22 @@
}); });
$('#productSelectionForm').submit(function(event) { $('#productSelectionForm').submit(function(event) {
console.log("Submit function called"); // console.log("Submit function called");
event.preventDefault(); event.preventDefault();
var isValid = $('#productSelectionForm').parsley().validate(); var isValid = $('#productSelectionForm').parsley().validate();
console.log('isValid', isValid) // console.log('isValid', isValid)
if (!isValid) { if (!isValid) {
$('#productSelectionForm').find('input, select, textarea').each(function() { $('#productSelectionForm').find('input, select, textarea').each(function() {
if ($(this).parsley().isValid() === false && !$(this).val()) { if ($(this).parsley().isValid() === false && !$(this).val()) {
console.log('Empty field ID:', this.id); // console.log('Empty field ID:', this.id);
} }
}); });
console.log('Form is Empty', 'Warning'); // console.log('Form is Empty', 'Warning');
return; return;
} }
productSelectionData = {}; productSelectionData = {};
// console.log("submit function is clicked"); // // console.log("submit function is clicked");
// event.preventDefault(); // event.preventDefault();
var formDataProductSelection = $("#productSelectionForm").serializeArray(); var formDataProductSelection = $("#productSelectionForm").serializeArray();
@ -340,14 +340,14 @@
policydetailsOpen(); policydetailsOpen();
} }
console.log("form data product selection : ", productSelectionData); // console.log("form data product selection : ", productSelectionData);
}) })
function policydetailsOpen() { function policydetailsOpen() {
// PolicyTabOpened(); // PolicyTabOpened();
console.log("function is called"); // console.log("function is called");
// Use the ID for the Policy Details tab button. // Use the ID for the Policy Details tab button.
// const policyDetailsTab = new bootstrap.Tab(document.getElementById('policy-details-tab')); // const policyDetailsTab = new bootstrap.Tab(document.getElementById('policy-details-tab'));
const policyDetailsTab = new bootstrap.Tab(document.getElementById('policy-details-tab')); const policyDetailsTab = new bootstrap.Tab(document.getElementById('policy-details-tab'));
@ -361,15 +361,15 @@
var isValid = $('#policyRiskSplitUpForm').parsley().validate(); var isValid = $('#policyRiskSplitUpForm').parsley().validate();
console.log('isValid', isValid); // console.log('isValid', isValid);
if (!isValid) { if (!isValid) {
$('#policyRiskSplitUpForm').find('input, select, textarea').each(function() { $('#policyRiskSplitUpForm').find('input, select, textarea').each(function() {
if ($(this).parsley().isValid() === false && !$(this).val()) { if ($(this).parsley().isValid() === false && !$(this).val()) {
console.log('Empty field ID:', this.id); // console.log('Empty field ID:', this.id);
} }
}); });
console.log('Form is Empty', 'Warning'); // console.log('Form is Empty', 'Warning');
return; return;
} }
@ -393,7 +393,7 @@
value: $(`#lossIN3Years_${i}`).is(':checked') ? 'on' : 'off' value: $(`#lossIN3Years_${i}`).is(':checked') ? 'on' : 'off'
}); });
} }
console.log("form from : ", formDataSplitUp); // console.log("form from : ", formDataSplitUp);
if (productSelectionData.multipleProduct == 'on') { if (productSelectionData.multipleProduct == 'on') {
let selectionType = productSelectionData.multilocation_type; let selectionType = productSelectionData.multilocation_type;
@ -413,11 +413,19 @@
toastr.error("Sum Insured Exceeds Allowed Limit", "ERROR"); toastr.error("Sum Insured Exceeds Allowed Limit", "ERROR");
return false; return false;
} }
console.log("Total SI: ", totalSI); // console.log("Total SI: ", totalSI);
}else{
let InProcess = [...document.querySelectorAll('[id^="stockInProcess_"]')].map(el => Number(el.value) || 0);
let rawMaterial = [...document.querySelectorAll('[id^="rawMaterial_"]')].map(el => Number(el.value) || 0);
let findMaterial = [...document.querySelectorAll('[id^="finishedStock_"]')].map(el => Number(el.value) || 0);
totalSI = InProcess.reduce((acc, val) => acc + val, 0) +
rawMaterial.reduce((acc, val) => acc + val, 0) +
findMaterial.reduce((acc, val) => acc + val, 0);
} }
} }
console.log("Form is trying to submit : ", formDataSplitUp); // console.log("Form is trying to submit : ", formDataSplitUp);
const groupData = []; const groupData = [];
@ -454,7 +462,7 @@
policyRiskSplitUpData = groupData; policyRiskSplitUpData = groupData;
console.log("Grouped Data as Objects: ", policyRiskSplitUpData); // console.log("Grouped Data as Objects: ", policyRiskSplitUpData);
savePolicyDataLocal(); savePolicyDataLocal();
}); });
@ -464,15 +472,15 @@
$("#policyRiskAddressForm").submit(function(event) { $("#policyRiskAddressForm").submit(function(event) {
event.preventDefault(); event.preventDefault();
var isValid = $('#policyRiskAddressForm').parsley().validate(); var isValid = $('#policyRiskAddressForm').parsley().validate();
console.log('isValid', isValid) // console.log('isValid', isValid)
if (!isValid) { if (!isValid) {
$('#policyRiskAddressForm').find('input, select, textarea').each(function() { $('#policyRiskAddressForm').find('input, select, textarea').each(function() {
if ($(this).parsley().isValid() === false && !$(this).val()) { if ($(this).parsley().isValid() === false && !$(this).val()) {
console.log('Empty field ID:', this.id); // console.log('Empty field ID:', this.id);
} }
}); });
console.log('Form is Empty', 'Warning'); // console.log('Form is Empty', 'Warning');
return; return;
} }
const formData = $("#policyRiskAddressForm").serializeArray(); const formData = $("#policyRiskAddressForm").serializeArray();
@ -505,7 +513,7 @@
}); });
policyRiskAddress = groupedData; policyRiskAddress = groupedData;
console.log("Grouped Data as Objects: ", policyRiskAddress); // console.log("Grouped Data as Objects: ", policyRiskAddress);
if (productSelectionData.singleProduct == 'on') { if (productSelectionData.singleProduct == 'on') {
savePolicyDataLocal(); savePolicyDataLocal();
@ -518,25 +526,25 @@
event.preventDefault(); event.preventDefault();
var isValid = $('#policyDetailsForm').parsley().validate(); var isValid = $('#policyDetailsForm').parsley().validate();
console.log('isValid', isValid) // console.log('isValid', isValid)
if (!isValid) { if (!isValid) {
$('#policyDetailsForm').find('input, select, textarea').each(function() { $('#policyDetailsForm').find('input, select, textarea').each(function() {
if ($(this).parsley().isValid() === false && !$(this).val()) { if ($(this).parsley().isValid() === false && !$(this).val()) {
console.log('Empty field ID:', this.id); // console.log('Empty field ID:', this.id);
} }
}); });
console.log('Form is Empty', 'Warning'); // console.log('Form is Empty', 'Warning');
return; return;
} }
var formData = $("#policyDetailsForm").serializeArray(); var formData = $("#policyDetailsForm").serializeArray();
$.each(formData, function(i, field) { $.each(formData, function(i, field) {
policyDetailsData[field.name] = field.value; policyDetailsData[field.name] = field.value;
}); });
// console.log("form data", policyDetailsData.location_no); // // console.log("form data", policyDetailsData.location_no);
if (formData !== null && formData !== '') { if (formData !== null && formData !== '') {
console.log("form submitted trying to open the ris info tab"); // console.log("form submitted trying to open the ris info tab");
// riskInfoTabOpened(); // riskInfoTabOpened();
const riskTab = new bootstrap.Tab(document.getElementById('risk-info-tab')); const riskTab = new bootstrap.Tab(document.getElementById('risk-info-tab'));
riskTab.show(); riskTab.show();
@ -567,11 +575,11 @@
} }
} else if (e.target.id === 'risk-splitup-tab') { } else if (e.target.id === 'risk-splitup-tab') {
contianertoCheck = document.getElementById("addRiskSplitUp"); contianertoCheck = document.getElementById("addRiskSplitUp");
console.log("policy det", policyRiskAddress.length) // console.log("policy det", policyRiskAddress.length)
if (!$.isEmptyObject(policyRiskAddress)) { if (!$.isEmptyObject(policyRiskAddress)) {
if (increment2 == 1) { if (increment2 == 1) {
policyRiskAddress.forEach(function() { policyRiskAddress.forEach(function() {
console.log("increment count is ", increment2) // console.log("increment count is ", increment2)
addHTMLInputForRiskSplitUP(); addHTMLInputForRiskSplitUP();
validatePolicyBasedOnProductSelection(); validatePolicyBasedOnProductSelection();
hideAndShowBurglary(); hideAndShowBurglary();
@ -585,20 +593,20 @@
} }
} else if (e.target.id === 'risk-info-tab') { } else if (e.target.id === 'risk-info-tab') {
console.log("function called "); // console.log("function called ");
contianertoCheck = document.getElementById("addRiskInfo"); contianertoCheck = document.getElementById("addRiskInfo");
// console.log("policy details data ", policyDetailsData); // // console.log("policy details data ", policyDetailsData);
if (!$.isEmptyObject(policyDetailsData)) { if (!$.isEmptyObject(policyDetailsData)) {
if (increment == 1) { if (increment == 1) {
console.log("inside if "); // console.log("inside if ");
addHTMLInputForRiskAddress(); addHTMLInputForRiskAddress();
$('select[id^="occupancy_"]').select2(); $('select[id^="occupancy_"]').select2();
validatePolicyBasedOnProductSelection(); validatePolicyBasedOnProductSelection();
} }
} else { } else {
console.log("inside else "); // console.log("inside else ");
if (contianertoCheck.innerHTML == "") { if (contianertoCheck.innerHTML == "") {
addHTMLInputForRiskAddressWarninig(); addHTMLInputForRiskAddressWarninig();
@ -624,11 +632,11 @@
} }
function addHTMLInputForRiskSplitUP() { function addHTMLInputForRiskSplitUP() {
// console.log("Function called ", increment2, " times"); // // console.log("Function called ", increment2, " times");
const container = document.getElementById("addRiskSplitUp"); const container = document.getElementById("addRiskSplitUp");
// container.innerHTML = ''; // container.innerHTML = '';
const newRowRisk = document.createElement("div"); const newRowRisk = document.createElement("div");
// console.log("Risk Split Up for address : ", policyRiskAddress.length) // // console.log("Risk Split Up for address : ", policyRiskAddress.length)
// policyRiskAddress // policyRiskAddress
newRowRisk.innerHTML += ` newRowRisk.innerHTML += `
@ -743,7 +751,7 @@
const container = document.getElementById('addRiskInfo'); const container = document.getElementById('addRiskInfo');
// container.innerHTML = ""; // container.innerHTML = "";
const newRow = document.createElement('div'); const newRow = document.createElement('div');
// console.log("policy details ", policyDetailsData); // // console.log("policy details ", policyDetailsData);
newRow.className = 'form-row dynamic-form-row mb-3'; newRow.className = 'form-row dynamic-form-row mb-3';
newRow2 = document.createElement("div"); newRow2 = document.createElement("div");
@ -882,8 +890,8 @@
$(document).on('click', '.duplicate-btn', function() { $(document).on('click', '.duplicate-btn', function() {
console.log("button is clicked"); // console.log("button is clicked");
console.log("increment cout ", increment); // console.log("increment cout ", increment);
if (policyDetailsData.location_no >= increment) { if (policyDetailsData.location_no >= increment) {
@ -933,7 +941,7 @@
}) })
function addOrRemoveAdd() { function addOrRemoveAdd() {
console.log("chceck box clicked"); // console.log("chceck box clicked");
if ($("#sameAsCommunicationAddress").is(":checked")) { if ($("#sameAsCommunicationAddress").is(":checked")) {
$("#pin_code_1").val(policyDetailsData.pin_code); $("#pin_code_1").val(policyDetailsData.pin_code);
$("#address1_1").val(policyDetailsData.address1); $("#address1_1").val(policyDetailsData.address1);
@ -952,7 +960,7 @@
if (selectedProduct.singleProduct == 'on') { if (selectedProduct.singleProduct == 'on') {
console.log("inside if "); // console.log("inside if ");
$('[class*="single_location"]').show(); $('[class*="single_location"]').show();
$("#locationNoDIV").hide(); $("#locationNoDIV").hide();
$("#location_no").removeAttr("required", false); $("#location_no").removeAttr("required", false);
@ -970,7 +978,7 @@
} else if (selectedProduct.multipleProduct == 'on') { } else if (selectedProduct.multipleProduct == 'on') {
console.log("inside elseif"); // console.log("inside elseif");
$('[class*="single_location"]').hide().removeAttr('required'); $('[class*="single_location"]').hide().removeAttr('required');
// $('[class*="single_location_occupancy"]').hide().removeAttr('required'); // $('[class*="single_location_occupancy"]').hide().removeAttr('required');
$('[class*="multi_location_company"]').show(); $('[class*="multi_location_company"]').show();
@ -1002,28 +1010,28 @@
// alert(element); // alert(element);
var selectedOccupancy = $(`#${element}`).val(); var selectedOccupancy = $(`#${element}`).val();
var selectedOccupancyMasterRow = occupancyMaster.find(iib => iib.id == selectedOccupancy); var selectedOccupancyMasterRow = occupancyMaster.find(iib => iib.id == selectedOccupancy);
console.log("selected occupancy masater ", selectedOccupancyMasterRow) // console.log("selected occupancy masater ", selectedOccupancyMasterRow)
console.log("selected occupancy masater ", occupancyMaster) // console.log("selected occupancy masater ", occupancyMaster)
var iibCODE = selectedOccupancyMasterRow.iib_code; var iibCODE = selectedOccupancyMasterRow.iib_code;
console.log("selected occupancy masater ", iibCODE) // console.log("selected occupancy masater ", iibCODE)
var elementID = element; var elementID = element;
let increment = elementID.split("_").pop(); let increment = elementID.split("_").pop();
console.log("selected occupancy masater increment ", increment) // console.log("selected occupancy masater increment ", increment)
console.log("selected occupancy masater element ", $(`#iibCode_${increment}`)) // console.log("selected occupancy masater element ", $(`#iibCode_${increment}`))
setTimeout(function() { setTimeout(function() {
$(`#iibCode_${increment}`).val(iibCODE); // Set the value $(`#iibCode_${increment}`).val(iibCODE); // Set the value
console.log("Selected --------------------", $(`#iibCode_${increment}`).val()); // Log the value // console.log("Selected --------------------", $(`#iibCode_${increment}`).val()); // Log the value
}, 1000); }, 1000);
} }
console.log("onchange occupancy function called "); // console.log("onchange occupancy function called ");
// console.log("onchange occupancy function called ", selectedOccupancy); // // console.log("onchange occupancy function called ", selectedOccupancy);
// console.log("onchange occupancy function called ", selectedOccupancyMasterRow); // // console.log("onchange occupancy function called ", selectedOccupancyMasterRow);
// console.log("onchange occupancy function called ", iibCODE); // // console.log("onchange occupancy function called ", iibCODE);
// console.log("onchange occupancy function called ", increment); // // console.log("onchange occupancy function called ", increment);
$('[class*="common_location_occupancy"]').show().prop("required", "required"); $('[class*="common_location_occupancy"]').show().prop("required", "required");
@ -1032,22 +1040,22 @@
$('[class*="single_location_occupancy"]').show().prop("required", "required"); $('[class*="single_location_occupancy"]').show().prop("required", "required");
} else if (selectedProduct.multipleProduct == 'on') { } else if (selectedProduct.multipleProduct == 'on') {
// console.log("Muliple location");f // // console.log("Muliple location");f
$('[class*="multiLocationOccupancy"]').show().prop('required', 'required'); $('[class*="multiLocationOccupancy"]').show().prop('required', 'required');
if (selectedProduct.multilocation_type == "multiLocation") { if (selectedProduct.multilocation_type == "multiLocation") {
// console.log("multiple location without Floater"); // // console.log("multiple location without Floater");
$('[class*="multiLocationOccupancyWithoutFloater"]').show().prop('required', 'required'); $('[class*="multiLocationOccupancyWithoutFloater"]').show().prop('required', 'required');
} else if (selectedProduct.multilocation_type == "multiFloater") { } else if (selectedProduct.multilocation_type == "multiFloater") {
// console.log("Muliple location With Floater"); // // console.log("Muliple location With Floater");
$('[class*="multiLocationOccupancyWithoutFloater"]').hide().removeAttr('required', false); $('[class*="multiLocationOccupancyWithoutFloater"]').hide().removeAttr('required', false);
} else if (selectedProduct.multilocation_type == "stockFloater") { } else if (selectedProduct.multilocation_type == "stockFloater") {
// console.log("multiple location with stock floater"); // // console.log("multiple location with stock floater");
$('[class*="multiLocationOccupancyWithoutFloater"]').show().prop('required', 'required'); $('[class*="multiLocationOccupancyWithoutFloater"]').show().prop('required', 'required');
$('[class*="stockSI"]').hide().removeAttr('required', false); $('[class*="stockSI"]').hide().removeAttr('required', false);
} }
@ -1109,7 +1117,7 @@
// Ensure policyName is correctly retrieved // Ensure policyName is correctly retrieved
var policyName = $('#policyName').val(); var policyName = $('#policyName').val();
if (!policyName) { if (!policyName) {
console.error("Policy name is undefined. Cannot save data."); // console.error("Policy name is undefined. Cannot save data.");
return; return;
} }
policyName = policyName.toLowerCase(); policyName = policyName.toLowerCase();
@ -1120,7 +1128,7 @@
localStorage.setItem('policyData', JSON.stringify(existingData)); localStorage.setItem('policyData', JSON.stringify(existingData));
if (!$.isEmptyObject(existingData)) { if (!$.isEmptyObject(existingData)) {
console.log("DATA FROM DB : ", (existingData)); // console.log("DATA FROM DB : ", (existingData));
let data = (existingData); let data = (existingData);
Object.keys(data).forEach(key => { Object.keys(data).forEach(key => {
@ -1133,7 +1141,7 @@
toastr.success("Policy Information Collected ","SUCCESS"); toastr.success("Policy Information Collected ","SUCCESS");
$('.loader').fadeOut(); $('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow'); $('.loader-mask').delay(350).fadeOut('slow');
console.log("Updated policy data in localStorage:", existingData); // console.log("Updated policy data in localStorage:", existingData);
} }
function saveTODB(data, leadID) { function saveTODB(data, leadID) {
@ -1141,7 +1149,7 @@
var url = '<?= base_url('rfq/savePolicyInfo') ?>'; var url = '<?= base_url('rfq/savePolicyInfo') ?>';
$('.loader').fadeIn(); $('.loader').fadeIn();
$('.loader-mask').fadeIn(); $('.loader-mask').fadeIn();
console.log("trying to submit data : ", data, " with this lead id : ", leadID); // console.log("trying to submit data : ", data, " with this lead id : ", leadID);
$.ajax({ $.ajax({
url: url, url: url,
data: { data: {
@ -1163,8 +1171,8 @@
error: function(xhr, status, error) { error: function(xhr, status, error) {
$('.loader').fadeOut(); $('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow'); $('.loader-mask').delay(350).fadeOut('slow');
console.error(xhr.responseText); // console.error(xhr.responseText);
console.error(status, error); // console.error(status, error);
} }
}) })
} }
@ -1188,14 +1196,14 @@
// alert("Data restored to original variables."); // alert("Data restored to original variables.");
} else { } else {
console.log("No policy data found in local storage."); // console.log("No policy data found in local storage.");
} }
} }
function prepareDataForEdit(data) { function prepareDataForEdit(data) {
// alert(policyName); // alert(policyName);
console.log("Prepare data : ",data); // console.log("Prepare data : ",data);
if (policyName == "Fire") { if (policyName == "Fire") {
data = data.fire; data = data.fire;
if (!data) { if (!data) {
@ -1215,7 +1223,7 @@
}else{ }else{
// alert("nothing"); // alert("nothing");
} }
console.log("policy data : ", data); // console.log("policy data : ", data);
// Populate Product Selection // Populate Product Selection
// Show first tab // Show first tab
@ -1233,7 +1241,7 @@
$('#singleProduct').prop('checked', data.productSelection.singleProduct === 'on'); $('#singleProduct').prop('checked', data.productSelection.singleProduct === 'on');
$('#multipleProduct').prop('checked', data.productSelection.multipleProduct === 'on'); $('#multipleProduct').prop('checked', data.productSelection.multipleProduct === 'on');
console.log($('#multipleProduct').is(":checked") ? "yes" : "no"); // console.log($('#multipleProduct').is(":checked") ? "yes" : "no");
$('#multipleProduct').is(":checked") ? $('#multilocation_type').show() : $('#multilocation_type').hide(); $('#multipleProduct').is(":checked") ? $('#multilocation_type').show() : $('#multilocation_type').hide();
$('#multilocation_type').val(data.productSelection.multilocation_type); $('#multilocation_type').val(data.productSelection.multilocation_type);
$("#client_type").val(data.productSelection.client_type); $("#client_type").val(data.productSelection.client_type);
@ -1247,7 +1255,7 @@
const policyDetails = data.policyDetails; const policyDetails = data.policyDetails;
Object.keys(policyDetails).forEach(key => { Object.keys(policyDetails).forEach(key => {
$(`#${key}`).val(policyDetails[key]); $(`#${key}`).val(policyDetails[key]);
// console.log("Key ",key," set value : ",policyDetails[key]); // // console.log("Key ",key," set value : ",policyDetails[key]);
}); });
// Populate Risk Addresses // Populate Risk Addresses
@ -1328,14 +1336,14 @@
var mobile = <?= isset($lead_data['client_type']) ? $lead_data['client_type'] : "" ?>; var mobile = <?= isset($lead_data['client_type']) ? $lead_data['client_type'] : "" ?>;
var email = <?= isset($lead_data['client_type']) ? $lead_data['client_type'] : "" ?>; var email = <?= isset($lead_data['client_type']) ? $lead_data['client_type'] : "" ?>;
var panNo = <?= isset($lead_data['client_type']) ? $lead_data['client_type'] : "" ?>; var panNo = <?= isset($lead_data['client_type']) ? $lead_data['client_type'] : "" ?>;
console.log("client_type : ".client_type); // console.log("client_type : ".client_type);
if (lead_data) { if (lead_data) {
// lead_data = JSON.parse(lead_data); // lead_data = JSON.parse(lead_data);
console.log("Lead Data : ", typeof(lead_data)); // console.log("Lead Data : ", typeof(lead_data));
if (lead_data.risk_location == "Single") { if (lead_data.risk_location == "Single") {
console.log("single "); // console.log("single ");
$("#singleProduct").prop("checked", true).trigger("change"); $("#singleProduct").prop("checked", true).trigger("change");
} else if (lead_data.risk_location.startsWith("multi")) { } else if (lead_data.risk_location.startsWith("multi")) {
@ -1356,9 +1364,9 @@
} }
function hideAndShowBurglary() { function hideAndShowBurglary() {
console.log("hide and show function called "); // console.log("hide and show function called ");
policyName = $("#policyName").val(); policyName = $("#policyName").val();
console.log("hiding the other policy not ths : ", policyName); // console.log("hiding the other policy not ths : ", policyName);
if (policyName == "Burglary") { if (policyName == "Burglary") {
$('[class*="burglary"]').show(); $('[class*="burglary"]').show();
$('[class*="fire"]').hide().removeAttr('required', false); $('[class*="fire"]').hide().removeAttr('required', false);
@ -1369,7 +1377,7 @@
} }
function resetAllform() { function resetAllform() {
console.log("FORM RESETED SUCCESSFULLY"); // console.log("FORM RESETED SUCCESSFULLY");
$("#productSelectionForm")[0].reset(); $("#productSelectionForm")[0].reset();
$("#policyDetailsForm")[0].reset(); $("#policyDetailsForm")[0].reset();
$("#policyRiskAddressForm")[0].reset(); $("#policyRiskAddressForm")[0].reset();
@ -1402,7 +1410,7 @@
}) })
function copyFirePolicy() { function copyFirePolicy() {
console.log("Copying Fire Policy Data..."); // console.log("Copying Fire Policy Data...");
storedPolicyData = JSON.parse(localStorage.getItem('policyData')); storedPolicyData = JSON.parse(localStorage.getItem('policyData'));
if (storedPolicyData.fire) { if (storedPolicyData.fire) {

View File

@ -46,12 +46,21 @@
/* background-color: #bfe0e2; */ /* background-color: #bfe0e2; */
} }
.table th[contenteditable], .table {
.table td[contenteditable] { border: 1px solid #007bff; /* Border around the table */
border: 1px solid #007bff; border-collapse: collapse; /* Ensures borders dont double up */
outline: none; width: 100%;
} }
.table th,
.table td {
border: 1px solid #007bff; /* Border for all table cells */
padding: 8px; /* Optional: Adds spacing inside cells */
text-align: left; /* Optional: Aligns text inside cells */
}
th:nth-child(2), th:nth-child(2),
td:nth-child(2) { td:nth-child(2) {
width: 720px; width: 720px;
@ -188,6 +197,7 @@
} }
.table-collapsible-bar { .table-collapsible-bar {
min-width: 1300px;
background-color: #f1f1f1; background-color: #f1f1f1;
padding: 10px; padding: 10px;
cursor: pointer; cursor: pointer;
@ -622,9 +632,11 @@
// Remove a proposal column // Remove a proposal column
function removeProposal(proposalNumber) { function removeProposal(proposalNumber) {
let startIndex = 0;
console.log("Remove Proposal : startIndex 1 ",startIndex);
// console.log('removeProposal'); // console.log('removeProposal');
// console.log(quotesConfig); console.log(quotesConfig);
if (!quotesConfig[proposalNumber]) return; // If proposal doesn't exist, exit if (!quotesConfig[proposalNumber]) return; // If proposal doesn't exist, exit
// Remove all child columns for the proposal // Remove all child columns for the proposal
@ -636,24 +648,29 @@
// Find the proposal header and calculate its colspan // Find the proposal header and calculate its colspan
const proposalHeader = headerRow1.querySelector(`th[data-proposal="${proposalNumber}"]`); const proposalHeader = headerRow1.querySelector(`th[data-proposal="${proposalNumber}"]`);
if (proposalHeader) { if (proposalHeader) {
console.log("Remove Proposal : quotesConfig ",quotesConfig[proposalNumber]);
console.log("Remove Proposal : proposalHeader ",proposalHeader);
if (rfq_or_qcr == 1){ if (rfq_or_qcr == 1){
var colspan = parseInt(quotesConfig[proposalNumber].length); var colspan = parseInt(quotesConfig[proposalNumber].length);
}else{ }else{
var colspan = parseInt(proposalHeader.getAttribute('colspan'), 10); var colspan = parseInt(proposalHeader.getAttribute('colspan'), 10);
} }
console.log("Remove Proposal : colspan ",colspan);
// Remove the proposal header // Remove the proposal header
proposalHeader.remove(); proposalHeader.remove();
// Remove corresponding sub-headers in the second header row // Remove corresponding sub-headers in the second header row
const subHeaders = headerRow2.querySelectorAll(`th`); const subHeaders = headerRow2.querySelectorAll(`th`);
let startIndex = 2; // Start after the first two columns (checkbox and Particulars) startIndex = 2; // Start after the first two columns (checkbox and Particulars)
console.log("Remove Proposal : startIndex 2",startIndex);
for (let i = 1; i < proposalNumber; i++) { for (let i = 1; i < proposalNumber; i++) {
startIndex += quotesConfig[i]?.length || 1; startIndex += quotesConfig[i]?.length || 0;
console.log("Remove Proposal : startIndex 3",startIndex);
} }
for (let i = 0; i < colspan; i++) { for (let i = 0; i < colspan; i++) {
console.log("Remove Proposal : colspan ",colspan);
console.log("Remove Proposal : startIndex 4",startIndex)
headerRow2.removeChild(headerRow2.children[startIndex]); headerRow2.removeChild(headerRow2.children[startIndex]);
} }
@ -2661,16 +2678,21 @@
function setQuotesConfig(overallColumnData) { function setQuotesConfig(overallColumnData) {
let quotesConfiguration = {}; // Stores the transformed output let quotesConfiguration = {}; // Stores the transformed output
let index = 1; // Keeps track of proposal index let index = 1; // Keeps track of proposal index
// console.log(overallColumnData);
Object.keys(overallColumnData).forEach((proposalKey) => { Object.keys(overallColumnData).forEach((proposalKey) => {
let parts = proposalKey.split(" ");
let lastNumber = parseInt(parts[parts.length - 1], 10);
index = lastNumber;
// console.log(proposalKey);
// console.log(index);
// console.log(value);
let proposal = overallColumnData[proposalKey]; let proposal = overallColumnData[proposalKey];
let insurersList = proposal.insurers.map(ins => ins.ins_name); // Extract insurer names let insurersList = proposal.insurers.map(ins => ins.ins_name); // Extract insurer names
// Create output format: index { "Quote asked", ...insurers } // Create output format: index { "Quote asked", ...insurers }
quotesConfiguration[index] = ["Quote asked", ...insurersList]; quotesConfiguration[index] = ["Quote asked", ...insurersList];
index++; // Increment index for next proposal
// proposalCount++;
}); });
return quotesConfiguration; return quotesConfiguration;
@ -2718,8 +2740,10 @@
// Initialize configurations // Initialize configurations
policyConfig = setPolicyConfiguration(proposalDataArray.proposal_data.over_all_column_data); policyConfig = setPolicyConfiguration(proposalDataArray.proposal_data.over_all_column_data);
quotesConfig = setQuotesConfig(proposalDataArray.proposal_data.over_all_column_data); quotesConfig = setQuotesConfig(proposalDataArray.proposal_data.over_all_column_data);
proposalCount = Object.keys(proposalDataArray.proposal_data.over_all_column_data).length; let keys = Object.keys(quotesConfig);
let lastKey = keys[keys.length - 1];
proposalCount = lastKey;
console.log(proposalCount);
// Calculate width increase // Calculate width increase
let increaseBy = rfq_or_qcr == 2 ? let increaseBy = rfq_or_qcr == 2 ?
getTotalCount(proposalDataArray) * 150 : getTotalCount(proposalDataArray) * 150 :
@ -2801,7 +2825,7 @@
}else { }else {
td.innerHTML = ""; td.innerHTML = "";
} }
td.contentEditable = true; // td.contentEditable = true;
// td.classList.add("readonly-select"); // td.classList.add("readonly-select");
} }
// Handle regular cells // Handle regular cells