CAllCrmActivity::Complete

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CAllCrmActivity
  4. Complete
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_activity.php
  • Класс: \CAllCrmActivity
  • Вызов: CAllCrmActivity::Complete
static function Complete($ID, $completed = true, $options = [])
{
	$ID = (int)($ID ?? 0);
	if ($ID <= 0)
	{
		self::RegisterError(['text' => 'Invalid arguments are supplied.']);

		return false;
	}

	if (is_string($completed))
	{
		$completed = mb_strtoupper($completed) === 'Y' ? 'Y' : 'N';
	}
	else
	{
		$completed = ((bool)$completed) ? 'Y' : 'N';
	}

	$dbRes = CCrmActivity::GetList(
		[],
		['ID'=> $ID, 'CHECK_PERMISSIONS' => 'N'],
		false,
		false,
		['ID', 'COMPLETED', 'PROVIDER_ID', 'PROVIDER_PARAMS']
	);
	$fields = $dbRes->Fetch();
	if (!is_array($fields))
	{
		return false;
	}

	if (isset($fields['COMPLETED']) && $fields['COMPLETED'] === $completed)
	{
		return true;
	}

	$skipBeforeHandler = $options['SKIP_BEFORE_HANDLER'] ?? false;
	if (!$skipBeforeHandler)
	{
		$provider = self::GetActivityProvider($fields);
		if ($provider !== null)
		{
			$provider::onBeforeComplete($ID, $fields);
		}
	}

	return self::Update($ID, ['COMPLETED' => $completed], true, true, $options);
}

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