From 1a1548a396280099c4554d7f0d02255746fe08a4 Mon Sep 17 00:00:00 2001 From: Bacca97 Date: Mon, 23 Apr 2018 17:28:39 +0200 Subject: [PATCH] =?UTF-8?q?Impianti=20filtrati=20per=20attivit=C3=A0=20su?= =?UTF-8?q?=20aggiunta=20articolo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/interventi/add_articolo.php | 2 ++ modules/my_impianti/ajax/select.php | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/interventi/add_articolo.php b/modules/interventi/add_articolo.php index 59c0254c9..2c62d31a2 100644 --- a/modules/interventi/add_articolo.php +++ b/modules/interventi/add_articolo.php @@ -13,6 +13,8 @@ $can_edit_prezzi = (in_array('Amministratori', $gruppi)) || (get_var('Mostra i p $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 in_interventi WHERE id='.prepare($id_record)); diff --git a/modules/my_impianti/ajax/select.php b/modules/my_impianti/ajax/select.php index 9279bb612..4209606bd 100644 --- a/modules/my_impianti/ajax/select.php +++ b/modules/my_impianti/ajax/select.php @@ -4,7 +4,21 @@ include_once __DIR__.'/../../../core.php'; switch ($resource) { case 'impianti': - if (isset($superselect['idanagrafica'])) { + 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) { + $filter[] = 'id='.prepare($element); + } + + $where[] = 'my_impianti_interventi.idintervento='.prepare($superselect['idintervento']); + + if (!empty($search)) { + $search_fields[] = 'nome LIKE '.prepare('%'.$search.'%'); + $search_fields[] = 'matricola LIKE '.prepare('%'.$search.'%'); + } + } + elseif (isset($superselect['idanagrafica'])) { $query = 'SELECT id, CONCAT(matricola, " - ", nome) AS descrizione FROM my_impianti |where| ORDER BY idsede'; foreach ($elements as $element) {