• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/kanban/entitybadge.php
  • Класс: Bitrix\Crm\Kanban\EntityBadge
  • Вызов: EntityBadge::queryOnlyActualBadgesIds
private function queryOnlyActualBadgesIds(int $entityTypeId, array $entityIds): array
{
	$suspendCondition = (new ConditionTree())
		->logic(ConditionTree::LOGIC_OR)
		->where(
			(new ConditionTree())
				->where('SOURCE_PROVIDER_ID', SourceIdentifier::CRM_OWNER_TYPE_PROVIDER)
				->whereNotIn('SOURCE_ENTITY_TYPE_ID', CCrmOwnerType::getAllSuspended())
		)
		->where('SOURCE_PROVIDER_ID', '<>',SourceIdentifier::CRM_OWNER_TYPE_PROVIDER);


	$entityBadgeIdsWithoutSuspendedQ = BadgeTable::query()
		->addSelect('MAX_ID')
		->registerRuntimeField('', new ExpressionField('MAX_ID', 'MAX(%s)', 'ID'))
		->where('ENTITY_TYPE_ID', $entityTypeId)
		->whereIn('ENTITY_ID', $entityIds)
		->where($suspendCondition)
		->setGroup(['ENTITY_ID']);

	return array_column($entityBadgeIdsWithoutSuspendedQ->fetchAll(), 'MAX_ID');
}