diff --git a/modules/contratti/plugins/add_articolo.php b/modules/contratti/plugins/add_articolo.php
index 1bba7bc99..ba459dfe9 100644
--- a/modules/contratti/plugins/add_articolo.php
+++ b/modules/contratti/plugins/add_articolo.php
@@ -13,7 +13,6 @@ for ($i = 0; $i < count($rs); ++$i) {
$idriga = get('idriga');
//$idautomezzo = (get('idautomezzo') == 'undefined') ? '' : get('idautomezzo');
-//$_SESSION['superselect']['idintervento'] = get('id_record');
// Lettura idanagrafica cliente e percentuale di sconto/rincaro in base al listino
$rs = $dbo->fetchArray('SELECT idanagrafica FROM co_contratti WHERE id='.prepare($id_record));
diff --git a/modules/interventi/add.php b/modules/interventi/add.php
index 5fe1b600b..ee62adb4b 100644
--- a/modules/interventi/add.php
+++ b/modules/interventi/add.php
@@ -156,7 +156,7 @@ if (empty($new_codice)) {
- {[ "type": "select", "label": "", "multiple": 1, "name": "idimpianti[]", "value": "", "placeholder": "...", "ajax-source": "impianti", "icon-after": "add||source=Attività |", "data-heavy": 0 ]}
+ {[ "type": "select", "label": "", "multiple": 1, "name": "idimpianti[]", "value": "", "placeholder": "...", "ajax-source": "impianti-cliente", "icon-after": "add||source=Attività |", "data-heavy": 0 ]}
diff --git a/modules/interventi/add_articolo.php b/modules/interventi/add_articolo.php
index a6edd23c0..2480aef25 100644
--- a/modules/interventi/add_articolo.php
+++ b/modules/interventi/add_articolo.php
@@ -111,7 +111,7 @@ echo '
// Impianto
echo '
- {[ "type": "select", "label": "'.tr('Impianto su cui installare').'", "name": "idimpianto", "value": "'.$idimpianto.'", "ajax-source": "impianti" ]}
+ {[ "type": "select", "label": "'.tr('Impianto su cui installare').'", "name": "idimpianto", "value": "'.$idimpianto.'", "ajax-source": "impianti-intervento" ]}
';
diff --git a/modules/my_impianti/ajax/select.php b/modules/my_impianti/ajax/select.php
index 96a1dbd9b..56940e55b 100644
--- a/modules/my_impianti/ajax/select.php
+++ b/modules/my_impianti/ajax/select.php
@@ -4,6 +4,19 @@ include_once __DIR__.'/../../../core.php';
switch ($resource) {
case 'impianti':
+ $query = 'SELECT id, CONCAT(matricola, " - ", nome) AS descrizione FROM my_impianti |where| ORDER BY id, idanagrafica';
+
+ foreach ($elements as $element) {
+ $filter[] = 'id='.prepare($element);
+ }
+
+ if (!empty($search)) {
+ $search_fields[] = 'nome LIKE '.prepare('%'.$search.'%');
+ $search_fields[] = 'matricola LIKE '.prepare('%'.$search.'%');
+ }
+ break;
+
+ case 'impianti-cliente':
if (isset($superselect['idanagrafica'])) {
$query = 'SELECT id, CONCAT(matricola, " - ", nome) AS descrizione FROM my_impianti |where| ORDER BY idsede';
@@ -19,7 +32,10 @@ switch ($resource) {
$search_fields[] = 'matricola LIKE '.prepare('%'.$search.'%');
}
}
- elseif( isset($superselect['idintervento']) ){
+ break;
+
+ case 'impianti-intervento':
+ if( isset($superselect['idintervento']) ){
$query = 'SELECT id, CONCAT(matricola, " - ", nome) AS descrizione FROM my_impianti INNER JOIN my_impianti_interventi ON my_impianti.id=my_impianti_interventi.idimpianto |where| ORDER BY idsede';
foreach ($elements as $element) {