show maps on customer view

This commit is contained in:
Ibnu Maksum 2024-03-23 12:56:25 +07:00
parent 58c4037d8c
commit 5426d9f35f
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
5 changed files with 56 additions and 27 deletions

View File

@ -2,6 +2,12 @@
# CHANGELOG
## 2024.3.23
- Maps full height
- Show Get Directions instead Coordinates
- Maps Label always show
## 2024.3.22
- Fix Broadcast Message by @Focuslinkstech

View File

@ -245,6 +245,7 @@ switch ($action) {
$ui->assign('v', $v);
$ui->assign('d', $customer);
$ui->assign('customFields', $customFields);
$ui->assign('xheader', $leafletpickerHeader);
$ui->display('customers-view.tpl');
} else {
r2(U . 'customers/list', 'e', $_L['Account_Not_Found']);

View File

@ -37,14 +37,6 @@
onclick="this.select()">
</li>
{/if}
{if $d['coordinates']}
<li class="list-group-item">
<b>{Lang::T('Coordinates')}</b> <span class="pull-right">
<a href="https://www.google.com/maps/dir//{$d['coordinates']}/" target="_blank">Get
Directions</a>
</span>
</li>
{/if}
<!--Customers Attributes view start -->
{if $customFields}
{foreach $customFields as $customField}
@ -82,6 +74,16 @@
<b>{Lang::T('Last Login')}</b> <span
class="pull-right">{Lang::dateTimeFormat($d['last_login'])}</span>
</li>
{if $d['coordinates']}
<li class="list-group-item">
<b>{Lang::T('Coordinates')}</b> <span class="pull-right">
<i class="glyphicon glyphicon-road"></i> <a style="color: black;"
href="https://www.google.com/maps/dir//{$d['coordinates']}/" target="_blank">Get
Directions</a>
</span>
<div id="map" style="width: '100%'; height: 100px;"></div>
</li>
{/if}
</ul>
<div class="row">
<div class="col-xs-4">
@ -230,4 +232,24 @@
</div>
</div>
{if $d['coordinates']}
{literal}
<script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script>
<script>
function setupMap(lat, lon) {
var map = L.map('map').setView([lat, lon], 17);
L.tileLayer('https://{s}.basemaps.cartocdn.com/rastertiles/light_all/{z}/{x}/{y}.png', {
attribution:
'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors &copy; <a href="https://carto.com/attributions">CARTO</a>',
subdomains: 'abcd',
maxZoom: 20
}).addTo(map);
var marker = L.marker([lat, lon]).addTo(map);
}
window.onload = function() {
{/literal}setupMap({$d['coordinates']});{literal}
}
</script>
{/literal}
{/if}
{include file="sections/footer.tpl"}

View File

@ -18,8 +18,8 @@
<div class="col-md-8">
<form id="site-search" method="post" action="{$_url}customers/list/">
<div class="input-group">
<input type="text" id="search-input" name="search" value="{$search}" class="form-control"
placeholder="{Lang::T('Search')}...">
<input type="text" id="search-input" name="search" value="{$search}"
class="form-control" placeholder="{Lang::T('Search')}...">
<div class="input-group-btn">
<button class="btn btn-success" type="submit"><span
class="fa fa-search"></span></button>
@ -28,8 +28,8 @@
</form>
</div>
<div class="col-md-4">
<a href="{$_url}customers/add" class="btn btn-primary btn-block"><i
class="ion ion-android-add"> </i> {Lang::T('Add New Contact')}</a>
<a href="{$_url}customers/add" class="btn btn-primary btn-block"><i class="ion ion-android-add">
</i> {Lang::T('Add New Contact')}</a>
</div>&nbsp;
</div>
<div class="table-responsive table_mobile">
@ -53,7 +53,7 @@
<tr>
<td onclick="window.location.href = '{$_url}customers/view/{$ds['id']}'"
style="cursor:pointer;">{$ds['username']}</td>
<td>{$ds['account_type']}</td>
<td>{$ds['account_type']}</td>
<td onclick="window.location.href = '{$_url}customers/view/{$ds['id']}'"
style="cursor: pointer;">{$ds['fullname']}</td>
<td>{Lang::moneyFormat($ds['balance'])}</td>
@ -83,23 +83,23 @@
<script>
// Functionality to filter table rows based on admin input
document.addEventListener('DOMContentLoaded', function () {
var searchInput = document.getElementById('search-input');
var tableRows = document.querySelectorAll('tbody tr');
document.addEventListener('DOMContentLoaded', function() {
var searchInput = document.getElementById('search-input');
var tableRows = document.querySelectorAll('tbody tr');
searchInput.addEventListener('input', function () {
var searchText = this.value.toLowerCase();
searchInput.addEventListener('input', function() {
var searchText = this.value.toLowerCase();
tableRows.forEach(function (row) {
var rowData = row.textContent.toLowerCase();
tableRows.forEach(function(row) {
var rowData = row.textContent.toLowerCase();
if (rowData.includes(searchText)) {
row.style.display = '';
} else {
row.style.display = 'none';
}
});
if (rowData.includes(searchText)) {
row.style.display = '';
} else {
row.style.display = 'none';
}
});
});
});
</script>
{include file="sections/footer.tpl"}

View File

@ -1,3 +1,3 @@
{
"version": "2024.3.22.1"
"version": "2024.3.23"
}