Selaa lähdekoodia

Dashboard Button einheitlich angepasst

erdo 1 päivä sitten
vanhempi
sitoutus
9ef16e3cb9
2 muutettua tiedostoa jossa 102 lisäystä ja 92 poistoa
  1. 48 77
      besitz.php
  2. 54 15
      gesamtliste.php

+ 48 - 77
besitz.php

@@ -1,12 +1,9 @@
 <?php
 require_once 'db_config.php';
-$msg = "";
 
-// Status-Update Logik
+$msg = "";
 if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['update_status'])) {
-    $stmt = $pdo->prepare("INSERT INTO besitzstatus (spieler_id, spiel_id, status) 
-                           VALUES (?, ?, ?) 
-                           ON DUPLICATE KEY UPDATE status = VALUES(status)");
+    $stmt = $pdo->prepare("INSERT INTO besitzstatus (spieler_id, spiel_id, status) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE status = VALUES(status)");
     $stmt->execute([(int)$_POST['spieler_id'], (int)$_POST['spiel_id'], $_POST['status']]);
     $msg = "Status aktualisiert!";
 }
@@ -18,98 +15,77 @@ $spiele = $pdo->query("SELECT s.*, t.bezeichnung as typ_name FROM spiele s LEFT
 <html lang="de">
 <head>
     <meta charset="UTF-8">
-    <title>EXIT - Bestandsverwaltung</title>
+    <title>EXIT - Bestand</title>
     <style>
-        /* THEME VARIABLEN */
-        :root { 
-            --bg: #f4f7f6; --card: #ffffff; --text: #333; --border: #ddd; --accent: #e67e22;
-            --table-head: #f8f9fa;
-        }
-        .dark-theme { 
-            --bg: #121212; --card: #1e1e1e; --text: #e0e0e0; --border: #333;
-            --table-head: #2a2a2a;
-        }
-
+        :root { --bg: #f4f7f6; --card: #ffffff; --text: #333; --border: #ddd; --accent: #e67e22; }
+        .dark-theme { --bg: #121212; --card: #1e1e1e; --text: #e0e0e0; --border: #333; }
         body { font-family: 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); padding: 20px; transition: 0.3s; }
         .container { max-width: 1200px; margin: auto; }
         
-        header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
-        h1 { color: var(--accent); margin: 0; }
-        
-        .alert { background: #27ae60; color: white; padding: 10px; border-radius: 5px; margin-bottom: 20px; text-align: center; transition: opacity 0.5s; }
-        
-        table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
+        /* DASHBOARD BUTTON DESIGN AUS ADMIN.PHP */
+        .btn-nav { 
+            background: var(--accent); 
+            color: white; 
+            padding: 10px 15px; 
+            border-radius: 6px; 
+            text-decoration: none; 
+            font-weight: bold; 
+            display: inline-block;
+            font-size: 0.9em;
+            transition: 0.2s;
+            border: none;
+            cursor: pointer;
+        }
+        .btn-nav:hover { opacity: 0.8; transform: translateY(-1px); }
+
+        table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); }
         th, td { padding: 12px; border-bottom: 1px solid var(--border); text-align: left; }
-        th { background: var(--table-head); color: var(--accent); text-transform: uppercase; font-size: 0.85em; }
-        
-        .game-info { display: flex; align-items: center; gap: 15px; }
-        .game-info img { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); }
         
-        select { background: var(--card); color: var(--text); border: 1px solid var(--border); padding: 8px; border-radius: 4px; width: 100%; cursor: pointer; transition: 0.3s; }
-        select.besitzt { border-left: 4px solid #27ae60; }
-        select.verkauft { border-left: 4px solid #f39c12; }
-        select.nicht { border-left: 4px solid #7f8c8d; }
-        
-        .back-link { color: var(--accent); text-decoration: none; font-weight: bold; border: 1px solid var(--accent); padding: 5px 15px; border-radius: 6px; }
-        .theme-toggle { background: var(--card); border: 1px solid var(--border); color: var(--text); padding: 8px 12px; border-radius: 20px; cursor: pointer; font-size: 1.1rem; }
+        /* Status Einfärbung Logik */
+        select { padding: 5px; border-radius: 4px; border: 1px solid var(--border); background: var(--card); color: var(--text); }
+        select[data-status="besitzt"] { background: #d4edda !important; color: #155724 !important; }
+        select[data-status="nicht besitzt"] { background: #f8d7da !important; color: #721c24 !important; }
+        select[data-status="verkauft"] { background: #fff3e0 !important; color: #e67e22 !important; }
     </style>
-    <script>
-        if (localStorage.getItem('theme') === 'dark') document.documentElement.classList.add('dark-theme');
-    </script>
 </head>
 <body>
 <div class="container">
-    <header>
-        <a href="index.php" class="back-link">← Dashboard</a>
-        <div style="display: flex; align-items: center; gap: 15px;">
-            <button onclick="toggleTheme()" class="theme-toggle" id="theme-icon">🌙</button>
+    <header style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;">
+        <h1>📦 Bestand / Besitz</h1>
+        <div style="display: flex; gap: 15px; align-items: center;">
+            <button onclick="toggleTheme()" id="theme-icon" style="background:none; border:none; cursor:pointer; font-size:1.2rem;">🌙</button>
+            <a href="index.php" class="btn-nav">Dashboard</a>
         </div>
     </header>
 
-    <h1>📦 Bestandsverwaltung</h1>
-    <p style="margin-bottom: 20px; opacity: 0.7;">Wer besitzt welches Spiel?</p>
-    
-    <?php if ($msg): ?><div class="alert" id="msg-box"><?= $msg ?></div><?php endif; ?>
-
     <table>
         <thead>
             <tr>
                 <th>Spiel</th>
-                <?php foreach ($spieler as $s): ?>
-                    <th><?= htmlspecialchars($s['name']) ?></th>
-                <?php endforeach; ?>
+                <?php foreach ($spieler as $s): ?><th><?= htmlspecialchars($s['name']) ?></th><?php endforeach; ?>
             </tr>
         </thead>
         <tbody>
             <?php foreach ($spiele as $sp): ?>
             <tr>
-                <td>
-                    <div class="game-info">
-                        <img src="<?= htmlspecialchars($sp['bild_url'] ?: 'https://via.placeholder.com/40') ?>">
-                        <div>
-                            <strong><?= htmlspecialchars($sp['titel']) ?></strong><br>
-                            <small style="opacity: 0.6;"><?= htmlspecialchars($sp['typ_name']) ?></small>
-                        </div>
-                    </div>
-                </td>
+                <td><strong><?= htmlspecialchars($sp['titel']) ?></strong></td>
                 <?php foreach ($spieler as $s): 
                     $st_stmt = $pdo->prepare("SELECT status FROM besitzstatus WHERE spieler_id = ? AND spiel_id = ?");
                     $st_stmt->execute([$s['id'], $sp['id']]);
-                    $current = $st_stmt->fetchColumn() ?: 'nicht besitzt';
-                    $class = ($current == 'besitzt') ? 'besitzt' : (($current == 'verkauft') ? 'verkauft' : 'nicht');
+                    $curr = $st_stmt->fetchColumn() ?: 'nicht besitzt';
                 ?>
-                    <td>
-                        <form method="POST" style="margin:0;">
-                            <input type="hidden" name="update_status" value="1">
-                            <input type="hidden" name="spieler_id" value="<?= $s['id'] ?>">
-                            <input type="hidden" name="spiel_id" value="<?= $sp['id'] ?>">
-                            <select name="status" class="<?= $class ?>" onchange="this.form.submit()">
-                                <option value="besitzt" <?= $current == 'besitzt' ? 'selected' : '' ?>>Besitzt</option>
-                                <option value="nicht besitzt" <?= $current == 'nicht besitzt' ? 'selected' : '' ?>>Nicht</option>
-                                <option value="verkauft" <?= $current == 'verkauft' ? 'selected' : '' ?>>Verkauft</option>
-                            </select>
-                        </form>
-                    </td>
+                <td>
+                    <form method="POST">
+                        <input type="hidden" name="update_status" value="1">
+                        <input type="hidden" name="spieler_id" value="<?= $s['id'] ?>">
+                        <input type="hidden" name="spiel_id" value="<?= $sp['id'] ?>">
+                        <select name="status" onchange="this.form.submit()" data-status="<?= $curr ?>">
+                            <option value="besitzt" <?= $curr=='besitzt'?'selected':'' ?>>Besitzt</option>
+                            <option value="nicht besitzt" <?= $curr=='nicht besitzt'?'selected':'' ?>>Nicht</option>
+                            <option value="verkauft" <?= $curr=='verkauft'?'selected':'' ?>>Verkauft</option>
+                        </select>
+                    </form>
+                </td>
                 <?php endforeach; ?>
             </tr>
             <?php endforeach; ?>
@@ -123,15 +99,10 @@ $spiele = $pdo->query("SELECT s.*, t.bezeichnung as typ_name FROM spiele s LEFT
         localStorage.setItem('theme', isDark ? 'dark' : 'light');
         document.getElementById('theme-icon').innerText = isDark ? '☀️' : '🌙';
     }
-
     if (localStorage.getItem('theme') === 'dark') {
+        document.documentElement.classList.add('dark-theme');
         document.getElementById('theme-icon').innerText = '☀️';
     }
-
-    setTimeout(function() { 
-        var msg = document.getElementById('msg-box'); 
-        if(msg) msg.style.opacity = '0'; 
-    }, 2000);
 </script>
 </body>
 </html>

+ 54 - 15
gesamtliste.php

@@ -34,6 +34,7 @@ $spieler = $pdo->query("SELECT * FROM spieler ORDER BY name ASC")->fetchAll();
         :root { 
             --bg: #f8f9fa; --card: #ffffff; --text: #333; --border: #ddd; 
             --header-bg: #2c3e50; --header-text: #ffffff; --row-border: #eee;
+            --accent: #e67e22;
         }
         .dark-theme { 
             --bg: #121212; --card: #1e1e1e; --text: #e0e0e0; --border: #333; 
@@ -45,7 +46,20 @@ $spieler = $pdo->query("SELECT * FROM spieler ORDER BY name ASC")->fetchAll();
         .header-area { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
         
         .nav-group { display: flex; align-items: center; gap: 10px; }
-        .back-link { color: #e67e22; text-decoration: none; font-weight: bold; padding: 8px 15px; border: 2px solid #e67e22; border-radius: 6px; }
+        
+        .back-link { 
+            background: var(--accent); 
+            color: white !important; 
+            text-decoration: none; 
+            font-weight: bold; 
+            padding: 10px 18px; 
+            border-radius: 6px; 
+            border: none;
+            display: inline-block;
+            transition: 0.2s;
+        }
+        .back-link:hover { opacity: 0.8; transform: translateY(-1px); }
+
         .theme-toggle { background: var(--card); border: 1px solid var(--border); color: var(--text); padding: 8px 12px; border-radius: 20px; cursor: pointer; font-size: 1.1rem; }
 
         .filter-bar { background: var(--card); padding: 15px; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); display: flex; gap: 15px; margin-bottom: 20px; align-items: center; border: 1px solid var(--border); }
@@ -89,7 +103,7 @@ $spieler = $pdo->query("SELECT * FROM spieler ORDER BY name ASC")->fetchAll();
         <h1>📝 Sammlungs-Übersicht</h1>
         <div class="nav-group">
             <button onclick="toggleTheme()" class="theme-toggle" id="theme-icon">🌙</button>
-            <a href="index.php" class="back-link">← Zum Dashboard</a>
+            <a href="index.php" class="back-link">Dashboard</a>
         </div>
     </div>
 
@@ -106,11 +120,11 @@ $spieler = $pdo->query("SELECT * FROM spieler ORDER BY name ASC")->fetchAll();
     <table id="exitTable">
         <thead>
             <tr>
-                <th onclick="sortTable(0)">ID</th>
+                <th onclick="sortTable(0)">ID</th>
                 <th>Bild</th>
-                <th onclick="sortTable(2)">Titel</th>
-                <th>Level</th>
-                <th>Bestwert</th>
+                <th onclick="sortTable(2)">Titel</th>
+                <th onclick="sortTable(3)">Level</th>
+                <th onclick="sortTable(4)">Bestwert</th>
                 <th>Besitzstatus</th>
             </tr>
         </thead>
@@ -197,18 +211,43 @@ $spieler = $pdo->query("SELECT * FROM spieler ORDER BY name ASC")->fetchAll();
     }
 
     function sortTable(n) {
-        var table = document.getElementById("exitTable"), rows, switching = true, i, x, y, should, dir = "asc", cnt = 0;
+        var table = document.getElementById("exitTable");
+        var rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0;
+        switching = true;
+        dir = "asc"; 
         while (switching) {
-            switching = false; rows = table.rows;
+            switching = false;
+            rows = table.rows;
             for (i = 1; i < (rows.length - 1); i++) {
-                should = false; x = rows[i].getElementsByTagName("TD")[n]; y = rows[i + 1].getElementsByTagName("TD")[n];
-                let valX = x.innerText.toLowerCase(); let valY = y.innerText.toLowerCase();
-                if (n === 0) { valX = parseInt(valX.replace('#','')); valY = parseInt(valY.replace('#','')); }
-                if (dir == "asc") { if (valX > valY) { should = true; break; } }
-                else { if (valX < valY) { should = true; break; } }
+                shouldSwitch = false;
+                x = rows[i].getElementsByTagName("TD")[n];
+                y = rows[i + 1].getElementsByTagName("TD")[n];
+                
+                let valX = x.innerText.toLowerCase().trim();
+                let valY = y.innerText.toLowerCase().trim();
+
+                // Spezielle Logik für ID (Zahlen)
+                if (n === 0) {
+                    valX = parseInt(valX.replace('#', '')) || 0;
+                    valY = parseInt(valY.replace('#', '')) || 0;
+                }
+
+                if (dir == "asc") {
+                    if (valX > valY) { shouldSwitch = true; break; }
+                } else if (dir == "desc") {
+                    if (valX < valY) { shouldSwitch = true; break; }
+                }
+            }
+            if (shouldSwitch) {
+                rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
+                switching = true;
+                switchcount ++;      
+            } else {
+                if (switchcount == 0 && dir == "asc") {
+                    dir = "desc";
+                    switching = true;
+                }
             }
-            if (should) { rows[i].parentNode.insertBefore(rows[i + 1], rows[i]); switching = true; cnt++; }
-            else if (cnt == 0 && dir == "asc") { dir = "desc"; switching = true; }
         }
     }
 </script>