• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/binding/contactcompany.php
  • Класс: Bitrix\Crm\Binding\ContactCompanyTable
  • Вызов: ContactCompanyTable::prepareFilterJoinSql
static function prepareFilterJoinSql($entityTypeID, $entityID, $tableAlias)
{
	if(!is_int($entityTypeID))
	{
		$entityTypeID = (int)$entityTypeID;
	}

	if(!\CCrmOwnerType::IsDefined($entityTypeID))
	{
		throw new Main\ArgumentOutOfRangeException('entityTypeID',
			\CCrmOwnerType::FirstOwnerType,
			\CCrmOwnerType::LastOwnerType
		);
	}

	if(!is_int($entityID))
	{
		$entityID = (int)$entityID;
	}

	if($entityID <= 0)
	{
		throw new Main\ArgumentException('Must be greater than zero', 'entityID');
	}

	if($entityTypeID === \CCrmOwnerType::Company)
	{
		return "INNER JOIN b_crm_contact_company CC ON CC.COMPANY_ID = {$entityID} AND CC.CONTACT_ID = {$tableAlias}.ID";
	}
	elseif($entityTypeID === \CCrmOwnerType::Contact)
	{
		return "INNER JOIN b_crm_contact_company CC ON CC.CONTACT_ID = {$entityID} AND CC.COMPANY_ID = {$tableAlias}.ID";
	}

	$entityTypeName = \CCrmOwnerType::ResolveName($entityTypeID);
	throw new Main\NotSupportedException("Entity type: '{$entityTypeName}' is not supported in current context");
}