feat: gestione geolocalizzazione

This commit is contained in:
valentina 2024-11-04 16:31:55 +01:00
parent 68643ab1be
commit f5244ff946
3 changed files with 6 additions and 0 deletions

View File

@ -23,6 +23,7 @@ if (!function_exists('geolocalizzazione')) {
function geolocalizzazione($id_record, $is_sede = false)
{
$dbo = database();
$lang = \Models\Locale::find(setting('Lingua'))->language_code;
if ($is_sede) {
$sede = $dbo->table('an_sedi')->where('id', $id_record)->first();
@ -69,6 +70,7 @@ if (!function_exists('geolocalizzazione')) {
} else {
$ch = curl_init();
}
$url = 'https://nominatim.openstreetmap.org/search.php?q='.$indirizzo.'&format=jsonv2&accept-language='.$lang;
$user_agent = 'traccar';
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);

View File

@ -462,6 +462,8 @@ class Anagrafica extends Model
} else {
$ch = curl_init();
}
$lang = \Models\Locale::find(setting('Lingua'))->language_code;
$url = 'https://nominatim.openstreetmap.org/search.php?q='.$indirizzo.'&format=jsonv2&accept-language='.$lang;
$user_agent = 'traccar';
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);

View File

@ -106,6 +106,8 @@ class Sede extends Model
} else {
$ch = curl_init();
}
$lang = \Models\Locale::find(setting('Lingua'))->language_code;
$url = 'https://nominatim.openstreetmap.org/search.php?q='.$indirizzo.'&format=jsonv2&accept-language='.$lang;
$user_agent = 'traccar';
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);