first commit

This commit is contained in:
exercict
2026-07-14 08:10:11 +04:00
commit fdfb0dd62e
60 changed files with 9930 additions and 0 deletions
+78
View File
@@ -0,0 +1,78 @@
<?php
declare(strict_types=1);
if (!function_exists('task_status_label')) {
function task_status_label(?string $status): string
{
return match ($status) {
'NEW' => 'Новая',
'IN_PROGRESS' => 'В работе',
'REVIEW' => 'На проверке',
'DONE' => 'Закрыта',
'CANCELED' => 'Отменена',
'OVERDUE' => 'Просрочена',
default => (string)$status,
};
}
}
if (!function_exists('task_priority_label')) {
function task_priority_label(?string $priority): string
{
return match ($priority) {
'LOW' => 'Низкий',
'MEDIUM' => 'Средний',
'HIGH' => 'Высокий',
'CRITICAL' => 'Критический',
default => (string)$priority,
};
}
}
if (!function_exists('taskDeadlineState')) {
function taskDeadlineState(?string $plannedAt, ?string $status = null): ?array
{
if (empty($plannedAt)) {
return null;
}
// Закрытые/отменённые не подсвечиваем
if (in_array($status, ['DONE', 'CANCELED'], true)) {
return null;
}
$plannedTs = strtotime($plannedAt);
if (!$plannedTs) {
return null;
}
$now = time();
$diff = $plannedTs - $now;
// больше 2 дней
if ($diff > 2 * 86400) {
return [
'code' => 'green',
'class' => 'deadline-green',
'text' => 'В запасе',
];
}
// от 1 до 2 дней
if ($diff > 86400) {
return [
'code' => 'yellow',
'class' => 'deadline-yellow',
'text' => 'Остался 1 день',
];
}
// меньше 1 дня или уже просрочено
return [
'code' => 'red',
'class' => 'deadline-red',
'text' => $diff < 0 ? 'Просрочено' : 'Меньше 1 дня',
];
}
}