CAllCrmActivity::GetCurrentQuantity

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CAllCrmActivity
  4. GetCurrentQuantity
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_activity.php
  • Класс: \CAllCrmActivity
  • Вызов: CAllCrmActivity::GetCurrentQuantity
static function GetCurrentQuantity($userID, $ownerTypeID)
{
	$userID = intval($userID);
	$ownerTypeID = intval($ownerTypeID);
	if($userID <= 0 || $ownerTypeID <= 0)
	{
		return 0;
	}

	$currentDay = time() + CTimeZone::GetOffset();
	$currentDayEnd = ConvertTimeStamp(mktime(23, 59, 59, date('n', $currentDay), date('j', $currentDay), date('Y', $currentDay)), 'FULL', SITE_ID);

	global $DB;
	$currentDayEnd = $DB->CharToDateFunction($DB->ForSql($currentDayEnd), 'FULL');
	$activityTable = CCrmActivity::USER_ACTIVITY_TABLE_NAME;
	$sql = "SELECT COUNT(DISTINCT a.OWNER_ID) AS CNT FROM {$activityTable} a WHERE a.USER_ID = {$userID} AND a.OWNER_TYPE_ID = {$ownerTypeID} AND a.ACTIVITY_TIME <= {$currentDayEnd}";

	$dbResult = $DB->Query(
		$sql,
		false,
		'File: '.__FILE__.'
Line: '.__LINE__ ); $result = $dbResult->Fetch(); return is_array($result) ? intval($result['CNT']) : 0; }

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