diff --git a/app/Controllers/PembelianController.php b/app/Controllers/PembelianController.php index 249546d77605d7c7b33fba02a2184044fcbc5da6..93d5aa3f4b7647b1982db40e53b9788f72c30106 100644 --- a/app/Controllers/PembelianController.php +++ b/app/Controllers/PembelianController.php @@ -43,6 +43,10 @@ class PembelianController { return $this->pembelianModel->getAllPembelian(); } + public function getAllPembelianWithDetails(){ + return $this->pembelianModel->getAllPembelianWithDetails(); + } + public function getPembelianByUserId($userId) { return $this->pembelianModel->getPembelianByUserId($userId); } diff --git a/app/Models/Pembelian.php b/app/Models/Pembelian.php index 9e94cecd9e9bfbe4ef673893f701808cbdbb1e06..c0a9ddff9eebc225c4f729d18e5fd0dc3f2a61a9 100644 --- a/app/Models/Pembelian.php +++ b/app/Models/Pembelian.php @@ -58,6 +58,13 @@ class PembelianModel { return $stmt->fetchAll(PDO::FETCH_ASSOC); } + public function getAllPembelianWithDetails(){ + global $db; + $stmt = $db->prepare("SELECT * FROM pembelian JOIN tickets ON pembelian.ticket_id = tickets.ticket_id JOIN events ON tickets.event_id = events.event_id ORDER BY pembelian_created_time DESC"); + $stmt->execute(); + return $stmt->fetchAll(PDO::FETCH_ASSOC); + } + public function getPembelianByUserId($userId){ global $db; $stmt = $db->prepare("SELECT * FROM pembelian JOIN tickets ON pembelian.ticket_id = tickets.ticket_id JOIN events ON tickets.event_id = events.event_id WHERE user_id = ? ORDER BY pembelian_created_time DESC"); diff --git a/app/Views/history/history.php b/app/Views/history/history.php index 77552fd3202c47dcfc215e077c9d1630d127a72c..810779df9c5beccde0873d6ad8260662e014465f 100644 --- a/app/Views/history/history.php +++ b/app/Views/history/history.php @@ -15,14 +15,16 @@ $pembelianController = new PembelianController(); + $userController = new UserController(); - // Handle search query - $searchQuery = isset($_GET['search']) ? $_GET['search'] : ''; - $sortKey = isset($_GET['sort']) ? $_GET['sort'] : 'name'; - $minStock = isset($_GET['min_stock']) ? $_GET['min_stock'] : null; + $isAdmin = $userController->getUser($_SESSION['user_id'])['isAdmin']; // Get search results or all pembelian (history) - $pembelians = $pembelianController->getPembelianByUserId($_SESSION['user_id']); + if (!$isAdmin){ + $pembelians = $pembelianController->getPembelianByUserId($_SESSION['user_id']); + } else { + $pembelians = $pembelianController->getAllPembelianWithDetails(); + } $paginationData = $pembelianController->paginateHistory($pembelians); $pembelians = $paginationData['pembelian']; $totalEvents = $paginationData['total']; diff --git a/app/Views/home/home.php b/app/Views/home/home.php index 4a14a80a4aa40e3487323bc21dcb09efddd83009..32ee979c11e5491d3796e4c97e067704daaf02c7 100644 --- a/app/Views/home/home.php +++ b/app/Views/home/home.php @@ -33,6 +33,8 @@ $totalEvents = $paginationData['total']; $currentPage = $paginationData['page']; $maxPage = $paginationData['maxpage']; + + $isAdmin = $userController->getUser($_SESSION['user_id'])['isAdmin']; ?> <!DOCTYPE html> @@ -50,6 +52,7 @@ <link rel="stylesheet" type="text/css" href="/../../styles/auth.css"> <link rel="stylesheet" type="text/css" href="/../../styles/dropdown.css"> <link rel="stylesheet" type="text/css" href="/../../styles/pagination.css"> + <link rel="stylesheet" type="text/css" href="/../../styles/media.css"> </head> <body> @@ -58,7 +61,9 @@ <div class="main-content"> <div class="column"> - <button onclick="openCreateEventPage()" id="createEventBtn" class="admin">Create Event</button> + <?php if ($isAdmin) : ?> + <button onclick="openCreateEventPage()" id="createEventBtn" class="admin">Create Event</button> + <?php endif; ?> <div class="row"> <input type="text" id="searchInput" placeholder="Search.." value="<?= htmlspecialchars($searchQuery)?>" style="width:250%;"> <select name="sort" id="sortSelect" class="styled-select"> diff --git a/app/Views/pembelian/pembelian.php b/app/Views/pembelian/pembelian.php index 941f09a60f0be28483d7f1aa93b16551649d9f85..2cfe244fcfb52c8143a33b44b56ccc7a6f83d906 100644 --- a/app/Views/pembelian/pembelian.php +++ b/app/Views/pembelian/pembelian.php @@ -10,32 +10,52 @@ <link rel="stylesheet" type="text/css" href="/../../styles/navbar.css"> <link rel="stylesheet" type="text/css" href="/../../styles/container.css"> <link rel="stylesheet" type="text/css" href="/../../styles/auth.css"> + <link rel="stylesheet" type="text/css" href="/../../styles/media.css"> <!-- Include any CSS styles or external libraries here --> </head> <body> <?php include 'Views/template/navbar.php';?> -<div class="main-content"> -<div class="column"> - <h1>Purchase Ticket</h1> - <!-- Display the ticket details --> - <h2>Ticket Details</h2> - <p>Ticket ID: <?php echo $ticket['ticket_id']; ?></p> - <p>Ticket Name: <?php echo $ticket['ticket_name']; ?></p> - <!-- <p>Price: <?php echo $ticket['ticket_price']; ?></p> --> - - <!-- Purchase Form --> - <form id="purchaseForm" method="post" action="/app/router.php?purchaseAction=purchaseTicket"> - <input type="hidden" name="ticketId" value="<?php echo $ticket['ticket_id']; ?>"> - <input type="hidden" name="userId" value="<?php echo $_SESSION['user_id']; ?>"> - - <!-- Additional form fields or options can be added here --> - - <button type="button" id="confirmPurchaseBtn">Confirm Purchase</button> - </form> -</div> -</div> + <div class="main-content"> + <div class="column"> + <h1>Purchase Ticket</h1> + <div class="event-container"> + <h2><?php echo $ticket['event_name']; ?></h2> + <div class="row"> + <img src="<?php echo '../../../'.$ticket['gambar']; ?>" alt="<?php echo $ticket['event_name']; ?>" width="35%"> + <video width="60%" controls> + <source src="<?php echo '../../../'.$ticket['vid']; ?>" type="video/mp4"> + Your browser does not support the video tag. + </video> + </div> + <div class="row"> + <div class="column" width="250"> + <p><strong>Location:</strong> <?php echo $ticket['event_location']; ?></p> + <p><strong>Date/Time:</strong> <?php echo $ticket['event_date']; ?></p> + <p><strong>Ticket Price:</strong> <?php echo $ticket['event_price']; ?></p> + <p><strong>Tickets Left:</strong> <?php echo $ticket['event_stock']; ?></p> + </div> + <!-- Display the ticket details --> + <div class="column"> + <h2>Ticket Details</h2> + <p>Ticket ID: <?php echo $ticket['ticket_id']; ?></p> + <p>Ticket Name: <?php echo $ticket['ticket_name']; ?></p> + + <!-- Purchase Form --> + </div> + <form id="purchaseForm" method="post" action="/app/router.php?purchaseAction=purchaseTicket"> + <input type="hidden" name="ticketId" value="<?php echo $ticket['ticket_id']; ?>"> + <input type="hidden" name="userId" value="<?php echo $_SESSION['user_id']; ?>"> + + <!-- Additional form fields or options can be added here --> + + <button type="button" id="confirmPurchaseBtn">Confirm Purchase</button> + </form> + </div> + </div> + </div> + </div> <!-- JavaScript code for the confirmation dialog --> <script> // Function to show the confirmation dialog diff --git a/app/Views/template/event.php b/app/Views/template/event.php index 72e1355946e3d17009d4cccf384bee3dfeee0fc1..3bbaade6f8863d7fb10af37bfecaa4103064aef8 100644 --- a/app/Views/template/event.php +++ b/app/Views/template/event.php @@ -9,12 +9,16 @@ <p><strong>Tickets Left:</strong> <?php echo $event['event_stock']; ?></p> </div> <form id="viewEventForm" method="post" action="/app/router.php?ticketAction=getTicket"> - <input type="hidden" name="eventId" value="<?php echo $event['event_id']; ?>"> - <button type="submit" id="buyTicket">Buy Ticket</button> + <input type="hidden" name="eventId" value="<?php echo $event['event_id']; ?>"> + <?php if (!$isAdmin) : ?> + <button type="submit" id="buyTicket">Buy Ticket</button> + <?php endif; ?> </form> <form id="viewEventForm" method="get" action="../event/update.php"> - <input type="hidden" name="id" value="<?php echo $event['event_id']; ?>"> - <button type="submit" id="updateEvent">Update Event</button> + <input type="hidden" name="id" value="<?php echo $event['event_id']; ?>"> + <?php if ($isAdmin) : ?> + <button type="submit" id="updateEvent">Update Event</button> + <?php endif; ?> </form> </div> </div> \ No newline at end of file diff --git a/app/Views/template/history.php b/app/Views/template/history.php index 277348fac36a027c8797241815d559fbdea3aa61..dbc33617b8f98ce4e0a32179079bcdd910cc6849 100644 --- a/app/Views/template/history.php +++ b/app/Views/template/history.php @@ -1,16 +1,15 @@ <div class="history-container"> <!-- <h2><?php echo $pembelian['pembelian_id']; ?></h2> --> - <div class="row"><img src="<?php echo '../../../'.$pembelian['gambar']; ?>" alt="<?php echo $event['event_name']; ?>" width="200"> + <div class="row"><img src="<?php echo '../../../'.$pembelian['gambar']; ?>" alt="<?php echo $pembelian['event_name']; ?>" width="30%"> <div class="column"> <p><strong>Location:</strong> <?php echo $pembelian['event_location']; ?></p> <p><strong>Date/Time:</strong> <?php echo $pembelian['event_date']; ?></p> <p><strong>Ticket Price:</strong> <?php echo $pembelian['event_price']; ?></p> - <p><strong>Tickets Left:</strong> <?php echo $pembelian['event_stock']; ?></p> </div> <div class="column"> <p><strong>Ticket ID:</strong> <?php echo $pembelian['ticket_id']; ?></p> <p><strong>User ID:</strong> <?php echo $pembelian['user_id']; ?></p> - <p><strong>Created Time:</strong> <?php echo $pembelian['pembelian_created_time']; ?></p> + <p><strong>Purchase Time:</strong> <?php echo $pembelian['pembelian_created_time']; ?></p> </div> </div> </div> \ No newline at end of file diff --git a/app/Views/template/navbar.php b/app/Views/template/navbar.php index 2c0486badd261d08b13186bdfb22e5ecbc72322b..ec8dd2abb5c9159fc789683ffbc72588471a9771 100644 --- a/app/Views/template/navbar.php +++ b/app/Views/template/navbar.php @@ -2,10 +2,9 @@ <div class="row"> <div class="navbar-toggle" onclick="toggleMenu()">☰</div> <ul> - <li><a href="../home/home.php">Home</a></li> - <li><a href="../home/home.php">Events</a></li> - <li><a href="../profile/view_profile.php">Profile</a></li> - <li><a href="../history/history.php">History</a></li> + <li><a href="/app/Views/home/home.php">Home</a></li> + <li><a href="/app/Views/profile/view_profile.php">Profile</a></li> + <li><a href="/app/Views/history/history.php">History</a></li> <!-- Logout Button --> <li> <form method="post" action="/app/router.php">