index.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <?php
  2. // index.php – Activity selection page
  3. require_once __DIR__ . '/db.php';
  4. $pdo = get_pdo();
  5. // Fetch all groups with their activities
  6. $sql = "
  7. SELECT
  8. ag.groupID,
  9. ag.groupName AS groupName,
  10. ag.sortOrder AS groupSort,
  11. a.activityID,
  12. a.activityName,
  13. a.sortOrder AS actSort
  14. FROM activity_groups ag
  15. JOIN activities a ON a.groupID = ag.groupID
  16. ORDER BY ag.sortOrder, ag.groupID, a.sortOrder, a.activityID
  17. ";
  18. $rows = $pdo->query($sql)->fetchAll();
  19. // Group by category
  20. $groups = [];
  21. foreach ($rows as $row) {
  22. $gid = $row['groupID'];
  23. if (!isset($groups[$gid])) {
  24. $groups[$gid] = ['name' => $row['groupName'], 'activities' => []];
  25. }
  26. $groups[$gid]['activities'][] = [
  27. 'id' => $row['activityID'],
  28. 'name' => $row['activityName'],
  29. ];
  30. }
  31. ?>
  32. <!DOCTYPE html>
  33. <html lang="en">
  34. <head>
  35. <meta charset="UTF-8">
  36. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  37. <title>PackIt – Choose Your Activities</title>
  38. <link rel="manifest" href="/manifest.webmanifest">
  39. <meta name="theme-color" content="#e8c547">
  40. <link rel="icon" type="image/png" sizes="192x192" href="/img/icon-192.png">
  41. <link rel="preconnect" href="https://fonts.googleapis.com">
  42. <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  43. <link href="https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Sans:wght@300;400;500;600&display=swap" rel="stylesheet">
  44. <style>
  45. :root {
  46. --bg: #0f1117;
  47. --surface: #181c27;
  48. --border: #2a2f3f;
  49. --accent: #e8c547;
  50. --accent2: #4fd1c5;
  51. --text: #e8eaf0;
  52. --muted: #7a8099;
  53. --danger: #e05555;
  54. --radius: 10px;
  55. --gap: 1.5rem;
  56. }
  57. *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  58. body {
  59. background: var(--bg);
  60. color: var(--text);
  61. font-family: 'DM Sans', sans-serif;
  62. font-size: 15px;
  63. min-height: 100vh;
  64. display: flex;
  65. flex-direction: column;
  66. }
  67. /* ---------- header ---------- */
  68. header {
  69. padding: 2.5rem var(--gap) 1.5rem;
  70. border-bottom: 1px solid var(--border);
  71. display: flex;
  72. align-items: flex-end;
  73. gap: 1rem;
  74. position: relative;
  75. overflow: hidden;
  76. }
  77. header::before {
  78. content: '';
  79. position: absolute;
  80. inset: 0;
  81. background: radial-gradient(ellipse 60% 80% at 10% 50%, rgba(232,197,71,.08) 0%, transparent 70%);
  82. pointer-events: none;
  83. }
  84. .logo {
  85. font-family: 'Bebas Neue', sans-serif;
  86. font-size: clamp(2.8rem, 6vw, 4.5rem);
  87. letter-spacing: .04em;
  88. color: var(--accent);
  89. line-height: 1;
  90. position: relative;
  91. }
  92. .tagline {
  93. font-size: .85rem;
  94. color: var(--muted);
  95. letter-spacing: .08em;
  96. text-transform: uppercase;
  97. padding-bottom: .25rem;
  98. position: relative;
  99. }
  100. /* ---------- main layout ---------- */
  101. main {
  102. flex: 1;
  103. max-width: 760px;
  104. width: 100%;
  105. margin: 0 auto;
  106. padding: 2.5rem var(--gap) 6rem;
  107. }
  108. .section-title {
  109. font-family: 'Bebas Neue', sans-serif;
  110. font-size: 1.15rem;
  111. letter-spacing: .12em;
  112. color: var(--accent2);
  113. text-transform: uppercase;
  114. margin-bottom: .75rem;
  115. display: flex;
  116. align-items: center;
  117. gap: .6rem;
  118. }
  119. .section-title::after {
  120. content: '';
  121. flex: 1;
  122. height: 1px;
  123. background: var(--border);
  124. }
  125. .activity-group {
  126. margin-bottom: 2rem;
  127. }
  128. .activity-grid {
  129. display: grid;
  130. grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  131. gap: .6rem;
  132. }
  133. /* Custom checkbox card */
  134. .activity-card {
  135. position: relative;
  136. }
  137. .activity-card input[type="checkbox"] {
  138. position: absolute;
  139. opacity: 0;
  140. width: 0; height: 0;
  141. }
  142. .activity-card label {
  143. display: flex;
  144. align-items: center;
  145. gap: .7rem;
  146. padding: .7rem 1rem;
  147. background: var(--surface);
  148. border: 1.5px solid var(--border);
  149. border-radius: var(--radius);
  150. cursor: pointer;
  151. transition: border-color .15s, background .15s, transform .1s;
  152. user-select: none;
  153. }
  154. .check-icon {
  155. width: 18px; height: 18px;
  156. border: 1.5px solid var(--border);
  157. border-radius: 5px;
  158. flex-shrink: 0;
  159. display: flex; align-items: center; justify-content: center;
  160. transition: background .15s, border-color .15s;
  161. background: var(--bg);
  162. }
  163. .check-icon svg { display: none; }
  164. .activity-card input:checked + label {
  165. border-color: var(--accent);
  166. background: rgba(232,197,71,.07);
  167. }
  168. .activity-card input:checked + label .check-icon {
  169. background: var(--accent);
  170. border-color: var(--accent);
  171. }
  172. .activity-card input:checked + label .check-icon svg { display: block; }
  173. .activity-card input:checked + label { transform: scale(1.01); }
  174. /* ---------- sticky footer bar ---------- */
  175. .action-bar {
  176. position: fixed;
  177. bottom: 0; left: 0; right: 0;
  178. background: rgba(15,17,23,.92);
  179. backdrop-filter: blur(12px);
  180. border-top: 1px solid var(--border);
  181. padding: 1rem var(--gap);
  182. display: flex;
  183. align-items: center;
  184. justify-content: space-between;
  185. gap: 1rem;
  186. z-index: 100;
  187. }
  188. .selection-count {
  189. font-size: .85rem;
  190. color: var(--muted);
  191. }
  192. .selection-count strong {
  193. color: var(--accent);
  194. font-variant-numeric: tabular-nums;
  195. }
  196. .btn-primary {
  197. background: var(--accent);
  198. color: #0f1117;
  199. font-family: 'DM Sans', sans-serif;
  200. font-weight: 600;
  201. font-size: .95rem;
  202. letter-spacing: .03em;
  203. padding: .7rem 1.8rem;
  204. border: none;
  205. border-radius: var(--radius);
  206. cursor: pointer;
  207. transition: background .15s, transform .1s, opacity .15s;
  208. }
  209. .btn-primary:hover { background: #f0d260; transform: translateY(-1px); }
  210. .btn-primary:active { transform: translateY(0); }
  211. .btn-primary:disabled { opacity: .35; cursor: not-allowed; transform: none; }
  212. /* select-all row */
  213. .controls {
  214. display: flex;
  215. gap: .75rem;
  216. margin-bottom: 2rem;
  217. flex-wrap: wrap;
  218. }
  219. .btn-ghost {
  220. background: transparent;
  221. color: var(--muted);
  222. border: 1.5px solid var(--border);
  223. border-radius: var(--radius);
  224. padding: .45rem 1rem;
  225. font-family: 'DM Sans', sans-serif;
  226. font-size: .8rem;
  227. font-weight: 500;
  228. letter-spacing: .04em;
  229. text-transform: uppercase;
  230. cursor: pointer;
  231. transition: color .15s, border-color .15s;
  232. }
  233. .btn-ghost:hover { color: var(--text); border-color: var(--muted); }
  234. footer {
  235. text-align: center;
  236. padding: 1rem;
  237. font-size: .75rem;
  238. color: var(--border);
  239. }
  240. footer a { color: var(--muted); text-decoration: none; }
  241. footer a:hover { color: var(--text); }
  242. </style>
  243. </head>
  244. <body>
  245. <header>
  246. <div class="logo">PackIt</div>
  247. <div class="tagline">Your smart packing companion</div>
  248. </header>
  249. <main>
  250. <div class="controls">
  251. <button class="btn-ghost" type="button" onclick="toggleAll(true)">Select all</button>
  252. <button class="btn-ghost" type="button" onclick="toggleAll(false)">Clear all</button>
  253. </div>
  254. <form id="actForm" action="list.php" method="GET">
  255. <?php foreach ($groups as $gid => $group): ?>
  256. <div class="activity-group">
  257. <div class="section-title"><?= htmlspecialchars($group['name']) ?></div>
  258. <div class="activity-grid">
  259. <?php foreach ($group['activities'] as $act): ?>
  260. <div class="activity-card">
  261. <input type="checkbox" name="aID[]"
  262. id="act_<?= $act['id'] ?>"
  263. value="<?= (int)$act['id'] ?>"
  264. onchange="updateCount()">
  265. <label for="act_<?= $act['id'] ?>">
  266. <span class="check-icon">
  267. <svg width="10" height="8" viewBox="0 0 10 8" fill="none">
  268. <path d="M1 4l3 3 5-6" stroke="#0f1117" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
  269. </svg>
  270. </span>
  271. <?= htmlspecialchars($act['name']) ?>
  272. </label>
  273. </div>
  274. <?php endforeach; ?>
  275. </div>
  276. </div>
  277. <?php endforeach; ?>
  278. </form>
  279. </main>
  280. <div class="action-bar">
  281. <div class="selection-count"><strong id="cnt">0</strong> activities selected</div>
  282. <button class="btn-primary" id="packBtn" disabled
  283. onclick="document.getElementById('actForm').submit()">
  284. Pack it! →
  285. </button>
  286. </div>
  287. <footer><a href="admin/">Admin</a></footer>
  288. <script>
  289. function updateCount() {
  290. const n = document.querySelectorAll('input[name="aID[]"]:checked').length;
  291. document.getElementById('cnt').textContent = n;
  292. document.getElementById('packBtn').disabled = n === 0;
  293. }
  294. function toggleAll(on) {
  295. document.querySelectorAll('input[name="aID[]"]').forEach(cb => cb.checked = on);
  296. updateCount();
  297. }
  298. // Offline support: installs the worker that keeps visited lists readable
  299. // without signal.
  300. if ('serviceWorker' in navigator) {
  301. window.addEventListener('load', () => navigator.serviceWorker.register('/sw.js').catch(() => {}));
  302. }
  303. </script>
  304. </body>
  305. </html>