Call::syncBadges

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. Call
  4. syncBadges
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/activity/provider/call.php
  • Класс: Bitrix\Crm\Activity\Provider\Call
  • Вызов: Call::syncBadges
static function syncBadges(int $activityId, array $activityFields, array $bindings): void
{
	$badge = Container::getInstance()->getBadge(
		Badge\Type\CallStatus::CALL_STATUS_TYPE,
		Badge\Type\CallStatus::MISSED_CALL_VALUE,
	);

	$sourceIdentifier = new Badge\SourceIdentifier(
		Badge\SourceIdentifier::CRM_OWNER_TYPE_PROVIDER,
		\CCrmOwnerType::Activity,
		$activityId,
	);

	$isCompleted = isset($activityFields['COMPLETED']) && $activityFields['COMPLETED'] === 'Y';
	if ($isCompleted)
	{
		foreach ($bindings as $singleBinding)
		{
			$itemIdentifier = new ItemIdentifier((int)$singleBinding['OWNER_TYPE_ID'], (int)$singleBinding['OWNER_ID']);
			$badge->unbind($itemIdentifier, $sourceIdentifier);
		}

		return;
	}

	$isMissed = isset($activityFields['SETTINGS']['MISSED_CALL']) && $activityFields['SETTINGS']['MISSED_CALL'] === true;
	if ($isMissed)
	{
		foreach ($bindings as $singleBinding)
		{
			$itemIdentifier = new ItemIdentifier((int)$singleBinding['OWNER_TYPE_ID'], (int)$singleBinding['OWNER_ID']);
			$badge->bind($itemIdentifier, $sourceIdentifier);
		}
	}
	else
	{
		foreach ($bindings as $singleBinding)
		{
			$itemIdentifier = new ItemIdentifier((int)$singleBinding['OWNER_TYPE_ID'], (int)$singleBinding['OWNER_ID']);
			$badge->unbind($itemIdentifier, $sourceIdentifier);
		}
	}
}

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