Add Location Picker
This commit is contained in:
parent
ffe913cb8f
commit
177cdef1cd
@ -5,6 +5,7 @@
|
||||
## 2024.3.22
|
||||
|
||||
- Fix Broadcast Message by @Focuslinkstech
|
||||
- Add Location Picker
|
||||
|
||||
## 2024.3.20
|
||||
|
||||
|
@ -16,6 +16,10 @@ if (empty ($action)) {
|
||||
$action = 'list';
|
||||
}
|
||||
|
||||
$leafletpickerHeader = <<<EOT
|
||||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css">
|
||||
EOT;
|
||||
|
||||
switch ($action) {
|
||||
case 'list':
|
||||
$search = _post('search');
|
||||
@ -89,6 +93,7 @@ switch ($action) {
|
||||
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin', 'Agent', 'Sales'])) {
|
||||
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
|
||||
}
|
||||
$ui->assign('xheader', $leafletpickerHeader);
|
||||
run_hook('view_add_customer'); #HOOK
|
||||
$ui->display('customers-add.tpl');
|
||||
break;
|
||||
@ -210,7 +215,6 @@ switch ($action) {
|
||||
$customFields = ORM::for_table('tbl_customers_fields')
|
||||
->where('customer_id', $customer['id'])
|
||||
->find_many();
|
||||
|
||||
$v = $routes['3'];
|
||||
if (empty ($v)) {
|
||||
$v = 'activation';
|
||||
@ -260,6 +264,7 @@ switch ($action) {
|
||||
if ($d) {
|
||||
$ui->assign('d', $d);
|
||||
$ui->assign('customFields', $customFields);
|
||||
$ui->assign('xheader', $leafletpickerHeader);
|
||||
$ui->display('customers-edit.tpl');
|
||||
} else {
|
||||
r2(U . 'customers/list', 'e', $_L['Account_Not_Found']);
|
||||
|
@ -534,5 +534,6 @@
|
||||
"20_Seconds": "20 Seconds",
|
||||
"Use_at_least_5_secs_if_you_are_sending_to_all_customers_to_avoid_being_banned_by_your_message_provider": "Use at least 5 secs if you are sending to all customers to avoid being banned by your message provider",
|
||||
"Testing__if_checked_no_real_message_is_sent_": "Testing [if checked no real message is sent]",
|
||||
"All_fields_are_required": "All fields are required"
|
||||
"All_fields_are_required": "All fields are required",
|
||||
"Personal": "Personal"
|
||||
}
|
@ -73,17 +73,6 @@
|
||||
<textarea name="address" id="address" class="form-control"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label">{Lang::T('Coordinates')}</label>
|
||||
<div class="col-md-9">
|
||||
<input name="coordinates" id="coordinates" class="form-control" value=""
|
||||
placeholder="6.465422, 3.406448">
|
||||
<span class="help-block">
|
||||
<small>{Lang::T('Latitude and Longitude coordinates for map must be separate with comma
|
||||
","')}</small>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label">{Lang::T('Service Type')}</label>
|
||||
<div class="col-md-9">
|
||||
@ -105,6 +94,14 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label">{Lang::T('Coordinates')}</label>
|
||||
<div class="col-md-9">
|
||||
<input name="coordinates" id="coordinates" class="form-control" value=""
|
||||
placeholder="6.465422, 3.406448">
|
||||
<div id="map" style="width: '100%'; height: 200px; min-height: 150px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -163,6 +160,42 @@
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script>
|
||||
<script>
|
||||
function getLocation() {
|
||||
if (navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(showPosition);
|
||||
} else {
|
||||
setupMap(51.505, -0.09);
|
||||
}
|
||||
}
|
||||
|
||||
function showPosition(position) {
|
||||
setupMap(position.coords.latitude, position.coords.longitude);
|
||||
}
|
||||
|
||||
function setupMap(lat, lon) {
|
||||
var map = L.map('map').setView([lat, lon], 13);
|
||||
L.tileLayer('https://{s}.basemaps.cartocdn.com/rastertiles/light_all/{z}/{x}/{y}.png', {
|
||||
attribution:
|
||||
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors © <a href="https://carto.com/attributions">CARTO</a>',
|
||||
subdomains: 'abcd',
|
||||
maxZoom: 20
|
||||
}).addTo(map);
|
||||
var marker = L.marker([lat, lon]).addTo(map);
|
||||
map.on('click', function(e){
|
||||
var coord = e.latlng;
|
||||
var lat = coord.lat;
|
||||
var lng = coord.lng;
|
||||
var newLatLng = new L.LatLng(lat, lng);
|
||||
marker.setLatLng(newLatLng);
|
||||
$('#coordinates').val(lat + ',' + lng);
|
||||
});
|
||||
}
|
||||
window.onload = function() {
|
||||
getLocation();
|
||||
}
|
||||
</script>
|
||||
{/literal}
|
||||
|
||||
|
||||
|
@ -77,16 +77,6 @@
|
||||
<textarea name="address" id="address" class="form-control">{$d['address']}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label">{Lang::T('Coordinates')}</label>
|
||||
<div class="col-md-9">
|
||||
<input name="coordinates" id="coordinates" class="form-control" value="{$d['coordinates']}">
|
||||
<span class="help-block">
|
||||
<small>{Lang::T('Latitude and Longitude coordinates for map must be separate with comma
|
||||
","')}</small>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label">{Lang::T('Service Type')}</label>
|
||||
<div class="col-md-9">
|
||||
@ -98,17 +88,25 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label">{Lang::T('Account Type')}</label>
|
||||
<div class="col-md-9">
|
||||
<select class="form-control" id="account_type" name="account_type">
|
||||
<option value="Personal" {if $d['account_type'] eq 'Personal' }selected{/if}>Personal
|
||||
</option>
|
||||
<option value="Business" {if $d['account_type'] eq 'Business' }selected{/if}>Business</option>
|
||||
<option value="Business" {if $d['account_type'] eq 'Business' }selected{/if}>Business
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label">{Lang::T('Coordinates')}</label>
|
||||
<div class="col-md-9">
|
||||
<input name="coordinates" id="coordinates" class="form-control" value="{$d['coordinates']}"
|
||||
placeholder="6.465422, 3.406448">
|
||||
<div id="map" style="width: '100%'; height: 200px; min-height: 150px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -186,6 +184,47 @@
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script>
|
||||
<script>
|
||||
function getLocation() {
|
||||
if (navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(showPosition);
|
||||
} else {
|
||||
setupMap(51.505, -0.09);
|
||||
}
|
||||
}
|
||||
|
||||
function showPosition(position) {
|
||||
setupMap(position.coords.latitude, position.coords.longitude);
|
||||
}
|
||||
|
||||
function setupMap(lat, lon) {
|
||||
var map = L.map('map').setView([lat, lon], 13);
|
||||
L.tileLayer('https://{s}.basemaps.cartocdn.com/rastertiles/light_all/{z}/{x}/{y}.png', {
|
||||
attribution:
|
||||
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors © <a href="https://carto.com/attributions">CARTO</a>',
|
||||
subdomains: 'abcd',
|
||||
maxZoom: 20
|
||||
}).addTo(map);
|
||||
var marker = L.marker([lat, lon]).addTo(map);
|
||||
map.on('click', function(e) {
|
||||
var coord = e.latlng;
|
||||
var lat = coord.lat;
|
||||
var lng = coord.lng;
|
||||
var newLatLng = new L.LatLng(lat, lng);
|
||||
marker.setLatLng(newLatLng);
|
||||
$('#coordinates').val(lat + ',' + lng);
|
||||
});
|
||||
}
|
||||
window.onload = function() {
|
||||
{/literal}{if $d['coordinates']}
|
||||
setupMap({$d['coordinates']});
|
||||
{else}
|
||||
getLocation();
|
||||
{/if}{literal}
|
||||
}
|
||||
</script>
|
||||
{/literal}
|
||||
|
||||
{include file="sections/footer.tpl"}
|
@ -38,7 +38,7 @@
|
||||
</li>
|
||||
{/if}
|
||||
<li class="list-group-item">
|
||||
<b>{Lang::T('Coordinates')}</b> <span class="pull-right">{Lang::T($d['coordinates'])}</span>
|
||||
<b>{Lang::T('Coordinates')}</b> <span class="pull-right">{$d['coordinates']}</span>
|
||||
</li>
|
||||
<!--Customers Attributes view start -->
|
||||
{if $customFields}
|
||||
|
@ -5,14 +5,27 @@
|
||||
|
||||
{literal}
|
||||
<script>
|
||||
window.onload = function() {
|
||||
var map = L.map('map').setView([51.505, -0.09], 13);
|
||||
function getLocation() {
|
||||
if (navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(showPosition);
|
||||
} else {
|
||||
setupMap(51.505, -0.09);
|
||||
}
|
||||
}
|
||||
|
||||
function showPosition(position) {
|
||||
setupMap(position.coords.latitude, position.coords.longitude);
|
||||
}
|
||||
|
||||
function setupMap(lat, lon) {
|
||||
var map = L.map('map').setView([lat, lon], 13);
|
||||
var group = L.featureGroup().addTo(map);
|
||||
|
||||
var customers = {/literal}{$customers|json_encode}{literal};
|
||||
|
||||
L.tileLayer('https://{s}.basemaps.cartocdn.com/rastertiles/light_all/{z}/{x}/{y}.png', {
|
||||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors © <a href="https://carto.com/attributions">CARTO</a>',
|
||||
attribution:
|
||||
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors © <a href="https://carto.com/attributions">CARTO</a>',
|
||||
subdomains: 'abcd',
|
||||
maxZoom: 20
|
||||
}).addTo(map);
|
||||
@ -40,6 +53,9 @@
|
||||
|
||||
map.fitBounds(group.getBounds());
|
||||
}
|
||||
window.onload = function() {
|
||||
getLocation();
|
||||
}
|
||||
</script>
|
||||
{/literal}
|
||||
{include file="sections/footer.tpl"}
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"version": "2024.3.22"
|
||||
"version": "2024.3.22.1"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user