77 lines
3.3 KiB
PHTML
77 lines
3.3 KiB
PHTML
<?php if (!empty($events)): ?>
|
|
<div class="inhalt">
|
|
<div class="content-container">
|
|
<div class="event-header">
|
|
<h2>Alle Ausstellungen</h2>
|
|
<?php if (isset($_SESSION['is_admin']) && $_SESSION['is_admin']): ?>
|
|
<a href="?controller=Event&do=showCreateEvent" class="admin-btn">Event erstellen</a>
|
|
<?php endif; ?>
|
|
</div>
|
|
<div class="event-container-inhalt">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>Beschreibung</th>
|
|
<th>Von</th>
|
|
<th>Bis</th>
|
|
<th>Preis</th>
|
|
<th>Tickets</th>
|
|
<?php if (isset($_SESSION['user_id'])): ?>
|
|
<th>Aktionen</th>
|
|
<?php endif; ?>
|
|
<?php if (isset($_SESSION['is_admin']) && $_SESSION['is_admin']): ?>
|
|
<th>Admin</th>
|
|
<?php endif; ?>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($events as $event): ?>
|
|
<tr class="event-row" data-event-id="<?php echo $event['event_id']; ?>" style="cursor: pointer;">
|
|
<td><?php echo htmlspecialchars($event['name']); ?></td>
|
|
<td><?php echo nl2br(htmlspecialchars($event['description'])); ?></td>
|
|
<td><?php echo date('d.m.Y', strtotime($event['start_date'])); ?></td>
|
|
<td><?php echo date('d.m.Y', strtotime($event['end_date'])); ?></td>
|
|
<td><?php echo number_format($event['ticket_price'], 2, ',', '.'); ?> €</td>
|
|
<td><?php echo (int) $event['max_tickets']; ?></td>
|
|
<?php if (isset($_SESSION['user_id'])): ?>
|
|
<td>
|
|
<a href="?controller=Ticket&do=showBuyTicketForm&event_id=<?php echo $event['event_id']; ?>" class="admin-btn">Ticket kaufen</a>
|
|
</td>
|
|
<?php endif; ?>
|
|
<?php if (isset($_SESSION['is_admin']) && $_SESSION['is_admin']): ?>
|
|
<td>
|
|
<a href="?controller=Event&do=showUpdateEvent&event_id=<?php echo $event['event_id']; ?>" class="admin-btn">Bearbeiten</a>
|
|
<a href="?controller=Event&do=deleteEvent&event_id=<?php echo $event['event_id']; ?>" class="admin-btn" onclick="return confirm('Wirklich löschen?');">Löschen</a>
|
|
</td>
|
|
<?php endif; ?>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const eventRows = document.querySelectorAll('.event-row');
|
|
|
|
eventRows.forEach(function(row) {
|
|
row.addEventListener('dblclick', function(e) {
|
|
// Don't trigger if clicking on a link or button
|
|
if (e.target.tagName === 'A' || e.target.tagName === 'BUTTON') {
|
|
return;
|
|
}
|
|
|
|
const eventId = this.getAttribute('data-event-id');
|
|
if (eventId) {
|
|
window.location.href = 'index.php?controller=Ticket&do=showBuyTicketForm&event_id=' + eventId;
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
<?php else: ?>
|
|
<p>Derzeit sind keine Ausstellungen verfügbar.</p>
|
|
<?php endif; ?>
|