document.getElementById('locationSearchResults').innerHTML = '
Type to search and press Enter... ';
> var modal = new bootstrap.Modal(document.getElementById("locationSearchModal"));
modal.show();
setTimeout(() => {
document.getElementById('locSearchInput').focus();
performLocationSearch(); // Auto fetch on open
}, 200);
}
function performLocationSearch() {
let kw = document.getElementById('locSearchInput').value;
let tbody = document.getElementById('locationSearchResults');
tbody.innerHTML = ' Searching... ';
let url = (typeof baseUrl !== 'undefined' ? baseUrl : (window.location.origin + '/flystarcourier/public')) + '/admin/shipments/geocodeSearch';
if (window.location.href.indexOf('/branch/') !== -1) {
url = url.replace('/admin/shipments/', '/branch/shipments/');
}
fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'X-Requested-With': 'XMLHttpRequest' },
body: 'keyword=' + encodeURIComponent(kw)
})
.then(r => r.json())
.then(res => {
if(res.status === 'success' && res.data && res.data.length > 0) {
let html = '';
res.data.forEach(item => {
let code = item.code || item.name.substring(0,3).toUpperCase();
let fullAddr = (item.full_address || item.name).replace(/'/g, "\\'");
html += `
${item.name}
${item.full_address}
${item.pincode || code}
Select
`;
});
tbody.innerHTML = html;
}
> var modalEl = document.getElementById("locationSearchModal");
var modal = bootstrap.Modal.getInstance(modalEl);
if (modal) modal.hide();
if(typeof checkVendorServiceability === 'function') checkVendorServiceability();
}
= $this->endSection() ?>
= $this->section('styles') ?>