- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/kanban/entity/entityactivities.php
- Класс: Bitrix\Crm\Kanban\Entity\EntityActivities
- Вызов: EntityActivities::getActivityStageIdByDeadlineAndIncoming
private function getActivityStageIdByDeadlineAndIncoming(?DateTime $deadline, bool $hasAnyIncomingChannel): string
{
if ($deadline === null && !$hasAnyIncomingChannel)
{
return $this->getStatusIdByCategoryId(self::STAGE_IDLE, $this->categoryId);
}
$userDeadline = Datetime::createFromTimestamp($deadline->getTimestamp());
$userDeadline->toUserTime();
$userDeadlineDate = Date::createFromTimestamp($userDeadline->getTimestamp());
$dateTime = $this->getUserCurrentDateTime(new DateTime());
$userCurrentDate = Date::createFromTimestamp($dateTime->getTimestamp());
if ($userCurrentDate->getTimestamp() > $userDeadlineDate->getTimestamp())
{
return $this->getStatusIdByCategoryId(self::STAGE_OVERDUE, $this->categoryId);
}
// today
$userTomorrowDate = $this->getTomorrowDay($dateTime);
if (($userTomorrowDate->getTimestamp() > $userDeadlineDate->getTimestamp()) || $hasAnyIncomingChannel)
{
return $this->getStatusIdByCategoryId(self::STAGE_PENDING, $this->categoryId);
}
// this week
$userThisWeekDate = $this->getLastWeekDay($dateTime);
if ($userThisWeekDate->getTimestamp() >= $userDeadlineDate->getTimestamp())
{
return $this->getStatusIdByCategoryId(self::STAGE_THIS_WEEK, $this->categoryId);
}
// next week
$userNextWeekDate = Date::createFromTimestamp($userThisWeekDate->add('+7 days')->getTimestamp());
if ($userNextWeekDate->getTimestamp() >= $userDeadlineDate->getTimestamp())
{
return $this->getStatusIdByCategoryId(self::STAGE_NEXT_WEEK, $this->categoryId);
}
return $this->getStatusIdByCategoryId(self::STAGE_LATER, $this->categoryId);
}