switched 2 inputs

This commit is contained in:
Luca Haid
2024-11-20 12:26:22 +00:00
parent b36f8108ad
commit 5bb51fd676
5 changed files with 118 additions and 46 deletions

View File

@@ -15,7 +15,7 @@ class WarehouseShippingNoteController extends TTCrud {
['key' => 'deliveryAddressLine', 'text' => 'L.-Adr.', 'required' => true],
['key' => 'deliveryAddressPLZ', 'text' => 'L.-Adr. PLZ', 'required' => true],
['key' => 'deliveryAddressEMail', 'text' => 'L.-Adr. EMail', 'required' => true, 'table' => false],
['key' => 'note', 'text' => 'Notiz', 'required' => true, 'table' => false],
['key' => 'note', 'text' => 'Art der Arbeit', 'required' => true, 'table' => false],
['key' => 'status',
'text' => 'Status',
'required' => true,
@@ -387,6 +387,37 @@ class WarehouseShippingNoteController extends TTCrud {
die(json_encode(['success' => true, 'status' => 'USER_NO_CAR']));
}
protected function geoAutocompleteAction() {
$search = $this->request->q;
$search = urlencode($search);
$url = "https://nominatim.haid.in/search?q=$search&format=json";
$data = json_decode(file_get_contents($url), true);
$out = [];
foreach ($data as $entry) {
$parsedDisplayNameParts = [];
foreach(explode(',', $entry['display_name']) as $part) {
// if str_includes Bezirk remove it
if (strpos($part, 'Bezirk') !== false) {
continue;
}
$parsedDisplayNameParts[] = $part;
}
$out[] = ['value' => $entry['lat'] . "," . $entry['lon'], 'text' => implode(',', $parsedDisplayNameParts)];
}
self::returnJson($out);
}
protected function geoReverseAction() {
$lat = $this->request->lat;
$lon = $this->request->lon;
$url = "https://nominatim.haid.in/reverse?lat=$lat&lon=$lon&format=json";
$data = json_decode(file_get_contents($url), true);
self::returnJson($data);
}
//TODO: export this to an api class for openstreetmap
protected function getDistanceAction() {
@@ -413,7 +444,7 @@ class WarehouseShippingNoteController extends TTCrud {
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://nominatim.openstreetmap.org/search?q=$address&format=json",
CURLOPT_URL => "https://nominatim.haid.in/search?q=$address&format=json",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_ENCODING => "",