diff --git a/public/index.php b/public/index.php index de18632..3e67e05 100644 --- a/public/index.php +++ b/public/index.php @@ -28,10 +28,40 @@ if (($_GET['page'] ?? null) === 'round' && isset($_GET['id'])) { $allRoundsInSeason = Round::getBySeason($selectedRound['season_id']); $roundsToShow = []; + $all_game_ids = []; foreach ($allRoundsInSeason as $round) { if ($round['id'] <= $selectedRound['id']) { - $round['games'] = Game::getGamesByRound($round['id']); + $gamesOfRound = Game::getGamesByRound($round['id']); + $round['games'] = $gamesOfRound; $roundsToShow[] = $round; + if (!empty($gamesOfRound)) { + $all_game_ids = array_merge($all_game_ids, array_column($gamesOfRound, 'id')); + } + } + } + + // Hole alle zahlenden User der Saison + $db = Database::getConnection(); + $stmt_users = $db->prepare("SELECT u.id, u.name FROM users u JOIN payments p ON u.id = p.user_id WHERE p.season_id = ? ORDER BY u.name ASC"); + $stmt_users->execute([$selectedRound['season_id']]); + $users = $stmt_users->fetchAll(\PDO::FETCH_ASSOC); + + // Hole alle relevanten Tipps + $tipps_map = []; + if (!empty($all_game_ids) && !empty($users)) { + $user_ids = array_column($users, 'id'); + $game_placeholders = implode(',', array_fill(0, count($all_game_ids), '?')); + $user_placeholders = implode(',', array_fill(0, count($user_ids), '?')); + + $stmt_tipps = $db->prepare(" + SELECT user_id, game_id, score1 AS tipp1, score2 AS tipp2, joker + FROM tipps + WHERE game_id IN ($game_placeholders) AND user_id IN ($user_placeholders) + "); + $stmt_tipps->execute(array_merge($all_game_ids, $user_ids)); + + foreach ($stmt_tipps->fetchAll(\PDO::FETCH_ASSOC) as $tipp) { + $tipps_map[$tipp['user_id']][$tipp['game_id']] = $tipp; } } diff --git a/src/Views/round.php b/src/Views/round.php index 73f576f..9c6c927 100644 --- a/src/Views/round.php +++ b/src/Views/round.php @@ -1,45 +1,90 @@ +

Tippübersicht bis:

- -

- - - - - - - - - - - - - + +

Keine teilnehmenden Spieler für diese Saison gefunden.

+ + +

+ +
+
AnpfiffHeimGastErgebnisStatus
+ - - - - - + + + + - - -
format('d.m.Y H:i')); ?>Spieler +
+
+ () +
- -

Für diese Runde wurden keine Spiele gefunden.

- - + + + + + + + -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']; + } + ?> + + + + 🃏 + + + + + + + + + +

Für diese Runde wurden keine Spiele gefunden.

+ + +

Zurück zur Startseite