• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/ui/task/deadline.php
  • Класс: BitrixTasksUITaskDeadline
  • Вызов: Deadline::buildState
public function buildState(int $status, string $deadline = null): array
{
	if ($status === Status::COMPLETED)
	{
		return [
			'state' => '',
			'color' => '',
			'fill' => true,
		];
	}

	if ($status === Status::DEFERRED)
	{
		return [
			'state' => Loc::getMessage('TASKS_GRID_TASK_ROW_CONTENT_DEADLINE_STATE_DEFERRED'),
			'color' => 'default',
			'fill' => false,
		];
	}

	if ($status === BitrixTasksInternalsTaskStatus::SUPPOSEDLY_COMPLETED)
	{
		return [
			'state' => Loc::getMessage('TASKS_GRID_TASK_ROW_CONTENT_DEADLINE_STATE_SUPPOSEDLY_COMPLETED'),
			'color' => 'warning',
			'fill' => false,
		];
	}

	if (
		!$deadline
		|| !($timestamp = $this->getDateTimestamp($deadline))
	)
	{
		return [
			'state' => Loc::getMessage('TASKS_GRID_TASK_ROW_CONTENT_DEADLINE_STATE_NO_DEADLINE'),
			'color' => 'light',
			'fill' => true,
		];
	}

	$expiredTime = $this->getExpiredTime($timestamp);
	$timeFormat = UI::getHumanTimeFormat($timestamp);
	$deadlineTime = ($timeFormat ? ', '.DateTime::createFromTimestamp($timestamp)->format($timeFormat) : '');
	$deadlineDateTime = $this->formatDate($deadline);

	$states = [
		'isExpired' => [
			'state' => $expiredTime,
			'color' => 'danger',
			'fill' => true,
		],
		'isToday' => [
			'state' => Loc::getMessage('TASKS_GRID_TASK_ROW_CONTENT_DEADLINE_STATE_TODAY', ['#TIME#' => $deadlineTime]),
			'color' => 'warning',
			'fill' => true,
		],
		'isTomorrow' => [
			'state' => Loc::getMessage('TASKS_GRID_TASK_ROW_CONTENT_DEADLINE_STATE_TOMORROW', ['#TIME#' => $deadlineTime]),
			'color' => 'success',
			'fill' => true,
		],
		'isThisWeek' => [
			'state' => $deadlineDateTime,
			'color' => 'primary',
			'fill' => true,
		],
		'isNextWeek' => [
			'state' => $deadlineDateTime,
			'color' => 'secondary',
			'fill' => true,
		],
		'isWoDeadline' => [
			'state' => $deadlineDateTime,
			'color' => 'light',
			'fill' => true,
		],
		'isMoreThatTwoWeeks' => [
			'state' => $deadlineDateTime,
			'color' => 'default',
			'fill' => true,
		],
	];

	foreach ($states as $function => $data)
	{
		if (method_exists(__CLASS__, $function) && $this->$function($timestamp))
		{
			return $data;
		}
	}

	return [];
}