Gutscheinverwaltung für Admins fertig gemacht:

Übersicht, Erstellen & Bearbeiten im einheitlichen Card-Design
Routing-Fehler nach Aktionen gefixt (Redirects & Erfolgsseiten) Gutscheine-Link in Navigation nur für Admins
This commit is contained in:
Karsten Tlotzek
2025-07-11 18:06:27 +02:00
parent 6cb75b0c1d
commit b89714a6e7
9 changed files with 118 additions and 28 deletions

View File

@@ -0,0 +1,19 @@
<div class="inhalt">
<div class="form-container">
<h1>Neuen Gutschein anlegen</h1>
<form class="form-horizontal" action="index.php" method="post">
<input type="hidden" name="controller" value="Gutschein">
<input type="hidden" name="do" value="createGutschein">
<label for="code">Code</label>
<input type="text" id="code" name="code" required>
<label for="discount">Rabatt (%)</label>
<input type="number" id="discount" name="discount" min="0" max="100" required>
<label for="event_id">Event-ID</label>
<input type="number" id="event_id" name="event_id" required>
<label for="valid_until">Gültig bis</label>
<input type="date" id="valid_until" name="valid_until" required>
<button class="admin-btn" type="submit">Erstellen</button>
</form>
<a href="?controller=Gutschein&do=adminVerwaltung" class="admin-btn" style="background:#888;">Abbrechen</a>
</div>
</div>

View File

@@ -0,0 +1,20 @@
<div class="inhalt">
<div class="form-container">
<h1>Gutschein bearbeiten</h1>
<form class="form-horizontal" action="index.php" method="post">
<input type="hidden" name="controller" value="Gutschein">
<input type="hidden" name="do" value="updateGutschein">
<input type="hidden" name="gutscheinid" value="<?=htmlspecialchars($gutschein['voucher_id'])?>">
<label for="code">Code</label>
<input type="text" id="code" name="code" required value="<?=htmlspecialchars($gutschein['code'])?>">
<label for="discount">Rabatt (%)</label>
<input type="number" id="discount" name="discount" min="0" max="100" required value="<?=htmlspecialchars($gutschein['discount'])?>">
<label for="event_id">Event-ID</label>
<input type="number" id="event_id" name="event_id" required value="<?=htmlspecialchars($gutschein['event_id'])?>">
<label for="valid_until">Gültig bis</label>
<input type="date" id="valid_until" name="valid_until" required value="<?=htmlspecialchars($gutschein['valid_until'])?>">
<button class="admin-btn" type="submit">Speichern</button>
</form>
<a href="?controller=Gutschein&do=adminVerwaltung" class="admin-btn" style="background:#888;">Abbrechen</a>
</div>
</div>

View File

@@ -0,0 +1,14 @@
<div class="inhalt">
<div class="status-box">
<h2>Gutschein erfolgreich erstellt!</h2>
<p>Du wirst in wenigen Sekunden zur Übersicht weitergeleitet...</p>
</div>
</div>
<script>
setTimeout(function() {
window.location.href = "?controller=Gutschein&do=adminVerwaltung";
}, 2000);
</script>
<noscript>
<meta http-equiv="refresh" content="2;url=?controller=Gutschein&do=adminVerwaltung">
</noscript>

View File

@@ -1,10 +1,10 @@
<?php include dirname(__DIR__) . '/header.phtml'; ?>
<div class="inhalt">
<h2>Alle Gutscheine</h2>
<a href="?controller=Gutschein&do=createGutscheinForm">Neuen Gutschein anlegen</a>
<div class="inhalt" style="flex-direction:column;align-items:center;">
<div class="gutschein-header-block">
<h2>Alle Gutscheine</h2>
<a href="?controller=Gutschein&do=createGutscheinForm" class="admin-btn">Neuen Gutschein anlegen</a>
</div>
<?php if (!empty($gutscheine)): ?>
<table border="1" cellpadding="8" cellspacing="0">
<table class="gutschein-table">
<thead>
<tr>
<th>Code</th>
@@ -22,8 +22,8 @@
<td><?php echo (int)$g['event_id']; ?></td>
<td><?php echo htmlspecialchars($g['valid_until']); ?></td>
<td>
<a href="?controller=Gutschein&action=editGutscheinForm&id=<?php echo $g['gutscheinid']; ?>">Bearbeiten</a> |
<a href="?controller=Gutschein&action=deleteGutschein&id=<?php echo $g['gutscheinid']; ?>" onclick="return confirm('Wirklich löschen?');">Löschen</a>
<a href="?controller=Gutschein&do=editGutscheinForm&gutscheinid=<?php echo $g['voucher_id']; ?>" class="admin-btn">Bearbeiten</a>
<a href="?controller=Gutschein&do=deleteGutschein&gutscheinid=<?php echo $g['voucher_id']; ?>" class="admin-btn" onclick="return confirm('Wirklich löschen?');">Löschen</a>
</td>
</tr>
<?php endforeach; ?>
@@ -32,5 +32,4 @@
<?php else: ?>
<p>Keine Gutscheine vorhanden.</p>
<?php endif; ?>
</div>
<?php include dirname(__DIR__) . '/footer.phtml'; ?>
</div>