tippspiel2027/src/Views/round.php

89 lines
4.1 KiB
PHP
Raw Normal View History

<?php
use App\Models\Game;
use App\Models\Tipp;
// 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';
?>
<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 echo htmlspecialchars($game['team1']); ?><br>
<?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'])): ?>
<i class="fa-solid fa-j joker-icon" title="Joker"></i>
<?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'; ?>