openstamanager/modules/stampe/ajax/select.php

62 lines
2.1 KiB
PHP
Raw Normal View History

2023-06-29 11:11:41 +02:00
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* 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/>.
*/
include_once __DIR__.'/../../../core.php';
switch ($resource) {
case 'allegati':
$id_module = $superselect['id_module'];
$id_plugin = $superselect['id_plugin'];
$id_record = $superselect['id_record'];
if (isset($id_module) || isset($id_plugin)) {
2024-04-18 17:44:05 +02:00
$query = 'SELECT `id`, `title` AS descrizione FROM zz_files |where|';
2023-06-29 11:11:41 +02:00
if (isset($id_module)) {
2024-03-11 10:40:42 +01:00
$where[] = '`zz_files`.`id_module` = '.prepare($id_module);
2023-06-29 11:11:41 +02:00
}
if (isset($id_plugin)) {
2024-03-11 10:40:42 +01:00
$where[] = '`zz_files`.`id_plugin` = '.prepare($id_plugin);
2023-06-29 11:11:41 +02:00
}
2024-03-11 10:40:42 +01:00
$where[] = '`zz_files`.`id_record` = '.prepare($id_record);
2023-06-29 11:11:41 +02:00
if ($is_fiscale != null) {
2024-03-11 10:40:42 +01:00
$where[] = '`zz_segments`.`is_fiscale` = '.prepare($is_fiscale);
2023-06-29 11:11:41 +02:00
}
if ($is_sezionale != null) {
2024-03-11 10:40:42 +01:00
$where[] = '`zz_segments`.`is_sezionale` = '.prepare($is_sezionale);
2023-06-29 11:11:41 +02:00
}
if ($escludi_id != null) {
2024-03-11 10:40:42 +01:00
$where[] = '`zz_segments`.`id` != '.prepare($escludi_id);
2023-06-29 11:11:41 +02:00
}
foreach ($elements as $element) {
2024-03-11 10:40:42 +01:00
$filter[] = '`id`='.prepare($element);
2023-06-29 11:11:41 +02:00
}
if (!empty($search)) {
2024-04-18 17:44:05 +02:00
$search_fields[] = '`zz_segments`.`title` LIKE '.prepare('%'.$search.'%');
2023-06-29 11:11:41 +02:00
}
}
break;
}