2021-09-06 11:17:25 +02:00
|
|
|
<?php
|
2021-11-15 11:51:08 +01:00
|
|
|
$seed = 's-' . mt_rand();
|
2021-09-06 11:17:25 +02:00
|
|
|
$variationIcon = '';
|
|
|
|
$variationClass = '';
|
2021-11-23 22:07:31 +01:00
|
|
|
if (!is_null($variation)) {
|
2021-11-15 11:51:08 +01:00
|
|
|
if ($variation == 0) {
|
|
|
|
$variationIcon = $this->FontAwesome->getClass('minus');
|
|
|
|
} elseif ($variation > 0) {
|
|
|
|
$variationIcon = 'trends-arrow-up-white fs-6';
|
|
|
|
$variationClass = 'bg-success';
|
|
|
|
} else {
|
|
|
|
$variationIcon = 'trends-arrow-up-white fs-6 fa-rotate-180 fa-flip-vertical';
|
|
|
|
$variationClass = 'bg-danger';
|
|
|
|
}
|
2021-09-06 11:17:25 +02:00
|
|
|
}
|
|
|
|
|
2021-11-12 15:40:03 +01:00
|
|
|
$series = [];
|
2021-11-15 11:51:08 +01:00
|
|
|
$statistics_day_number = '';
|
2021-11-12 15:40:03 +01:00
|
|
|
if (!empty($timeline['created']['timeline'])) {
|
2021-11-15 11:51:08 +01:00
|
|
|
$statistics_day_number = $timeline['created']['days'];
|
|
|
|
$i = count($series);
|
|
|
|
$series[$i]['name'] = __('Created');
|
|
|
|
$series[$i]['type'] = !empty($chartType) ? $chartType : 'column';
|
2021-11-12 15:40:03 +01:00
|
|
|
foreach ($timeline['created']['timeline'] as $entry) {
|
2021-11-15 11:51:08 +01:00
|
|
|
$series[$i]['data'][] = ['x' => $entry['time'], 'y' => $entry['count']];
|
2021-11-12 15:40:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!empty($timeline['modified']['timeline'])) {
|
2021-11-15 11:51:08 +01:00
|
|
|
$statistics_day_number = empty($statistics_day_number) ? $timeline['modified']['days'] : $statistics_day_number;
|
|
|
|
$i = count($series);
|
|
|
|
$series[$i]['name'] = __('Modified');
|
|
|
|
$series[$i]['type'] = !empty($chartType) ? $chartType : 'line';
|
2021-11-12 15:40:03 +01:00
|
|
|
foreach ($timeline['modified']['timeline'] as $entry) {
|
2021-11-15 11:51:08 +01:00
|
|
|
$series[$i]['data'][] = ['x' => $entry['time'], 'y' => $entry['count']];
|
2021-11-12 15:40:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-15 11:51:08 +01:00
|
|
|
$variationHtml = '';
|
2021-11-23 22:07:31 +01:00
|
|
|
if (!is_null($variation)) {
|
2021-11-15 11:51:08 +01:00
|
|
|
$variationHtml = sprintf(
|
|
|
|
'<div class="badge %s fw-bold"><span class="%s me-2 align-middle"></span>%s</div>',
|
|
|
|
$variationClass,
|
|
|
|
$variationIcon,
|
2021-11-23 22:07:31 +01:00
|
|
|
!is_null($variation) ? h($variation) : ''
|
2021-11-15 11:51:08 +01:00
|
|
|
);
|
|
|
|
}
|
2021-09-06 11:17:25 +02:00
|
|
|
|
2021-09-07 09:59:36 +02:00
|
|
|
$titleHtml = isset($title) ? h($title) : ($titleHtml ?? '');
|
2021-11-15 11:51:08 +01:00
|
|
|
$leftContent = sprintf(
|
2021-11-23 22:07:31 +01:00
|
|
|
'<div class="">%s</div><h2 class="my-2 text-nowrap">%s <span class="fs-8 fw-light">%s</span></h2>%s',
|
2021-09-07 09:59:36 +02:00
|
|
|
$titleHtml,
|
2021-09-06 11:17:25 +02:00
|
|
|
h($number ?? ''),
|
2021-11-15 11:51:08 +01:00
|
|
|
__('Past {0} days', $statistics_day_number),
|
2021-09-06 11:17:25 +02:00
|
|
|
$variationHtml
|
|
|
|
);
|
|
|
|
$rightContent = sprintf('<div class="">%s</div>', $this->element('charts/bar', [
|
2021-11-12 15:40:03 +01:00
|
|
|
'series' => $series,
|
2021-11-15 11:51:08 +01:00
|
|
|
'chartOptions' => array_merge(
|
|
|
|
[
|
|
|
|
'chart' => [
|
|
|
|
'height' => '90px',
|
|
|
|
],
|
|
|
|
'stroke' => [
|
|
|
|
'width' => [0, 2],
|
|
|
|
'curve' => 'smooth',
|
|
|
|
],
|
2021-11-12 15:40:03 +01:00
|
|
|
],
|
2021-11-15 11:51:08 +01:00
|
|
|
!empty($chartOptions) ? $chartOptions : []
|
|
|
|
)
|
2021-09-06 11:17:25 +02:00
|
|
|
]));
|
2021-11-23 22:07:31 +01:00
|
|
|
$cardContent = sprintf(
|
|
|
|
'<div class="highlight-panel-container d-flex align-items-center justify-content-between %s" style="%s"><div class="number-container">%s</div><div class="chart-container w-50">%s</div></div>',
|
|
|
|
$panelClasses ?? '',
|
|
|
|
$panelStyle ?? '',
|
|
|
|
$leftContent,
|
|
|
|
$rightContent
|
|
|
|
);
|
2021-09-06 11:17:25 +02:00
|
|
|
|
|
|
|
echo $this->Bootstrap->card([
|
2022-11-24 12:50:11 +01:00
|
|
|
'bodyVariant' => 'secondary',
|
2021-09-06 11:17:25 +02:00
|
|
|
'bodyHTML' => $cardContent,
|
2021-11-23 22:07:31 +01:00
|
|
|
'bodyClass' => 'p-3',
|
2021-11-15 11:51:08 +01:00
|
|
|
'class' => ['shadow-sm', (empty($panelNoGrow) ? 'grow-on-hover' : '')]
|
2021-09-06 11:17:25 +02:00
|
|
|
]);
|
|
|
|
|
|
|
|
?>
|