CCrmDealRecurringRestProxy::innerDelete

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmDealRecurringRestProxy
  4. innerDelete
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
  • Класс: \CCrmDealRecurringRestProxy
  • Вызов: CCrmDealRecurringRestProxy::innerDelete
protected function innerDelete($ID, &$errors, array $params = null)
{
	$recurringInstance = \Bitrix\Crm\Recurring\Entity\Deal::getInstance();
	if (!$recurringInstance->isAllowedExpose())
	{
		$errors[] = 'Recurring is not allowed';
		return false;
	}

	$recurringDataRaw = $recurringInstance->getList([
		'filter' => ['ID' => (int)$ID],
		'limit' => 1
	]);

	if (!($recurringDataRaw->fetch()))
	{
		$errors[] = 'Recurring deal is not found.';
		return false;
	}
	elseif(!CCrmDeal::CheckDeletePermission(0, CCrmPerms::GetCurrentUserPermissions()))
	{
		$errors[] = 'Access denied.';
		return false;
	}

	try
	{
		$dealRecurring = \Bitrix\Crm\Recurring\Entity\Deal::getInstance();
		$r = $dealRecurring->delete($ID);
		if (!$r->isSuccess())
		{
			$errors = $r->getErrorMessages();
			return false;
		}
		return true;
	}
	catch(Main\SystemException $ex)
	{
		$errors[] = $ex->getMessage();
		return false;
	}
}

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