CAllCrmActivity::Postpone

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

	$offset = (int)$offset;
	if($offset <= 0 && !$params['USE_NEGATIVE_OFFSET'])
	{
		return array();
	}

	if(!is_array($params))
	{
		$params = array();
	}

	$fields = isset($params['FIELDS']) && is_array($params['FIELDS']) ? $params['FIELDS'] : array();
	if(!(isset($fields['PROVIDER_ID'])
		&& isset($fields['TYPE_ID'])
		&& isset($fields['START_TIME'])
		&& isset($fields['END_TIME']))
	)
	{
		$dbResult = self::GetList(
			array(),
			array('=ID' => $ID, 'CHECK_PERMISSIONS' => 'N'),
			false,
			false,
			array('ID', 'START_TIME', 'END_TIME', 'PROVIDER_ID', 'TYPE_ID', 'ASSOCIATED_ENTITY_ID')
		);

		$fields = $dbResult->Fetch();
		if(!is_array($fields))
		{
			self::RegisterError(array('text' => 'Activity is not found.'));
			return array();
		}
	}

	$provider = self::GetActivityProvider($fields);
	if($provider === null)
	{
		self::RegisterError(array('text' => 'Could not find provider.'));
		return array();
	}

	$updateFields = array();
	if(!$provider::tryPostpone($offset, $fields, $updateFields))
	{
		self::RegisterError(array('text' => 'Postpone denied by provider.'));
		return array();
	}

	if(!empty($updateFields))
	{
		if (!empty($fields['CALENDAR_EVENT_ID']))
		{
			$updateFields['CALENDAR_EVENT_ID'] = $fields['CALENDAR_EVENT_ID'];
		}
		self::Update($ID, $updateFields);
	}

	$dbResult = self::GetList(
		array(),
		array('=ID' => $ID, 'CHECK_PERMISSIONS' => 'N'),
		false,
		false,
		array('ID', 'START_TIME', 'END_TIME', 'DEADLINE')
	);

	$updateFields = $dbResult->Fetch();
	return $updateFields;
}

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