Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion modules/anagrafiche/ajax/select.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)).')';
Expand Down