Files
thetool/application/WarehouseLocation/WarehouseLocationController.php
2024-10-10 08:49:50 +02:00

44 lines
1.6 KiB
PHP

<?php
class WarehouseLocationController extends TTCrud {
protected string $headerTitle = 'Lagerorte';
protected string $createText = 'Lagerort erstellen';
protected array $columns = [
['key' => 'title', 'text' => 'Titel', 'required' => true],
['key' => 'assignedTo', 'text' => 'Zugewiesen an', 'required' => true,
'table' => ['filter' => 'select', 'items' => []],
'modal' => ['type' => 'select', 'items' => []]],
['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' => 'Lagerort wurde erstellt',
'update' => 'Lagerort wurde aktualisiert',
'delete' => 'Lagerort wurde gelöscht',
'noChanges' => 'Keine Änderungen',
];
public function prepareCrudConfig() {
$users = array_map(function($user) {
return ['value' => $user->id, 'text' => $user->name];
}, UserModel::search(['employee' => true]));
$this->columns[1]['modal']['items'] = $users;
}
protected function beforeUpdate($postData): bool {
(new WarehouseHistoryController)->create($postData, $this->mod);
return true;
}
protected function getHistoryAction() {
$this->prepareCrudConfig();
self::returnJson((new WarehouseHistoryController)->getHistory($this->request->id, $this->mod, $this->columns));
}
}