ActivityCounter::calculateValue

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. ActivityCounter
  4. calculateValue
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/counter/activitycounter.php
  • Класс: Bitrix\Crm\Counter\ActivityCounter
  • Вызов: ActivityCounter::calculateValue
public function calculateValue(): int
{
	if (
		!\Bitrix\Crm\Settings\CounterSettings::getInstance()->isEnabled()
		|| !\Bitrix\Crm\Settings\CounterSettings::getInstance()->canBeCounted()
	)
	{
		return 0; // counters feature is completely disabled
	}

	$queries = array(
		$this->prepareEntityQuery(\CCrmOwnerType::Contact)->getQuery(),
		$this->prepareEntityQuery(\CCrmOwnerType::Company)->getQuery(),
		$this->prepareEntityQuery(\CCrmOwnerType::Lead)->getQuery(),
		$this->prepareEntityQuery(\CCrmOwnerType::Deal)->getQuery(),
		$this->prepareEntityQuery(\CCrmOwnerType::Order)->getQuery()
	);

	$dbResult = Main\Application::getConnection()->query(
		/** @lang MySQL */
		'SELECT COUNT(DISTINCT t.ACTIVITY_ID) QTY FROM ('.implode(' UNION ALL ', $queries).') t'
	);
	$fields = $dbResult->fetch();
	return is_array($fields) ? (int)$fields['QTY'] : 0;
}

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