Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
StoreDocumentAllowNegationProductQuantityRule.php
1<?php
2
4
7
12{
16 public function check($params): bool
17 {
18 $item = $params['item'];
19
20 if ($item instanceof StoreDocument)
21 {
22 $typesWithCheck = [
23 StoreDocument::TYPE_DEDUCT,
24 StoreDocument::TYPE_MOVING,
25 StoreDocument::TYPE_SALES_ORDERS,
26 ];
27 if (in_array($item->getType(), $typesWithCheck, true))
28 {
29 $permission = PermissionDictionary::getStoreDocumentPermissionId(
30 PermissionDictionary::CATALOG_STORE_DOCUMENT_ALLOW_NEGATION_PRODUCT_QUANTITY,
31 $item->getType()
32 );
33
34 return $this->checkPermission($permission);
35 }
36
37 // for other types, allows to go into the negative.
38 return true;
39 }
40
41 return false;
42 }
43
51 private function checkPermission(string $permission): bool
52 {
53 return $this->user->getPermission($permission) === 1;
54 }
55}