From 3faec473ef15ade28861d80c7d98ad8b919d6cee Mon Sep 17 00:00:00 2001 From: pbbfa23cse Date: Mon, 7 Jul 2025 20:32:35 +0200 Subject: [PATCH] Added Styles to Create and Update Event --- Controller/EventController.php | 37 ++++++++++++++++++++++++++ Views/Event/showCreateEvent.phtml | 44 ++++++++++++++++++++++++------- Views/Event/showUpdateEvent.phtml | 30 ++++++++++++++++++--- 3 files changed, 97 insertions(+), 14 deletions(-) diff --git a/Controller/EventController.php b/Controller/EventController.php index fbe201d..bca7a6e 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -3,6 +3,7 @@ namespace Blog\Controller; use Blog\Model\EventModel; +use Blog\Model\StandortModel; class EventController { @@ -61,4 +62,40 @@ class EventController { $this->model->deleteEvent($id); $this->view->setVars(['id' => $id]); } + + public function showUpdateEvent() { + $id = $_GET['event_id'] ?? null; + if (!$id) { + // handle error, e.g., redirect or show error message + $this->view->setVars(['error' => 'Keine Event-ID angegeben.']); + return; + } + $event = $this->model->getEvent($id); + if (!$event) { + $this->view->setVars(['error' => 'Event nicht gefunden.']); + return; + } + // Map DB fields to view fields if needed + $eventView = [ + 'id' => $event['event_id'], + 'name' => $event['name'], + 'start_date' => $event['start_date'], + 'end_date' => $event['end_date'], + 'location_id' => $event['location_id'], + 'description' => $event['description'], + 'max_tickets' => $event['max_tickets'], + 'ticket_price' => $event['ticket_price'], + ]; + // Fetch location name (city) + $standortModel = new StandortModel(); + $location = $standortModel->getStandort($event['location_id']); + $eventView['location_name'] = $location['city'] ?? ''; + $this->view->setVars(['event' => $eventView]); + } + + public function showCreateEvent() { + $standortModel = new \Blog\Model\StandortModel(); + $locations = $standortModel->getStandorte(); + $this->view->setVars(['locations' => $locations]); + } } \ No newline at end of file diff --git a/Views/Event/showCreateEvent.phtml b/Views/Event/showCreateEvent.phtml index 185470e..caba922 100644 --- a/Views/Event/showCreateEvent.phtml +++ b/Views/Event/showCreateEvent.phtml @@ -1,12 +1,36 @@ - -
-
-

Das Event "" wurde erfolgreich erstellt!

- Weiter -
-
+

Create Event

+
+ +
- \ No newline at end of file + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ \ No newline at end of file diff --git a/Views/Event/showUpdateEvent.phtml b/Views/Event/showUpdateEvent.phtml index e4cd61c..86cf753 100644 --- a/Views/Event/showUpdateEvent.phtml +++ b/Views/Event/showUpdateEvent.phtml @@ -3,10 +3,32 @@ include dirname(__DIR__).'/header.phtml'; ?>
-
-

Das Event mit der ID "" wurde erfolgreich bearbeitet!

- Weiter -
+

Update Event

+
+ +
+ + +
+ + +
+ + +
+ + + +
+ + +
+ + +
+ + +
\ No newline at end of file