CIM37 - Improved error handling geolocation
This commit is contained in:
@@ -221,31 +221,33 @@ $view .= '<div class="content-block">
|
|||||||
if (!empty($responses->geolocation) || $responses->geolocation != ''){
|
if (!empty($responses->geolocation) || $responses->geolocation != ''){
|
||||||
|
|
||||||
$geolocation = json_decode($responses->geolocation,true);
|
$geolocation = json_decode($responses->geolocation,true);
|
||||||
$view .= '<div class="content-block">
|
if ($geolocation[1] != ''){
|
||||||
<div id="map" style="height:300px;z-index: 0;">
|
$view .= '<div class="content-block">
|
||||||
</div>
|
<div id="map" style="height:300px;z-index: 0;">
|
||||||
<script>
|
</div>
|
||||||
// initialize Leaflet
|
<script>
|
||||||
var map = L.map(\'map\').setView({lon: '.$geolocation[1].', lat: '.$geolocation[0].'}, 10);
|
// initialize Leaflet
|
||||||
|
var map = L.map(\'map\').setView({lon: '.$geolocation[1].', lat: '.$geolocation[0].'}, 10);
|
||||||
|
|
||||||
//Add TSS Avatar to MAP
|
//Add TSS Avatar to MAP
|
||||||
var TSSemp = L.icon({
|
var TSSemp = L.icon({
|
||||||
iconUrl: \'./assets/images/EP.png\',
|
iconUrl: \'./assets/images/EP.png\',
|
||||||
iconSize: [50, 50], // size of the icon
|
iconSize: [50, 50], // size of the icon
|
||||||
});
|
});
|
||||||
L.marker(['.$geolocation[0].','.$geolocation[1].'], {icon: TSSemp}).addTo(map);
|
L.marker(['.$geolocation[0].','.$geolocation[1].'], {icon: TSSemp}).addTo(map);
|
||||||
|
|
||||||
// add the OpenStreetMap tiles
|
// add the OpenStreetMap tiles
|
||||||
L.tileLayer(\'https://tile.openstreetmap.org/{z}/{x}/{y}.png\', {
|
L.tileLayer(\'https://tile.openstreetmap.org/{z}/{x}/{y}.png\', {
|
||||||
maxZoom: 19,
|
maxZoom: 19,
|
||||||
attribution: \'© <a href="https://openstreetmap.org/copyright">OpenStreetMap contributors</a>\'
|
attribution: \'© <a href="https://openstreetmap.org/copyright">OpenStreetMap contributors</a>\'
|
||||||
}).addTo(map);
|
}).addTo(map);
|
||||||
|
|
||||||
// show the scale bar on the lower left corner
|
// show the scale bar on the lower left corner
|
||||||
L.control.scale({imperial: true, metric: true}).addTo(map);
|
L.control.scale({imperial: true, metric: true}).addTo(map);
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
';
|
';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get all related service events
|
//Get all related service events
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ $equipment = [
|
|||||||
'service_date' => $date,
|
'service_date' => $date,
|
||||||
'warranty_date' => $date,
|
'warranty_date' => $date,
|
||||||
'order_ref' => '',
|
'order_ref' => '',
|
||||||
'geolocation' => ''
|
'geolocation' => []
|
||||||
];
|
];
|
||||||
|
|
||||||
$equipment_ID = $_GET['equipmentID'] ?? '';
|
$equipment_ID = $_GET['equipmentID'] ?? '';
|
||||||
@@ -65,6 +65,8 @@ if (isset($_GET['equipmentID'])) {
|
|||||||
|
|
||||||
if ($update_allowed === 1 || $equipment_owner === 1 || $update_allowed_special === 1){
|
if ($update_allowed === 1 || $equipment_owner === 1 || $update_allowed_special === 1){
|
||||||
if (isset($_POST['submit'])) {
|
if (isset($_POST['submit'])) {
|
||||||
|
//GEOLOCATION ARRAY convert to JSON
|
||||||
|
$_POST['geolocation'] = json_encode($_POST['geolocation'],JSON_UNESCAPED_UNICODE);
|
||||||
//GET ALL POST DATA
|
//GET ALL POST DATA
|
||||||
$data = json_encode($_POST, JSON_UNESCAPED_UNICODE);
|
$data = json_encode($_POST, JSON_UNESCAPED_UNICODE);
|
||||||
//Secure data
|
//Secure data
|
||||||
@@ -101,6 +103,8 @@ if (isset($_GET['equipmentID'])) {
|
|||||||
} else {
|
} else {
|
||||||
// Create a new equipment
|
// Create a new equipment
|
||||||
if (isset($_POST['submit']) && $create_allowed === 1) {
|
if (isset($_POST['submit']) && $create_allowed === 1) {
|
||||||
|
//GEOLOCATION ARRAY convert to JSON
|
||||||
|
$_POST['geolocation'] = json_encode($_POST['geolocation'],JSON_UNESCAPED_UNICODE);
|
||||||
//GET ALL POST DATA
|
//GET ALL POST DATA
|
||||||
$data = json_encode($_POST, JSON_UNESCAPED_UNICODE);
|
$data = json_encode($_POST, JSON_UNESCAPED_UNICODE);
|
||||||
//Secure data
|
//Secure data
|
||||||
@@ -217,7 +221,7 @@ $view .= '
|
|||||||
$changelog = showlog('equipment',$equipment_ID)?? '';
|
$changelog = showlog('equipment',$equipment_ID)?? '';
|
||||||
|
|
||||||
//GEOLOCATION
|
//GEOLOCATION
|
||||||
$geo_details = $equipment['geolocation'] ?? '';
|
$geo_details = json_decode($equipment['geolocation']) ?? '';
|
||||||
if (is_array($geo_details)) {
|
if (is_array($geo_details)) {
|
||||||
$geodetails_lat = $geo_details[0];
|
$geodetails_lat = $geo_details[0];
|
||||||
$geodetails_lon = $geo_details[1];
|
$geodetails_lon = $geo_details[1];
|
||||||
|
|||||||
Reference in New Issue
Block a user