DealInWork::prepareActivityQuery

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. DealInWork
  4. prepareActivityQuery
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/widget/data/dealinwork.php
  • Класс: Bitrix\Crm\Widget\Data\DealInWork
  • Вызов: DealInWork::prepareActivityQuery
static function prepareActivityQuery($startDate, $endDate, $responsibleIDs = null, $categoryID = -1, $group = '')
{
	$query = new Query(DealActivityStatisticsTable::getEntity());
	$query->addSelect('OWNER_ID');
	$query->addFilter('=IS_LOST', false);
	$query->addFilter('>=DEADLINE_DATE', $startDate);
	$query->addFilter('<=DEADLINE_DATE', $endDate);
	$query->addGroup('OWNER_ID');

	if(is_array($responsibleIDs) && !empty($responsibleIDs))
	{
		$query->addFilter('@RESPONSIBLE_ID', $responsibleIDs);
	}

	if($categoryID >= 0)
	{
		//HACK: use SqlExpression to avoid filter sql like (CATEGORY_ID IS NULL OR CATEGORY_ID = 0), that cause the filesort.
		$query->addFilter('=CATEGORY_ID', new Main\DB\SqlExpression('?i', $categoryID));
	}

	if($group === self::GROUP_BY_DATE)
	{
		$query->addSelect('DEADLINE_DATE', 'DATE');
		$query->addGroup('DEADLINE_DATE');
		$query->addOrder('DEADLINE_DATE', 'ASC');
	}
	elseif($group === self::GROUP_BY_USER)
	{
		$query->addSelect('RESPONSIBLE_ID');
		$query->addGroup('RESPONSIBLE_ID');
	}

	return $query;
}

Добавить комментарий