tippspiel2027/src/Views/ranking.php

98 lines
5 KiB
PHP
Raw Normal View History

<?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
}
?>
<h1>Rangliste</h1>
<h2>Saison: <?php echo htmlspecialchars($currentSeason['name']); ?></h2>
<?php if ($selectedRound): ?>
<div class="round-filter">
<form method="get">
<input type="hidden" name="page" value="ranking">
<label for="round_id">Runde auswählen:</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>
</div>
<div class="legend">
<div class="legend-item">🏆 Tagessieger</div>
<div class="legend-item"><span class="joker-icon"></span> Joker gesetzt</div>
<div class="legend-item"><div class="legend-color" style="background-color: orange;"></div> Exaktes Ergebnis</div>
<div class="legend-item"><div class="legend-color" style="background-color: red;"></div> Exakt mit Joker</div>
<div class="legend-item"><div class="legend-color" style="background-color: gold;"></div> Richtige Differenz</div>
<div class="legend-item"><div class="legend-color" style="background-color: grey;"></div> Richtige Tendenz</div>
</div>
<div class="table-container">
<?php if (!empty($ranking)): ?>
<table>
<thead>
<tr>
<th class="text-center">Platz</th>
<th>Name</th>
<th class="text-center">🏆</th>
<th class="text-center">Punkte (Gesamt)</th>
<th class="text-center">Punkte (Runde)</th>
<?php foreach ($games as $game): ?>
<th class="game-header">
<?php echo htmlspecialchars($game['team1']); ?><br>
<?php echo htmlspecialchars($game['team2']); ?><br>
<small>(<?php echo App\Models\Game::getResultString($game['score1'], $game['score2'], $game['kickoff']); ?>)</small>
</th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php foreach ($ranking as $entry): ?>
<tr>
<td class="text-center"><?php echo $entry['rank']; ?>.</td>
<td><?php echo htmlspecialchars($entry['name']); ?></td>
<td class="text-center"><?php echo in_array($entry['id'], $dailyWinners) ? '🏆' : ''; ?></td>
<td class="text-center"><strong><?php echo $entry['score']; ?></strong></td>
<td class="text-center"><?php echo $entry['round_score']; ?></td>
<?php foreach ($games as $game): ?>
<?php
$tipp = $entry['tipps'][$game['id']];
$td_class = $tipp['color'];
// Spezielle Farbe für exakten Tipp mit Joker
if ($td_class === 'col_exact' && $tipp['is_joker']) {
$td_class = 'col_joker_exact';
}
?>
<td class="tipp-cell <?php echo htmlspecialchars($td_class); ?>" title="Tipp: <?php echo htmlspecialchars($tipp['text']); ?> | Punkte: <?php echo $tipp['points']; ?>">
<?php echo $tipp['points']; ?>
<?php if ($tipp['is_joker']): ?>
<span class="joker-icon" title="Joker"></span>
<?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>
<?php else: ?>
<p>Keine Runde für die Anzeige ausgewählt oder gefunden.</p>
<?php endif; ?>
<?php require __DIR__ . '/partials/footer.php'; ?>