WebOrbiton
v1.0.0.1

StocketBase

152 lines · 8.2 KB
  1. <?php
  2. ​
  3. declare(strict_types=1);
  4. ​
  5. require_once __DIR__ . '/icons.php';
  6. require_once __DIR__ . '/asset.php';
  7. require_once __DIR__ . '/font-library.php';
  8. require_once __DIR__ . '/activity-log.php';
  9. ​
  10. $dashAvailableFonts = FontLibrary::available();
  11. ​
  12. $dashSiteName = Config::get('APP_NAME', 'StocketBase');
  13. $dashCurrentUser = Auth::user();
  14. $dashCurrentRole = Auth::role();
  15. $dashIsAdmin = Auth::hasRoleAtLeast(Auth::ROLE_STORE_OWNER);
  16. $dashIsManager = Auth::hasRoleAtLeast(Auth::ROLE_STORE_MANAGER);
  17. require_once __DIR__ . '/avatar.php';
  18. require_once __DIR__ . '/status-label.php';
  19. ​
  20. ?>
  21. <!DOCTYPE html>
  22. <html lang="en">
  23. ​
  24. <head>
  25. <meta charset="utf-8">
  26. <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
  27. <title><?= htmlspecialchars($dashPageTitle ?? 'Dashboard') ?> - <?= htmlspecialchars($dashSiteName) ?></title>
  28. <?= Asset::favicon() ?>
  29. <?= Asset::css('assets/dashboard.css') ?>
  30. <style>
  31. <?php foreach ($dashAvailableFonts as $dashFont): ?>
  32. <?= FontLibrary::fontFaceCss($dashFont['display_name'], $dashFont['display_name']) ?>
  33. <?php endforeach; ?>
  34. </style>
  35. </head>
  36. ​
  37. <body data-theme="dark">
  38. <script>
  39. (function() {
  40. try {
  41. var t = localStorage.getItem('stocketbase_dashboard_theme');
  42. if (t === 'dark' || t === 'light') {
  43. document.body.setAttribute('data-theme', t);
  44. } else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) {
  45. document.body.setAttribute('data-theme', 'light');
  46. }
  47. } catch (e) {}
  48. })();
  49. </script>
  50. <script>
  51. (function() {
  52. try {
  53. var minimal = localStorage.getItem('stocketbase_dashboard_minimal') === '1';
  54. if (minimal) {
  55. document.body.classList.add('dash-minimal');
  56. }
  57. if (minimal || localStorage.getItem('stocketbase_dashboard_glass') === '0') {
  58. document.body.classList.add('dash-no-glass');
  59. }
  60. } catch (e) {}
  61. })();
  62. </script>
  63. <script>
  64. (function() {
  65. try {
  66. var validScales = [80, 90, 100, 110, 120, 130, 140, 150];
  67. var sidebarScale = parseInt(localStorage.getItem('stocketbase_dashboard_sidebar_scale'), 10);
  68. var mainScale = parseInt(localStorage.getItem('stocketbase_dashboard_main_scale'), 10);
  69. if (validScales.indexOf(sidebarScale) === -1) {
  70. sidebarScale = 100;
  71. }
  72. if (validScales.indexOf(mainScale) === -1) {
  73. mainScale = 100;
  74. }
  75. if (sidebarScale !== 100 || mainScale !== 100) {
  76. var style = document.createElement('style');
  77. var rules = '';
  78. if (sidebarScale !== 100) {
  79. rules += '.dash-sidebar{zoom:' + (sidebarScale / 100) + ';}';
  80. }
  81. if (mainScale !== 100) {
  82. rules += '.dash-main{zoom:' + (mainScale / 100) + ';}';
  83. }
  84. style.textContent = rules;
  85. document.head.appendChild(style);
  86. }
  87. } catch (e) {}
  88. })();
  89. </script>
  90. <?= Icons::sprite() ?>
  91. ​
  92. <div class="dash-mobile-topbar">
  93. <div class="dash-brand"><span class="dash-brand-dot"></span><?= htmlspecialchars($dashSiteName) ?></div>
  94. <div class="dash-mobile-topbar-right">
  95. <button type="button" class="dash-theme-toggle" aria-label="Switch between light and dark">
  96. <?= Icons::icon('sun', 'icon icon-sm icon-sun') ?>
  97. <?= Icons::icon('moon', 'icon icon-sm icon-moon') ?>
  98. </button>
  99. <?= Avatar::html($dashCurrentUser, 'dash-user-avatar') ?>
  100. </div>
  101. </div>
  102. ​
  103. <div class="dash-shell">
  104. <aside class="dash-sidebar">
  105. ​
  106. <div class="dash-brand-row">
  107. <div class="dash-brand"><span class="dash-brand-dot"></span><?= htmlspecialchars($dashSiteName) ?></div>
  108. <button type="button" class="dash-theme-toggle" id="dash-theme-toggle-btn" aria-label="Switch between light and dark">
  109. <?= Icons::icon('sun', 'icon icon-sm icon-sun') ?>
  110. <?= Icons::icon('moon', 'icon icon-sm icon-moon') ?>
  111. </button>
  112. </div>
  113. ​
  114. <nav class="dash-nav">
  115. <a href="dashboard.php?view=overview" class="<?= ($dashView ?? '') === 'overview' ? 'active' : '' ?>"><?= Icons::icon('overview') ?>Overview</a>
  116. <a href="dashboard.php?view=products" class="<?= in_array($dashView ?? '', ['products', 'product-edit'], true) ? 'active' : '' ?>"><?= Icons::icon('grid') ?>Products</a>
  117. <a href="dashboard.php?view=categories" class="<?= ($dashView ?? '') === 'categories' ? 'active' : '' ?>"><?= Icons::icon('categories') ?>Categories</a>
  118. <?php if ($dashIsManager): ?>
  119. <a href="dashboard.php?view=orders" class="<?= in_array($dashView ?? '', ['orders', 'order-detail'], true) ? 'active' : '' ?>"><?= Icons::icon('checklist') ?>Orders</a>
  120. <a href="dashboard.php?view=customers" class="<?= in_array($dashView ?? '', ['customers', 'customer-detail'], true) ? 'active' : '' ?>"><?= Icons::icon('users') ?>Customers</a>
  121. <a href="dashboard.php?view=discounts" class="<?= ($dashView ?? '') === 'discounts' ? 'active' : '' ?>"><?= Icons::icon('tag') ?>Discounts</a>
  122. <a href="dashboard.php?view=reviews" class="<?= ($dashView ?? '') === 'reviews' ? 'active' : '' ?>"><?= Icons::icon('star') ?>Reviews</a>
  123. <a href="files.php" class="<?= ($dashActivePage ?? '') === 'files' ? 'active' : '' ?>"><?= Icons::icon('download') ?>Files</a>
  124. <?php endif; ?>
  125. <a href="dashboard.php?view=pages" class="<?= ($dashView ?? '') === 'pages' ? 'active' : '' ?>"><?= Icons::icon('pages') ?>Pages</a>
  126. <a href="dashboard.php?view=stats" class="<?= ($dashView ?? '') === 'stats' ? 'active' : '' ?>"><?= Icons::icon('stats') ?>Statistics</a>
  127. <a href="dashboard.php?view=security" class="<?= ($dashView ?? '') === 'security' ? 'active' : '' ?>"><?= Icons::icon('lock') ?>Security</a>
  128. <a href="interface.php" class="<?= ($dashActivePage ?? '') === 'interface' ? 'active' : '' ?>"><?= Icons::icon('sliders') ?>Appearance</a>
  129. <?php if ($dashIsAdmin): ?>
  130. <div class="dash-nav-divider"></div>
  131. <a href="admin.php" class="<?= ($dashActivePage ?? '') === 'admin' ? 'active' : '' ?>"><?= Icons::icon('team') ?>Team</a>
  132. <a href="settings.php" class="<?= ($dashActivePage ?? '') === 'settings' ? 'active' : '' ?>"><?= Icons::icon('settings') ?>Settings</a>
  133. <a href="languages.php" class="<?= ($dashActivePage ?? '') === 'languages' ? 'active' : '' ?>"><?= Icons::icon('translate') ?>Languages</a>
  134. <a href="ads.php" class="<?= ($dashActivePage ?? '') === 'ads' ? 'active' : '' ?>"><?= Icons::icon('ads') ?>Ads</a>
  135. <?php if (ActivityLog::isEnabled()): ?>
  136. <a href="activity.php" class="<?= ($dashActivePage ?? '') === 'activity' ? 'active' : '' ?>"><?= Icons::icon('activity') ?>Activity log</a>
  137. <?php endif; ?>
  138. <a href="analytics.php" class="<?= ($dashActivePage ?? '') === 'analytics' ? 'active' : '' ?>"><?= Icons::icon('analytics') ?>Analytics</a>
  139. <?php endif; ?>
  140. </nav>
  141. ​
  142. <div class="dash-user">
  143. <?= Avatar::html($dashCurrentUser, 'dash-user-avatar') ?>
  144. <div class="dash-user-info">
  145. <div class="dash-user-name"><?= htmlspecialchars($dashCurrentUser['display_name']) ?></div>
  146. <div class="dash-user-role"><?= htmlspecialchars(Auth::roleLabel($dashCurrentRole)) ?></div>
  147. </div>
  148. <a href="team-login.php?logout=1" class="dash-user-logout" aria-label="Log out"><?= Icons::icon('logout', 'icon icon-sm') ?></a>
  149. </div>
  150. ​
  151. </aside>
  152. <main class="dash-main">