implemented new features for warehouseorderrequest
This commit is contained in:
@@ -6,21 +6,47 @@ class WarehouseOrderRequestController extends TTCrud {
|
||||
protected string $createText = 'Bestellwunsch erstellen';
|
||||
|
||||
protected array $columns = [
|
||||
['key' => 'id', 'text' => 'ID', 'modal' => false],
|
||||
['key' => 'id', 'text' => 'ID', 'modal' => false, 'table' => false],
|
||||
['key' => 'anzahl', 'text' => 'Anzahl', 'required' => true, 'type' => 'number'],
|
||||
['key' => 'ware', 'text' => 'Ware', 'required' => true],
|
||||
['key' => 'ware',
|
||||
'text' => 'Ware',
|
||||
'required' => true,
|
||||
'type' => 'autocomplete',
|
||||
'table' => ['class' => 'text-nowrap', 'filter' => 'autocomplete'],
|
||||
'modal' => [
|
||||
'apiUrl' => 'WarehouseArticle/autocomplete',
|
||||
'type' => 'autocomplete',
|
||||
'returnText' => true]],
|
||||
['key' => 'verwendungszweck', 'text' => 'Verwendungszweck', 'required' => true],
|
||||
['key' => 'create', 'text' => 'Erstellt am', 'required' => true, 'modal' => false, 'filter' => 'datetime'],
|
||||
['key' => 'createBy', 'text' => 'Beauftragt von', 'required' => true, 'table' => ['filter' => 'select'], 'modal' => ['visible' => false, 'type' => 'select', 'items' => []]],
|
||||
['key' => 'distributorId', 'text' => 'Lieferant', 'required' => true, 'type' => 'autocomplete', 'table' => ['class' => 'text-nowrap', 'filter' => 'autocomplete'], 'modal' => [
|
||||
'apiUrl' => 'WarehouseDistributor/autocomplete', 'items' => 'WarehouseDistributor/autocomplete', 'type' => 'autocomplete']],
|
||||
['key' => 'order', 'text' => 'Bestellt am', 'required' => false, 'filter' => 'datetime'],
|
||||
['key' => 'create', 'text' => 'Beauftragt am', 'required' => true, 'modal' => false, 'table' => ['filter' => 'datepicker']],
|
||||
['key' => 'createBy',
|
||||
'text' => 'Beauftragt von',
|
||||
'required' => true,
|
||||
'table' => ['filter' => 'select'],
|
||||
'modal' => ['visible' => false, 'type' => 'select', 'items' => []]],
|
||||
['key' => 'distributorId',
|
||||
'text' => 'Lieferant',
|
||||
'required' => false,
|
||||
'type' => 'autocomplete',
|
||||
'table' => ['class' => 'text-nowrap', 'filter' => 'autocomplete'],
|
||||
'modal' => [
|
||||
'apiUrl' => 'WarehouseDistributor/autocomplete',
|
||||
'type' => 'autocomplete']],
|
||||
['key' => 'order', 'text' => 'Bestellt am', 'required' => false, 'type' => 'datepicker', 'table' => ['filter' => 'datepicker']],
|
||||
['key' => 'orderBy', 'text' => 'Bestellt von', 'required' => false, 'table' => ['filter' => 'select'], 'modal' => ['type' => 'select', 'items' => []]],
|
||||
['key' => 'takeOver', 'text' => 'Übernommen am', 'required' => false, 'filter' => 'datetime'],
|
||||
['key' => 'takeOverBy', 'text' => 'Übernommen von', 'required' => false, 'table' => ['filter' => 'select'], 'modal' => ['type' => 'select', 'items' => []]],
|
||||
['key' => 'takeOver', 'text' => 'Übernommen am', 'required' => false, 'type' => 'datepicker', 'table' => ['filter' => 'datepicker']],
|
||||
['key' => 'takeOverBy',
|
||||
'text' => 'Übernommen von',
|
||||
'required' => false,
|
||||
'table' => ['filter' => 'select'],
|
||||
'modal' => ['type' => 'select', 'items' => []]],
|
||||
['key' => 'warehouseLocation', 'text' => 'Lagerort', 'required' => false, 'type' => 'varchar'],
|
||||
['key' => 'note', 'text' => 'Notiz', 'required' => false, 'type' => 'text'],
|
||||
['key' => 'actions', 'text' => 'Aktionen', 'required' => false, 'modal' => false, 'table' => ['filter' => false, 'sortable' => false, 'class' => 'text-center']],
|
||||
['key' => 'note', 'text' => 'Notiz', 'required' => false, 'type' => 'textarea'],
|
||||
['key' => 'actions',
|
||||
'text' => 'Aktionen',
|
||||
'required' => false,
|
||||
'modal' => false,
|
||||
'table' => ['filter' => false, 'sortable' => false, 'class' => 'text-center']],
|
||||
];
|
||||
|
||||
protected array $additionalActions = [['key' => 'openHistory', 'title' => 'Historie', 'class' => 'fas fa-history text-primary']];
|
||||
@@ -30,6 +56,8 @@ class WarehouseOrderRequestController extends TTCrud {
|
||||
'delete' => 'Bestellwunsch wurde gelöscht',
|
||||
'noChanges' => 'Keine Änderungen',];
|
||||
|
||||
protected array $additionalJSVariables = ['BASE_URL' => '/WarehouseOrderRequest'];
|
||||
|
||||
public function permissionCheck(): bool {
|
||||
return $this->user->can(["WarehouseUser"]);
|
||||
}
|
||||
@@ -38,13 +66,35 @@ class WarehouseOrderRequestController extends TTCrud {
|
||||
// Fill Users in createBy column
|
||||
$userArray = array_map(function ($user) {
|
||||
return ['value' => intval($user->id), 'text' => $user->name];
|
||||
}, UserModel::search());
|
||||
}, UserModel::search(['employee' => true]));
|
||||
$createByColumn = array_search('createBy', array_column($this->columns, 'key'));
|
||||
$this->columns[$createByColumn]['modal']['items'] = $userArray;
|
||||
$orderByColumn = array_search('orderBy', array_column($this->columns, 'key'));
|
||||
$this->columns[$orderByColumn]['modal']['items'] = $userArray;
|
||||
$takeOverByColumn = array_search('takeOverBy', array_column($this->columns, 'key'));
|
||||
$this->columns[$takeOverByColumn]['modal']['items'] = $userArray;
|
||||
|
||||
// if this user can WarehouseAdmin is false then set modal false to warehouselocation, takeOverBy, takeOver, orderBy, order
|
||||
if (!$this->user->can(["WarehouseAdmin"])) {
|
||||
$warehouselocationColumn = array_search('warehouseLocation', array_column($this->columns, 'key'));
|
||||
$this->columns[$warehouselocationColumn]['modal']['visible'] = false;
|
||||
$takeOverByColumn = array_search('takeOverBy', array_column($this->columns, 'key'));
|
||||
$this->columns[$takeOverByColumn]['modal']['visible'] = false;
|
||||
$takeOverColumn = array_search('takeOver', array_column($this->columns, 'key'));
|
||||
$this->columns[$takeOverColumn]['modal']['visible'] = false;
|
||||
$orderByColumn = array_search('orderBy', array_column($this->columns, 'key'));
|
||||
$this->columns[$orderByColumn]['modal']['visible'] = false;
|
||||
$orderColumn = array_search('order', array_column($this->columns, 'key'));
|
||||
$this->columns[$orderColumn]['modal']['visible'] = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function customAutoCompleteWare($value) {
|
||||
if (!is_numeric($value)) return [ 'id' => $value, 'title' => $value];
|
||||
|
||||
$article = WarehouseArticleModel::get(intval($value));
|
||||
return [ 'id' => $article->id, 'title' => $article->title ];
|
||||
}
|
||||
|
||||
protected function beforeUpdate($postData): bool {
|
||||
@@ -53,6 +103,7 @@ class WarehouseOrderRequestController extends TTCrud {
|
||||
}
|
||||
|
||||
protected function getHistoryAction() {
|
||||
$this->prepareCrudConfig();
|
||||
self::returnJson((new WarehouseHistoryController)->getHistory($this->request->id, $this->mod, $this->columns));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user