diff --git a/CSS/style.css b/CSS/style.css index 282af9d..e49d023 100644 --- a/CSS/style.css +++ b/CSS/style.css @@ -539,4 +539,17 @@ td a:hover { margin-bottom: 18px; width: 100%; text-align: center; +} +.gutschein-header-block { + width: 100%; + max-width: 1100px; + display: flex; + flex-direction: column; + align-items: center; + margin-bottom: 18px; +} +.gutschein-table { + max-width: 1100px; + width: 100%; + margin: 0 auto; } \ No newline at end of file diff --git a/Controller/AuthController.php b/Controller/AuthController.php index c59dd1f..c7bfa6b 100644 --- a/Controller/AuthController.php +++ b/Controller/AuthController.php @@ -105,8 +105,7 @@ class AuthController exit; } - public function changePassword() - { + public function changePassword() { $email = $_POST['email'] ?? ''; $oldpw = $_POST['old_password'] ?? ''; $newpw = $_POST['password'] ?? ''; diff --git a/Controller/GutscheinController.php b/Controller/GutscheinController.php index 859a3d1..97b9a4f 100644 --- a/Controller/GutscheinController.php +++ b/Controller/GutscheinController.php @@ -19,16 +19,27 @@ class GutscheinController { $this->view->setVars(['gutscheine' => $gutscheine]); } + public function createGutscheinForm() { + if (!isset($_SESSION['is_admin']) || !$_SESSION['is_admin']) { + header('Location: index.php'); + exit; + } + $this->view->setDoMethodName('createGutscheinForm'); + } + public function createGutschein() { + if (!isset($_SESSION['is_admin']) || !$_SESSION['is_admin']) { + header('Location: index.php'); + exit; + } $data = [ 'code' => $_POST['code'] ?? null, - 'rabatt' => $_POST['rabatt'] ?? null, - 'eventid' => $_POST['eventid'] ?? null, - 'gültigkeit' => $_POST['gültigkeit'] ?? null + 'discount' => $_POST['discount'] ?? null, + 'event_id' => $_POST['event_id'] ?? null, + 'valid_until' => $_POST['valid_until'] ?? null ]; - $erg = $this->model->createGutschein($data); - $this->view->setVars(['gutschein' => $erg]); - exit; + $this->model->createGutschein($data); + $this->view->setDoMethodName('showCreateSuccess'); } public function editGutscheinForm() { @@ -40,18 +51,32 @@ class GutscheinController { } public function updateGutschein() { - $id = $_POST['gutscheinid']; - $data = [ - 'code' => $_POST['code'] ?? null, - 'rabatt' => $_POST['rabatt'] ?? null, - 'eventid' => $_POST['eventid'] ?? null, - 'gültigkeit' => $_POST['gültigkeit'] ?? null - ]; - $this->model->updateGutschein($id, $data); + $id = $_POST['gutscheinid']; + $data = [ + 'code' => $_POST['code'] ?? null, + 'discount' => $_POST['discount'] ?? null, + 'event_id' => $_POST['event_id'] ?? null, + 'valid_until' => $_POST['valid_until'] ?? null + ]; + $this->model->updateGutschein($id, $data); + header('Location: index.php?controller=Gutschein&do=adminVerwaltung'); + exit; } public function deleteGutschein() { $id = $_GET['gutscheinid'] ?? null; $this->model->deleteGutschein($id); + header('Location: index.php?controller=Gutschein&do=adminVerwaltung'); + exit; + } + + public function adminVerwaltung() { + if (!isset($_SESSION['is_admin']) || !$_SESSION['is_admin']) { + header('Location: index.php'); + exit; + } + $gutscheine = $this->model->getGutscheine(); + $this->view->setVars(['gutscheine' => $gutscheine]); + $this->view->setDoMethodName('showGutscheine'); } } \ No newline at end of file diff --git a/Controller/NewsController.php b/Controller/NewsController.php index 1d36fd7..2bc4ef5 100644 --- a/Controller/NewsController.php +++ b/Controller/NewsController.php @@ -47,7 +47,6 @@ class NewsController { header('Location: index.php?controller=News&do=showNews'); exit; } - // Leere Felder für das Formular $this->view->setVars([ 'errors' => [], 'validData' => [] @@ -116,7 +115,6 @@ class NewsController { return; } } - // Fehlerfall: zurück zur Übersicht header('Location: index.php?controller=News&do=showNews'); exit; } diff --git a/Views/Gutschein/createGutscheinForm.phtml b/Views/Gutschein/createGutscheinForm.phtml new file mode 100644 index 0000000..09c86e6 --- /dev/null +++ b/Views/Gutschein/createGutscheinForm.phtml @@ -0,0 +1,19 @@ +
+
+

Neuen Gutschein anlegen

+
+ + + + + + + + + + + +
+ Abbrechen +
+
\ No newline at end of file diff --git a/Views/Gutschein/editGutscheinForm.phtml b/Views/Gutschein/editGutscheinForm.phtml new file mode 100644 index 0000000..945e6d2 --- /dev/null +++ b/Views/Gutschein/editGutscheinForm.phtml @@ -0,0 +1,20 @@ +
+
+

Gutschein bearbeiten

+
+ + + + + + + + + + + + +
+ Abbrechen +
+
\ No newline at end of file diff --git a/Views/Gutschein/showCreateSuccess.phtml b/Views/Gutschein/showCreateSuccess.phtml new file mode 100644 index 0000000..8ce0c3d --- /dev/null +++ b/Views/Gutschein/showCreateSuccess.phtml @@ -0,0 +1,14 @@ +
+
+

Gutschein erfolgreich erstellt!

+

Du wirst in wenigen Sekunden zur Übersicht weitergeleitet...

+
+
+ + \ No newline at end of file diff --git a/Views/Gutschein/showGutscheine.phtml b/Views/Gutschein/showGutscheine.phtml index a5566e9..fe01dd1 100644 --- a/Views/Gutschein/showGutscheine.phtml +++ b/Views/Gutschein/showGutscheine.phtml @@ -1,10 +1,10 @@ - - -
-

Alle Gutscheine

- Neuen Gutschein anlegen +
+
+

Alle Gutscheine

+ Neuen Gutschein anlegen +
- +
@@ -22,8 +22,8 @@ @@ -32,5 +32,4 @@

Keine Gutscheine vorhanden.

- - \ No newline at end of file + \ No newline at end of file diff --git a/Views/header.phtml b/Views/header.phtml index 886310a..50b7ce9 100644 --- a/Views/header.phtml +++ b/Views/header.phtml @@ -16,6 +16,9 @@ EventInfosProfil + + Gutscheine + LogoutLogin
Code - Bearbeiten | - Löschen + Bearbeiten + Löschen