Updated WarehouseOrderRequest

This commit is contained in:
Luca Haid
2025-01-20 15:40:13 +01:00
parent 1cfadaf5e2
commit 6e87b77387
4 changed files with 86 additions and 3 deletions

View File

@@ -7,7 +7,6 @@ class WarehouseOrderRequestController extends TTCrud {
protected array $columns = [
['key' => 'id', 'text' => 'ID', 'modal' => false, 'table' => false],
['key' => 'anzahl', 'text' => 'Anzahl', 'required' => true, 'type' => 'number'],
['key' => 'ware',
'text' => 'Ware',
'required' => true,
@@ -17,6 +16,7 @@ class WarehouseOrderRequestController extends TTCrud {
'apiUrl' => 'WarehouseArticle/autocomplete',
'type' => 'autocomplete',
'returnText' => true]],
['key' => 'anzahl', 'text' => 'Anzahl', 'required' => true, 'type' => 'number'],
['key' => 'verwendungszweck', 'text' => 'Verwendungszweck', 'required' => true],
['key' => 'create', 'text' => 'Beauftragt am', 'required' => true, 'modal' => false, 'table' => ['filter' => 'datepicker']],
['key' => 'createBy',
@@ -88,6 +88,7 @@ class WarehouseOrderRequestController extends TTCrud {
$this->columns[$orderColumn]['modal']['visible'] = false;
}
$this->additionalJSVariables['user_id'] = $this->user->id;
}
protected function customAutoCompleteWare($value) {
@@ -102,6 +103,28 @@ class WarehouseOrderRequestController extends TTCrud {
return true;
}
protected function afterCreate($postData): void {
if ($_SERVER['HTTP_HOST'] == 'localhost') return;
$email = new Emailnotification();
$paddedId = str_pad($this->mod->id, 5, '0', STR_PAD_LEFT);
$email->setSubject("TheTool: Neue Interne Bestellung #$paddedId");
$body = "Hallo,\n\nes wurde eine neue interne Bestellung erstellt.\n\n";
$body .= "Bestellnummer: #$paddedId\n";
$body .= "Ware: " . $postData['ware'] . "\n";
$body .= "Anzahl: " . $postData['anzahl'] . "\n";
$body .= "Verwendungszweck: " . $postData['verwendungszweck'] . "\n";
$body .= "Beauftragt von: " . $this->user->name . "\n";
$body .= "Beauftragt am: " . date('d.m.Y H:i') . "\n";
$body .= "Notiz: " . $postData['note'] . "\n\n";
$email->setBody($body);
$email->setFrom(TT_OUTGOING_EMAIL_2FA, TT_OUTGOING_EMAIL_2FA);
$email->setTo("einkauf@xinon.at", "Einkauf");
$email->send();
}
protected function getHistoryAction() {
$this->prepareCrudConfig();
self::returnJson((new WarehouseHistoryController)->getHistory($this->request->id, $this->mod, $this->columns));