v1.3.1 - siehe Release Notes
This commit is contained in:
59
colors.php
59
colors.php
@@ -1,10 +1,5 @@
|
||||
<?php
|
||||
session_start();
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header("Location: login.php");
|
||||
exit();
|
||||
}
|
||||
|
||||
include('inc/check_login.php');
|
||||
require_once 'inc/db.php';
|
||||
|
||||
$is_admin = ($_SESSION['role'] === 'admin');
|
||||
@@ -80,6 +75,18 @@ if ($is_admin && $_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
}
|
||||
}
|
||||
|
||||
// --- Sortierung mit Richtung (asc/desc) ---
|
||||
$sort = $_GET['sort'] ?? 'name';
|
||||
$dir = $_GET['dir'] ?? 'asc';
|
||||
$sort = in_array($sort, ['name', 'usage']) ? $sort : 'name';
|
||||
$dir = in_array($dir, ['asc', 'desc']) ? $dir : 'asc';
|
||||
|
||||
if ($sort === 'usage') {
|
||||
$order_by = "usage_count $dir, c.name ASC";
|
||||
} else {
|
||||
$order_by = "c.name $dir";
|
||||
}
|
||||
|
||||
// --- Farben mit Nutzungszähler laden ---
|
||||
$colors = [];
|
||||
$result = mysqli_query($conn, "
|
||||
@@ -92,7 +99,7 @@ $result = mysqli_query($conn, "
|
||||
FROM colors c
|
||||
LEFT JOIN meetings m ON c.id = m.color_id
|
||||
GROUP BY c.id, c.name, c.hex_code, c.is_special
|
||||
ORDER BY c.name
|
||||
ORDER BY $order_by
|
||||
");
|
||||
while ($row = mysqli_fetch_assoc($result)) {
|
||||
$colors[] = $row;
|
||||
@@ -174,27 +181,49 @@ require_once 'inc/header.php';
|
||||
<table class="table table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Farbe</th>
|
||||
<th>Anz</th>
|
||||
<th>
|
||||
<?php
|
||||
$name_dir = ($sort === 'name' && $dir === 'asc') ? 'desc' : 'asc';
|
||||
$name_arrow = '';
|
||||
if ($sort === 'name') {
|
||||
$name_arrow = $dir === 'asc' ? 'arrow_upward' : 'arrow_downward';
|
||||
}
|
||||
?>
|
||||
<a href="?sort=name&dir=<?= $name_dir ?>" class="link-secondary text-decoration-none">
|
||||
Name <?php if ($name_arrow): ?><span class="material-symbols-outlined" style="font-size:1em;"><?= $name_arrow ?></span><?php endif; ?>
|
||||
</a>
|
||||
</th>
|
||||
<th>
|
||||
<?php
|
||||
$usage_dir = ($sort === 'usage' && $dir === 'asc') ? 'desc' : 'asc';
|
||||
$usage_arrow = '';
|
||||
if ($sort === 'usage') {
|
||||
$usage_arrow = $dir === 'asc' ? 'arrow_upward' : 'arrow_downward';
|
||||
}
|
||||
?>
|
||||
<a href="?sort=usage&dir=<?= $usage_dir ?>" class="link-secondary text-decoration-none">
|
||||
Anzahl <?php if ($usage_arrow): ?><span class="material-symbols-outlined" style="font-size:1em;"><?= $usage_arrow ?></span><?php endif; ?>
|
||||
</a>
|
||||
</th>
|
||||
<?php if ($is_admin): ?>
|
||||
<th>Aktionen</th>
|
||||
<th></th>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($colors as $color): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<td class="align-middle">
|
||||
<div style="background-color: <?= htmlspecialchars($color['hex_code']); ?>; width: 40px; height: 20px; border: 1px solid #ccc;"></div>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= htmlspecialchars($color['name']); ?>
|
||||
<?php if ($color['is_special']): ?>
|
||||
<span class="badge bg-info ms-1" title="Sonderfarbe – nicht im Zufallsmodus">★</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<div style="background-color: <?= htmlspecialchars($color['hex_code']); ?>; width: 40px; height: 20px; border: 1px solid #ccc;"></div>
|
||||
</td>
|
||||
<td>
|
||||
<td class="align-middle">
|
||||
<?= (int)$color['usage_count']; ?>
|
||||
</td>
|
||||
<?php if ($is_admin): ?>
|
||||
|
||||
Reference in New Issue
Block a user