- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/kanban/entity/entityactivities.php
- Класс: Bitrix\Crm\Kanban\Entity\EntityActivities
- Вызов: EntityActivities::getEntityCounterForStage
private function getEntityCounterForStage(string $stageId, array $activityCounterFilterValues): ?\Bitrix\Crm\Counter\EntityCounter
{
$counterExtras = [];
if (!is_null($this->categoryId))
{
$counterExtras['CATEGORY_ID'] = $this->categoryId;
}
if ($this->isStageSkippedByActivitiesFilter($stageId, $activityCounterFilterValues))
{
return null;
}
switch ($stageId)
{
case $this->getStatusIdByCategoryId(self::STAGE_OVERDUE, $this->categoryId):
if (in_array(EntityCounterType::INCOMING_CHANNEL, $activityCounterFilterValues))
{
$counterExtras['HAS_ANY_INCOMING_CHANEL'] = true;
}
return \Bitrix\Crm\Counter\EntityCounterFactory::create(
$this->entityTypeId,
EntityCounterType::OVERDUE,
0,
$counterExtras
);
case $this->getStatusIdByCategoryId(self::STAGE_PENDING, $this->categoryId):
$counterType = EntityCounterType::UNDEFINED;
if (in_array(EntityCounterType::PENDING, $activityCounterFilterValues) || empty($activityCounterFilterValues))
{
$counterType |= EntityCounterType::PENDING;
}
if (in_array(EntityCounterType::READY_TODO, $activityCounterFilterValues))
{
$counterType |= EntityCounterType::READY_TODO;
$counterExtras['PERIOD_FROM'] = new DateTime();
$counterExtras['PERIOD_TO'] = new DateTime();
}
if (in_array(EntityCounterType::INCOMING_CHANNEL, $activityCounterFilterValues) || empty($activityCounterFilterValues))
{
$counterType |= EntityCounterType::INCOMING_CHANNEL;
if (count($activityCounterFilterValues) === 1) // only INCOMING_CHANNEL type in filter
{
$counterExtras['HAS_ANY_INCOMING_CHANEL'] = true;
}
}
$currentUserTodayMidnight = $this->getUserCurrentDateTime(new DateTime())
->setTime(0, 0,0 );
$counterExtras['ACT_VIEW_RESTRICT_DEADLINE_FROM'] = $currentUserTodayMidnight;
return \Bitrix\Crm\Counter\EntityCounterFactory::create(
$this->entityTypeId,
// also show INCOMING_CHANNEL with PENDING
$counterType,
0,
array_merge(
$counterExtras,
[
'ONLY_MIN_DEADLINE' => true,
'ONLY_MIN_INCOMING_CHANNEL' => true,
'INCOMING_CHANNEL_PERIOD_FROM' => \CCrmDateTimeHelper::getUserDate(new DateTime())
],
),
);
case $this->getStatusIdByCategoryId(self::STAGE_THIS_WEEK, $this->categoryId):
$counterType = EntityCounterType::PENDING;
$lastWeekDay = $this->getLastWeekDay(new DateTime());
$tomorrow = $this->getTomorrowDay(new DateTime());
if (in_array(EntityCounterType::READY_TODO, $activityCounterFilterValues))
{
$counterType = EntityCounterType::READY_TODO;
}
$counterExtras['PERIOD_FROM'] = $tomorrow;
$counterExtras['PERIOD_TO'] = $lastWeekDay;
$counterExtras['HAS_ANY_INCOMING_CHANEL'] = false;
$counterExtras['ONLY_MIN_DEADLINE'] = true;
$counterExtras['ACT_VIEW_RESTRICT_DEADLINE_FROM'] = $tomorrow;
return \Bitrix\Crm\Counter\EntityCounterFactory::create(
$this->entityTypeId,
$counterType,
0,
$counterExtras
);
case $this->getStatusIdByCategoryId(self::STAGE_NEXT_WEEK, $this->categoryId):
$counterType = EntityCounterType::PENDING;
$lastWeekDay = $this->getLastWeekDay(new DateTime());
$nextWeekFirstDay = (clone $lastWeekDay)->add('+1 day');
$nextWeekLastDay = (clone $lastWeekDay)->add('+7 days');
if (in_array(EntityCounterType::READY_TODO, $activityCounterFilterValues))
{
$counterType = EntityCounterType::READY_TODO;
}
$counterExtras['PERIOD_FROM'] = $nextWeekFirstDay;
$counterExtras['PERIOD_TO'] = $nextWeekLastDay;
$counterExtras['HAS_ANY_INCOMING_CHANEL'] = false;
$counterExtras['ONLY_MIN_DEADLINE'] = true;
$counterExtras['ACT_VIEW_RESTRICT_DEADLINE_FROM'] = $nextWeekFirstDay;
return \Bitrix\Crm\Counter\EntityCounterFactory::create(
$this->entityTypeId,
$counterType,
0,
$counterExtras
);
case $this->getStatusIdByCategoryId(self::STAGE_IDLE, $this->categoryId):
return \Bitrix\Crm\Counter\EntityCounterFactory::create(
$this->entityTypeId,
EntityCounterType::IDLE,
0,
$counterExtras
);
case $this->getStatusIdByCategoryId(self::STAGE_LATER, $this->categoryId):
$counterType = EntityCounterType::PENDING;
if (in_array(EntityCounterType::READY_TODO, $activityCounterFilterValues))
{
$counterType = EntityCounterType::READY_TODO;
}
$lastWeekDay = $this->getLastWeekDay(new DateTime())->add('+8 days');
$counterExtras['PERIOD_FROM'] = $lastWeekDay;
$counterExtras['PERIOD_TO'] = (new DateTime())->setDate(9990, 1, 1)->disableUserTime();
$counterExtras['HAS_ANY_INCOMING_CHANEL'] = false;
$counterExtras['ONLY_MIN_DEADLINE'] = true;
$counterExtras['ACT_VIEW_RESTRICT_DEADLINE_FROM'] = $lastWeekDay;
return \Bitrix\Crm\Counter\EntityCounterFactory::create(
$this->entityTypeId,
$counterType,
0,
$counterExtras
);
}
return null;
}