3namespace Bitrix\Catalog\Controller;
5use Bitrix\Catalog\Access\ActionDictionary;
6use Bitrix\Catalog\StoreDocumentTable;
7use Bitrix\Catalog\v2\Contractor\Provider\Manager;
8use Bitrix\Crm\Integration\Catalog\Contractor\StoreDocumentContractorTable;
9use Bitrix\Main\Engine\Action;
10use Bitrix\Main\Engine\Response\DataType\Page;
12use Bitrix\Main\Result;
13use Bitrix\Main\UI\PageNavigation;
26 && !Manager::isActiveProviderByModule(Manager::PROVIDER_STORE_DOCUMENT,
'crm')
29 $this->addError(
new Error(
'Contractors should be provided by CRM'));
64 $canModify = $this->checkDocumentAccess(ActionDictionary::ACTION_STORE_DOCUMENT_MODIFY);
65 if (!$canModify->isSuccess())
70 $checkFieldsResult = $this->checkFields(
$fields);
71 if (!$checkFieldsResult->isSuccess())
73 $this->addErrors($checkFieldsResult->getErrors());
78 $addResult = StoreDocumentContractorTable::add([
79 'DOCUMENT_ID' => (
int)
$fields[
'DOCUMENT_ID'],
80 'ENTITY_ID' => (
int)
$fields[
'ENTITY_ID'],
81 'ENTITY_TYPE_ID' => (
int)
$fields[
'ENTITY_TYPE_ID'],
84 if (!$addResult->isSuccess())
86 $this->addErrors($checkFieldsResult->getErrors());
92 'DOCUMENT_CONTRACTOR' => $this->
get($addResult->getId()),
104 $existsResult = $this->
exists($id);
105 if (!$existsResult->isSuccess())
107 $this->addError(
new Error(
'Binding was not found'));
112 $canModify = $this->checkDocumentAccess(ActionDictionary::ACTION_STORE_DOCUMENT_MODIFY);
113 if (!$canModify->isSuccess())
118 $deleteResult = StoreDocumentContractorTable::delete($id);
121 $this->addErrors($deleteResult->getErrors());
142 bool $__calculateTotalCount =
true
146 'DOCUMENT_CONTRACTOR',
163 $documentId = (int)
$fields[
'DOCUMENT_ID'];
164 $entityTypeId = (int)
$fields[
'ENTITY_TYPE_ID'];
169 $result->addError(
new Error(
'Store document was not found'));
187 $result->addError(
new Error(
'Store document was not found'));
194 $result->addError(
new Error(
'Type of store document is wrong'));
197 if ($document[
'STATUS'] ===
'Y')
199 $result->addError(
new Error(
'Unable to edit conducted document'));
203 $entityTypeId !== \CCrmOwnerType::Contact
204 && $entityTypeId !== \CCrmOwnerType::Company
215 $bindingExists = $this->existsByFilter([
216 'DOCUMENT_ID' => $documentId,
217 'ENTITY_TYPE_ID' => $entityTypeId,
220 if ($bindingExists->isSuccess())
222 $result->addError(
new Error(
'This contractor has been already bound to this document'));
225 if ($entityTypeId === \CCrmOwnerType::Company)
227 $documentCompanyBinding = StoreDocumentContractorTable::getRow([
230 'DOCUMENT_ID' => $documentId,
231 'ENTITY_TYPE_ID' => \CCrmOwnerType::Company,
235 if (!empty($documentCompanyBinding))
237 $result->addError(
new Error(
'This document already has a Company contractor'));
246 $result = $this->checkDocumentAccess(ActionDictionary::ACTION_STORE_DOCUMENT_VIEW);
253 $this->accessController->check(Controller::CATALOG_STORE)
254 && $this->accessController->check(Controller::CATALOG_READ);
256 if (!$canReadDocument)
272 return $this->checkDocumentAccess(ActionDictionary::ACTION_STORE_DOCUMENT_MODIFY);
305 return new StoreDocumentContractorTable;
checkModifyPermissionEntity()
listAction(PageNavigation $pageNavigation, array $select=[], array $filter=[], array $order=[], bool $__calculateTotalCount=true)
checkReadPermissionEntity()
processBeforeAction(Action $action)
checkPermissionEntity($name, $arguments=[])
static getRow(array $parameters)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
getList(array $select, array $filter, array $order, PageNavigation $pageNavigation=null)
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"