v1.0.0.1
StocketBase
- <?php
-
- declare(strict_types=1);
-
- require_once __DIR__ . '/icons.php';
- require_once __DIR__ . '/asset.php';
- require_once __DIR__ . '/font-library.php';
- require_once __DIR__ . '/activity-log.php';
-
- $dashAvailableFonts = FontLibrary::available();
-
- $dashSiteName = Config::get('APP_NAME', 'StocketBase');
- $dashCurrentUser = Auth::user();
- $dashCurrentRole = Auth::role();
- $dashIsAdmin = Auth::hasRoleAtLeast(Auth::ROLE_STORE_OWNER);
- $dashIsManager = Auth::hasRoleAtLeast(Auth::ROLE_STORE_MANAGER);
- require_once __DIR__ . '/avatar.php';
- require_once __DIR__ . '/status-label.php';
-
- ?>
- <!DOCTYPE html>
- <html lang="en">
-
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
- <title><?= htmlspecialchars($dashPageTitle ?? 'Dashboard') ?> - <?= htmlspecialchars($dashSiteName) ?></title>
- <?= Asset::favicon() ?>
- <?= Asset::css('assets/dashboard.css') ?>
- <style>
- <?php foreach ($dashAvailableFonts as $dashFont): ?>
- <?= FontLibrary::fontFaceCss($dashFont['display_name'], $dashFont['display_name']) ?>
- <?php endforeach; ?>
- </style>
- </head>
-
- <body data-theme="dark">
- <script>
- (function() {
- try {
- var t = localStorage.getItem('stocketbase_dashboard_theme');
- if (t === 'dark' || t === 'light') {
- document.body.setAttribute('data-theme', t);
- } else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) {
- document.body.setAttribute('data-theme', 'light');
- }
- } catch (e) {}
- })();
- </script>
- <script>
- (function() {
- try {
- var minimal = localStorage.getItem('stocketbase_dashboard_minimal') === '1';
- if (minimal) {
- document.body.classList.add('dash-minimal');
- }
- if (minimal || localStorage.getItem('stocketbase_dashboard_glass') === '0') {
- document.body.classList.add('dash-no-glass');
- }
- } catch (e) {}
- })();
- </script>
- <script>
- (function() {
- try {
- var validScales = [80, 90, 100, 110, 120, 130, 140, 150];
- var sidebarScale = parseInt(localStorage.getItem('stocketbase_dashboard_sidebar_scale'), 10);
- var mainScale = parseInt(localStorage.getItem('stocketbase_dashboard_main_scale'), 10);
- if (validScales.indexOf(sidebarScale) === -1) {
- sidebarScale = 100;
- }
- if (validScales.indexOf(mainScale) === -1) {
- mainScale = 100;
- }
- if (sidebarScale !== 100 || mainScale !== 100) {
- var style = document.createElement('style');
- var rules = '';
- if (sidebarScale !== 100) {
- rules += '.dash-sidebar{zoom:' + (sidebarScale / 100) + ';}';
- }
- if (mainScale !== 100) {
- rules += '.dash-main{zoom:' + (mainScale / 100) + ';}';
- }
- style.textContent = rules;
- document.head.appendChild(style);
- }
- } catch (e) {}
- })();
- </script>
- <?= Icons::sprite() ?>
-
- <div class="dash-mobile-topbar">
- <div class="dash-brand"><span class="dash-brand-dot"></span><?= htmlspecialchars($dashSiteName) ?></div>
- <div class="dash-mobile-topbar-right">
- <button type="button" class="dash-theme-toggle" aria-label="Switch between light and dark">
- <?= Icons::icon('sun', 'icon icon-sm icon-sun') ?>
- <?= Icons::icon('moon', 'icon icon-sm icon-moon') ?>
- </button>
- <?= Avatar::html($dashCurrentUser, 'dash-user-avatar') ?>
- </div>
- </div>
-
- <div class="dash-shell">
- <aside class="dash-sidebar">
-
- <div class="dash-brand-row">
- <div class="dash-brand"><span class="dash-brand-dot"></span><?= htmlspecialchars($dashSiteName) ?></div>
- <button type="button" class="dash-theme-toggle" id="dash-theme-toggle-btn" aria-label="Switch between light and dark">
- <?= Icons::icon('sun', 'icon icon-sm icon-sun') ?>
- <?= Icons::icon('moon', 'icon icon-sm icon-moon') ?>
- </button>
- </div>
-
- <nav class="dash-nav">
- <a href="dashboard.php?view=overview" class="<?= ($dashView ?? '') === 'overview' ? 'active' : '' ?>"><?= Icons::icon('overview') ?>Overview</a>
- <a href="dashboard.php?view=products" class="<?= in_array($dashView ?? '', ['products', 'product-edit'], true) ? 'active' : '' ?>"><?= Icons::icon('grid') ?>Products</a>
- <a href="dashboard.php?view=categories" class="<?= ($dashView ?? '') === 'categories' ? 'active' : '' ?>"><?= Icons::icon('categories') ?>Categories</a>
- <?php if ($dashIsManager): ?>
- <a href="dashboard.php?view=orders" class="<?= in_array($dashView ?? '', ['orders', 'order-detail'], true) ? 'active' : '' ?>"><?= Icons::icon('checklist') ?>Orders</a>
- <a href="dashboard.php?view=customers" class="<?= in_array($dashView ?? '', ['customers', 'customer-detail'], true) ? 'active' : '' ?>"><?= Icons::icon('users') ?>Customers</a>
- <a href="dashboard.php?view=discounts" class="<?= ($dashView ?? '') === 'discounts' ? 'active' : '' ?>"><?= Icons::icon('tag') ?>Discounts</a>
- <a href="dashboard.php?view=reviews" class="<?= ($dashView ?? '') === 'reviews' ? 'active' : '' ?>"><?= Icons::icon('star') ?>Reviews</a>
- <a href="files.php" class="<?= ($dashActivePage ?? '') === 'files' ? 'active' : '' ?>"><?= Icons::icon('download') ?>Files</a>
- <?php endif; ?>
- <a href="dashboard.php?view=pages" class="<?= ($dashView ?? '') === 'pages' ? 'active' : '' ?>"><?= Icons::icon('pages') ?>Pages</a>
- <a href="dashboard.php?view=stats" class="<?= ($dashView ?? '') === 'stats' ? 'active' : '' ?>"><?= Icons::icon('stats') ?>Statistics</a>
- <a href="dashboard.php?view=security" class="<?= ($dashView ?? '') === 'security' ? 'active' : '' ?>"><?= Icons::icon('lock') ?>Security</a>
- <a href="interface.php" class="<?= ($dashActivePage ?? '') === 'interface' ? 'active' : '' ?>"><?= Icons::icon('sliders') ?>Appearance</a>
- <?php if ($dashIsAdmin): ?>
- <div class="dash-nav-divider"></div>
- <a href="admin.php" class="<?= ($dashActivePage ?? '') === 'admin' ? 'active' : '' ?>"><?= Icons::icon('team') ?>Team</a>
- <a href="settings.php" class="<?= ($dashActivePage ?? '') === 'settings' ? 'active' : '' ?>"><?= Icons::icon('settings') ?>Settings</a>
- <a href="languages.php" class="<?= ($dashActivePage ?? '') === 'languages' ? 'active' : '' ?>"><?= Icons::icon('translate') ?>Languages</a>
- <a href="ads.php" class="<?= ($dashActivePage ?? '') === 'ads' ? 'active' : '' ?>"><?= Icons::icon('ads') ?>Ads</a>
- <?php if (ActivityLog::isEnabled()): ?>
- <a href="activity.php" class="<?= ($dashActivePage ?? '') === 'activity' ? 'active' : '' ?>"><?= Icons::icon('activity') ?>Activity log</a>
- <?php endif; ?>
- <a href="analytics.php" class="<?= ($dashActivePage ?? '') === 'analytics' ? 'active' : '' ?>"><?= Icons::icon('analytics') ?>Analytics</a>
- <?php endif; ?>
- </nav>
-
- <div class="dash-user">
- <?= Avatar::html($dashCurrentUser, 'dash-user-avatar') ?>
- <div class="dash-user-info">
- <div class="dash-user-name"><?= htmlspecialchars($dashCurrentUser['display_name']) ?></div>
- <div class="dash-user-role"><?= htmlspecialchars(Auth::roleLabel($dashCurrentRole)) ?></div>
- </div>
- <a href="team-login.php?logout=1" class="dash-user-logout" aria-label="Log out"><?= Icons::icon('logout', 'icon icon-sm') ?></a>
- </div>
-
- </aside>
- <main class="dash-main">