diff --git a/Layout/default/ConstructionConsent/Index.php b/Layout/default/ConstructionConsent/Index.php index 1d19c4dbc..ffc544640 100644 --- a/Layout/default/ConstructionConsent/Index.php +++ b/Layout/default/ConstructionConsent/Index.php @@ -165,7 +165,7 @@ $pagination_entity_name = "Zustimmungserklärungen"; 1, "filter" => ["project_id" => (is_array($filter) && array_key_exists("project_id", $filter) ? $filter["project_id"] : "")]])?>"> Filter zurücksetzen - isAdmin() && is_array($filter) && array_key_exists("project_id", $filter) && !empty($filter["project_id"])): ?> + diff --git a/Layout/default/ConstructionConsent/View.php b/Layout/default/ConstructionConsent/View.php index 0a703c5d4..1881a7840 100644 --- a/Layout/default/ConstructionConsent/View.php +++ b/Layout/default/ConstructionConsent/View.php @@ -375,7 +375,9 @@ $pagination_entity_name = "Adressen";
files) && count($owner->files)): foreach($owner->files as $file): ?> - $file->file_id])?>"> filename?>
+ $file->file_id])?>"> filename?> + $file->id])?>" onclick="if(!confirm('Datei wirklich löschen?')) return false;" title="Datei Löschen"> +
diff --git a/application/ConstructionConsentOwner/ConstructionConsentOwnerController.php b/application/ConstructionConsentOwner/ConstructionConsentOwnerController.php index a3495dba5..f594ad2c7 100644 --- a/application/ConstructionConsentOwner/ConstructionConsentOwnerController.php +++ b/application/ConstructionConsentOwner/ConstructionConsentOwnerController.php @@ -156,6 +156,50 @@ class ConstructionConsentOwnerController extends mfBaseController } + protected function deleteFileAction() { + // display errors + ini_set('display_errors', 1); + ini_set('display_startup_errors', 1); + error_reporting(E_ALL); + $id = $this->request->id; + + $file = new ConstructionConsentOwnerFile($id); + if(!$file->id) { + $this->layout()->setFlash("Datei nicht gefunden!", "error"); + $this->redirect("ConstructionConsent"); + } + + $owner = new ConstructionConsentOwner($file->constructionconsentowner_id); + if(!$owner->id) { + $this->layout()->setFlash("Besitzer nicht gefunden!", "error"); + $this->redirect("ConstructionConsent"); + } + + $consent = $owner->consent; + if(!$consent->id) { + $this->layout()->setFlash("Zustimmungserklärung nicht gefunden!", "error"); + $this->redirect("ConstructionConsent"); + } + + $project = new ConstructionConsentProject($consent->constructionconsentproject_id); + + if(!$project->id) { + $this->layout()->setFlash("Zustimmungserklärungsprojekt nicht gefunden!", "error"); + $this->redirect("ConstructionConsent"); + } + + if (!in_array($project->id, $this->constructionConsentProjects)) { + $this->layout()->setFlash("Sie sind nicht berechtigt, diese Zustimmungserklärung zu bearbeiten", "error"); + $this->redirect("ConstructionConsent"); + } + + $file->file->delete(); + $file->delete(); + + $this->layout()->setFlash("Datei gelöscht!", "success"); + $this->redirect("ConstructionConsent", "View", ["id" => $owner->constructionconsent_id]); + } + protected function apiAction() { $do = $this->request->do; $data = []; diff --git a/application/WarehouseEShopOrder/WarehouseEShopOrderController.php b/application/WarehouseEShopOrder/WarehouseEShopOrderController.php index ef00b3cd8..d1b8b26c7 100644 --- a/application/WarehouseEShopOrder/WarehouseEShopOrderController.php +++ b/application/WarehouseEShopOrder/WarehouseEShopOrderController.php @@ -343,7 +343,7 @@ class WarehouseEShopOrderController extends TTCrud { $id = WarehouseEShopOrderModel::create(['status' => 'new', 'extRef' => $json['extRef'], 'deliveryMode' => $json['deliveryMode'], - 'deliveryAddressAdditional' => $json['deliveryAddressAdditional'], + 'deliveryAddressAdditional' => $json['deliveryAddressAdditional'] ?? '', 'deliveryAddressName' => $json['deliveryAddressName'], 'deliveryAddressLine' => $json['deliveryAddressLine'], 'deliveryAddressPLZ' => $json['deliveryAddressPLZ'], @@ -388,21 +388,19 @@ class WarehouseEShopOrderController extends TTCrud { $user = UserModel::getOne($json['createBy']); - foreach (["eshop-versand@xinon.at", $user->email] as $emailAddr) { - $email = new Emailnotification(); - $email->setSubject("Bestellbestätigung Bestellung #$subjectId - Referenz: " . $json['extRef']); - $email->setBody($body); - $email->setFrom(TT_OUTGOING_EMAIL_2FA, TT_OUTGOING_EMAIL_2FA); - $email->setTo($emailAddr); - $email->send(); - } + if ($_SERVER['HTTP_HOST'] !== 'localhost') + foreach (["eshop-versand@xinon.at", $user->email] as $emailAddr) { + $email = new Emailnotification(); + $email->setSubject("Bestellbestätigung Bestellung #$subjectId - Referenz: " . $json['extRef']); + $email->setBody($body); + $email->setFrom(TT_OUTGOING_EMAIL_2FA, TT_OUTGOING_EMAIL_2FA); + $email->setTo($emailAddr); + $email->send(); + } self::returnJson(['success' => true, 'message' => $this->infoMessages['create'], 'id' => $id]); - - $json['id'] = $id; - die(json_encode($json)); } protected function beforeCreate(): bool { diff --git a/application/WarehouseEShopOrder/WarehouseEShopOrderModel.php b/application/WarehouseEShopOrder/WarehouseEShopOrderModel.php index 8f1c5b6fb..c9868567b 100644 --- a/application/WarehouseEShopOrder/WarehouseEShopOrderModel.php +++ b/application/WarehouseEShopOrder/WarehouseEShopOrderModel.php @@ -19,7 +19,7 @@ class WarehouseEShopOrderModel extends TTCrudBaseModel { public string $status; public string $deliveryMode; public string $deliveryAddressName; - public string $deliveryAddressAdditional; + public ?string $deliveryAddressAdditional; public string $deliveryAddressLine; public string $deliveryAddressPLZ; public string $deliveryAddressCity; diff --git a/public/js/pages/WarehouseEShop/WarehouseEShop.js b/public/js/pages/WarehouseEShop/WarehouseEShop.js index 716fc3c6a..3cf7deda8 100644 --- a/public/js/pages/WarehouseEShop/WarehouseEShop.js +++ b/public/js/pages/WarehouseEShop/WarehouseEShop.js @@ -65,12 +65,12 @@ Vue.component('warehouse-e-shop', { const response = await axios.post(`${window['TT_CONFIG']['BASE_PATH']}/WarehouseEShopOrder/createOrder`, { shoppingCart: this.shoppingCart, deliveryMode: this.createOrderDialogData.deliveryMode, - extRef: this.createOrderDialogData.extRef.trim(), - deliveryAddressName: this.createOrderDialogData.deliveryAddressName.trim(), - deliveryAddressAdditional: this.createOrderDialogData.deliveryAddressAdditional.trim(), - deliveryAddressLine: this.createOrderDialogData.deliveryAddressLine.trim(), - deliveryAddressPLZ: this.createOrderDialogData.deliveryAddressPLZ.trim(), - deliveryAddressCity: this.createOrderDialogData.deliveryAddressCity.trim(), + extRef: this.createOrderDialogData.extRef?.trim(), + deliveryAddressName: this.createOrderDialogData.deliveryAddressName?.trim(), + deliveryAddressAdditional: this.createOrderDialogData.deliveryAddressAdditional?.trim(), + deliveryAddressLine: this.createOrderDialogData.deliveryAddressLine?.trim(), + deliveryAddressPLZ: this.createOrderDialogData.deliveryAddressPLZ?.trim(), + deliveryAddressCity: this.createOrderDialogData.deliveryAddressCity?.trim(), }); if (response.data.success) { this.window.notify('success', response.data.message || 'Erfolgreich gespeichert');