38 if ($this->user->isAdmin())
43 if (
$entity === StoreTable::class)
45 return $this->getStoreFilter(
$action);
48 if (
$entity === StoreDocumentTable::class)
50 return $this->getDocumentFilter(
$action);
53 if (
$entity === StoreProductTable::class)
55 return $this->getProductFilter(
$action);
58 if (Loader::includeModule(
'sale'))
60 if (
$entity === ShipmentTable::class)
62 return $this->getSaleShipmentFilter(
$action);
77 private function validateEntity(
string $entity): void
81 StoreProductTable::class,
82 StoreDocumentTable::class,
87 if (!in_array(
$entity, $available,
true))
102 $allowedStores = $this->controller->getPermissionValue(
$action);
103 if (empty($allowedStores))
110 if (in_array(PermissionDictionary::VALUE_VARIATION_ALL, $allowedStores,
true))
116 '=ID' => $allowedStores,
127 private function getDocumentFilter(
string $action):
array
129 $allowedStores = $this->controller->getPermissionValue(
$action);
130 if (empty($allowedStores))
134 '=ELEMENTS.ID' =>
null,
136 '=ELEMENTS.STORE_TO' =>
null,
137 '=ELEMENTS.STORE_FROM' =>
null,
141 elseif (in_array(PermissionDictionary::VALUE_VARIATION_ALL, $allowedStores,
true))
149 '=ELEMENTS.ID' =>
null,
150 '=ELEMENTS.STORE_TO' => $allowedStores,
151 '=ELEMENTS.STORE_FROM' => $allowedStores,
153 '=ELEMENTS.STORE_TO' =>
null,
154 '=ELEMENTS.STORE_FROM' =>
null,
162 ->setFilter($documentFilter)
167 '@ID' =>
new SqlExpression(
$query),
178 private function getProductFilter(
string $action):
array
180 $allowedStores = $this->controller->getPermissionValue(
$action);
181 if (empty($allowedStores))
188 if (in_array(PermissionDictionary::VALUE_VARIATION_ALL, $allowedStores,
true))
194 '=STORE_ID' => $allowedStores,
205 private function getSaleShipmentFilter(
string $action):
array
207 $allowedStores = $this->controller->getPermissionValue(
$action);
208 if (empty($allowedStores))
215 if (in_array(PermissionDictionary::VALUE_VARIATION_ALL, $allowedStores,
true))
220 $allowedStores[] =
null;
222 '=STORE_ID' => $allowedStores,
226 ShipmentItemStoreTable::query()
227 ->setSelect([
'ORDER_DELIVERY_BASKET_ID'])
228 ->setFilter($storeFilter)
235 '=SHIPMENT_ITEM.ID' =>
null,
236 '@SHIPMENT_ITEM.ID' =>
new SqlExpression(
$query),
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)