LuminaWebsite/bugs.php
Maaxxs 5dabbccbd7 Gear planner, dashboard polish, images on bug reports
Gear planner:
- Personal gear sets (18 slots) with enchant, exceed, soul imprint and manastones,
  stat totals by source and side-by-side comparison of 2-4 sets
- Sets can be shown on the own profile page (read-only for other members)
- Admin catalog: import items from aion2hub.com (Global client), compare stored
  values with the source one by one or all at once, at most one request per second
- New permissions gear.view (all with dashboard access) and gear.manage

Dashboard:
- Role badges ordered like the member list (roster_order)
- Stronger hover effect on "Rangliste & Verlauf" / "Zum Lumishop", no more blue
  hover on secondary buttons
- "Anstehende Raids" box links to the raids page, next raids link to the raid
  and to the calendar day
- Raid attendance only knows present/absent (old "excused" entries count as unset)

Bug reports:
- Up to 5 images per report, pasting copied images with Ctrl+V (also for the gallery)
- Images are only served to the reporter and bugs.manage via bug_image.php

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 09:27:09 +02:00

151 lines
7.5 KiB
PHP

<?php
require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/bugs.php';
require_permission('bugs.manage');
// Standard: alles, was noch zu tun ist (offen + in Arbeit).
$filters = [
'todo' => ['Zu erledigen', "b.status IN ('open', 'in_progress')"],
'open' => ['Offen', "b.status = 'open'"],
'in_progress' => ['In Arbeit', "b.status = 'in_progress'"],
'done' => ['Behoben', "b.status = 'done'"],
'rejected' => ['Abgelehnt', "b.status = 'rejected'"],
'all' => ['Alle', '1 = 1'],
];
$filter = (string) ($_GET['status'] ?? 'todo');
if (!array_key_exists($filter, $filters)) {
$filter = 'todo';
}
$counts = db()->query('SELECT status, COUNT(*) FROM bug_reports GROUP BY status')->fetchAll(PDO::FETCH_KEY_PAIR);
$counts = array_map('intval', $counts);
$countFor = static function (string $key) use ($counts): int {
return match ($key) {
'todo' => ($counts['open'] ?? 0) + ($counts['in_progress'] ?? 0),
'all' => array_sum($counts),
default => $counts[$key] ?? 0,
};
};
$bugs = db()->query(
"SELECT b.*, u.username, u.display_name, u.discord_id, u.avatar_filename,
h.username AS handler_username, h.display_name AS handler_display_name
FROM bug_reports b
LEFT JOIN users u ON u.id = b.user_id
LEFT JOIN users h ON h.id = b.handled_by
WHERE {$filters[$filter][1]}
ORDER BY FIELD(b.status, 'open', 'in_progress', 'done', 'rejected'), b.created_at DESC"
)->fetchAll();
$bugImages = bug_images_for(array_column($bugs, 'id'));
$pageTitle = 'Fehlermeldungen';
include __DIR__ . '/includes/header.php';
?>
<div class="panel panel-filter-bar">
<div class="raid-header">
<h1>Fehlermeldungen</h1>
</div>
<p class="text-muted">Bugs, die Mitglieder im Dashboard gemeldet haben. Status und Antwort sieht der Melder in seinem Dashboard unter „Meine Meldungen“.</p>
<div class="filter-tabs">
<?php foreach ($filters as $key => [$label]): ?>
<a href="/bugs.php?status=<?= e($key) ?>" class="filter-tab<?= $filter === $key ? ' active' : '' ?>">
<?= e($label) ?> <span class="filter-tab-count"><?= $countFor($key) ?></span>
</a>
<?php endforeach; ?>
</div>
</div>
<?php if (empty($bugs)): ?>
<div class="panel">
<p class="text-muted">Hier gibt es gerade nichts - keine Fehlermeldungen in dieser Ansicht.</p>
</div>
<?php else: ?>
<div class="report-list">
<?php foreach ($bugs as $bug): ?>
<?php
$reporterName = $bug['user_id'] === null
? 'Gelöschtes Konto'
: ($bug['display_name'] !== '' ? $bug['display_name'] : $bug['username']);
$reporter = $bug['user_id'] === null ? null : [
'id' => $bug['user_id'], 'username' => $bug['username'], 'display_name' => $bug['display_name'],
'discord_id' => $bug['discord_id'], 'avatar_filename' => $bug['avatar_filename'],
];
$handlerName = $bug['handler_username'] !== null
? ($bug['handler_display_name'] !== '' ? $bug['handler_display_name'] : $bug['handler_username'])
: null;
?>
<div class="report-card bug-card bug-card-<?= e($bug['status']) ?>" id="bug-<?= (int) $bug['id'] ?>">
<div class="report-card-main">
<div class="report-card-user">
<?php if ($reporter): ?>
<?= avatar_html($reporter, 40) ?>
<?php endif; ?>
<div class="report-card-user-info">
<strong><?= e($bug['title']) ?></strong>
<span class="text-muted">
<?= e(bug_area_label($bug['area'])) ?> · von <?= e($reporterName) ?> · <?= e(date('d.m.Y H:i', strtotime($bug['created_at']))) ?>
</span>
</div>
</div>
<div class="report-card-badges">
<?= bug_status_badge($bug['status']) ?>
</div>
</div>
<div class="report-card-body">
<div class="report-reason-text"><?= e($bug['description']) ?></div>
<?= bug_images_html($bugImages[(int) $bug['id']] ?? [], (int) $bug['id']) ?>
<?php if (!empty($bug['screenshot_url'])): ?>
<div class="report-evidence">
<?= icon('link') ?>
<a href="<?= e($bug['screenshot_url']) ?>" target="_blank" rel="noopener noreferrer">Screenshot ansehen</a>
</div>
<?php endif; ?>
<?php if (!empty($bug['user_agent'])): ?>
<div class="report-evidence" title="Browser / Gerät des Melders">
<?= icon('hash') ?>
<span class="report-evidence-text"><?= e($bug['user_agent']) ?></span>
</div>
<?php endif; ?>
</div>
<form method="post" action="/bug_action.php" class="bug-manage-form">
<?= csrf_field() ?>
<input type="hidden" name="action" value="update">
<input type="hidden" name="id" value="<?= (int) $bug['id'] ?>">
<input type="hidden" name="filter" value="<?= e($filter) ?>">
<div class="bug-manage-row">
<select name="status" aria-label="Status">
<?php foreach (BUG_STATUSES as $key => [$label]): ?>
<option value="<?= e($key) ?>"<?= $bug['status'] === $key ? ' selected' : '' ?>><?= e($label) ?></option>
<?php endforeach; ?>
</select>
<input type="text" name="admin_note" maxlength="5000"
placeholder="Antwort an den Melder (optional)"
value="<?= e((string) ($bug['admin_note'] ?? '')) ?>">
<button type="submit" class="button-small">Speichern</button>
</div>
</form>
<div class="report-card-footer">
<span class="text-muted">
<?php if ($handlerName !== null && $bug['updated_at'] !== null): ?>
Zuletzt bearbeitet von <?= e($handlerName) ?> am <?= e(date('d.m.Y H:i', strtotime($bug['updated_at']))) ?>
<?php else: ?>
Noch nicht bearbeitet
<?php endif; ?>
</span>
<form method="post" action="/bug_action.php" class="inline-form" onsubmit="return confirm('Diese Fehlermeldung wirklich endgültig löschen?');">
<?= csrf_field() ?>
<input type="hidden" name="action" value="delete">
<input type="hidden" name="id" value="<?= (int) $bug['id'] ?>">
<input type="hidden" name="filter" value="<?= e($filter) ?>">
<button type="submit" class="icon-button icon-button-danger" title="Löschen"><?= icon('trash') ?></button>
</form>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
<script src="<?= e(asset_url('/assets/js/lightbox.js')) ?>" defer></script>
<?php include __DIR__ . '/includes/footer.php'; ?>