Files
thetool/application/WarehouseDistributor/WarehouseDistributorController.php
2024-07-16 06:55:46 +00:00

45 lines
2.1 KiB
PHP

<?php
class WarehouseDistributorController extends TTCrud {
protected string $headerTitle = 'Lieferant';
protected string $createText = 'Lieferant erstellen';
// @formatter:off
protected array $columns = [
['key' => 'name', 'text' => 'Name', 'required' => true, 'table' => ['priority' => 11]],
['key' => 'address', 'text' => 'Adresse', 'required' => true],
['key' => 'plz', 'text' => 'PLZ', 'required' => true],
['key' => 'city', 'text' => 'Stadt', 'required' => true],
['key' => 'countryId', 'text' => 'Land', 'required' => true, 'modal' => ['type' => 'select', 'items' => []]],
['key' => 'email', 'text' => 'E-Mail', 'required' => true],
['key' => 'phone', 'text' => 'Telefon', 'required' => true],
['key' => 'contactPerson', 'text' => 'Kontaktperson', 'required' => true],
['key' => 'actions', 'text' => 'Aktionen', 'required' => false, 'modal' => false, 'table' => ['filter' => false, 'sortable' => false, 'class' => 'text-center', 'priority' => 10]],
];
// @formatter:on
protected array $additionalActions = [['key' => 'openHistory', 'title' => 'Historie', 'class' => 'fas fa-history text-primary']];
protected array $infoMessages = ['create' => 'Lieferant wurde erstellt',
'update' => 'Lieferant wurde aktualisiert',
'delete' => 'Lieferant wurde gelöscht',
'noChanges' => 'Keine Änderungen',];
public function prepareCrudConfig() {
$countries = array_map(function ($country) {
return ['value' => $country->id, 'text' => $country->name];
}, CountryModel::getAll());
$this->columns[4]['modal']['items'] = $countries;
}
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));
}
}