cerebrate/templates/element/widgets/highlight-panel.php

44 lines
1.3 KiB
PHP
Raw Normal View History

<?php
$variationIcon = '';
$variationClass = '';
if ($variation == 0) {
2021-10-18 14:56:51 +02:00
$variationIcon = $this->FontAwesome->getClass('minus');
} elseif ($variation > 0) {
2021-10-18 14:56:51 +02:00
$variationIcon = 'trends-arrow-up-white fs-6';
$variationClass = 'bg-success';
} else {
2021-10-18 14:56:51 +02:00
$variationIcon = 'trends-arrow-up-white fs-6 fa-rotate-180 fa-flip-vertical';
$variationClass = 'bg-danger';
}
2021-10-18 14:56:51 +02:00
$variationHtml = sprintf(
'<div class="badge %s fw-bold"><span class="%s me-2 align-middle"></span>%s</div>',
$variationClass,
2021-10-18 14:56:51 +02:00
$variationIcon,
!empty($variation) ? h($variation) : ''
);
$titleHtml = isset($title) ? h($title) : ($titleHtml ?? '');
$leftContent = sprintf('<div class="">%s</div><h2 class="my-2">%s</h2>%s',
$titleHtml,
h($number ?? ''),
$variationHtml
);
$rightContent = sprintf('<div class="">%s</div>', $this->element('charts/bar', [
'chartData' => $chartData,
'chartOptions' => [
]
]));
$cardContent = sprintf('<div class="highlight-panel-container d-flex align-items-center justify-content-between"><div class="number-container">%s</div><div class="chart-container w-50">%s</div></div>', $leftContent, $rightContent);
echo $this->Bootstrap->card([
'variant' => 'secondary',
'bodyHTML' => $cardContent,
'bodyClass' => 'p-3',
'class' => 'grow-on-hover shadow-sm'
]);
?>