- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/kanban/entity/entityactivities.php
- Класс: Bitrix\Crm\Kanban\Entity\EntityActivities
- Вызов: EntityActivities::calculateTotalForStage
public function calculateTotalForStage(string $stageId, array $filter): int
{
$entityManager = EntityManager::resolveByTypeID($this->entityTypeId);
if (!$entityManager)
{
return 0;
}
$stagesIds = array_column($this->getStagesList($this->categoryId), 'STATUS_ID');
if (!in_array($stageId, $stagesIds, true))
{
return 0;
}
// if today is last week day, STAGE_THIS_WEEK cannot contain items:
if ($stageId === $this->getStatusIdByCategoryId(self::STAGE_THIS_WEEK, $this->categoryId))
{
$lastWeekDay = $this->getLastWeekDay(new DateTime());
if ($lastWeekDay->getTimestamp() === (new Date())->getTimestamp())
{
return 0;
}
}
if ($this->isStageSkippedByActivitiesFilter($stageId, $this->getActivityCounterFilterValue($filter)))
{
return 0;
}
$stageFilter = $this->prepareCounterFilter($stageId, $filter);
return $entityManager->getCount([
'filter' => $stageFilter,
]);
}