From 6c1e578227408f1ab668f901d5c6bea4002d3361 Mon Sep 17 00:00:00 2001 From: RiFav <13521075@std.stei.itb.ac.id> Date: Sat, 7 Oct 2023 22:42:09 +0700 Subject: [PATCH] feat: prepare update event feature --- app/Controllers/EventController.php | 25 +++++++++++++++++++++++++ app/router.php | 6 ++++++ 2 files changed, 31 insertions(+) diff --git a/app/Controllers/EventController.php b/app/Controllers/EventController.php index 2f2001e..1771423 100644 --- a/app/Controllers/EventController.php +++ b/app/Controllers/EventController.php @@ -97,9 +97,34 @@ class EventController { ob_end_flush(); } } + elseif ($_POST['eventAction'] === 'updateEvent') { + unset($_POST['eventAction']); + $eventId = $_POST['eventId']; + $eventName = $_POST['eventName']; + $eventPrice = $_POST['eventPrice']; + $eventDate = $_POST['eventDate']; + $eventLocation = $_POST['eventLocation']; + + $imageFilePath = isset($_FILES['gambar']) && $_FILES['gambar']['error'] === 0 ? $_FILES['gambar'] : null; + $vidFilePath = isset($_FILES['vid']) && $_FILES['vid']['error'] === 0 ? $_FILES['vid'] : null; + + $this->updateEvent($eventId, $eventName, $eventPrice, $eventDate, $eventLocation, $imageFilePath, $vidFilePath); + header("Location:Views/home/home.php"); + ob_end_flush(); + } } else { // Handle other actions here, if needed } + if (isset($_GET['eventAction'])) { + if ($_GET['eventAction'] === 'getEvent') { + $eventId = $_GET['eventId']; + unset($_GET['eventAction']); + unset($_GET['eventId']); + echo json_encode($this->getEvent($eventId)); + } else { + // Handle other actions here, if needed + } + } if (isset($_GET['action'])) { if ($_GET['action'] === 'purchaseTicket') { diff --git a/app/router.php b/app/router.php index e766c4b..af5841a 100644 --- a/app/router.php +++ b/app/router.php @@ -21,4 +21,10 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { $pembelianController->handleRequest(); } } + +elseif ($_SERVER["REQUEST_METHOD"] == "GET") { + if (isset($_GET["eventAction"]) && isset($_GET["eventId"])) { + $eventController->handleRequest(); + } +} ?> \ No newline at end of file -- GitLab