2019-07-09 18:29:40 +02:00
|
|
|
<?php
|
2020-09-07 15:04:06 +02:00
|
|
|
/*
|
|
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
2021-01-20 15:08:51 +01:00
|
|
|
* Copyright (C) DevCode s.r.l.
|
2020-09-07 15:04:06 +02: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/>.
|
|
|
|
*/
|
2019-07-09 18:29:40 +02:00
|
|
|
|
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
|
|
|
|
use Plugins\StatisticheArticoli\Stats;
|
|
|
|
|
2019-07-10 16:31:10 +02:00
|
|
|
$calendar_id = filter('calendar_id');
|
2020-01-08 12:30:53 +01:00
|
|
|
$direzione = filter('direzione');
|
2019-07-09 18:29:40 +02:00
|
|
|
$start = filter('start');
|
|
|
|
$end = filter('end');
|
|
|
|
|
|
|
|
$prezzi = Stats::prezzi($id_record, $start, $end, $direzione);
|
|
|
|
$prezzo_min = $prezzi['min'];
|
|
|
|
$prezzo_max = $prezzi['max'];
|
|
|
|
$prezzo_medio = $prezzi['media'];
|
|
|
|
|
|
|
|
$oscillazione = $prezzo_max['prezzo'] - $prezzo_min['prezzo'];
|
2024-08-27 09:20:20 +02:00
|
|
|
$oscillazione_percentuale = $prezzo_medio ? $oscillazione * 100 / ($prezzo_medio ?: 1) : 0;
|
2019-07-09 18:29:40 +02:00
|
|
|
|
2024-05-23 11:36:25 +02:00
|
|
|
$data_min = $prezzo_min['data'] ? strtotime((string) $prezzo_min['data']) : '';
|
|
|
|
$data_max = $prezzo_max['data'] ? strtotime((string) $prezzo_max['data']) : '';
|
2019-07-09 18:29:40 +02:00
|
|
|
if ($data_min == $data_max) {
|
|
|
|
$andamento = tr('N.D.');
|
|
|
|
} elseif ($data_min < $data_max) {
|
2019-07-10 15:02:09 +02:00
|
|
|
$andamento = tr('In aumento');
|
2019-07-09 18:29:40 +02:00
|
|
|
} else {
|
2019-07-10 15:02:09 +02:00
|
|
|
$andamento = tr('In diminuzione');
|
2019-07-09 18:29:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
2019-07-10 16:31:10 +02:00
|
|
|
<tr id="row-'.$calendar_id.'">
|
|
|
|
<td class="text-center">'.$calendar_id.'</td>
|
2019-07-09 18:29:40 +02:00
|
|
|
<td>'.dateFormat($start).' - '.dateFormat($end).'</td>
|
2019-07-10 16:31:10 +02:00
|
|
|
<td class="text-right">'.moneyFormat($prezzo_min['prezzo']).'</td>
|
|
|
|
<td class="text-right">'.moneyFormat($prezzo_medio).'</td>
|
|
|
|
<td class="text-right">'.moneyFormat($prezzo_max['prezzo']).'</td>
|
|
|
|
<td class="text-right">'.moneyFormat($oscillazione).'</td>
|
|
|
|
<td class="text-right">'.Translator::numberToLocale($oscillazione_percentuale, '2').' %</td>
|
2019-07-09 18:29:40 +02:00
|
|
|
<td>'.$andamento.'</td>
|
|
|
|
</tr>';
|