added new warehouseorder features
This commit is contained in:
@@ -8,6 +8,7 @@ class WarehouseOrderRequestController extends TTCrud {
|
||||
//@formatter:off
|
||||
protected array $columns = [
|
||||
['key' => 'id', 'text' => 'Bestellnummer', 'table' => ['filter' => false], 'modal' => false],
|
||||
['key' => 'addressId', 'text' => 'Kunde', 'required' => false, 'type' => 'autocomplete', 'table' => ['class' => 'text-nowrap', 'filter' => 'autocomplete'], 'modal' => ['apiUrl' => 'Address/api?do=findAddress', 'items' => '/Address/Api?do=findAddress', 'type' => 'autocomplete']],
|
||||
['key' => 'purpose', 'text' => 'Verwendungszweck', 'required' => true],
|
||||
['key' => 'positions', 'text' => 'Positionen', 'required' => true, 'modal' => ['type' => 'positions-manager', 'config' => [
|
||||
'header' => 'Positionen',
|
||||
@@ -35,11 +36,16 @@ class WarehouseOrderRequestController extends TTCrud {
|
||||
['value' => 0, 'text' => 'Bestellwunsch nicht storniert', 'icon' => 'fa-regular fa-circle-check text-success'],
|
||||
['value' => 1, 'text' => 'Bestellwunsch storniert', 'icon' => 'fa-regular fa-circle-xmark text-danger']]], 'table' => ['filter' => 'iconSelect']
|
||||
],
|
||||
['key' => 'done', 'text' => 'Erledigt', 'modal' => ['visible' => false, 'type' => 'icon-select', 'items' => [
|
||||
['value' => 0, 'text' => 'Bestellwunsch nicht erledigt', 'icon' => 'fa-regular fa-circle-check text-success'],
|
||||
['value' => 1, 'text' => 'Bestellwunsch erledigt', 'icon' => 'fa-regular fa-circle-xmark text-danger']]], 'table' => ['filter' => 'iconSelect']
|
||||
],
|
||||
['key' => 'actions', 'text' => 'Aktionen', 'required' => false, 'modal' => false, 'table' => ['filter' => false, 'sortable' => false, 'class' => 'text-center']],
|
||||
];
|
||||
//@formatter:on
|
||||
|
||||
protected array $permissionCheck = ['WarehouseUser'];
|
||||
protected array $defaultOrder = ['key' => 'create', 'order' => 'DESC'];
|
||||
|
||||
protected array $additionalActions = [
|
||||
['key' => 'openHistory', 'title' => 'Historie', 'class' => 'fas fa-history text-primary'],
|
||||
@@ -59,37 +65,6 @@ class WarehouseOrderRequestController extends TTCrud {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function afterCreate($postData): void {
|
||||
return;
|
||||
//TODO: this should be working again
|
||||
if ($_SERVER['HTTP_HOST'] === 'localhost') return;
|
||||
die("TODO we need this to work with new positions manager");
|
||||
|
||||
$email = new Emailnotification();
|
||||
$postData['ware'] = is_numeric($postData['ware']) ? WarehouseArticleModel::get((int) $postData['ware'])->title : $postData['ware'];
|
||||
$paddedId = str_pad($postData['id'], 5, '0', STR_PAD_LEFT);
|
||||
|
||||
$email->setSubject("TheTool: Neue Interne Bestellung #$paddedId")
|
||||
->setBody(<<<BODY
|
||||
Hallo,
|
||||
|
||||
es wurde eine neue interne Bestellung erstellt.
|
||||
|
||||
Bestellnummer: #$paddedId
|
||||
Ware: {$postData['ware']}
|
||||
Anzahl: {$postData['anzahl']}
|
||||
Verwendungszweck: {$postData['verwendungszweck']}
|
||||
Beauftragt von: {$this->user->name}
|
||||
Beauftragt am: {date('d.m.Y H:i')}
|
||||
Notiz: {$postData['note']}
|
||||
|
||||
BODY
|
||||
)
|
||||
->setFrom(TT_OUTGOING_EMAIL_2FA, TT_OUTGOING_EMAIL_2FA)
|
||||
->setTo("einkauf@xinon.at", "Einkauf")
|
||||
->send();
|
||||
}
|
||||
|
||||
protected function cancelAction() {
|
||||
$id = filter_var($this->request->id, FILTER_VALIDATE_INT);
|
||||
$cancel = filter_var($this->request->cancel, FILTER_VALIDATE_INT, ['options' => ['min_range' => 0, 'max_range' => 1]]);
|
||||
@@ -101,6 +76,17 @@ BODY
|
||||
self::returnJson(['success' => true]);
|
||||
}
|
||||
|
||||
protected function doneAction() {
|
||||
$id = filter_var($this->request->id, FILTER_VALIDATE_INT);
|
||||
$done = filter_var($this->request->done, FILTER_VALIDATE_INT, ['options' => ['min_range' => 0, 'max_range' => 1]]);
|
||||
|
||||
if (!$id || $done === false) self::returnJson(['error' => 'Ungültige Anfrage']);
|
||||
if (!(WarehouseOrderRequestModel::get($id))) self::returnJson(['error' => 'Bestellwunsch nicht gefunden']);
|
||||
|
||||
WarehouseOrderRequestModel::update(['id' => $id, 'done' => $done]);
|
||||
self::returnJson(['success' => true]);
|
||||
}
|
||||
|
||||
protected function createNewLogAction() {
|
||||
$postData = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
|
||||
class WarehouseOrderRequestModel extends TTCrudBaseModel {
|
||||
public int $id;
|
||||
public ?int $addressId;
|
||||
public string $purpose;
|
||||
public string $positions;
|
||||
public ?string $note;
|
||||
public ?string $linkedOrderIds;
|
||||
public ?int $cancelled;
|
||||
public ?int $done;
|
||||
public int $create;
|
||||
public int $createBy;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user