Lead Management System






Lead Details

Name:
Phone:
Year:

Make:
Model:
Miles:

Color:
VIN:
Price:
Trade:

Last Contact:
Notes:

Schedule Event/Task












Loading…



async function loadLeadData(row) {
showLoading();
try {
const response = await gapi.client.sheets.spreadsheets.values.get({
spreadsheetId: SPREADSHEET_ID,
range: `Master List!A${row}:V${row}`
});

const values = response.result.values[0];
if (values) {
const leadData = {
id: values[0],
year: values[4],
make: values[5],
model: values[6],
price: values[7],
trade: values[8],
name: values[14],
phone: values[15],
vin: values[16],
miles: values[17],
color: values[18],
notes: values[20],
lastContact: values[21]
};
updateLeadDisplay(leadData);
currentRow = row;
}
} catch (error) {
console.error(‘Error loading lead:’, error);
alert(‘Error loading lead data’);
} finally {
hideLoading();
}
}

function updateLeadDisplay(leadData) {
document.getElementById(‘leadName’).textContent = leadData.name || ”;
document.getElementById(‘leadPhone’).textContent = leadData.phone || ”;
document.getElementById(‘leadYear’).textContent = leadData.year || ”;
document.getElementById(‘leadMake’).textContent = leadData.make || ”;
document.getElementById(‘leadModel’).textContent = leadData.model || ”;
document.getElementById(‘leadMiles’).textContent = leadData.miles || ”;
document.getElementById(‘leadColor’).textContent = leadData.color || ”;
document.getElementById(‘leadVin’).textContent = leadData.vin || ”;
document.getElementById(‘leadPrice’).textContent = formatCurrency(leadData.price);
document.getElementById(‘leadTrade’).textContent = formatCurrency(leadData.trade);
document.getElementById(‘leadLastContact’).textContent = leadData.lastContact || ”;
document.getElementById(‘leadNotes’).textContent = leadData.notes || ‘No notes available.’;

document.getElementById(‘eventTitle’).value = `Follow up with ${leadData.name} – ${leadData.year} ${leadData.make} ${leadData.model}`;
document.getElementById(‘eventNotes’).value = leadData.notes || ”;
}

function formatCurrency(value) {
return new Intl.NumberFormat(‘en-US’, { style: ‘currency’, currency: ‘USD’ }).format(value || 0);
}

async function searchLeads() {
const searchTerm = document.getElementById(‘searchInput’).value.trim().toLowerCase();
if (!searchTerm) {
alert(‘Please enter a search term’);
return;
}

showLoading();
try {
const response = await gapi.client.sheets.spreadsheets.values.get({
spreadsheetId: SPREADSHEET_ID,
range: ‘Master List!A2:V’
});

const rows = response.result.values;
if (rows && rows.length > 0) {
const results = rows.filter((row, index) => {
const searchFields = [
row[14], // name
row[15], // phone
row[4], // year
row[5], // make
row[6], // model
row[16], // vin
row[20] // notes
].map(field => String(field || ”).toLowerCase());

return searchFields.some(field => field.includes(searchTerm));
}).slice(0, 10);

displaySearchResults(results);
}
} catch (error) {
console.error(‘Error searching:’, error);
alert(‘Error performing search’);
} finally {
hideLoading();
}
}

function displaySearchResults(results) {
const resultsDiv = document.getElementById(‘searchResults’);
if (!results || results.length === 0) {
resultsDiv.innerHTML = ‘

No results found

‘;
return;
}

resultsDiv.innerHTML = results.map((row, index) => `

${row[14]} – ${row[4]} ${row[5]} ${row[6]}

Phone: ${row[15]} | VIN: ${row[16]}

`).join(”);
}

async function applyStamp(stampType) {
showLoading();
try {
const dateStamp = new Date().toLocaleDateString() + ” ” + stampType;
await gapi.client.sheets.spreadsheets.values.update({
spreadsheetId: SPREADSHEET_ID,
range: `Master List!V${currentRow}`,
valueInputOption: ‘RAW’,
resource: {
values: [[dateStamp]]
}
});
loadLeadData(currentRow);
} catch (error) {
console.error(‘Error applying stamp:’, error);
alert(‘Error applying stamp’);
} finally {
hideLoading();
}
}

function nextLead() {
loadLeadData(currentRow + 1);
}

// Initialize the Google API client
gapi.load(‘client:auth2’, initClient);




Reset password

Enter your email address and we will send you a link to change your password.

Get started with your account

to save your favourite homes and more

Sign up with email

Get started with your account

to save your favourite homes and more

By clicking the «SIGN UP» button you agree to the Terms of Use and Privacy Policy
Powered by Estatik