Skip to content
Snippets Groups Projects
Commit 40306e9a authored by Bitha17's avatar Bitha17
Browse files

feat: add delete event button

parent cea43655
No related merge requests found
...@@ -145,6 +145,23 @@ ...@@ -145,6 +145,23 @@
// Trigger the debounceSearch function when the sorting option changes // Trigger the debounceSearch function when the sorting option changes
debounceSearch(); debounceSearch();
}); });
// Function to show delete confirmation dialog
function showConfirmationDialog(eventId) {
if (confirm("Are you sure you want to delete this event?")) {
// If the user confirms, submit the corresponding form
document.getElementById("deleteEventForm" + eventId).submit();
}
}
// Attach the confirmation dialog to all buttons with the class "confirmDeleteBtn"
const deleteButtons = document.querySelectorAll(".confirmDeleteBtn");
deleteButtons.forEach(button => {
button.addEventListener("click", function() {
const eventId = this.getAttribute("data-eventid");
showConfirmationDialog(eventId);
});
});
</script> </script>
</body> </body>
......
...@@ -8,17 +8,24 @@ ...@@ -8,17 +8,24 @@
<p><strong>Ticket Price:</strong> <?php echo $event['event_price']; ?></p> <p><strong>Ticket Price:</strong> <?php echo $event['event_price']; ?></p>
<p><strong>Tickets Left:</strong> <?php echo $event['event_stock']; ?></p> <p><strong>Tickets Left:</strong> <?php echo $event['event_stock']; ?></p>
</div> </div>
<form id="viewEventForm" method="post" action="/app/router.php?ticketAction=getTicket"> <form id="viewEventForm" method="get" action="/app/router.php">
<input type="hidden" name="eventId" value="<?php echo $event['event_id']; ?>"> <input type="hidden" name="eventId" value="<?php echo $event['event_id']; ?>">
<?php if (!$isAdmin) : ?> <?php if (!$isAdmin) : ?>
<button type="submit" id="buyTicket">Buy Ticket</button> <button type="submit" name="ticketAction" value="getTicket">Buy Ticket</button>
<?php endif; ?> <?php endif; ?>
</form> </form>
<form id="viewEventForm" method="get" action="../event/update.php"> <?php if ($isAdmin) : ?>
<input type="hidden" name="id" value="<?php echo $event['event_id']; ?>"> <div class="colummn">
<?php if ($isAdmin) : ?> <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> <button type="submit" id="updateEvent">Update Event</button>
<?php endif; ?> </form>
</form> <form id="deleteEventForm<?php echo $event['event_id']; ?>" method="post" action="/app/router.php">
<input type="hidden" name="eventId" value="<?php echo $event['event_id']; ?>">
<input type="hidden" name="eventAction" value="deleteEvent">
<button type="button" class="confirmDeleteBtn" data-eventid="<?php echo $event['event_id']; ?>">Delete Event</button>
</form>
</div>
<?php endif; ?>
</div> </div>
</div> </div>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment