index.php 8.5 KB

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