umfassende updates

This commit is contained in:
torsten 2026-10-18 21:40:43 +02:00
parent 3331f08091
commit 50cd802d33
16 changed files with 441 additions and 78 deletions

View file

@ -23,10 +23,17 @@ class Roundmail {
/**
* Anzahl aller protokollierten Mails.
*
* @param bool $excludeReminders Automatische Erinnerungen (Betreff REMINDER_TOPIC) nicht mitzählen
* @return int
*/
public static function count() {
public static function count($excludeReminders = false) {
$db = Database::getConnection();
if ($excludeReminders) {
$stmt = $db->prepare("SELECT COUNT(*) FROM roundmails WHERE topic <> :topic");
$stmt->bindValue(':topic', self::REMINDER_TOPIC);
$stmt->execute();
return (int)$stmt->fetchColumn();
}
return (int)$db->query("SELECT COUNT(*) FROM roundmails")->fetchColumn();
}
@ -35,19 +42,25 @@ class Roundmail {
*
* @param int $limit
* @param int $offset
* @param bool $excludeReminders Automatische Erinnerungen (Betreff REMINDER_TOPIC) auslassen
* @return array
*/
public static function getPage($limit, $offset) {
public static function getPage($limit, $offset, $excludeReminders = false) {
$db = Database::getConnection();
$stmt = $db->prepare(
"SELECT m.id, m.send_date, m.topic, m.recipients, COALESCE(u.name, 'Automailer') AS sender_name
FROM roundmails m
LEFT JOIN users u ON u.id = m.user_id
ORDER BY m.send_date DESC, m.id DESC
LIMIT ? OFFSET ?"
);
$stmt->bindValue(1, (int)$limit, \PDO::PARAM_INT);
$stmt->bindValue(2, (int)$offset, \PDO::PARAM_INT);
$sql = "SELECT m.id, m.send_date, m.topic, m.recipients, COALESCE(u.name, 'Automailer') AS sender_name
FROM roundmails m
LEFT JOIN users u ON u.id = m.user_id";
if ($excludeReminders) {
$sql .= " WHERE m.topic <> :topic";
}
$sql .= " ORDER BY m.send_date DESC, m.id DESC LIMIT :limit OFFSET :offset";
$stmt = $db->prepare($sql);
if ($excludeReminders) {
$stmt->bindValue(':topic', self::REMINDER_TOPIC);
}
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);
$stmt->bindValue(':offset', (int)$offset, \PDO::PARAM_INT);
$stmt->execute();
return $stmt->fetchAll();
}

View file

@ -3,6 +3,8 @@ use App\Models\Round;
$pageTitle = 'Runden-E-Mails versenden';
require __DIR__ . '/../partials/header.php';
$reminderParam = ($excludeReminders ?? false) ? '&amp;hide_reminders=1' : '';
?>
<h1>Runden-E-Mails</h1>
@ -91,12 +93,17 @@ require __DIR__ . '/../partials/header.php';
<tr><th>Nachricht</th><td><?php echo nl2br(htmlspecialchars(html_entity_decode(strip_tags(Round::reportToText($viewMail['message'])), ENT_QUOTES, 'UTF-8'))); ?></td></tr>
</table>
<?php $backPage = max(1, (int)($_GET['p'] ?? 1)); ?>
<p><a href="/index.php?page=admin_roundmails<?php if ($backPage > 1) echo '&amp;p=' . $backPage; ?>">Zurück zur Übersicht</a></p>
<p><a href="/index.php?page=admin_roundmails<?php if ($backPage > 1) echo '&amp;p=' . $backPage; ?><?php echo $reminderParam; ?>">Zurück zur Übersicht</a></p>
<?php else: ?>
<p><a href="/index.php?page=admin_roundmails&amp;new=1">Neue Mail schreiben</a></p>
<label class="reminder-toggle">
<input type="checkbox" id="toggle-reminders" <?php echo $excludeReminders ? 'checked' : ''; ?>>
Erinnerungen ein/ausblenden
</label>
<table>
<thead>
<tr>
@ -110,7 +117,7 @@ require __DIR__ . '/../partials/header.php';
<?php foreach ($mails as $mail): ?>
<tr>
<td><?php echo date('d.m.Y', strtotime($mail['send_date'])); ?></td>
<td><a href="/index.php?page=admin_roundmails&amp;id=<?php echo (int)$mail['id']; ?><?php if ($currentPage > 1) echo '&amp;p=' . $currentPage; ?>"><?php echo htmlspecialchars($mail['topic']); ?></a></td>
<td><a href="/index.php?page=admin_roundmails&amp;id=<?php echo (int)$mail['id']; ?><?php if ($currentPage > 1) echo '&amp;p=' . $currentPage; ?><?php echo $reminderParam; ?>"><?php echo htmlspecialchars($mail['topic']); ?></a></td>
<td><?php echo htmlspecialchars($mail['sender_name']); ?></td>
<td><?php echo $mail['recipients'] === '' ? 0 : count(explode(',', $mail['recipients'])); ?></td>
</tr>
@ -121,8 +128,27 @@ require __DIR__ . '/../partials/header.php';
</tbody>
</table>
<script>
(function () {
var toggle = document.getElementById('toggle-reminders');
if (!toggle) return;
toggle.addEventListener('change', function () {
var params = new URLSearchParams(window.location.search);
if (this.checked) {
params.set('hide_reminders', '1');
} else {
params.delete('hide_reminders');
}
params.delete('p');
window.location.search = params.toString();
});
})();
</script>
<?php if ($totalPages > 1):
$pageUrl = fn($n) => '/index.php?page=admin_roundmails' . ($n > 1 ? '&amp;p=' . $n : '');
$pageUrl = fn($n) => '/index.php?page=admin_roundmails'
. $reminderParam
. ($n > 1 ? '&amp;p=' . $n : '');
// Angezeigt werden erste und letzte Seite sowie zwei Seiten um die aktuelle herum
$shown = array_unique(array_filter(
[1, $currentPage - 2, $currentPage - 1, $currentPage, $currentPage + 1, $currentPage + 2, $totalPages],
@ -167,6 +193,7 @@ require __DIR__ . '/../partials/header.php';
.mail-form input[type="text"], .mail-form textarea { width: 100%; box-sizing: border-box; }
.mail-form .buttons button { margin: 0 0.4em 0.4em 0; }
.mail-form .hint { color: #666; font-size: 0.8em; }
.reminder-toggle { display: inline-flex; align-items: center; gap: 0.4em; margin-bottom: 1em; cursor: pointer; }
.pagination { margin-top: 1em; display: flex; flex-wrap: wrap; gap: 0.3em; align-items: center; }
.pagination a, .pagination span { padding: 0.2em 0.6em; border: 1px solid #ccc; border-radius: 3px; text-decoration: none; }
.pagination a { color: var(--link); }

View file

@ -133,4 +133,48 @@ $failedRoundId = $failedForm ? (int)($failedForm['round_id'] ?? 0) : null;
.round-admin .hint { color: #666; font-size: 0.8em; }
</style>
<script>
(function () {
function pad(n) { return String(n).padStart(2, '0'); }
function isoToGerman(iso) {
var m = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/.exec(iso || '');
if (!m) return iso || '';
return m[3] + '.' + m[2] + '.' + m[1] + ' ' + m[4] + ':' + m[5];
}
document.querySelectorAll('input[type="datetime-local"]').forEach(function (input) {
input.dataset.iso = input.value;
function showText() {
if (document.activeElement === input) return;
input.type = 'text';
input.value = isoToGerman(input.dataset.iso);
}
function showPicker() {
input.type = 'datetime-local';
input.value = input.dataset.iso;
if (typeof input.showPicker === 'function') {
try { input.showPicker(); } catch (e) {}
}
}
input.addEventListener('focus', showPicker);
input.addEventListener('input', function () {
if (input.type === 'datetime-local') {
input.dataset.iso = input.value;
}
});
input.addEventListener('blur', showText);
var form = input.closest('form');
if (form) {
form.addEventListener('submit', showPicker);
}
showText();
});
})();
</script>
<?php require __DIR__ . '/../partials/footer.php'; ?>

View file

@ -12,38 +12,35 @@ require __DIR__ . '/../partials/header.php';
<p style="color: red;"><?php echo htmlspecialchars($error); ?></p>
<?php endif; ?>
<!-- Form for creating/editing a user -->
<h2><?php echo $editUser ? 'Benutzer bearbeiten' : 'Neuen Benutzer anlegen'; ?></h2>
<!-- Form for editing a user -->
<?php if ($editUser): ?>
<h2>Benutzer bearbeiten</h2>
<form action="/index.php?page=admin_users" method="post">
<?php if ($editUser): ?>
<input type="hidden" name="action" value="update">
<input type="hidden" name="id" value="<?php echo htmlspecialchars($editUser['id']); ?>">
<?php else: ?>
<input type="hidden" name="action" value="create">
<?php endif; ?>
<input type="hidden" name="action" value="update">
<input type="hidden" name="id" value="<?php echo htmlspecialchars($editUser['id']); ?>">
<div class="form-group">
<label for="firstname">Vorname:</label>
<input type="text" id="firstname" name="firstname" value="<?php echo htmlspecialchars($editUser['firstname'] ?? ''); ?>" required>
<input type="text" id="firstname" name="firstname" value="<?php echo htmlspecialchars($editUser['firstname']); ?>" required>
</div>
<div class="form-group">
<label for="lastname">Nachname:</label>
<input type="text" id="lastname" name="lastname" value="<?php echo htmlspecialchars($editUser['lastname'] ?? ''); ?>" required>
<input type="text" id="lastname" name="lastname" value="<?php echo htmlspecialchars($editUser['lastname']); ?>" required>
</div>
<div class="form-group">
<label for="email">E-Mail:</label>
<input type="email" id="email" name="email" value="<?php echo htmlspecialchars($editUser['email'] ?? ''); ?>" required>
<input type="email" id="email" name="email" value="<?php echo htmlspecialchars($editUser['email']); ?>" required>
</div>
<div class="form-group">
<label for="password">Passwort:</label>
<input type="password" id="password" name="password" placeholder="<?php echo $editUser ? 'Leer lassen, um nicht zu ändern' : ''; ?>">
<input type="password" id="password" name="password" placeholder="Leer lassen, um nicht zu ändern">
</div>
<div class="form-group">
<label for="admin">Admin:</label>
<input type="checkbox" id="admin" name="admin" value="1" <?php echo !empty($editUser['admin']) ? 'checked' : ''; ?>>
</div>
<?php if ($editUser && !empty($currentSeason)): ?>
<?php if (!empty($currentSeason)): ?>
<div class="form-group">
<label for="has_paid">Bezahlt (<?php echo htmlspecialchars($currentSeason['name']); ?>):</label>
<input type="checkbox" id="has_paid" name="has_paid" value="1" <?php echo isset($payments[$editUser['id']]) ? 'checked' : ''; ?>>
@ -51,14 +48,13 @@ require __DIR__ . '/../partials/header.php';
<?php endif; ?>
<div class="form-group">
<button type="submit"><?php echo $editUser ? 'Speichern' : 'Anlegen'; ?></button>
<?php if ($editUser): ?>
<a href="/index.php?page=admin_users">Abbrechen</a>
<?php endif; ?>
<button type="submit">Speichern</button>
<a href="/index.php?page=admin_users">Abbrechen</a>
</div>
</form>
<hr>
<?php endif; ?>
<!-- User List -->
<h2>Benutzerliste</h2>

View file

@ -7,12 +7,12 @@ require __DIR__ . '/partials/header.php';
<h1>Willkommen bei Tippspiel 2027</h1>
<h2>Rundenübersicht</h2>
<h2>Abgeschlossene Runden:</h2>
<?php if ($currentSeason): ?>
<p>Saison: <strong><?php echo htmlspecialchars($currentSeason['name']); ?></strong></p>
<?php if ($rounds): ?>
<?php foreach ($rounds as $round): ?>
<h3><a href="/index.php?page=round&id=<?php echo htmlspecialchars($round['id']); ?>"><?php echo htmlspecialchars($round['name']); ?></a></h3>
<h3><a href="/index.php?page=ranking&round_id=<?php echo htmlspecialchars($round['id']); ?>"><?php echo htmlspecialchars($round['name']); ?></a></h3>
<?php if (!empty($round['report'])): ?>
<p><?php echo nl2br(htmlspecialchars(Round::reportToText($round['report']))); ?></p>
<?php endif; ?>

View file

@ -52,7 +52,7 @@ $exactExamples = ['1:0', '2:1', '2:2', '3:1', '3:2', '4:2', '5:3'];
<tr><td><strong>Richtige Tendenz</strong> (Sieg Heim / Unentschieden / Sieg Gast richtig, Ergebnis falsch)</td><td>1</td></tr>
<tr><td><strong>Exaktes Ergebnis</strong></td><td>2 + Torbonus</td></tr>
<tr><td>Mit <strong>Joker</strong></td><td>Punkte des Spiels × 2</td></tr>
<tr><td><strong>Rundenbonus</strong>: Jedes Spiel der Runde bringt dir mindestens einen Punkt</td><td>+ <?php echo Tipp::ALL_HITS_BONUS; ?> (wird nicht verdoppelt)</td></tr>
<tr><td><strong>Rundenbonus</strong>: Alle 4 Spiele der Runde haben mindestens die Tendenz getroffen</td><td>+ <?php echo Tipp::ALL_HITS_BONUS; ?> (wird nicht verdoppelt)</td></tr>
</tbody>
</table>

View file

@ -0,0 +1,115 @@
<?php
use App\Models\Quota;
use App\Models\Season;
$pageTitle = 'Anleitung-Admin';
require __DIR__ . '/../partials/header.php';
$defaults = Quota::defaults();
$euro = fn($amount) => number_format($amount, 2, ',', '.') . ' €';
?>
<div class="guide">
<h1>Anleitung-Admin</h1>
<p class="lead">So verwaltest du Saisons und Quoten. Dieser Bereich richtet sich ausschließlich an Administratoren.</p>
<nav class="guide-toc">
<a href="#saison-anlegen">Saison anlegen</a>
<a href="#saison-umschalten">Saison umschalten</a>
<a href="#quoten">Quoten</a>
</nav>
<h2 id="saison-anlegen">1. Neue Saison anlegen</h2>
<ol>
<li>Öffne unter <em>Administration → Saisons verwalten</em> die Saisonverwaltung.</li>
<li>Fülle das Formular „Neue Saison anlegen" aus:
<ul>
<li><strong>Name:</strong> z.&nbsp;B. „HINRUNDE 26/27".</li>
<li><strong>Runden:</strong> Anzahl der Spieltage. Pro Runde werden automatisch <strong><?php echo Season::GAMES_PER_ROUND; ?> Spiele</strong> angelegt.</li>
<li><strong>Max. gleiche Joker:</strong> Wie oft dasselbe Ergebnis pro Saison mit Joker getippt werden darf (Standard <?php echo Season::DEFAULT_MAX_IDENTICAL_JOKERTIPPS; ?>).</li>
</ul>
</li>
<li>Lege die Quoten fest (siehe <a href="#quoten">Abschnitt Quoten</a>). Es gelten die Standardwerte, du kannst sie aber anpassen.</li>
<li>Klicke <strong>„Anlegen"</strong>. Die Saison wird erstellt und automatisch als <strong>aktiv</strong> gesetzt.</li>
</ol>
<div class="example">
<strong>Wichtig nach dem Anlegen:</strong> Die Saison enthält zunächst nur Platzhalter-Runden
(„1. Spieltag", „2. Spieltag", …) mit Platzhalter-Spielen („Mannschaft 1" bis „Mannschaft 8"),
deren Anstoßzeiten 7 Monate in der Zukunft liegen. Trage unter
<em>Administration → Spiele &amp; Ergebnisse eintragen</em> die echten Paarungen und Anstoßzeiten ein.
Erst dadurch werden die Runden tippbar und später (nach dem Anpfiff) gesperrt.
</div>
<h2 id="saison-umschalten">2. Saison umschalten &amp; verwalten</h2>
<ul>
<li>Die <strong>Saison-Liste</strong> zeigt alle Saisons; die aktive ist fett markiert (Spalte „Aktiv").</li>
<li>Mit <strong>„Als aktiv setzen"</strong> wechselst du die aktive Saison. Alle Bereiche
(Startseite, Tipps, Rangliste, Quoten, Erinnerungen) beziehen sich danach auf die neue Saison.</li>
<li>Über <strong>„Bearbeiten"</strong> kannst du Name, Rundenanzahl, Joker-Limit und Quoten nachträglich anpassen.
Hinweis: Eine Änderung der Rundenanzahl legt keine neuen Runden an und löscht keine.</li>
<li><strong>„Löschen"</strong> entfernt eine Saison samt Runden, Spielen, Tipps, Zahlungen und Quoten.
Die <strong>aktive Saison kann nicht gelöscht werden</strong> – schalte zuerst auf eine andere um.</li>
</ul>
<h2 id="quoten">3. Wie die Quoten funktionieren</h2>
<p>Die Quoten legen fest, wie der Pott verteilt wird. Der <strong>Pott</strong> ergibt sich aus
<em>bezahlte Spieler × Einsatz</em>.</p>
<h3>Die drei Quoten-Gruppen</h3>
<table class="guide-table">
<thead><tr><th>Quote</th><th>Bedeutung</th><th>Standard</th></tr></thead>
<tbody>
<tr><td><strong>Einsatz</strong></td><td>Betrag, den jeder aktive Spieler pro Saison zahlt (in €)</td><td><?php echo $defaults['einsatz']; ?> €</td></tr>
<tr><td><strong>Tagessieg</strong></td><td>Anteil des Potts für die Tagessiege (in %)</td><td><?php echo $defaults['tagessieg']; ?> %</td></tr>
<tr><td><strong>Platzierung</strong></td><td>Anteil des Potts für das Platzierungsgeld (in %)</td><td><?php echo $defaults['platzierung']; ?> %</td></tr>
<tr><td><strong>Platz 1 … <?php echo Quota::PLACES; ?></strong></td><td>Aufteilung des Platzierungstopfs auf die Plätze (in %)</td><td>siehe Tabelle unten</td></tr>
</tbody>
</table>
<p><strong>Regeln:</strong> Tagessieg + Platzierung müssen zusammen <strong>100 %</strong> ergeben,
und Platz 1 bis <?php echo Quota::PLACES; ?> ebenfalls <strong>100 %</strong>. Das Formular prüft das beim Speichern.</p>
<h3>Standard-Platzierungsquoten</h3>
<table class="guide-table compact">
<thead>
<tr><th>Platz</th><?php for ($place = 1; $place <= Quota::PLACES; $place++): ?><th><?php echo $place; ?></th><?php endfor; ?></tr>
</thead>
<tbody>
<tr><td>Anteil</td>
<?php for ($place = 1; $place <= Quota::PLACES; $place++): ?>
<td><?php echo $defaults['platz' . $place]; ?> %</td>
<?php endfor; ?>
</tr>
</tbody>
</table>
<h3>So wird gerechnet</h3>
<ul>
<li><strong>Pott</strong> = bezahlte Spieler × Einsatz.</li>
<li><strong>Tagessieg je Runde</strong> = Pott × Tagessieg-% ÷ Rundenzahl, abgerundet auf einen durch 6 teilbaren Betrag.
Der Rundungsrest wandert in den Platzierungstopf.</li>
<li><strong>Platzierungstopf</strong> = Pott × Platzierung-% + Rundungsrest der Tagessiege.</li>
<li><strong>Platz N</strong> = Platzierungstopf × Platz-N-%, abgerundet auf einen durch 6 teilbaren Betrag.</li>
<li>Was danach vom Pott übrig bleibt (Rundungsreste), geht <strong>zusätzlich an Platz 1</strong>.</li>
</ul>
<p class="hint">Die konkreten Beträge für die aktive Saison siehst du in der Saisonverwaltung
(rechts neben jedem Quotenfeld) und unter <a href="/index.php?page=info_quotas">Quoten</a>.</p>
</div>
<style>
.guide { max-width: 900px; line-height: 1.5; }
.guide .lead { color: #555; }
.guide h2 { margin-top: 1.8em; border-bottom: 1px solid #ddd; padding-bottom: 0.2em; scroll-margin-top: 1em; }
.guide-toc { background: none; padding: 0; margin: 0 0 1em; }
.guide-toc a { margin-right: 1em; font-weight: normal; color: var(--link); }
.guide-table { width: auto; margin: 0.8em 0; }
.guide-table td:last-child, .guide-table th:last-child { text-align: center; }
.guide-table.compact td, .guide-table.compact th { padding: 4px 10px; text-align: center; }
.guide-table.compact td:first-child, .guide-table.compact th:first-child { text-align: left; }
.guide .example { background: #f9f9f9; border: 1px solid #ddd; padding: 0.8em 1em; margin: 1em 0; }
.guide .hint { color: #666; font-size: 0.9em; }
</style>
<?php require __DIR__ . '/../partials/footer.php'; ?>

View file

@ -5,6 +5,7 @@ require __DIR__ . '/../partials/header.php';
$myId = (int)$user['id'];
?>
<div class="money-centered">
<h1>Geldrangliste</h1>
<table class="money-table">
@ -25,6 +26,7 @@ $myId = (int)$user['id'];
<?php endforeach; ?>
</tbody>
</table>
</div>
<script>
// Wie im Legacy (Link auf #playerid_<eigene ID>): ohne Anker zur eigenen Zeile springen
@ -35,7 +37,8 @@ if (!location.hash) {
</script>
<style>
.money-table { width: auto; min-width: 400px; }
.money-centered { text-align: center; }
.money-table { width: auto; min-width: 400px; margin: 1em auto 0; text-align: left; }
.money-table td.amount { text-align: right; }
.money-table tr.me td { background: #fff3cd; font-weight: bold; }
.money-table tr:target td { background: #fff3cd; }

View file

@ -3,6 +3,7 @@ $pageTitle = 'Ausschüttungsübersicht';
require __DIR__ . '/../partials/header.php';
?>
<div class="money-centered">
<h1>Ausschüttungsübersicht <?php echo htmlspecialchars($detailUser['name']); ?></h1>
<table class="money-table">
@ -31,9 +32,11 @@ require __DIR__ . '/../partials/header.php';
</table>
<p><a href="/index.php?page=money_ranking#playerid_<?php echo (int)$detailUser['id']; ?>">Zurück</a></p>
</div>
<style>
.money-table { width: auto; min-width: 400px; }
.money-centered { text-align: center; }
.money-table { width: auto; min-width: 400px; margin: 1em auto 0; text-align: left; }
.money-table td.amount { text-align: right; }
.money-table tr.total td { font-weight: bold; border-top: 2px solid #999; }
</style>

View file

@ -10,8 +10,10 @@ $euro = fn($amount) => number_format($amount, 2, ',', '.') . ' €';
<?php if (!$currentSeason): ?>
<p>Es gibt noch keine Saison.</p>
<?php else: ?>
<div class="quota-centered">
<h1><?php echo htmlspecialchars($currentSeason['name']); ?></h1>
<h2>Ausschüttungs-Quoten</h2>
</div>
<div class="quota-section">
<h3>Spiel-Einsatz</h3>
@ -39,6 +41,7 @@ $euro = fn($amount) => number_format($amount, 2, ',', '.') . ' €';
<?php endif; ?>
<style>
.quota-centered { text-align: center; }
.quota-section { text-align: center; }
.info-table { width: auto; min-width: 350px; margin-left: auto; margin-right: auto; }
.info-table th { width: 200px; font-weight: normal; }

View file

@ -13,7 +13,7 @@
<link rel="stylesheet" href="/css/style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" integrity="sha512-SnH5WK+bZxgPHs44uWIX+LLJAJ9/2PkPKZ5QiAj6Ta86w+fsb2TkcmfRyVX3pBnMFcV7oQPJkl9QevSCWr3W6A==" crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
<body>
<body class="<?php echo htmlspecialchars($bodyClass ?? ''); ?>">
<nav class="site-nav">
<a href="/" class="brand"><span class="brand-ball">⚽</span> Tippspiel <span class="brand-year">2027</span></a>
<a href="/">Start</a>
@ -44,6 +44,9 @@
<a href="#" onclick="return false;">Info</a>
<span class="nav-dropdown-content">
<a href="/index.php?page=guide">Anleitung</a>
<?php if (App\Core\Auth::isAdmin()): ?>
<a href="/index.php?page=guide_admin">Anleitung-Admin</a>
<?php endif; ?>
<a href="/index.php?page=info_quotas">Quoten</a>
<a href="/index.php?page=money_ranking">Geldrangliste</a>
</span>

View file

@ -3,6 +3,7 @@ $pageTitle = 'Rangliste';
if ($selectedRound) {
$pageTitle .= ' - ' . htmlspecialchars($selectedRound['name']);
}
$bodyClass = 'ranking-page';
require __DIR__ . '/partials/header.php';
// Stellt sicher, dass die benötigten Variablen vorhanden sind
@ -16,6 +17,11 @@ if (!isset($currentSeason) || !isset($ranking) || !isset($games) || !isset($allR
.game-header {
width: 100px; /* Feste Breite für die Spiele-Spalten */
}
table.ranking-table {
width: auto; /* Keine feste Breite, damit die Tabelle frei wachsen kann */
min-width: 100%;
max-width: none; /* Default-max-width (800px) aufheben */
}
.tipp-points {
width: 55px; /* Breite für den Tipp (z.B. 2:1) */
box-sizing: border-box;
@ -76,12 +82,66 @@ if (!isset($currentSeason) || !isset($ranking) || !isset($games) || !isset($allR
padding: 6px 10px;
font-size: 0.8em;
gap: 6px 12px;
justify-content: center;
flex-wrap: nowrap; /* nicht umbrechen, volle Breite nutzen */
justify-content: flex-start;
}
.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; }
/* Rundenpunkte als Link mit Aufschlüsselungs-Popup */
.round-points-link {
background: none;
box-shadow: none;
border: none;
border-radius: 0;
padding: 0;
color: var(--link);
text-transform: none;
letter-spacing: 0;
font-family: var(--font);
font-weight: 700;
text-decoration: underline;
cursor: pointer;
}
.round-points-link:hover { background: none; color: var(--pitch-dark); }
.breakdown-modal { position: fixed; inset: 0; z-index: 100; }
.breakdown-modal[hidden] { display: none; }
.breakdown-modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.5); }
.breakdown-modal-dialog {
position: relative;
margin: 12vh auto;
max-width: 440px;
width: calc(100% - 2em);
background: #fff;
border-radius: 10px;
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
padding: 1.2em 1.2em 1.4em;
}
.breakdown-modal-close {
position: absolute;
top: 0.3em;
right: 0.4em;
background: none;
box-shadow: none;
border: none;
border-radius: 0;
padding: 0.1em 0.3em;
font-size: 1.6em;
line-height: 1;
color: var(--muted);
cursor: pointer;
}
.breakdown-modal-close:hover { background: none; color: var(--ink); }
.bd-title { font-weight: 800; font-size: 1.1em; margin-bottom: 0.6em; color: var(--pitch-dark); }
.bd-table { width: 100%; max-width: none; margin: 0 0 0.8em; border: 1px solid var(--line); }
.bd-table th, .bd-table td { padding: 4px 8px; font-size: 0.9em; }
.bd-table .bd-num { text-align: right; }
.bd-joker { font-size: 0.85em; color: var(--muted); }
.bd-line { display: flex; justify-content: space-between; padding: 0.15em 0; }
.bd-line.bd-total { border-top: 2px solid var(--pitch-dark); margin-top: 0.4em; padding-top: 0.4em; font-weight: 700; }
@media (max-width: 700px) {
.ranking-toolbar h1 { font-size: 1.1em; }
.ranking-toolbar .round-filter { margin-left: 0; }
@ -107,16 +167,15 @@ if (!isset($currentSeason) || !isset($ranking) || !isset($games) || !isset($allR
</div>
<?php if ($selectedRound): ?>
<div class="table-container sticky-header">
<?php if (!empty($ranking)): ?>
<table>
<table class="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>
<th class="text-center">Punkte<br>(Gesamt)</th>
<th class="text-center">Punkte<br>(Runde)</th>
<?php foreach ($games as $game): ?>
<th class="game-header" colspan="2">
<?php echo htmlspecialchars($game['team1']); ?><br>
@ -131,6 +190,29 @@ if (!isset($currentSeason) || !isset($ranking) || !isset($games) || !isset($allR
$rowClasses = [];
if ($entry['rank'] <= 3) $rowClasses[] = 'rank-' . $entry['rank'];
if ((int)$entry['user_id'] === (int)App\Core\Auth::id()) $rowClasses[] = 'me';
// Aufschlüsselung der Rundenpunkte für den Popup
$breakdownGamePoints = 0;
$breakdownRows = '';
foreach ($games as $game) {
$cell = $entry['cells'][$game['id']];
$pts = (int)$cell['points'];
$breakdownGamePoints += $pts;
$breakdownRows .= '<tr>'
. '<td>' . htmlspecialchars($game['team1'] . ' – ' . $game['team2']) . '</td>'
. '<td>' . htmlspecialchars($cell['text']) . ($cell['joker'] ? ' <span class="bd-joker">(Joker)</span>' : '') . '</td>'
. '<td class="bd-num">' . $pts . '</td>'
. '</tr>';
}
$breakdownBonus = (int)$entry['points'] - $breakdownGamePoints;
$breakdown = '<div class="bd-title">' . htmlspecialchars($entry['name']) . '</div>'
. '<table class="bd-table"><thead><tr><th>Spiel</th><th>Tipp</th><th>Punkte</th></tr></thead>'
. '<tbody>' . $breakdownRows . '</tbody></table>'
. '<div class="bd-line">Spiele gesamt: <strong>' . $breakdownGamePoints . ' P.</strong></div>';
if ($breakdownBonus > 0) {
$breakdown .= '<div class="bd-line">Rundenbonus (alle Spiele mind. Tendenz): <strong>+' . $breakdownBonus . ' P.</strong></div>';
}
$breakdown .= '<div class="bd-line bd-total">Rundenpunkte: <strong>' . (int)$entry['points'] . ' P.</strong></div>';
?>
<tr<?php if ($rowClasses) echo ' class="' . implode(' ', $rowClasses) . '"'; ?>
<?php if ((int)$entry['user_id'] === (int)App\Core\Auth::id()) echo ' id="me-row"'; ?>>
@ -138,7 +220,7 @@ if (!isset($currentSeason) || !isset($ranking) || !isset($games) || !isset($allR
<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>
<td class="text-center"><button type="button" class="round-points-link" data-breakdown="<?php echo htmlspecialchars($breakdown, ENT_QUOTES); ?>"><?php echo (int)$entry['points']; ?></button></td>
<?php foreach ($games as $game): ?>
<?php
$tipp = $entry['cells'][$game['id']];
@ -162,7 +244,6 @@ if (!isset($currentSeason) || !isset($ranking) || !isset($games) || !isset($allR
<?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>
@ -175,6 +256,14 @@ if (!isset($currentSeason) || !isset($ranking) || !isset($games) || !isset($allR
<p>Keine Runde für die Anzeige ausgewählt oder gefunden.</p>
<?php endif; ?>
<div class="breakdown-modal" id="breakdown-modal" hidden>
<div class="breakdown-modal-backdrop" data-close></div>
<div class="breakdown-modal-dialog" role="dialog" aria-modal="true">
<button type="button" class="breakdown-modal-close" data-close aria-label="Schließen">&times;</button>
<div class="breakdown-modal-body" id="breakdown-modal-body"></div>
</div>
</div>
<script>
// Springe beim Laden zur eigenen Zeile, falls der eingeloggte Spieler in der Tabelle ist
window.addEventListener('load', function () {
@ -183,6 +272,27 @@ if (!isset($currentSeason) || !isset($ranking) || !isset($games) || !isset($allR
me.scrollIntoView({ block: 'center' });
}
});
(function () {
var modal = document.getElementById('breakdown-modal');
var body = document.getElementById('breakdown-modal-body');
if (!modal || !body) return;
function open(html) { body.innerHTML = html; modal.hidden = false; }
function close() { modal.hidden = true; }
document.querySelectorAll('.round-points-link').forEach(function (btn) {
btn.addEventListener('click', function () {
open(btn.getAttribute('data-breakdown'));
});
});
modal.addEventListener('click', function (e) {
if (e.target.hasAttribute && e.target.hasAttribute('data-close')) close();
});
document.addEventListener('keydown', function (e) {
if (e.key === 'Escape') close();
});
})();
</script>
<?php require __DIR__ . '/partials/footer.php'; ?>