added new way to select areas for shipping note

This commit is contained in:
Luca Haid
2025-04-28 13:42:10 +02:00
parent fee73ab5f2
commit 3390deb336

View File

@@ -438,11 +438,10 @@ class WarehouseShippingNoteController extends TTCrud {
protected function geoAutocompleteAction() {
$search = $this->request->q;
$search = urlencode($search);
$url = "https://nominatim.haid.in/search?q=$search&format=json";
$url = "https://nominatim.haid.in/search?q=$search&format=json&addressdetails=1";
$data = json_decode(file_get_contents($url), true);
$out = [];
foreach ($data as $entry) {
$parsedDisplayNameParts = [];
foreach (explode(',', $entry['display_name']) as $part) {
@@ -460,7 +459,7 @@ class WarehouseShippingNoteController extends TTCrud {
}
}
}
$out[] = ['value' => $entry['lat'] . "," . $entry['lon'] . (!isset($entry['house_number']) ? ", area" : ""), 'text' => implode(',', $parsedDisplayNameParts)];
$out[] = ['value' => $entry['lat'] . "," . $entry['lon'] . (!isset($entry['address']['house_number']) ? ", area" : ""), 'text' => implode(',', $parsedDisplayNameParts)];
}