Added some permissions for warehouse

This commit is contained in:
Luca Haid
2024-11-14 11:08:01 +01:00
parent c393d8e6a1
commit 5914ac6320
5 changed files with 36 additions and 13 deletions
@@ -2,7 +2,7 @@
class WarehouseArticleController extends TTCrud {
protected string $headerTitle = 'Artikel';
protected string $createText = 'Artikel erstellen';
protected $createText = 'Artikel erstellen';
// @formatter:off
protected array $columns = [
@@ -32,11 +32,26 @@ class WarehouseArticleController extends TTCrud {
];
// @formatter:on
protected array $additionalJSVariables = ['WAREHOUSE_ADMIN' => true];
protected array $infoMessages = ['create' => 'Artikel wurde erstellt',
'update' => 'Artikel wurde aktualisiert',
'delete' => 'Artikel wurde gelöscht',
'noChanges' => 'Keine Änderungen',];
protected function prepareCrudConfig() {
if (!$this->user->can('WarehouseAdmin')) {
// find column with key actions, cheapestPurchasePrice, warningAmount, criticalAmount and set table to false
foreach ($this->columns as $key => $column) {
if (in_array($column['key'], ['actions', 'cheapestPurchasePrice', 'warningAmount', 'criticalAmount'])) {
$this->columns[$key]['table'] = false;
}
}
$this->createText = false;
$this->additionalJSVariables['WAREHOUSE_ADMIN'] = false;
}
}
protected function beforeUpdate($postData): bool {
(new WarehouseHistoryController)->create($postData, $this->mod);
return true;