58 lines
3.6 KiB
PHP
58 lines
3.6 KiB
PHP
<?php
|
|
//TODO: enable switching distributors in the order preview
|
|
|
|
class WarehouseOrderRequestController extends TTCrud {
|
|
protected string $headerTitle = 'Bestellwünsche';
|
|
protected string $createText = 'Bestellwunsch erstellen';
|
|
|
|
protected array $columns = [
|
|
['key' => 'id', 'text' => 'ID', 'modal' => false],
|
|
['key' => 'anzahl', 'text' => 'Anzahl', 'required' => true, 'type' => 'number'],
|
|
['key' => 'ware', 'text' => 'Ware', 'required' => 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' => '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' => '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']],
|
|
];
|
|
|
|
protected array $additionalActions = [['key' => 'openHistory', 'title' => 'Historie', 'class' => 'fas fa-history text-primary']];
|
|
|
|
protected array $infoMessages = ['create' => 'Bestellwunsch wurde erstellt.',
|
|
'update' => 'Bestellwunsch wurde aktualisiert',
|
|
'delete' => 'Bestellwunsch wurde gelöscht',
|
|
'noChanges' => 'Keine Änderungen',];
|
|
|
|
public function permissionCheck(): bool {
|
|
return $this->user->can(["WarehouseUser"]);
|
|
}
|
|
|
|
protected function prepareCrudConfig() {
|
|
// Fill Users in createBy column
|
|
$userArray = array_map(function ($user) {
|
|
return ['value' => intval($user->id), 'text' => $user->name];
|
|
}, UserModel::search());
|
|
$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;
|
|
}
|
|
|
|
protected function beforeUpdate($postData): bool {
|
|
(new WarehouseHistoryController)->create($postData, $this->mod);
|
|
return true;
|
|
}
|
|
|
|
protected function getHistoryAction() {
|
|
self::returnJson((new WarehouseHistoryController)->getHistory($this->request->id, $this->mod, $this->columns));
|
|
}
|
|
} |