CIM37 - Country view
This commit is contained in:
@@ -229,7 +229,9 @@ echo <<<EOT
|
||||
<title>$title</title>
|
||||
<link rel="icon" type="image/png" href="$icon_image">
|
||||
<link href="./style/admin.css" rel="stylesheet" type="text/css">
|
||||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" />
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v6.0.0/css/all.css">
|
||||
<script src="./assets/leaflet.js"></script>
|
||||
</head>
|
||||
<body class="admin">
|
||||
<aside class="responsive-width-100 responsive-hidden">
|
||||
@@ -1851,4 +1853,52 @@ function createPartner($user_salesid,$user_soldto,$p_name,$p_type, $token){
|
||||
}
|
||||
}
|
||||
return $p_return;
|
||||
}
|
||||
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// Update GEOlOCATION
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
function geolocationUpdate($token){
|
||||
include dirname(__FILE__,2).'/settings/settings.php';
|
||||
//GET ALL WARRANTY REGISTRATIONS WHERE NO GEOLOCATION SET
|
||||
$sql = 'SELECT e.*, h.* FROM equipment e join history h on e.rowID = h.equipmentid where h.type = "Warranty" AND e.geolocation is Null';
|
||||
$pdo = dbConnect($dbname);
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute();
|
||||
$messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
//FOR ALL RECORDS RETURN FIND GEOLOCATION AT OSM
|
||||
foreach ($messages as $message){
|
||||
$warranty = json_decode($message['description']);
|
||||
|
||||
//API URL OSM
|
||||
$api_url = 'https://nominatim.openstreetmap.org/search?format=json&city='.$warranty->city.'&country='.$warranty->country;
|
||||
|
||||
//BUILD UP FILESTREAM
|
||||
$httpOptions = [
|
||||
"http" => [
|
||||
"method" => "GET",
|
||||
"header" => "User-Agent: Nominatim-Test"
|
||||
]
|
||||
];
|
||||
|
||||
$streamContext = stream_context_create($httpOptions);
|
||||
$geo_feedback = file_get_contents($api_url, false, $streamContext);
|
||||
$geo_feedback = json_decode($geo_feedback, true) ?? '';
|
||||
|
||||
//CHECK IF RESULTS ARE FOUND
|
||||
if (!empty($geo_feedback) || $geo_feedback !=''){
|
||||
$lat = $geo_feedback[0]["lat"] ?? '';
|
||||
$long = $geo_feedback[0]["lon"] ?? '';
|
||||
$geo_feedback = array($lat,$long);
|
||||
//JSON ENCODE GEOLOCATION RECEIVED AND SENT TO EQUIPMENT API
|
||||
$geo_feedback = json_encode($geo_feedback);
|
||||
//BUILD POST DATA
|
||||
$data = json_encode(array("rowID" => $message['equipmentid'] , "geolocation" => $geo_feedback), JSON_UNESCAPED_UNICODE);
|
||||
//Secure data
|
||||
$payload = generate_payload($data);
|
||||
//API call
|
||||
ioAPI('/v1/equipments', $payload, $token);
|
||||
}
|
||||
}
|
||||
}
|
||||
6
assets/leaflet.js
Normal file
6
assets/leaflet.js
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user