index.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. declare(strict_types=1);
  3. use App\App\Bootstrap;
  4. use App\Admin\Auth;
  5. use App\Storage\JsonStore;
  6. require dirname(__DIR__) . '/src/autoload.php';
  7. Bootstrap::init();
  8. $app = Bootstrap::config('app');
  9. $auth = new Auth();
  10. $auth->requireLogin();
  11. $store = new JsonStore();
  12. $list = $store->listSubmissions();
  13. $query = trim((string) ($_GET['q'] ?? ''));
  14. if ($query !== '') {
  15. $list = array_values(array_filter($list, static function (array $item) use ($query): bool {
  16. return strpos(strtolower((string) ($item['email'] ?? '')), strtolower($query)) !== false;
  17. }));
  18. }
  19. ?><!doctype html>
  20. <html lang="de">
  21. <head>
  22. <meta charset="utf-8">
  23. <meta name="viewport" content="width=device-width, initial-scale=1">
  24. <title>Admin Übersicht</title>
  25. <link rel="stylesheet" href="<?= htmlspecialchars(Bootstrap::url('assets/css/tokens.css')) ?>">
  26. <link rel="stylesheet" href="<?= htmlspecialchars(Bootstrap::url('assets/css/base.css')) ?>">
  27. </head>
  28. <body class="admin-page">
  29. <header class="site-header">
  30. <div class="container header-inner">
  31. <a class="brand" href="<?= htmlspecialchars(Bootstrap::url('admin/index.php')) ?>">
  32. <img class="brand-logo" src="<?= htmlspecialchars(Bootstrap::url('assets/images/feuerwehr-Logo-invers.webp')) ?>" alt="Feuerwehr Logo">
  33. <div class="brand-title"><?= htmlspecialchars((string) ($app['project_name'] ?? 'Admin')) ?></div>
  34. </a>
  35. </div>
  36. </header>
  37. <main class="container">
  38. <section class="card">
  39. <h1>Abgeschlossene Anträge</h1>
  40. <p><a href="<?= htmlspecialchars(Bootstrap::url('admin/login.php?logout=1')) ?>">Abmelden</a></p>
  41. <form method="get" class="field">
  42. <label for="q">Suche E-Mail</label>
  43. <input id="q" name="q" value="<?= htmlspecialchars($query) ?>">
  44. </form>
  45. <?php if (empty($list)): ?>
  46. <p>Keine Anträge vorhanden.</p>
  47. <?php else: ?>
  48. <div class="table-responsive">
  49. <table class="responsive-table">
  50. <thead>
  51. <tr>
  52. <th>E-Mail</th>
  53. <th>Eingereicht</th>
  54. <th>Aktion</th>
  55. </tr>
  56. </thead>
  57. <tbody>
  58. <?php foreach ($list as $item): ?>
  59. <tr>
  60. <td data-label="E-Mail"><?= htmlspecialchars((string) ($item['email'] ?? '')) ?></td>
  61. <td data-label="Eingereicht"><?= htmlspecialchars((string) ($item['submitted_at'] ?? '')) ?></td>
  62. <td data-label="Aktion"><a href="<?= htmlspecialchars(Bootstrap::url('admin/application.php?id=' . urlencode((string) ($item['application_key'] ?? '')))) ?>">Details</a></td>
  63. </tr>
  64. <?php endforeach; ?>
  65. </tbody>
  66. </table>
  67. </div>
  68. <?php endif; ?>
  69. </section>
  70. </main>
  71. </body>
  72. </html>