index.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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"
  44. src="<?= htmlspecialchars(Bootstrap::url('assets/images/feuerwehr-logo-invers.webp')) ?>"
  45. alt="Feuerwehr Logo">
  46. <div class="brand-title"><?= htmlspecialchars((string) ($app['project_name'] ?? 'Admin')) ?></div>
  47. </a>
  48. </div>
  49. </header>
  50. <main class="container">
  51. <section class="card">
  52. <div class="admin-toolbar">
  53. <div>
  54. <h1>Abgeschlossene Anträge</h1>
  55. <a href="<?= htmlspecialchars(Bootstrap::url('admin/login.php?logout=1')) ?>">Abmelden</a>
  56. </div>
  57. <form method="get" class="field">
  58. <label for="q">Suche Name oder E-Mail</label>
  59. <input id="q" name="q" value="<?= htmlspecialchars($query) ?>">
  60. </form>
  61. </div>
  62. <div class="alert alert-warning">
  63. <strong>Hinweis:</strong> Anträge werden nach <?= (int) ($app['retention']['submission_days'] ?? 90) ?>
  64. Tagen aus Datenschutzgründen automatisch gelöscht.
  65. </div>
  66. <?php if (empty($list)): ?>
  67. <p>Keine Anträge vorhanden.</p>
  68. <?php else: ?>
  69. <div class="table-responsive">
  70. <table class="responsive-table table-dense admin-submissions-table">
  71. <thead>
  72. <tr>
  73. <th>Vorname</th>
  74. <th>Nachname</th>
  75. <th>E-Mail</th>
  76. <th>Eingereicht</th>
  77. <th>Aktion</th>
  78. </tr>
  79. </thead>
  80. <tbody>
  81. <?php foreach ($list as $item):
  82. $formData = (array) ($item['form_data'] ?? []);
  83. ?>
  84. <tr>
  85. <td data-label="Vorname"><?= htmlspecialchars((string) ($formData['vorname'] ?? '')) ?></td>
  86. <td data-label="Nachname"><?= htmlspecialchars((string) ($formData['nachname'] ?? '')) ?>
  87. </td>
  88. <td data-label="E-Mail"><?= htmlspecialchars((string) ($item['email'] ?? '')) ?></td>
  89. <td data-label="Eingereicht"><?= htmlspecialchars((string) ($item['submitted_at'] ?? '')) ?>
  90. </td>
  91. <td data-label="Aktion"><a
  92. href="<?= htmlspecialchars(Bootstrap::url('admin/application.php?id=' . urlencode((string) ($item['application_key'] ?? '')))) ?>">Details</a>
  93. </td>
  94. </tr>
  95. <?php endforeach; ?>
  96. </tbody>
  97. </table>
  98. </div>
  99. <?php endif; ?>
  100. </section>
  101. </main>
  102. </body>
  103. </html>