2021-03-01 15:01:02 +01:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
2021-07-15 10:58:36 +02:00
|
|
|
* Copyright (C) DevCode s.r.l.
|
2021-03-01 15:01:02 +01:00
|
|
|
*
|
|
|
|
* 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) {
|
|
|
|
/*
|
|
|
|
* Opzioni utilizzate:
|
|
|
|
* - idanagrafica
|
|
|
|
*/
|
2021-03-01 16:32:08 +01:00
|
|
|
case 'ordini-cliente':
|
2021-03-01 15:01:02 +01:00
|
|
|
if (isset($superselect['idanagrafica'])) {
|
2024-03-01 11:32:13 +01:00
|
|
|
$query = 'SELECT
|
|
|
|
`or_ordini`.`id` AS id,
|
|
|
|
CONCAT("Ordine ", `numero_esterno`, " del ", DATE_FORMAT(data, "%d/%m/%Y"), " [", `or_statiordine_lang`.`name` , "]") AS descrizione
|
|
|
|
FROM
|
|
|
|
`or_ordini`
|
|
|
|
INNER JOIN `or_tipiordine` ON `or_ordini`.`idtipoordine` = `or_tipiordine`.`id`
|
|
|
|
INNER JOIN `an_anagrafiche` ON `or_ordini`.`idanagrafica` = `an_anagrafiche`.`idanagrafica`
|
|
|
|
INNER JOIN `or_statiordine` ON `or_ordini`.`idstatoordine` = `or_statiordine`.`id`
|
2024-03-22 15:52:24 +01:00
|
|
|
LEFT JOIN `or_statiordine_lang` ON (`or_statiordine_lang`.`id_record` = `or_statiordine`.`id` AND `or_statiordine_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).')
|
2021-03-01 16:32:08 +01:00
|
|
|
|where|
|
2024-03-01 11:32:13 +01:00
|
|
|
ORDER BY
|
|
|
|
`or_ordini`.`id`';
|
2021-03-01 15:01:02 +01:00
|
|
|
|
|
|
|
foreach ($elements as $element) {
|
2024-03-01 11:32:13 +01:00
|
|
|
$filter[] = '`or_ordini`.`id`='.prepare($element);
|
2021-03-01 15:01:02 +01:00
|
|
|
}
|
|
|
|
|
2024-03-01 11:32:13 +01:00
|
|
|
$where[] = '`or_tipiordine`.`dir`='.prepare('entrata');
|
2021-03-01 15:01:02 +01:00
|
|
|
if (empty($elements)) {
|
2024-03-01 11:32:13 +01:00
|
|
|
$where[] = '`an_anagrafiche`.`idanagrafica`='.prepare($superselect['idanagrafica']);
|
2021-03-01 15:01:02 +01:00
|
|
|
|
2022-01-11 16:32:55 +01:00
|
|
|
$stato = !empty($superselect['stato']) ? $superselect['stato'] : 'is_fatturabile';
|
2024-03-01 11:32:13 +01:00
|
|
|
$where[] = '`or_statiordine`.'.$stato.' = 1)';
|
2021-03-01 15:01:02 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2021-03-01 16:01:19 +01:00
|
|
|
}
|