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:
parent
6cb75b0c1d
commit
b89714a6e7
@ -540,3 +540,16 @@ td a:hover {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
.gutschein-header-block {
|
||||
width: 100%;
|
||||
max-width: 1100px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
.gutschein-table {
|
||||
max-width: 1100px;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
}
|
@ -105,8 +105,7 @@ class AuthController
|
||||
exit;
|
||||
}
|
||||
|
||||
public function changePassword()
|
||||
{
|
||||
public function changePassword() {
|
||||
$email = $_POST['email'] ?? '';
|
||||
$oldpw = $_POST['old_password'] ?? '';
|
||||
$newpw = $_POST['password'] ?? '';
|
||||
|
@ -19,16 +19,27 @@ class GutscheinController {
|
||||
$this->view->setVars(['gutscheine' => $gutscheine]);
|
||||
}
|
||||
|
||||
public function createGutscheinForm() {
|
||||
if (!isset($_SESSION['is_admin']) || !$_SESSION['is_admin']) {
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
$this->view->setDoMethodName('createGutscheinForm');
|
||||
}
|
||||
|
||||
public function createGutschein() {
|
||||
if (!isset($_SESSION['is_admin']) || !$_SESSION['is_admin']) {
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
$data = [
|
||||
'code' => $_POST['code'] ?? null,
|
||||
'rabatt' => $_POST['rabatt'] ?? null,
|
||||
'eventid' => $_POST['eventid'] ?? null,
|
||||
'gültigkeit' => $_POST['gültigkeit'] ?? null
|
||||
'discount' => $_POST['discount'] ?? null,
|
||||
'event_id' => $_POST['event_id'] ?? null,
|
||||
'valid_until' => $_POST['valid_until'] ?? null
|
||||
];
|
||||
$erg = $this->model->createGutschein($data);
|
||||
$this->view->setVars(['gutschein' => $erg]);
|
||||
exit;
|
||||
$this->model->createGutschein($data);
|
||||
$this->view->setDoMethodName('showCreateSuccess');
|
||||
}
|
||||
|
||||
public function editGutscheinForm() {
|
||||
@ -40,18 +51,32 @@ class GutscheinController {
|
||||
}
|
||||
|
||||
public function updateGutschein() {
|
||||
$id = $_POST['gutscheinid'];
|
||||
$data = [
|
||||
'code' => $_POST['code'] ?? null,
|
||||
'rabatt' => $_POST['rabatt'] ?? null,
|
||||
'eventid' => $_POST['eventid'] ?? null,
|
||||
'gültigkeit' => $_POST['gültigkeit'] ?? null
|
||||
];
|
||||
$this->model->updateGutschein($id, $data);
|
||||
$id = $_POST['gutscheinid'];
|
||||
$data = [
|
||||
'code' => $_POST['code'] ?? null,
|
||||
'discount' => $_POST['discount'] ?? null,
|
||||
'event_id' => $_POST['event_id'] ?? null,
|
||||
'valid_until' => $_POST['valid_until'] ?? null
|
||||
];
|
||||
$this->model->updateGutschein($id, $data);
|
||||
header('Location: index.php?controller=Gutschein&do=adminVerwaltung');
|
||||
exit;
|
||||
}
|
||||
|
||||
public function deleteGutschein() {
|
||||
$id = $_GET['gutscheinid'] ?? null;
|
||||
$this->model->deleteGutschein($id);
|
||||
header('Location: index.php?controller=Gutschein&do=adminVerwaltung');
|
||||
exit;
|
||||
}
|
||||
|
||||
public function adminVerwaltung() {
|
||||
if (!isset($_SESSION['is_admin']) || !$_SESSION['is_admin']) {
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
$gutscheine = $this->model->getGutscheine();
|
||||
$this->view->setVars(['gutscheine' => $gutscheine]);
|
||||
$this->view->setDoMethodName('showGutscheine');
|
||||
}
|
||||
}
|
@ -47,7 +47,6 @@ class NewsController {
|
||||
header('Location: index.php?controller=News&do=showNews');
|
||||
exit;
|
||||
}
|
||||
// Leere Felder für das Formular
|
||||
$this->view->setVars([
|
||||
'errors' => [],
|
||||
'validData' => []
|
||||
@ -116,7 +115,6 @@ class NewsController {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Fehlerfall: zurück zur Übersicht
|
||||
header('Location: index.php?controller=News&do=showNews');
|
||||
exit;
|
||||
}
|
||||
|
19
Views/Gutschein/createGutscheinForm.phtml
Normal file
19
Views/Gutschein/createGutscheinForm.phtml
Normal 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>
|
20
Views/Gutschein/editGutscheinForm.phtml
Normal file
20
Views/Gutschein/editGutscheinForm.phtml
Normal 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>
|
14
Views/Gutschein/showCreateSuccess.phtml
Normal file
14
Views/Gutschein/showCreateSuccess.phtml
Normal 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>
|
@ -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; ?>
|
||||
@ -33,4 +33,3 @@
|
||||
<p>Keine Gutscheine vorhanden.</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php include dirname(__DIR__) . '/footer.phtml'; ?>
|
@ -16,6 +16,9 @@
|
||||
<a id="link-tickets" class="links" href="?controller=Event&do=showEvents">Event</a>
|
||||
<a id="link-infos" class="links" href="?controller=News&do=showNews">Infos</a>
|
||||
<a id="link-profil" class="links" href="?controller=Profile&do=showProfile">Profil</a>
|
||||
<?php if (isset($_SESSION['is_admin']) && $_SESSION['is_admin']): ?>
|
||||
<a id="link-gutscheinverwaltung" class="links" href="?controller=Gutschein&do=adminVerwaltung">Gutscheine</a>
|
||||
<?php endif; ?>
|
||||
<a id="link-logout" class="links" href="?controller=Auth&do=logout">Logout</a>
|
||||
<?php else: ?>
|
||||
<a id="link-login" class="links" href="?controller=Auth&do=showLoginForm">Login</a>
|
||||
|
Loading…
x
Reference in New Issue
Block a user