101 lines
4.8 KiB
PHP
101 lines
4.8 KiB
PHP
<?php
|
|
use App\Models\Game;
|
|
use App\Models\Tipp;
|
|
use App\Models\Team;
|
|
|
|
// Stellt sicher, dass die benötigten Variablen vorhanden sind
|
|
if (!isset($selectedRound) || !isset($roundsToShow) || !isset($users) || !isset($tipps_map)) {
|
|
echo "Fehler: Daten für die Rundenansicht nicht gefunden.";
|
|
exit;
|
|
}
|
|
|
|
$pageTitle = 'Tippübersicht - ' . htmlspecialchars($selectedRound['name']);
|
|
require __DIR__ . '/partials/header.php';
|
|
|
|
$teamLogo = function ($name) {
|
|
static $cache = [];
|
|
if (array_key_exists($name, $cache)) {
|
|
return $cache[$name];
|
|
}
|
|
$team = Team::resolve($name);
|
|
$cache[$name] = ($team && Team::logoExists($team)) ? Team::logoUrl($team) : null;
|
|
return $cache[$name];
|
|
};
|
|
?>
|
|
|
|
<h1>Tippübersicht bis: <?php echo htmlspecialchars($selectedRound['name']); ?></h1>
|
|
|
|
<?php if (empty($users)): ?>
|
|
<p>Keine teilnehmenden Spieler für diese Saison gefunden.</p>
|
|
<?php else: ?>
|
|
<?php foreach ($roundsToShow as $round): ?>
|
|
<h2><?php echo htmlspecialchars($round['name']); ?></h2>
|
|
<?php if (!empty($round['games'])): ?>
|
|
<div class="table-container">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Spieler</th>
|
|
<?php foreach ($round['games'] as $game): ?>
|
|
<th class="game-header">
|
|
<?php $l1 = $teamLogo($game['team1']); if ($l1): ?><img src="<?php echo htmlspecialchars($l1); ?>" alt="" class="team-logo"><?php endif; ?>
|
|
<?php echo htmlspecialchars($game['team1']); ?><br>
|
|
<?php $l2 = $teamLogo($game['team2']); if ($l2): ?><img src="<?php echo htmlspecialchars($l2); ?>" alt="" class="team-logo"><?php endif; ?>
|
|
<?php echo htmlspecialchars($game['team2']); ?><br>
|
|
<small>(<?php echo Game::getResultString($game['score1'], $game['score2'], $game['kickoff']); ?>)</small>
|
|
</th>
|
|
<?php endforeach; ?>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($users as $user): ?>
|
|
<tr>
|
|
<td><?php echo htmlspecialchars($user['name']); ?></td>
|
|
<?php foreach ($round['games'] as $game): ?>
|
|
<?php
|
|
$tipp = $tipps_map[$user['id']][$game['id']] ?? null;
|
|
$color = '';
|
|
$text = '-';
|
|
$is_joker = false;
|
|
|
|
if ($tipp && $game['score1'] > -1) {
|
|
$color = Tipp::getCol($game['score1'], $game['score2'], $tipp['tipp1'], $tipp['tipp2'], $tipp['joker']);
|
|
}
|
|
if ($tipp) {
|
|
// Zeige Tipps nur für gesperrte Spiele
|
|
if (Game::isLocked($game['kickoff'])) {
|
|
$text = $tipp['tipp1'] . ':' . $tipp['tipp2'];
|
|
} else {
|
|
$text = 'verdeckt';
|
|
}
|
|
$is_joker = (bool)$tipp['joker'];
|
|
}
|
|
?>
|
|
<?php
|
|
$td_class = $color;
|
|
// Spezielle Farbe für exakten Tipp mit Joker
|
|
if ($td_class === 'col_exact' && $is_joker) {
|
|
$td_class = 'col_joker_exact';
|
|
}
|
|
?>
|
|
<td class="tipp-cell <?php echo htmlspecialchars($td_class); ?>" title="Tipp: <?php echo htmlspecialchars($text); ?>">
|
|
<?php echo htmlspecialchars($text); ?>
|
|
<?php if ($is_joker && Game::isLocked($game['kickoff'])): ?>
|
|
<img src="/img/joker.png" alt="Joker" class="joker-icon" title="Joker">
|
|
<?php endif; ?>
|
|
</td>
|
|
<?php endforeach; ?>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<?php else: ?>
|
|
<p>Für diese Runde wurden keine Spiele gefunden.</p>
|
|
<?php endif; ?>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
|
|
<p><a href="/">Zurück zur Startseite</a></p>
|
|
|
|
<?php require __DIR__ . '/partials/footer.php'; ?>
|