feat: Saisons-Verwaltung im Admin-Bereich implementieren und Menü anpassen

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
torsten 2026-10-04 17:55:58 +02:00
parent 374b8fed6e
commit 55e03541ff
4 changed files with 245 additions and 1 deletions

View file

@ -8,7 +8,7 @@ require __DIR__ . '/partials/header.php';
<div class="admin-menu">
<ul>
<li><a href="/index.php?page=admin_users">Benutzer verwalten</a></li>
<li><a href="#">Saisons & Runden verwalten</a></li>
<li><a href="/index.php?page=admin_seasons">Saisons verwalten</a></li>
<li><a href="#">Spiele & Ergebnisse eintragen</a></li>
<li><a href="#">Zahlungen verwalten</a></li>
<li><a href="#">Systemeinstellungen</a></li>

101
src/Views/admin/seasons.php Normal file
View file

@ -0,0 +1,101 @@
<?php
$pageTitle = 'Saisons verwalten';
require __DIR__ . '/../partials/header.php';
?>
<h1>Saisons verwalten</h1>
<?php if (!empty($message)): ?>
<p style="color: green;"><?php echo htmlspecialchars($message); ?></p>
<?php endif; ?>
<?php if (!empty($error)): ?>
<p style="color: red;"><?php echo htmlspecialchars($error); ?></p>
<?php endif; ?>
<!-- Form for creating/editing a season -->
<h2><?php echo $editSeason ? 'Saison bearbeiten' : 'Neue Saison anlegen'; ?></h2>
<form action="/index.php?page=admin_seasons" method="post">
<?php if ($editSeason): ?>
<input type="hidden" name="action" value="update">
<input type="hidden" name="id" value="<?php echo htmlspecialchars($editSeason['id']); ?>">
<?php else: ?>
<input type="hidden" name="action" value="create">
<?php endif; ?>
<div class="form-group">
<label for="name">Name:</label>
<input type="text" id="name" name="name" value="<?php echo htmlspecialchars($editSeason['name'] ?? ''); ?>" required>
</div>
<div class="form-group">
<label for="rounds">Runden:</label>
<input type="number" id="rounds" name="rounds" value="<?php echo htmlspecialchars($editSeason['rounds'] ?? '34'); ?>" required>
</div>
<div class="form-group">
<button type="submit"><?php echo $editSeason ? 'Speichern' : 'Anlegen'; ?></button>
<?php if ($editSeason): ?>
<a href="/index.php?page=admin_seasons">Abbrechen</a>
<?php endif; ?>
</div>
</form>
<hr>
<!-- Season List -->
<h2>Saison-Liste</h2>
<table>
<thead>
<tr>
<th>Name</th>
<th>Runden</th>
<th>Aktiv</th>
<th>Aktionen</th>
</tr>
</thead>
<tbody>
<?php foreach ($seasons as $season): ?>
<tr <?php if ($currentSeason['id'] === $season['id']) echo 'style="font-weight: bold;"'; ?>>
<td><?php echo htmlspecialchars($season['name']); ?></td>
<td><?php echo htmlspecialchars($season['rounds']); ?></td>
<td><?php echo $currentSeason['id'] === $season['id'] ? 'Ja' : 'Nein'; ?></td>
<td>
<a href="/index.php?page=admin_seasons&edit_id=<?php echo $season['id']; ?>">Bearbeiten</a>
<?php if ($currentSeason['id'] !== $season['id']): ?>
<form action="/index.php?page=admin_seasons" method="post" style="display: inline;">
<input type="hidden" name="action" value="set_current">
<input type="hidden" name="id" value="<?php echo $season['id']; ?>">
<button type="submit" class="link-button">Als aktiv setzen</button>
</form>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<style>
/* From users.php, for consistency */
.form-group {
margin-bottom: 1rem;
}
.form-group label {
display: inline-block;
width: 150px;
text-align: right;
margin-right: 10px;
}
.form-group button, .form-group a {
margin-left: calc(150px + 10px);
}
.link-button {
background: none;
border: none;
color: #007bff;
cursor: pointer;
padding: 0;
font-size: inherit;
text-decoration: underline;
font-family: inherit;
}
</style>
<?php require __DIR__ . '/../partials/footer.php'; ?>