index.php 8.7 KB

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