WebOrbiton
v1.0.0.0

StocketBase

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