56 lines
1.6 KiB
PHP
56 lines
1.6 KiB
PHP
|
|
<?php
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
if (!isset($open_count) && !isset($error)) {
|
||
|
|
require_once dirname(dirname(__DIR__)) . '/actions/user/summary_widget_action.php';
|
||
|
|
$viewData = task_cert_user_summary_widget_action();
|
||
|
|
if (is_array($viewData)) {
|
||
|
|
extract($viewData, EXTR_SKIP);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
$error = $error ?? null;
|
||
|
|
$openCount = (int) ($open_count ?? 0);
|
||
|
|
$overdueCount = (int) ($overdue_count ?? 0);
|
||
|
|
$escalatedCount = (int) ($escalated_count ?? 0);
|
||
|
|
|
||
|
|
if (!function_exists('task_cert_render_styles')) {
|
||
|
|
require_once dirname(dirname(__DIR__)) . '/bootstrap.php';
|
||
|
|
}
|
||
|
|
task_cert_render_styles(['user']);
|
||
|
|
$myTasksUrl = task_cert_view_url('user.my_tasks');
|
||
|
|
|
||
|
|
$buildLabel = static function (int $count, string $singular, string $plural): string {
|
||
|
|
return $count . ' ' . ($count === 1 ? $singular : $plural);
|
||
|
|
};
|
||
|
|
|
||
|
|
$parts = [];
|
||
|
|
if ($openCount > 0) {
|
||
|
|
$parts[] = $buildLabel($openCount, 'offene Aufgabe', 'offene Aufgaben');
|
||
|
|
}
|
||
|
|
if ($overdueCount > 0) {
|
||
|
|
$parts[] = $buildLabel($overdueCount, 'überfällige Aufgabe', 'überfällige Aufgaben');
|
||
|
|
}
|
||
|
|
if ($escalatedCount > 0) {
|
||
|
|
$parts[] = $buildLabel($escalatedCount, 'eskalierte Aufgabe', 'eskalierte Aufgaben');
|
||
|
|
}
|
||
|
|
|
||
|
|
if ($error || $parts === []) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
$message = '';
|
||
|
|
if (count($parts) === 1) {
|
||
|
|
$message = $parts[0];
|
||
|
|
} elseif (count($parts) === 2) {
|
||
|
|
$message = $parts[0] . ' und ' . $parts[1];
|
||
|
|
} else {
|
||
|
|
$message = $parts[0] . ', ' . $parts[1] . ' und ' . $parts[2];
|
||
|
|
}
|
||
|
|
?>
|
||
|
|
<div class="task-cert task-cert-user-summary-widget">
|
||
|
|
<a href="<?php echo TaskCertView::e($myTasksUrl); ?>" class="task-cert-user-summary-bar">
|
||
|
|
Sie haben <?php echo TaskCertView::e($message); ?>.
|
||
|
|
</a>
|
||
|
|
</div>
|