DealChannelStatistics::prepareEntityListFilter

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. DealChannelStatistics
  4. prepareEntityListFilter
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/widget/data/dealchannelstatistics.php
  • Класс: Bitrix\Crm\Widget\Data\DealChannelStatistics
  • Вызов: DealChannelStatistics::prepareEntityListFilter
public function prepareEntityListFilter(array $filterParams)
{
	$filter = self::internalizeFilter($filterParams);
	$query = new Query(DealChannelStatisticsTable::getEntity());
	$query->addSelect('OWNER_ID');
	$query->addGroup('OWNER_ID');

	$semanticID = $filter->getExtraParam('semanticID', PhaseSemantics::UNDEFINED);
	if($semanticID !== PhaseSemantics::UNDEFINED)
	{
		$query->addFilter('=STAGE_SEMANTIC_ID', $semanticID);
	}

	$period = $filter->getPeriod();
	$periodStartDate = $period['START'];
	$periodEndDate = $period['END'];

	if(PhaseSemantics::isFinal($semanticID))
	{
		if($periodStartDate !== null)
		{
			$query->addFilter('>=END_DATE', $periodStartDate);
		}
		if(!$periodEndDate !== null)
		{
			$query->addFilter('<=END_DATE', $periodEndDate);
		}
	}
	else
	{
		if($periodStartDate !== null)
		{
			$query->addFilter('>=END_DATE', $periodStartDate);
		}
		if(!$periodEndDate !== null)
		{
			$query->addFilter('<=START_DATE', $periodEndDate);
		}
	}

	$responsibleIDs = $filter->getResponsibleIDs();
	if(!empty($responsibleIDs))
	{
		$query->addFilter('@RESPONSIBLE_ID', $responsibleIDs);
	}

	$channelTypeID = $filter->getExtraParam('channelTypeID', ChannelType::UNDEFINED);
	if($channelTypeID !== ChannelType::UNDEFINED)
	{
		$query->addFilter('=CHANNEL_TYPE_ID', $channelTypeID);
	}

	$channelOriginID = $filter->getExtraParam('channelOriginID', '');
	if($channelOriginID !== '')
	{
		$query->addFilter('=CHANNEL_ORIGIN_ID', $channelOriginID);
	}

	$channelComponentID = $filter->getExtraParam('channelComponentID', '');
	if($channelComponentID !== '')
	{
		$query->addFilter('=CHANNEL_COMPONENT_ID', $channelComponentID);
	}

	return array(
		'__JOINS' => array(
			array(
				'TYPE' => 'INNER',
				'SQL' => 'INNER JOIN('.$query->getQuery().') DS ON DS.OWNER_ID = L.ID'
			)
		)
	);
}

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