2 Commity 6c4be09f1d ... 92514314cf

Autor SHA1 Wiadomość Data
  erdo 92514314cf Spiele mit unbekanntem Ergebnis können erfasst werden 7 miesięcy temu
  erdo 1bf58a9d56 Swipper mit Pfeilen bestückt 7 miesięcy temu
2 zmienionych plików z 136 dodań i 42 usunięć
  1. 15 3
      gesamtliste.php
  2. 121 39
      index.php

+ 15 - 3
gesamtliste.php

@@ -6,8 +6,10 @@ require_once 'db_config.php';
 $filterPlayerId = isset($_GET['team_filter']) ? (int)$_GET['team_filter'] : 0;
 $filterTypId = isset($_GET['typ_filter']) ? (int)$_GET['typ_filter'] : 0;
 
-// SQL Query mit Filtern und Standard-Sortierung nach Titel (A-Z)
-$sql = "SELECT sp.*, t.bezeichnung as typ_name, MAX(sc.sterne) as best_sterne, 
+// SQL Query: COUNT(sc.id) hinzugefügt, um "gespielt" ohne Sterne zu erkennen
+$sql = "SELECT sp.*, t.bezeichnung as typ_name, 
+               MAX(sc.sterne) as best_sterne,
+               COUNT(sc.id) as anzahl_scores,
                (SELECT status FROM besitzstatus WHERE spiel_id = sp.id AND spieler_id = :fid) as einzel_status,
                (SELECT GROUP_CONCAT(CONCAT(p.name, ': ', b.status) SEPARATOR '||') 
                 FROM besitzstatus b JOIN spieler p ON b.spieler_id = p.id 
@@ -158,7 +160,17 @@ $typen = $pdo->query("SELECT * FROM game_typen ORDER BY bezeichnung ASC")->fetch
                         <?= ($lvl == 'unknown') ? 'Unbekannt' : $lvl ?>
                     </span>
                 </td>
-                <td><?= $row['best_sterne'] ? "<b>{$row['best_sterne']} ★</b>" : "-" ?></td>
+                <td>
+                    <?php 
+                        if ($row['best_sterne'] > 0) {
+                            echo "<b>{$row['best_sterne']} ★</b>";
+                        } elseif ($row['anzahl_scores'] > 0) {
+                            echo "<i style='opacity:0.7'>Gespielt</i>";
+                        } else {
+                            echo "-";
+                        }
+                    ?>
+                </td>
                 <td>
                     <?php if ($filterPlayerId > 0): 
                         $st = $row['einzel_status'] ?: 'nicht besitzt';

+ 121 - 39
index.php

@@ -12,21 +12,27 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_player'])) {
 
 // --- LOGIK: SCORE HINZUFÜGEN ---
 if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_score'])) {
+    $unbekannt = isset($_POST['ergebnis_unbekannt']);
+    
+    // Wenn unbekannt, werden 0-Werte gespeichert
+    $zeit = $unbekannt ? 0 : (int)$_POST['zeit'];
+    $hilfe = $unbekannt ? 0 : (int)$_POST['hilfe'];
+    $sterne = $unbekannt ? 0 : (int)$_POST['sterne'];
+
     $sql = "INSERT INTO scores (spieler_id, spiel_id, zeit, hilfe, sterne) VALUES (?, ?, ?, ?, ?)";
     $stmt = $pdo->prepare($sql);
     $stmt->execute([
         $_POST['spieler_id'], 
         $_POST['spiel_id'], 
-        (int)$_POST['zeit'], 
-        (int)$_POST['hilfe'], 
-        (int)$_POST['sterne']
+        $zeit, 
+        $hilfe, 
+        $sterne
     ]);
     header("Location: index.php?success=score");
     exit;
 }
 
 // --- DATEN ABFRAGEN ---
-// ÄNDERUNG: JOIN hinzugefügt, um den Typ-Namen zu erhalten
 $sqlGames = "SELECT s.*, t.bezeichnung as typ_name 
              FROM spiele s 
              LEFT JOIN game_typen t ON s.typ_id = t.id 
@@ -52,7 +58,6 @@ $allScores = $pdo->query($sqlScores)->fetchAll();
     <title>EXIT - Dashboard</title>
     <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css" />
     <style>
