A new page records items handed in (item, quantity, when, and from whom - a website account or a free-text name) and taken out (when, now or entered by hand, and optionally to whom). Stock is always computed from the movements, withdrawals can't exceed it, and a deposit can only be deleted once nothing of it has been taken out. Stock is shown as cards with the item picture and quantity, name and category below, plus search and a category filter; the history lists every movement with who entered it. The item list holds 2,301 weapons, armor pieces, accessories and consumables read from the Aion 2 wiki's MediaWiki API, with each item's icon downscaled to 128px under assets/images/warehouse/. It is loaded into the database on first visit and again whenever the JSON changes. Unknown names can be added as custom items after a confirmation, since the wiki lists no materials. warehouse.view and warehouse.manage are new permissions. Missing core permissions are now created automatically and granted to the Administrator group, and the two tables are created like the other schema additions. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
195 lines
10 KiB
PHP
195 lines
10 KiB
PHP
<?php
|
|
/** @var string|null $pageTitle */
|
|
$currentUser = current_user();
|
|
// Den Mitgliederbereich (Seitenleiste) bekommen nur freigeschaltete Konten - wer noch auf
|
|
// die Freischaltung wartet, sieht das schlichte Layout wie auf der Login-Seite.
|
|
$shellUser = ($currentUser && $currentUser['status'] === 'active') ? $currentUser : null;
|
|
$canViewUsers = $currentUser && user_has_permission('users.view');
|
|
$canManageRoles = $currentUser && user_has_permission('roles.manage');
|
|
$canViewRaids = $currentUser && user_has_permission('raids.view');
|
|
$canViewPremades = $currentUser && user_has_permission('premades.view');
|
|
$canViewEvents = $currentUser && user_has_permission('events.view');
|
|
$canViewMap = $currentUser && user_has_permission('map.view');
|
|
$canViewWarehouse = $currentUser && user_has_permission('warehouse.view');
|
|
$canViewMembers = $currentUser && user_has_permission('members.view');
|
|
$canViewReports = $currentUser && user_has_permission('reports.view');
|
|
$showAdminMenu = $canViewUsers || $canManageRoles || $canViewReports;
|
|
// Neue Discord-Anmeldungen, die auf Freischaltung warten - als Zahl am Menuepunkt.
|
|
$pendingUserCount = $canViewUsers
|
|
? (int) db()->query("SELECT COUNT(*) FROM users WHERE status = 'pending'")->fetchColumn()
|
|
: 0;
|
|
|
|
$currentScript = basename((string) ($_SERVER['SCRIPT_NAME'] ?? ''));
|
|
$isDashboardActive = $currentScript === 'dashboard.php';
|
|
$isProfileActive = $currentScript === 'profile.php';
|
|
$isRaidsActive = $currentScript === 'raids.php';
|
|
$isPremadesActive = $currentScript === 'premades.php';
|
|
$isEventsActive = $currentScript === 'events.php';
|
|
$isMapActive = $currentScript === 'map.php';
|
|
$isWarehouseActive = $currentScript === 'warehouse.php';
|
|
$isMembersActive = $currentScript === 'members.php';
|
|
$isReportsActive = $currentScript === 'reports.php';
|
|
$isUsersActive = in_array($currentScript, ['users.php', 'user_form.php', 'user_delete.php', 'user_approve.php'], true);
|
|
$isRolesActive = in_array($currentScript, ['roles.php', 'role_form.php', 'role_delete.php'], true);
|
|
|
|
// Jeder Bereich bekommt ein eigenes, dezentes Hintergrundbild.
|
|
$pageBackgrounds = [
|
|
'dashboard.php' => 'bg-dashboard',
|
|
'profile.php' => 'bg-profile',
|
|
'raids.php' => 'bg-raids',
|
|
'premades.php' => 'bg-premades',
|
|
'events.php' => 'bg-events',
|
|
'map.php' => 'bg-map',
|
|
'warehouse.php' => 'bg-warehouse',
|
|
'members.php' => 'bg-members',
|
|
'users.php' => 'bg-admin',
|
|
'user_form.php' => 'bg-admin',
|
|
'user_delete.php' => 'bg-admin',
|
|
'roles.php' => 'bg-roles',
|
|
'role_form.php' => 'bg-roles',
|
|
'role_delete.php' => 'bg-roles',
|
|
'reports.php' => 'bg-reports',
|
|
];
|
|
$pageBackgroundClass = $pageBackgrounds[$currentScript] ?? '';
|
|
|
|
// Erfolgsmeldungen ("Bestätigungen") bekommen ein zentriertes Popup mit Haken-Animation statt
|
|
// des Balkens oben - andere Meldungstypen (z.B. Fehler) bleiben als Balken, da die dort meist
|
|
// wichtige Details/Handlungsaufforderungen stehen, die man nicht nur kurz einblenden will.
|
|
$allFlashes = get_flashes();
|
|
$successFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($f['type'] ?? '') === 'success'));
|
|
$otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($f['type'] ?? '') !== 'success'));
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta name="csrf-token" content="<?= e(csrf_token()) ?>">
|
|
<title><?= e(($pageTitle ?? '') !== '' ? $pageTitle . ' - Lumina Ascendens' : 'Lumina Ascendens') ?></title>
|
|
<link rel="icon" type="image/x-icon" href="/assets/images/favicon.ico">
|
|
<link rel="icon" type="image/png" sizes="16x16" href="/assets/images/favicon-16.png">
|
|
<link rel="icon" type="image/png" sizes="32x32" href="/assets/images/favicon-32.png">
|
|
<link rel="icon" type="image/png" sizes="48x48" href="/assets/images/favicon-48.png">
|
|
<link rel="apple-touch-icon" href="/assets/images/apple-touch-icon.png">
|
|
<link rel="stylesheet" href="/assets/css/style.css">
|
|
</head>
|
|
<body<?= $shellUser ? '' : ' class="guest-bg"' ?>>
|
|
<?php if (!empty($successFlashes)): ?>
|
|
<div class="success-popup-overlay" id="success-popup" role="status" title="Klicken zum Schließen">
|
|
<div class="success-popup">
|
|
<svg class="success-check" viewBox="0 0 52 52" aria-hidden="true">
|
|
<circle class="success-check-circle" cx="26" cy="26" r="24" fill="none"/>
|
|
<path class="success-check-mark" fill="none" d="M14 27l7 7 16-16"/>
|
|
</svg>
|
|
<?php foreach ($successFlashes as $flash): ?>
|
|
<p><?= e($flash['message']) ?></p>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
<script src="/assets/js/success-popup.js"></script>
|
|
<?php endif; ?>
|
|
<?php if ($shellUser): ?>
|
|
<div class="app-shell">
|
|
<div class="mobile-topbar">
|
|
<button type="button" class="sidebar-toggle" aria-label="Menü öffnen" aria-expanded="false">
|
|
<?= icon('menu') ?>
|
|
</button>
|
|
<a href="/" class="mobile-topbar-brand"><img src="/assets/images/logo-mark.svg" alt="Lumina Ascendens"></a>
|
|
</div>
|
|
<div class="sidebar-backdrop"></div>
|
|
<aside class="sidebar">
|
|
<div class="sidebar-brand"><a href="/"><img src="/assets/images/logo-mark.svg" alt="Lumina Ascendens"></a></div>
|
|
<nav class="sidebar-nav">
|
|
<a href="/dashboard.php" class="sidebar-link<?= $isDashboardActive ? ' active' : '' ?>" title="Dashboard">
|
|
<?= icon('home') ?><span class="label">Dashboard</span>
|
|
</a>
|
|
<a href="/profile.php" class="sidebar-link<?= $isProfileActive ? ' active' : '' ?>" title="Mein Profil">
|
|
<?= icon('profile') ?><span class="label">Mein Profil</span>
|
|
</a>
|
|
<?php if ($canViewMembers): ?>
|
|
<a href="/members.php" class="sidebar-link<?= $isMembersActive ? ' active' : '' ?>" title="Mitglieder">
|
|
<?= icon('users') ?><span class="label">Mitglieder</span>
|
|
</a>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($canViewRaids || $canViewPremades || $canViewEvents || $canViewMap || $canViewWarehouse): ?>
|
|
<div class="sidebar-nav-gap"></div>
|
|
<?php endif; ?>
|
|
<?php if ($canViewRaids): ?>
|
|
<a href="/raids.php" class="sidebar-link<?= $isRaidsActive ? ' active' : '' ?>" title="Raids">
|
|
<?= icon('calendar') ?><span class="label">Raids</span>
|
|
</a>
|
|
<?php endif; ?>
|
|
<?php if ($canViewPremades): ?>
|
|
<a href="/premades.php" class="sidebar-link<?= $isPremadesActive ? ' active' : '' ?>" title="Premades">
|
|
<?= icon('shield') ?><span class="label">Premades</span>
|
|
</a>
|
|
<?php endif; ?>
|
|
<?php if ($canViewEvents): ?>
|
|
<a href="/events.php" class="sidebar-link<?= $isEventsActive ? ' active' : '' ?>" title="Events">
|
|
<?= icon('bell') ?><span class="label">Events</span>
|
|
</a>
|
|
<?php endif; ?>
|
|
<?php if ($canViewMap): ?>
|
|
<a href="/map.php" class="sidebar-link<?= $isMapActive ? ' active' : '' ?>" title="Karte">
|
|
<?= icon('map') ?><span class="label">Karte</span>
|
|
</a>
|
|
<?php endif; ?>
|
|
<?php if ($canViewWarehouse): ?>
|
|
<a href="/warehouse.php" class="sidebar-link<?= $isWarehouseActive ? ' active' : '' ?>" title="Lagerhaus">
|
|
<?= icon('box') ?><span class="label">Lagerhaus</span>
|
|
</a>
|
|
<?php endif; ?>
|
|
<?php if ($showAdminMenu): ?>
|
|
<div class="sidebar-section-label">Admin</div>
|
|
<?php if ($canViewUsers): ?>
|
|
<a href="/admin/users.php" class="sidebar-link<?= $isUsersActive ? ' active' : '' ?>" title="Benutzerverwaltung">
|
|
<?= icon('users') ?><span class="label">Benutzerverwaltung</span>
|
|
<?php if ($pendingUserCount > 0): ?>
|
|
<span class="sidebar-badge" title="Warten auf Freischaltung"><?= $pendingUserCount ?></span>
|
|
<?php endif; ?>
|
|
</a>
|
|
<?php endif; ?>
|
|
<?php if ($canManageRoles): ?>
|
|
<a href="/admin/roles.php" class="sidebar-link<?= $isRolesActive ? ' active' : '' ?>" title="Berechtigungsgruppen">
|
|
<?= icon('shield') ?><span class="label">Berechtigungsgruppen</span>
|
|
</a>
|
|
<?php endif; ?>
|
|
<?php if ($canViewReports): ?>
|
|
<a href="/reports.php" class="sidebar-link<?= $isReportsActive ? ' active' : '' ?>" title="Reports">
|
|
<?= icon('flag') ?><span class="label">Reports</span>
|
|
</a>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
</nav>
|
|
<div class="sidebar-footer">
|
|
<div class="sidebar-user">
|
|
<?= avatar_html($currentUser, 36) ?>
|
|
<div>Angemeldet als<br><strong><?= e($currentUser['display_name'] !== '' ? $currentUser['display_name'] : $currentUser['username']) ?></strong></div>
|
|
</div>
|
|
<a href="/logout.php" class="sidebar-link" title="Abmelden">
|
|
<?= icon('log-out') ?><span class="label">Abmelden</span>
|
|
</a>
|
|
</div>
|
|
</aside>
|
|
<div class="app-content<?= $pageBackgroundClass ? ' ' . e($pageBackgroundClass) : '' ?>">
|
|
<main class="container<?= !empty($containerWide) ? ' container-wide' : '' ?>">
|
|
<?php foreach ($otherFlashes as $flash): ?>
|
|
<div class="flash flash-<?= e($flash['type']) ?>"><?= e($flash['message']) ?></div>
|
|
<?php endforeach; ?>
|
|
<?php else: ?>
|
|
<header class="navbar">
|
|
<div class="navbar-brand"><a href="/"><img src="/assets/images/logo-mark.svg" alt="Lumina Ascendens"></a></div>
|
|
<div class="navbar-user">
|
|
<?php if ($currentUser): ?>
|
|
<a href="/logout.php">Abmelden</a>
|
|
<?php else: ?>
|
|
<a href="/login.php">Login</a>
|
|
<?php endif; ?>
|
|
</div>
|
|
</header>
|
|
<main class="container">
|
|
<?php foreach ($otherFlashes as $flash): ?>
|
|
<div class="flash flash-<?= e($flash['type']) ?>"><?= e($flash['message']) ?></div>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|