FIX_sAles Tracker Oppunity Changes

This commit is contained in:
sanjeev.p 2026-04-17 10:39:42 +05:30
parent 72dbadcb7d
commit f19c1b9627
3 changed files with 131 additions and 28 deletions

View File

@ -474,6 +474,8 @@
<script>
var actualLeadClientName = '';
var actualLeadShortName = '';
let claimIndex = 1;
setTimeout(() => {
@ -1936,6 +1938,22 @@
console.warn(`Incurred claim date field #${incurred_claim_date_id} not found.`);
}
// --- Re-populate Actual Lead data if it was cleared ---
if ($('#actual_lead_id').val() && $('#actual_lead_id').val() != 0) {
$('#client_name').val(actualLeadClientName);
// Re-generate short name from the stored client name to ensure consistency
if (actualLeadClientName.trim() !== '') {
let baseName = actualLeadClientName
.trim()
.substring(0, 10)
.replace(/\s+/g, '')
.toUpperCase();
makeUniqueShortName(baseName);
} else {
$('#client_short_name').val('').parsley().reset();
}
}
})
function insurerChange(input, unique_id) {
@ -2284,8 +2302,9 @@
function leadTypeBsedHideAndShow(value, resetValues = false) {
if (value == 1) {
var actual_lead_id = $('#actual_lead_id').val();
if (value == 1 || (actual_lead_id && actual_lead_id != 0 && value == 3)) {
$('.btnDiv').show();
$('.claim-row').hide();
@ -2509,17 +2528,17 @@
// CLIENT DETAILS AUTO FILL
// -------------------------------
if (actual_lead_client_details) {
$('#client_name').val(actual_lead_client_details.company_name || '');
actualLeadClientName = actual_lead_client_details.company_name || '';
$('#client_name').val(actualLeadClientName);
$('#gst').val(actual_lead_client_details.gst_number || '');
existingShortName = actual_lead_client_details.short_name || '';
if (existingShortName) {
// ── Short name EXISTS — just populate and validate ────────
$('#client_short_name').val(existingShortName);
// validateInput($('#client_short_name')[0], 'clients', 'short_name');
} else {
// existingShortName = actual_lead_client_details.short_name || '';
// if (existingShortName) {
// // ── Short name EXISTS — just populate and validate ────────
// $('#client_short_name').val(existingShortName);
// // validateInput($('#client_short_name')[0], 'clients', 'short_name');
// } else { }
// Auto-generate short name from company name
// Use a small delay to ensure DOM is ready
setTimeout(function () {
@ -2531,9 +2550,31 @@
makeUniqueShortName(baseName);
}, 300);
}
}
// Auto-generate short name from client name on user input.
$('#client_name').on('input', function() {
let clientName = $(this).val();
if (clientName.trim() !== '') {
let baseName = clientName
.trim()
.substring(0, 10)
.replace(/\s+/g, '')
.toUpperCase();
makeUniqueShortName(baseName);
} else {
$('#client_short_name').val('').parsley().reset();
}
});
// Keep short name variable in sync if it's generated or changed
$('#client_short_name').on('input change', function() {
if ($('#actual_lead_id').val() && $('#actual_lead_id').val() != 0) {
actualLeadShortName = $(this).val();
}
});
// -------------------------------
// CONTACT PERSON AUTO FILL
// -------------------------------

View File

@ -835,13 +835,23 @@
}
function showEmailHistoryModal() {
var $modal = $('#EmailModal');
if (typeof jQuery !== 'undefined' && jQuery.fn && typeof jQuery.fn.modal === 'function') {
$modal.modal('show');
const el = document.getElementById('EmailModal');
if (!el) return;
// Prefer Bootstrap 5 modal API (used by other modals in this file).
if (window.bootstrap && bootstrap.Modal) {
// Some Bootstrap builds don't include getOrCreateInstance()
if (typeof bootstrap.Modal.getOrCreateInstance === 'function') {
bootstrap.Modal.getOrCreateInstance(el).show();
} else {
new bootstrap.Modal(el).show();
}
return;
}
if (window.bootstrap && bootstrap.Modal) {
bootstrap.Modal.getOrCreateInstance(document.getElementById('EmailModal')).show();
// Fallback for legacy Bootstrap setups that attach $.fn.modal.
if (typeof jQuery !== 'undefined' && jQuery.fn && typeof jQuery.fn.modal === 'function') {
$('#EmailModal').modal('show');
}
}
@ -853,6 +863,19 @@
function getLeadsDataForMailHistory(lead_id){
console.log("******** Inside Fnz :", lead_id);
// Open the modal immediately; then fill the table after API response.
// This prevents the click from looking "non-working" while the request runs.
const container = document.querySelector(".history-container");
if (container) {
container.innerHTML = `
<div class="d-flex justify-content-center align-items-center" style="height: 50vh; width:100%;">
<p class="text-center font-color-black"><i>Loading...</i></p>
</div>
`;
}
showEmailHistoryModal();
let url = '<?php echo base_url('/util/getLeadEmailHistory/') ?>' + lead_id;
console.log("******** Fetching:", url);
@ -862,8 +885,7 @@
})
.then(response => response.json())
.then(response => {
let container = document.querySelector(".history-container");
container.innerHTML = "";
if (container) container.innerHTML = "";
if (response.status === "success" && response.data.length > 0) {
console.log("******** 1" + response.status);
let table = `
@ -974,7 +996,7 @@
})
.catch(error => {
console.log("******** 3" + error);
document.querySelector(".history-container").innerHTML = `
if (container) container.innerHTML = `
<div class="d-flex justify-content-center align-items-center" style="height: 50vh; width:100%;">
<p class="text-center font-color-black"><i>No Data Found</i></p>
</div>

View File

@ -489,6 +489,8 @@ var pageBackButton = '<a href="<?= base_url('leads/list') ?>" class="topbar-icon
<script>
var actualLeadClientName = '';
var actualLeadShortName = '';
$(document).ready(function() {
$('#rfq_qcr_viewers').parsley({
@ -848,12 +850,29 @@ var pageBackButton = '<a href="<?= base_url('leads/list') ?>" class="topbar-icon
$('#policy_end_date').val("");
$("#appendArea_1").empty();
// --- Re-populate Actual Lead data if it was cleared ---
if ($('#actual_lead_id').val() && $('#actual_lead_id').val() != 0) {
$('#client_name').val(actualLeadClientName);
// Re-generate short name from the stored client name to ensure consistency
if (actualLeadClientName.trim() !== '') {
let baseName = actualLeadClientName
.trim()
.substring(0, 10)
.replace(/\s+/g, '')
.toUpperCase();
makeUniqueShortName(baseName);
} else {
$('#client_short_name').val('').parsley().reset();
}
}
})
function leadTypeBsedHideAndShow(value, resetValues = false) {
if (value == 1) {
var actual_lead_id = $('#actual_lead_id').val();
if (value == 1 || (actual_lead_id && actual_lead_id != 0 && value == 3)) {
$('.btnDiv').show();
$('.claim-row').hide();
@ -1336,17 +1355,17 @@ var pageBackButton = '<a href="<?= base_url('leads/list') ?>" class="topbar-icon
// CLIENT DETAILS AUTO FILL
// -------------------------------
if (actual_lead_client_details) {
$('#client_name').val(actual_lead_client_details.company_name || '');
actualLeadClientName = actual_lead_client_details.company_name || '';
$('#client_name').val(actualLeadClientName);
$('#gst').val(actual_lead_client_details.gst_number || '');
existingShortName = actual_lead_client_details.short_name || '';
if (existingShortName) {
// ── Short name EXISTS — just populate and validate ────────
$('#client_short_name').val(existingShortName);
// validateInput($('#client_short_name')[0], 'clients', 'short_name');
// existingShortName = actual_lead_client_details.short_name || '';
// if (existingShortName) {
// // ── Short name EXISTS — just populate and validate ────────
// $('#client_short_name').val(existingShortName);
// // validateInput($('#client_short_name')[0], 'clients', 'short_name');
} else {
// } else {}
// Auto-generate short name from company name
// Use a small delay to ensure DOM is ready
setTimeout(function () {
@ -1358,9 +1377,30 @@ var pageBackButton = '<a href="<?= base_url('leads/list') ?>" class="topbar-icon
makeUniqueShortName(baseName);
}, 300);
}
}
// Auto-generate short name from client name on user input.
$('#client_name').on('input', function() {
let clientName = $(this).val();
if (clientName.trim() !== '') {
let baseName = clientName
.trim()
.substring(0, 10)
.replace(/\s+/g, '')
.toUpperCase();
makeUniqueShortName(baseName);
} else {
$('#client_short_name').val('').parsley().reset();
}
});
// Keep short name variable in sync if it's generated or changed
$('#client_short_name').on('input change', function() {
if ($('#actual_lead_id').val() && $('#actual_lead_id').val() != 0) {
actualLeadShortName = $(this).val();
}
});
// -------------------------------
// CONTACT PERSON AUTO FILL
// -------------------------------