2018-02-04 09:41:46 +01:00
|
|
|
<?php
|
2020-09-07 15:04:06 +02:00
|
|
|
/*
|
|
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
|
|
|
* Copyright (C) DevCode s.n.c.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2018-02-04 09:41:46 +01:00
|
|
|
|
2020-08-26 18:03:59 +02:00
|
|
|
use Util\Ini;
|
|
|
|
|
2018-02-04 09:41:46 +01:00
|
|
|
include_once __DIR__.'/../../../core.php';
|
|
|
|
|
|
|
|
switch ($resource) {
|
2020-08-14 09:55:05 +02:00
|
|
|
/*
|
2020-08-17 08:17:21 +02:00
|
|
|
* Opzioni utilizzate:
|
|
|
|
* - matricola
|
|
|
|
*/
|
2018-02-04 09:41:46 +01:00
|
|
|
case 'componenti':
|
2020-08-17 16:25:01 +02:00
|
|
|
if (isset($superselect['matricola'])) {
|
2018-02-04 09:41:46 +01:00
|
|
|
$query = 'SELECT id, nome AS descrizione, contenuto FROM my_impianto_componenti |where| ORDER BY id';
|
|
|
|
|
|
|
|
foreach ($elements as $element) {
|
2019-05-17 19:17:12 +02:00
|
|
|
$filter[] = 'id='.prepare($element);
|
2018-02-04 09:41:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$temp = [];
|
2020-08-17 16:25:01 +02:00
|
|
|
$impianti = explode(',', $superselect['matricola']);
|
2018-02-04 09:41:46 +01:00
|
|
|
foreach ($impianti as $key => $idimpianto) {
|
|
|
|
$temp[] = 'idimpianto='.prepare($idimpianto);
|
|
|
|
}
|
|
|
|
$where[] = '('.implode(' OR ', $temp).')';
|
|
|
|
|
|
|
|
if (!empty($search)) {
|
|
|
|
$search_fields[] = 'nome LIKE '.prepare('%'.$search.'%');
|
|
|
|
}
|
|
|
|
|
2019-02-22 10:37:37 +01:00
|
|
|
$results = AJAX::selectResults($query, $where, $filter, $search, $limit, $custom);
|
2019-05-17 18:58:37 +02:00
|
|
|
$data = $results['results'];
|
|
|
|
foreach ($data as $key => $value) {
|
2020-08-26 18:03:59 +02:00
|
|
|
$matricola = Ini::getValue($value['contenuto'], 'Matricola');
|
2018-02-04 09:41:46 +01:00
|
|
|
|
2019-05-17 18:58:37 +02:00
|
|
|
$data[$key]['text'] = (empty($matricola) ? '' : $matricola.' - ').$data[$key]['text'];
|
2018-02-04 09:41:46 +01:00
|
|
|
|
2020-08-26 18:03:59 +02:00
|
|
|
unset($data[$key]['contenuto']);
|
2018-02-04 09:41:46 +01:00
|
|
|
}
|
2019-05-17 18:58:37 +02:00
|
|
|
|
|
|
|
$results['results'] = $data;
|
2018-02-04 09:41:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|