index.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. $formData = (array) ($item['form_data'] ?? []);
  17. $haystack = [
  18. strtolower((string) ($formData['vorname'] ?? '')),
  19. strtolower((string) ($formData['nachname'] ?? '')),
  20. strtolower((string) ($item['email'] ?? '')),
  21. ];
  22. foreach ($haystack as $value) {
  23. if ($value !== '' && strpos($value, strtolower($query)) !== false) {
  24. return true;
  25. }
  26. }
  27. return false;
  28. }));
  29. }
  30. ?><!doctype html>
  31. <html lang="de">
  32. <head>
  33. <meta charset="utf-8">
  34. <meta name="viewport" content="width=device-width, initial-scale=1">
  35. <title>Admin Übersicht</title>
  36. <link rel="stylesheet" href="<?= htmlspecialchars(Bootstrap::url('assets/css/tokens.css')) ?>">
  37. <link rel="stylesheet" href="<?= htmlspecialchars(Bootstrap::url('assets/css/base.css')) ?>">
  38. </head>
  39. <body class="admin-page">
  40. <header class="site-header">
  41. <div class="container header-inner">
  42. <a class="brand" href="<?= htmlspecialchars(Bootstrap::url('admin/index.php')) ?>">
  43. <img class="brand-logo" src="<?= htmlspecialchars(Bootstrap::url('assets/images/feuerwehr-logo-invers.webp')) ?>" alt="Feuerwehr Logo">
  44. <div class="brand-title"><?= htmlspecialchars((string) ($app['project_name'] ?? 'Admin')) ?></div>
  45. </a>
  46. </div>
  47. </header>
  48. <main class="container">
  49. <section class="card">
  50. <div class="admin-toolbar">
  51. <div>
  52. <h1>Abgeschlossene Anträge</h1>
  53. <a href="<?= htmlspecialchars(Bootstrap::url('admin/login.php?logout=1')) ?>">Abmelden</a>
  54. </div>
  55. <form method="get" class="field">
  56. <label for="q">Suche Name oder E-Mail</label>
  57. <input id="q" name="q" value="<?= htmlspecialchars($query) ?>">
  58. </form>
  59. </div>
  60. <?php if (empty($list)): ?>
  61. <p>Keine Anträge vorhanden.</p>
  62. <?php else: ?>
  63. <div class="table-responsive">
  64. <table class="responsive-table table-dense admin-submissions-table">
  65. <thead>
  66. <tr>
  67. <th>Vorname</th>
  68. <th>Nachname</th>
  69. <th>E-Mail</th>
  70. <th>Eingereicht</th>
  71. <th>Aktion</th>
  72. </tr>
  73. </thead>
  74. <tbody>
  75. <?php foreach ($list as $item):
  76. $formData = (array) ($item['form_data'] ?? []);
  77. ?>
  78. <tr>
  79. <td data-label="Vorname"><?= htmlspecialchars((string) ($formData['vorname'] ?? '')) ?></td>
  80. <td data-label="Nachname"><?= htmlspecialchars((string) ($formData['nachname'] ?? '')) ?></td>
  81. <td data-label="E-Mail"><?= htmlspecialchars((string) ($item['email'] ?? '')) ?></td>
  82. <td data-label="Eingereicht"><?= htmlspecialchars((string) ($item['submitted_at'] ?? '')) ?></td>
  83. <td data-label="Aktion"><a href="<?= htmlspecialchars(Bootstrap::url('admin/application.php?id=' . urlencode((string) ($item['application_key'] ?? '')))) ?>">Details</a></td>
  84. </tr>
  85. <?php endforeach; ?>
  86. </tbody>
  87. </table>
  88. </div>
  89. <?php endif; ?>
  90. </section>
  91. </main>
  92. </body>
  93. </html>