Document::confirmAction

  1. Bitrix24 API (v. 23.675.0)
  2. catalog
  3. Document
  4. confirmAction
  • Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/controller/document.php
  • Класс: BitrixCatalogControllerDocument
  • Вызов: Document::confirmAction
public function confirmAction(int $id): ?bool
{
	if (!Feature::isInventoryManagementEnabled())
	{
		$this->addError(new Error(Loc::getMessage('DOCUMENT_CONTROLLER_NO_INVENTORY_MANAGEMENT_ENABLED_ERROR')));

		return null;
	}

	if (!$this->checkDocumentAccess(ActionDictionary::ACTION_STORE_DOCUMENT_CONDUCT, $id))
	{
		return null;
	}

	$document = StoreDocumentTable::getById($id)->fetch();
	if (!$document)
	{
		$message = Loc::getMessage('CATALOG_CONTROLLER_DOCUMENT_NOT_FOUND');
		$this->addError(
			new Error($message)
		);

		return null;
	}

	$userId = CurrentUser::get()->getId();

	if (!CCatalogDocs::conductDocument($id, $userId))
	{
		$error = '';

		global $APPLICATION;

		if ($APPLICATION->GetException())
		{
			$error = $APPLICATION->GetException()->GetString();
			$APPLICATION->ResetException();
		}

		$message = Loc::getMessage(
			'CATALOG_CONTROLLER_DOCUMENT_CONDUCT_ERROR',
			[
				'#ERROR#' => $error,
			]
		);

		$this->addError(new Error($message));

		return null;
	}

	return true;
}

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