25 public function getFilter(
string $entity, array $params = []): array
27 $action = (string)($params[
'action'] ??
'');
33 Loader::includeModule(
'sale');
35 $this->validateEntity($entity);
37 if ($this->user->isAdmin())
42 if ($entity === StoreDocumentTable::class)
44 return $this->getDocumentFilter($action);
47 if ($entity === StoreDocumentElementTable::class)
49 return $this->getElementFilter($action);
52 if ($entity === ShipmentTable::class)
54 return $this->getShipmentFilter($action);
57 if ($entity === ShipmentItemTable::class)
59 return $this->getShipmentItemFilter($action);
71 private function validateEntity(
string $entity): void
74 StoreDocumentTable::class,
75 StoreDocumentElementTable::class,
77 ShipmentItemTable::class,
80 if (!in_array($entity, $available,
true))
93 private function getDocumentFilter(
string $action): ?array
95 $types = array_filter(
96 PermissionDictionary::getAvailableStoreDocuments(),
97 fn(
string $docType) => $this->controller->check($action,
null, [
'value' => $docType])
108 '=DOC_TYPE' => $types,
119 private function getElementFilter(
string $action): ?array
121 $types = array_filter(
122 PermissionDictionary::getAvailableStoreDocuments(),
123 fn(
string $docType) => $this->controller->check($action,
null, [
'value' => $docType])
134 '=DOCUMENT.DOC_TYPE' => $types,
145 private function getShipmentFilter(
string $action): ?array
165 private function getShipmentItemFilter(
string $action): ?array
168 return $this->getShipmentFilter($action);