Erster Durchstich mit updates

This commit is contained in:
torsten 2026-10-17 17:21:33 +02:00
parent d3fd60b548
commit 3331f08091
60 changed files with 693 additions and 195 deletions

View file

@ -0,0 +1,188 @@
<?php
$pageTitle = 'Rangliste';
if ($selectedRound) {
$pageTitle .= ' - ' . htmlspecialchars($selectedRound['name']);
}
require __DIR__ . '/partials/header.php';
// Stellt sicher, dass die benötigten Variablen vorhanden sind
if (!isset($currentSeason) || !isset($ranking) || !isset($games) || !isset($allRounds) || !isset($selectedRound)) {
echo "Fehler: Daten für die Rangliste nicht gefunden.";
// exit; // Besser, eine freundliche Nachricht im Layout anzuzeigen
}
?>
<style>
.game-header {
width: 100px; /* Feste Breite für die Spiele-Spalten */
}
.tipp-points {
width: 55px; /* Breite für den Tipp (z.B. 2:1) */
box-sizing: border-box;
text-align: center;
}
.tipp-joker {
width: 70px; /* Breite für vergrößerten Joker */
box-sizing: border-box;
padding-left: 5px;
text-align: center;
}
.joker-icon {
width: 2rem; /* Größe weiter auf 75% reduziert */
height: 2rem; /* Größe weiter auf 75% reduziert */
vertical-align: middle;
}
.daily-winner-icon {
font-size: 2rem; /* Größe verdoppeln */
vertical-align: middle;
}
#round_id {
font-size: inherit; /* Schriftgröße an die Umgebung anpassen */
}
table th, table td {
padding-top: 0.1rem;
padding-bottom: 0.1rem;
}
/* Kompakter Kopfbereich: Titel, Saison und Rundenwahl auf einer Zeile */
.ranking-toolbar {
display: flex;
flex-wrap: wrap;
align-items: baseline;
gap: 0.3em 0.9em;
margin-bottom: 0.8em;
}
.ranking-toolbar h1 {
margin: 0;
padding: 0;
border-bottom: none;
font-size: 1.3em;
}
.ranking-toolbar .season {
font-family: var(--font-display);
font-weight: 700;
color: var(--pitch-dark);
}
.ranking-toolbar .round-filter {
margin: 0 0 0 auto;
}
.ranking-toolbar .round-filter label {
margin-right: 0.3em;
}
/* Legende als kompakte Fußzeile unter der Tabelle */
.legend.legend-footer {
margin: 10px 0 0;
padding: 6px 10px;
font-size: 0.8em;
gap: 6px 12px;
justify-content: center;
}
.legend.legend-footer .legend-color { width: 12px; height: 12px; }
.legend.legend-footer .joker-icon { width: 1.1em; height: 1.1em; }
.legend.legend-footer .daily-winner-icon { font-size: 1em; }
@media (max-width: 700px) {
.ranking-toolbar h1 { font-size: 1.1em; }
.ranking-toolbar .round-filter { margin-left: 0; }
}
</style>
<div class="ranking-toolbar">
<h1>Rangliste</h1>
<span class="season"><?php echo htmlspecialchars($currentSeason['name']); ?></span>
<?php if ($selectedRound): ?>
<form method="get" class="round-filter">
<input type="hidden" name="page" value="ranking">
<label for="round_id">Runde:</label>
<select name="round_id" id="round_id" onchange="this.form.submit()">
<?php foreach ($allRounds as $round): ?>
<option value="<?php echo $round['id']; ?>" <?php echo ($round['id'] == $selectedRound['id']) ? 'selected' : ''; ?>>
<?php echo htmlspecialchars($round['name']); ?>
</option>
<?php endforeach; ?>
</select>
</form>
<?php endif; ?>
</div>
<?php if ($selectedRound): ?>
<div class="table-container sticky-header">
<?php if (!empty($ranking)): ?>
<table>
<thead>
<tr>
<th class="text-center">Platz</th>
<th>Name</th>
<th class="text-center"><span class="daily-winner-icon">🏆</span></th>
<th class="text-center">Punkte (Gesamt)</th>
<th class="text-center">Punkte (Runde)</th>
<?php foreach ($games as $game): ?>
<th class="game-header" colspan="2">
<?php echo htmlspecialchars($game['team1']); ?><br>
<?php echo htmlspecialchars($game['team2']); ?><br>
<small>(<?php echo htmlspecialchars(App\Models\Game::getResultString($game['score1'], $game['score2'], $game['kickoff'])); ?>)</small>
</th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php foreach ($ranking as $entry):
$rowClasses = [];
if ($entry['rank'] <= 3) $rowClasses[] = 'rank-' . $entry['rank'];
if ((int)$entry['user_id'] === (int)App\Core\Auth::id()) $rowClasses[] = 'me';
?>
<tr<?php if ($rowClasses) echo ' class="' . implode(' ', $rowClasses) . '"'; ?>
<?php if ((int)$entry['user_id'] === (int)App\Core\Auth::id()) echo ' id="me-row"'; ?>>
<td class="text-center"><span class="rank-badge"><?php echo $entry['rank']; ?>.</span></td>
<td><?php echo htmlspecialchars($entry['name']); ?></td>
<td class="text-center"><?php echo $entry['is_day_winner'] ? '<span class="daily-winner-icon">🏆</span>' : ''; ?></td>
<td class="text-center"><strong><?php echo $entry['total']; ?></strong></td>
<td class="text-center"><?php echo $entry['points']; ?></td>
<?php foreach ($games as $game): ?>
<?php
$tipp = $entry['cells'][$game['id']];
// Farbklasse kommt fertig aus Tipp::getCol (col_tendenz / col_exact / col_joker_exact)
$td_class = $tipp['color'];
$title = "Punkte: " . $tipp['points'];
?>
<td class="tipp-cell tipp-points <?php echo htmlspecialchars($td_class); ?>" title="<?php echo $title; ?>">
<?php echo htmlspecialchars($tipp['text']); ?>
</td>
<td class="tipp-cell tipp-joker" title="<?php echo $title; ?>">
<?php if ($tipp['joker']): ?>
<img src="/img/joker.png" alt="Joker" class="joker-icon" title="Joker">
<?php endif; ?>
</td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<p>Für diese Saison gibt es noch keine Rangliste (möglicherweise haben noch keine Spieler bezahlt).</p>
<?php endif; ?>
</div>
<div class="legend legend-footer">
<div class="legend-item"><span class="daily-winner-icon">🏆</span> Tagessieger</div>
<div class="legend-item"><img src="/img/joker.png" alt="Joker" class="joker-icon"> Joker gesetzt</div>
<div class="legend-item"><div class="legend-color" style="background-color: var(--col-tendenz);"></div> Richtige Tendenz</div>
<div class="legend-item"><div class="legend-color" style="background-color: var(--col-exact);"></div> Richtiges Ergebnis</div>
<div class="legend-item"><div class="legend-color" style="background-color: var(--col-joker-exact);"></div> Richtiges Ergebnis mit Joker</div>
</div>
<?php else: ?>
<p>Keine Runde für die Anzeige ausgewählt oder gefunden.</p>
<?php endif; ?>
<script>
// Springe beim Laden zur eigenen Zeile, falls der eingeloggte Spieler in der Tabelle ist
window.addEventListener('load', function () {
var me = document.getElementById('me-row');
if (me) {
me.scrollIntoView({ block: 'center' });
}
});
</script>
<?php require __DIR__ . '/partials/footer.php'; ?>