diff --git a/modules/gestione_componenti/ajax/select.php b/modules/gestione_componenti/ajax/select.php index 6ab3d6505..b3523195e 100644 --- a/modules/gestione_componenti/ajax/select.php +++ b/modules/gestione_componenti/ajax/select.php @@ -8,7 +8,7 @@ switch ($resource) { $query = 'SELECT id, nome AS descrizione, contenuto FROM my_impianto_componenti |where| ORDER BY id'; foreach ($elements as $element) { - $filter[] = 'idimpianto='.prepare($element); + $filter[] = 'id='.prepare($element); } $temp = []; diff --git a/modules/my_impianti/plugins/my_impianti.interventi.php b/modules/my_impianti/plugins/my_impianti.interventi.php index 9d1503d36..095e97583 100644 --- a/modules/my_impianti/plugins/my_impianti.interventi.php +++ b/modules/my_impianti/plugins/my_impianti.interventi.php @@ -32,18 +32,12 @@ if (filter('op') == 'link_myimpianti') { flash()->info(tr('Informazioni impianti salvate!')); } elseif (filter('op') == 'link_componenti') { $components = (array) post('componenti'); + $id_impianto = post('id_impianto'); - $list = (!empty(post('list'))) ? explode(',', post('list')) : []; - foreach ($list as $delete) { - if (!in_array($delete, $components)) { - $dbo->query('DELETE FROM my_componenti_interventi WHERE id_componente = '.prepare($delete).' AND id_intervento = '.prepare($id_record)); - } - } + $dbo->query('DELETE FROM my_componenti_interventi WHERE id_componente IN (SELECT id FROM my_impianto_componenti WHERE idimpianto = '.prepare($id_impianto).') AND id_intervento = '.prepare($id_record)); foreach ($components as $component) { - if (!in_array($component, $list)) { - $dbo->query('INSERT INTO my_componenti_interventi(id_componente, id_intervento) VALUES('.prepare($component).', '.prepare($id_record).')'); - } + $dbo->query('INSERT INTO my_componenti_interventi(id_componente, id_intervento) VALUES ('.prepare($component).', '.prepare($id_record).')'); } flash()->info(tr('Informazioni componenti salvate!')); @@ -117,37 +111,14 @@ foreach ($rs as $r) {