-        /* THEME VARIABLEN */
         :root { 
             --bg: #f4f7f6; --card: #ffffff; --text: #333; --border: #ddd; --accent: #e67e22;
             --input-bg: #fff; --footer-bg: #f1f1f1; --success: #27ae60;
@@ -77,10 +82,52 @@ $allScores = $pdo->query($sqlScores)->fetchAll();
 
         .theme-toggle { background: var(--card); border: 1px solid var(--border); color: var(--text); width: 42px; height: 34px; border-radius: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.3s; }
 
-        .swiper { width: 100%; padding-top: 10px; padding-bottom: 40px; }
+        .swiper-outer-wrapper {
+            position: relative;
+            width: 100%;
+            padding: 0 50px; 
+            box-sizing: border-box;
+            margin-bottom: 40px;
+        }
+
+        .swiper { width: 100%; padding-top: 10px; }
         .swiper-slide { width: 320px; height: auto; }
         .swiper-pagination-progressbar { background: var(--border) !important; height: 4px !important; top: 0 !important; }
         .swiper-pagination-progressbar-fill { background: var(--accent) !important; }
+        
+        .swiper-button-next, .swiper-button-prev { 
+            color: var(--text); 
+            background: none;   
+            width: auto;        
+            height: auto;       
+            box-shadow: none;   
+            border: none;       
+            position: absolute;
+            top: 50%;
+            transform: translateY(-50%);
+            z-index: 10;
+            opacity: 0.5;       
+            transition: all 0.3s ease;
+        }
+
+        .swiper-button-next:hover, .swiper-button-prev:hover {
+            color: var(--accent);
+            opacity: 1;
+            transform: translateY(-50%) scale(1.1);
+        }
+
+        .swiper-button-prev { left: 10px; }
+        .swiper-button-next { right: 10px; }
+
+        .swiper-button-next:after, .swiper-button-prev:after { 
+            font-size: 40px;    
+            font-weight: bold; 
+        }
+
+        @media (max-width: 768px) {
+            .swiper-outer-wrapper { padding: 0 10px; }
+            .swiper-button-next, .swiper-button-prev { display: none; }
+        }
 
         .card { background: var(--card); border-radius: 12px; border: 1px solid var(--border); overflow: hidden; height: 100%; box-shadow: 0 4px 15px rgba(0,0,0,0.1); }
         .card img { width: 100%; height: 180px; object-fit: cover; opacity: 0.9; }
@@ -114,6 +161,9 @@ $allScores = $pdo->query($sqlScores)->fetchAll();
         
         #playerModal { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--card); padding: 30px; border-radius: 12px; border: 1px solid var(--accent); z-index: 2000; color: var(--text); box-shadow: 0 0 50px rgba(0,0,0,0.5); }
         .overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 1500; }
+        
+        .unknown-box { margin-bottom: 15px; display: flex; align-items: center; gap: 8px; font-size: 0.9em; }
+        .unknown-box input { width: auto; margin: 0; cursor: pointer; }
     </style>
     <script>
         if (localStorage.getItem('theme') === 'dark') document.documentElement.classList.add('dark-theme');
@@ -133,37 +183,41 @@ $allScores = $pdo->query($sqlScores)->fetchAll();
         <button onclick="toggleTheme()" class="theme-toggle" id="theme-icon">🌙</button>
     </header>
 
