CCrmSipHelper::getLeadId

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmSipHelper
  4. getLeadId
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/sip_helper.php
  • Класс: \CCrmSipHelper
  • Вызов: CCrmSipHelper::getLeadId
static function getLeadId(int $entityTypeId,int $entityId,bool $isAdmin): array
{
	$result = [];
	$filter = ['STATUS_SEMANTIC_ID' => 'P', 'CHECK_PERMISSIONS' => $isAdmin ? 'N' : 'Y'];
	switch ($entityTypeId)
	{
		case CCrmOwnerType::Contact:
			$filter['=CONTACT_ID'] = $entityId;
			break;
		case CCrmOwnerType::Company:
			$filter['=COMPANY_ID'] = $entityId;
			break;
		default:
			throw new ArgumentException("Unsupported entity type");
	}

	$cursor = CCrmLead::GetListEx(
		[
			Item\Lead::FIELD_NAME_DATE_CREATE => 'ASC',
		],
		$filter,
		false,
		['nTopCount' => 1],
		['ID']
	);

	if (is_object($cursor))
	{
		while ($deal = $cursor->Fetch())
		{
			$result[] = $deal['ID'];
		}
	}

	return $result;
}

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