Uses the bot's new ?status= query param on /api/raids. fetch_raids() takes a status argument (whitelisted against active/archived/all, falls back to active on anything else) and appends it to the request URL. Archived raids get a dimmed card style and an "Archiviert" badge using the new archived/archived_at fields. Verified all three filters end-to-end against the live API. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
119 lines
4.6 KiB
PHP
119 lines
4.6 KiB
PHP
<?php
|
|
require_once __DIR__ . '/includes/bootstrap.php';
|
|
require_once __DIR__ . '/includes/raids_api.php';
|
|
require_permission('raids.view');
|
|
|
|
$status = (string) ($_GET['status'] ?? 'active');
|
|
if (!in_array($status, RAID_STATUSES, true)) {
|
|
$status = 'active';
|
|
}
|
|
|
|
$raids = [];
|
|
$apiError = null;
|
|
|
|
try {
|
|
$raids = fetch_raids($status);
|
|
} catch (Throwable $e) {
|
|
$apiError = $e->getMessage();
|
|
}
|
|
|
|
$statusLabels = [
|
|
'active' => 'Aktiv',
|
|
'archived' => 'Archiviert',
|
|
'all' => 'Alle',
|
|
];
|
|
$emptyLabels = [
|
|
'active' => 'Aktuell sind keine aktiven Raids geplant.',
|
|
'archived' => 'Es sind keine archivierten Raids vorhanden.',
|
|
'all' => 'Aktuell sind keine Raids vorhanden.',
|
|
];
|
|
|
|
$pageTitle = 'Raids';
|
|
include __DIR__ . '/includes/header.php';
|
|
?>
|
|
<div class="panel">
|
|
<h1>Raids</h1>
|
|
<p class="text-muted">Raid-Termine deiner Gilde.</p>
|
|
<div class="filter-tabs">
|
|
<?php foreach ($statusLabels as $value => $label): ?>
|
|
<a href="/raids.php?status=<?= e($value) ?>" class="filter-tab<?= $status === $value ? ' active' : '' ?>"><?= e($label) ?></a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<?php if ($apiError): ?>
|
|
<div class="panel">
|
|
<div class="flash flash-error">Raid-Daten konnten nicht geladen werden: <?= e($apiError) ?></div>
|
|
</div>
|
|
<?php elseif (empty($raids)): ?>
|
|
<div class="panel">
|
|
<p class="text-muted"><?= e($emptyLabels[$status]) ?></p>
|
|
</div>
|
|
<?php else: ?>
|
|
<?php foreach ($raids as $raid): ?>
|
|
<?php
|
|
$title = (string) ($raid['title'] ?? 'Raid');
|
|
$dateLabel = (string) ($raid['date'] ?? '');
|
|
if (!empty($raid['timestamp'])) {
|
|
$dateLabel = date('d.m.Y H:i', (int) $raid['timestamp']) . ' Uhr';
|
|
}
|
|
$requirements = trim((string) ($raid['requirements'] ?? ''));
|
|
$gearscore = trim((string) ($raid['gearscore'] ?? ''));
|
|
$maxSlots = (int) ($raid['max_slots'] ?? 0);
|
|
$signups = is_array($raid['signups'] ?? null) ? $raid['signups'] : [];
|
|
$isArchived = !empty($raid['archived']) || !empty($raid['archived_at']);
|
|
$archivedAt = $raid['archived_at'] ?? null;
|
|
|
|
$groupNames = array_values(array_filter(array_map('trim', explode(',', (string) ($raid['groups'] ?? '')))));
|
|
|
|
$signupsByGroup = [];
|
|
foreach ($signups as $signup) {
|
|
$groupNumber = (int) ($signup['group'] ?? 0);
|
|
$signupsByGroup[$groupNumber][] = $signup;
|
|
}
|
|
?>
|
|
<div class="panel<?= $isArchived ? ' panel-archived' : '' ?>">
|
|
<div class="raid-header">
|
|
<h2><?= e($title) ?></h2>
|
|
<div class="badge-group">
|
|
<?php if ($isArchived): ?>
|
|
<span class="badge badge-disabled">Archiviert<?= $archivedAt ? ' (' . e((string) $archivedAt) . ')' : '' ?></span>
|
|
<?php endif; ?>
|
|
<span class="badge"><?= count($signups) ?> / <?= $maxSlots ?> angemeldet</span>
|
|
</div>
|
|
</div>
|
|
<p class="text-muted"><?= e($dateLabel) ?></p>
|
|
<?php if ($requirements !== ''): ?>
|
|
<p><strong>Anforderungen:</strong> <?= e($requirements) ?></p>
|
|
<?php endif; ?>
|
|
<?php if ($gearscore !== ''): ?>
|
|
<p><strong>Gearscore:</strong> <?= e($gearscore) ?></p>
|
|
<?php endif; ?>
|
|
|
|
<?php if (!empty($groupNames)): ?>
|
|
<div class="raid-groups">
|
|
<?php foreach ($groupNames as $index => $groupName): ?>
|
|
<?php $members = $signupsByGroup[$index + 1] ?? []; ?>
|
|
<div class="raid-group">
|
|
<h3><?= e($groupName) ?></h3>
|
|
<?php if (empty($members)): ?>
|
|
<p class="text-muted">Keine Anmeldungen</p>
|
|
<?php else: ?>
|
|
<ul>
|
|
<?php foreach ($members as $member): ?>
|
|
<li>
|
|
<?= e((string) ($member['name'] ?? '?')) ?>
|
|
<span class="text-muted">(<?= e((string) ($member['class'] ?? '')) ?>)</span>
|
|
</li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
|
|
<?php include __DIR__ . '/includes/footer.php'; ?>
|