From d7efa43506e312b103f15a8e6065add9c6c39b8e Mon Sep 17 00:00:00 2001 From: Andrea Bruno <21980406+Andrea-Bruno@users.noreply.github.com> Date: Thu, 15 Oct 2026 13:30:49 +0200 Subject: [PATCH] Fix sedi secondarie non visualizzate nel selettore sedi_azienda --- modules/anagrafiche/ajax/select.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/anagrafiche/ajax/select.php b/modules/anagrafiche/ajax/select.php index ae612368d..064cf8d92 100755 --- a/modules/anagrafiche/ajax/select.php +++ b/modules/anagrafiche/ajax/select.php @@ -430,11 +430,14 @@ $user = auth_osm()->getUser(); $id_azienda = setting('Azienda predefinita'); - $query = "SELECT * FROM (SELECT '0' AS id, 'Sede legale' AS `nome_sede`, CONCAT_WS(' - ', \"".tr('Sede legale')."\" , (SELECT CONCAT (`citta`, IF(`indirizzo`!='',CONCAT(' (', `indirizzo`, ')'), ''),' (', `ragione_sociale`,')') FROM `an_anagrafiche` |where|)) AS descrizione UNION SELECT `id`, `nome_sede`, CONCAT_WS(' - ', `nome_sede`, CONCAT(`citta`, IF(`indirizzo`!='',CONCAT(' (', `indirizzo`, ')'), '')) ) FROM `an_sedi` |where| ORDER BY `nome_sede`) AS tab |filter| ORDER BY descrizione"; + $query = "SELECT * FROM (SELECT '0' AS id, 'Sede legale' AS `nome_sede`, CONCAT_WS(' - ', \"".tr('Sede legale')."\" , (SELECT CONCAT (`citta`, IF(`indirizzo`!='',CONCAT(' (', `indirizzo`, ')'), ''),' (', `ragione_sociale`,')') FROM `an_anagrafiche` |where|)) AS descrizione UNION SELECT `id`, `nome_sede`, CONCAT_WS(' - ', `nome_sede`, CONCAT(`citta`, IF(`indirizzo`!='',CONCAT(' (', `indirizzo`, ')'), '')) ) FROM `an_sedi` |where_sedi| ORDER BY `nome_sede`) AS tab |filter| ORDER BY descrizione"; $where[] = '`id`='.prepare($id_azienda); $where[] = 'deleted_at IS NULL'; + // Secondary seats belong to the company through id_anagrafica, not their own primary key + $query = str_replace('|where_sedi|', 'WHERE `id_anagrafica`='.prepare($id_azienda).' AND deleted_at IS NULL', $query); + // filtro in base alle sedi abilitate dell'utente if ($user->gruppo != 'Amministratori') { $filter[] = '`id` IN('.implode(',', array_map(prepare(...), $user->sedi)).')';