-    <div class="swiper mySwiper">
-        <div class="swiper-pagination"></div>
-        <div class="swiper-wrapper">
-            <?php foreach ($exitGames as $game): 
-                $lvl_class = (empty($game['level']) || strtolower($game['level']) == 'unknown') ? 'unknown' : $game['level'];
-            ?>
-                <div class="swiper-slide">
-                    <div class="card">
-                        <img src="<?= htmlspecialchars($game['bild_url']) ?>" alt="Cover" onerror="this.src='https://via.placeholder.com/320x180?text=Kein+Bild'">
-                        <div class="content">
-                            <span class="badge level-<?= $lvl_class ?>"><?= htmlspecialchars($game['level'] ?: 'Unbekannt') ?></span>
-                            <h2><?= htmlspecialchars($game['titel']) ?></h2>
-                            <table class="stats">
-                                <?php 
-                                $found = false;
-                                foreach ($allScores as $entry): 
-                                    if ($entry['spiel_id'] == $game['id']): $found = true; ?>
-                                    <tr>
-                                        <td><strong><?= htmlspecialchars($entry['spieler_name']) ?></strong></td>
-                                        <td><?= $entry['zeit'] ?>'</td>
-                                        <td style="color:#f1c40f"><?= $entry['sterne'] ?>★</td>
-                                    </tr>
-                                <?php endif; endforeach; 
-                                if (!$found) echo "<tr><td colspan='3' style='opacity:0.5'>Noch keine Scores.</td></tr>";
-                                ?>
-                            </table>
+    <div class="swiper-outer-wrapper">
+        <div class="swiper mySwiper">
+            <div class="swiper-pagination"></div>
+            <div class="swiper-wrapper">
+                <?php foreach ($exitGames as $game): 
+                    $lvl_class = (empty($game['level']) || strtolower($game['level']) == 'unknown') ? 'unknown' : $game['level'];
+                ?>
+                    <div class="swiper-slide">
+                        <div class="card">
+                            <img src="<?= htmlspecialchars($game['bild_url']) ?>" alt="Cover" onerror="this.src='https://via.placeholder.com/320x180?text=Kein+Bild'">
+                            <div class="content">
+                                <span class="badge level-<?= $lvl_class ?>"><?= htmlspecialchars($game['level'] ?: 'Unbekannt') ?></span>
+                                <h2><?= htmlspecialchars($game['titel']) ?></h2>
+                                <table class="stats">
+                                    <?php 
+                                    $found = false;
+                                    foreach ($allScores as $entry): 
+                                        if ($entry['spiel_id'] == $game['id']): $found = true; ?>
+                                        <tr>
+                                            <td><strong><?= htmlspecialchars($entry['spieler_name']) ?></strong></td>
+                                            <td><?= $entry['zeit'] > 0 ? $entry['zeit']."'" : '?' ?></td>
+                                            <td style="color:#f1c40f"><?= $entry['sterne'] > 0 ? $entry['sterne']."★" : "gespielt" ?></td>
+                                        </tr>
+                                    <?php endif; endforeach; 
+                                    if (!$found) echo "<tr><td colspan='3' style='opacity:0.5'>Noch keine Scores.</td></tr>";
+                                    ?>
+                                </table>
+                            </div>
                         </div>
                     </div>
-                </div>
-            <?php endforeach; ?>
+                <?php endforeach; ?>
+            </div>
         </div>
+        <div class="swiper-button-prev"></div>
+        <div class="swiper-button-next"></div>
     </div>
 
     <div class="bottom-section">
@@ -192,10 +246,16 @@ $allScores = $pdo->query($sqlScores)->fetchAll();
                         <option value="<?= $p['id'] ?>"><?= htmlspecialchars($p['name']) ?></option>
                     <?php endforeach; ?>
                 </select>
-                <div style="display: flex; gap: 10px;">
-                    <input type="number" name="zeit" placeholder="Min" required>
-                    <input type="number" name="sterne" min="1" max="10" placeholder="Sterne">
-                    <input type="number" name="hilfe" placeholder="Hilfe">
+                
+                <div class="unknown-box">
+                    <input type="checkbox" name="ergebnis_unbekannt" id="ergebnis_unbekannt" onchange="toggleInputs()">
+                    <label for="ergebnis_unbekannt">Ergebnisse unbekannt</label>
+                </div>
+
+                <div id="input-fields" style="display: flex; gap: 10px;">
+                    <input type="number" name="zeit" id="zeit" placeholder="Min" required>
+                    <input type="number" name="sterne" id="sterne" min="1" max="10" placeholder="Sterne">
+                    <input type="number" name="hilfe" id="hilfe" placeholder="Hilfe">
                 </div>
                 <button type="submit" name="add_score">Score speichern</button>
             </form>
@@ -230,8 +290,30 @@ $allScores = $pdo->query($sqlScores)->fetchAll();
     }
     if (localStorage.getItem('theme') === 'dark') themeIcon.innerText = '☀️';
 
+    function toggleInputs() {
+        const check = document.getElementById('ergebnis_unbekannt');
+        const fields = ['zeit', 'sterne', 'hilfe'];
+        fields.forEach(id => {
+            const el = document.getElementById(id);
+            el.disabled = check.checked;
+            if (check.checked) el.value = '';
+            if (id === 'zeit') el.required = !check.checked;
+        });
+        document.getElementById('input-fields').style.opacity = check.checked ? '0.5' : '1';
+    }
+
     new Swiper(".mySwiper", {
-        slidesPerView: "auto", spaceBetween: 20, grabCursor: true, pagination: { el: ".swiper-pagination", type: "progressbar" },
+        slidesPerView: "auto", 
+        spaceBetween: 20, 
+        grabCursor: true, 
+        pagination: { 
+            el: ".swiper-pagination", 
+            type: "progressbar" 
+        },
+        navigation: {
+            nextEl: ".swiper-button-next",
+            prevEl: ".swiper-button-prev",
+        },
     });
 
     function toggleModal() {