CAllCrmDeal::FindByCommunication

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CAllCrmDeal
  4. FindByCommunication
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_deal.php
  • Класс: \CAllCrmDeal
  • Вызов: CAllCrmDeal::FindByCommunication
static function FindByCommunication($entityTypeID, $type, $value, $checkPermissions = true, array $select = null, array $order = null)
{
	if(!is_int($entityTypeID))
	{
		$entityTypeID = (int)$entityTypeID;
	}

	if($entityTypeID !== CCrmOwnerType::Contact && $entityTypeID !== CCrmOwnerType::Company)
	{
		return array();
	}

	$criterion = new \Bitrix\Crm\Integrity\DuplicateCommunicationCriterion($type, $value);
	/** @var \Bitrix\Crm\Integrity\Duplicate $duplicate */
	$duplicate = $criterion->find($entityTypeID, 20);
	if($duplicate === null)
	{
		return array();
	}

	$entityIDs = array();
	$entities = $duplicate->getEntities();
	foreach($entities as $entity)
	{
		/** @var \Bitrix\Crm\Integrity\DuplicateEntity $entity */
		$entityIDs[] = $entity->getEntityID();
	}
	//return $entityMap;

	if($select === null)
	{
		$select = array();
	}

	if($order === null)
	{
		$order = array();
	}

	if(empty($entityIDs))
	{
		return array();
	}

	if($entityTypeID === CCrmOwnerType::Contact)
	{
		$filter = array('@CONTACT_ID' => $entityIDs);
	}
	else//($entityTypeID === CCrmOwnerType::Company)
	{
		$filter = array('@COMPANY_ID' => $entityIDs);
	}

	if (!$checkPermissions)
	{
		$filter['CHECK_PERMISSIONS'] = 'N';
	}

	$results = array();
	$dbResult = self::GetListEx($order, $filter, false, false, $select);
	if(is_object($dbResult))
	{
		while($filelds = $dbResult->Fetch())
		{
			$results[] = $filelds;
		}
	}
	return $results;
}

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