index.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. declare(strict_types=1);
  3. use App\App\Bootstrap;
  4. use App\Security\EntraAuth;
  5. use App\Security\Csrf;
  6. use App\Storage\JsonStore;
  7. require dirname(__DIR__) . '/src/autoload.php';
  8. Bootstrap::init();
  9. $app = Bootstrap::config('app');
  10. $auth = new EntraAuth();
  11. $auth->requireLogin();
  12. $currentUser = $auth->user() ?? ['email' => '', 'name' => ''];
  13. $store = new JsonStore();
  14. $list = array_values(array_filter(
  15. $store->listSubmissions(),
  16. static fn (array $item): bool => (bool) ($item['is_minor_submission'] ?? false)
  17. ));
  18. $flash = '';
  19. if (($_GET['done'] ?? '') === '1') {
  20. $flash = 'Eingang des unterschriebenen Formulars wurde bestätigt und die Empfänger wurden benachrichtigt.';
  21. } elseif (($_GET['done'] ?? '') === 'already') {
  22. $flash = 'Für diesen Antrag war der Eingang bereits bestätigt.';
  23. }
  24. $formatDate = static function (string $value): string {
  25. $ts = strtotime($value);
  26. return $ts !== false ? date('d.m.Y H:i', $ts) : $value;
  27. };
  28. $csrf = Csrf::token();
  29. ?><!doctype html>
  30. <html lang="de">
  31. <head>
  32. <meta charset="utf-8">
  33. <meta name="viewport" content="width=device-width, initial-scale=1">
  34. <title>Jugendwart-Portal</title>
  35. <link rel="stylesheet" href="<?= htmlspecialchars(Bootstrap::url('assets/css/tokens.css')) ?>">
  36. <link rel="stylesheet" href="<?= htmlspecialchars(Bootstrap::url('assets/css/base.css')) ?>">
  37. </head>
  38. <body class="admin-page">
  39. <header class="site-header">
  40. <div class="container header-inner">
  41. <a class="brand" href="<?= htmlspecialchars(Bootstrap::url('portal/index.php')) ?>">
  42. <img class="brand-logo" src="<?= htmlspecialchars(Bootstrap::url('assets/images/feuerwehr-logo-invers.webp')) ?>" alt="Feuerwehr Logo">
  43. <div class="brand-title"><?= htmlspecialchars((string) ($app['project_name'] ?? 'Jugendwart-Portal')) ?></div>
  44. </a>
  45. </div>
  46. </header>
  47. <main class="container">
  48. <section class="card">
  49. <div class="admin-toolbar">
  50. <div>
  51. <h1>Unterschriebene Formulare (Minderjährige)</h1>
  52. <p>Angemeldet als <?= htmlspecialchars($currentUser['name'] !== '' ? $currentUser['name'] : $currentUser['email']) ?>
  53. &middot; <a href="<?= htmlspecialchars(Bootstrap::url('portal/login.php?logout=1')) ?>">Abmelden</a></p>
  54. </div>
  55. </div>
  56. <?php if ($flash !== ''): ?>
  57. <p class="alert alert-success"><?= htmlspecialchars($flash) ?></p>
  58. <?php endif; ?>
  59. <p>Bitte bestätigen Sie hier den Eingang des handschriftlich unterschriebenen Formulars
  60. (Einverständniserklärung Minderjährige). Dadurch werden die Empfänger des Antrags automatisch informiert.</p>
  61. <?php if (empty($list)): ?>
  62. <p>Keine minderjährigen Anträge vorhanden.</p>
  63. <?php else: ?>
  64. <div class="table-responsive">
  65. <table class="responsive-table table-dense admin-submissions-table">
  66. <thead>
  67. <tr>
  68. <th>Vorname</th>
  69. <th>Nachname</th>
  70. <th>E-Mail</th>
  71. <th>Eingereicht</th>
  72. <th>Status</th>
  73. </tr>
  74. </thead>
  75. <tbody>
  76. <?php foreach ($list as $item):
  77. $formData = (array) ($item['form_data'] ?? []);
  78. $received = (array) ($item['signed_form_received'] ?? []);
  79. $isReceived = $received !== [];
  80. $key = (string) ($item['application_key'] ?? '');
  81. ?>
  82. <tr>
  83. <td data-label="Vorname"><?= htmlspecialchars((string) ($formData['vorname'] ?? '')) ?></td>
  84. <td data-label="Nachname"><?= htmlspecialchars((string) ($formData['nachname'] ?? '')) ?></td>
  85. <td data-label="E-Mail"><?= htmlspecialchars((string) ($item['email'] ?? '')) ?></td>
  86. <td data-label="Eingereicht"><?= htmlspecialchars($formatDate((string) ($item['submitted_at'] ?? ''))) ?></td>
  87. <td data-label="Status">
  88. <?php if ($isReceived): ?>
  89. Erhalten am <?= htmlspecialchars($formatDate((string) ($received['received_at'] ?? ''))) ?>
  90. <?php $rBy = trim((string) ($received['received_by'] ?? ($received['received_by_email'] ?? '')));
  91. if ($rBy !== ''): ?>
  92. durch <?= htmlspecialchars($rBy) ?>
  93. <?php endif; ?>
  94. <?php else: ?>
  95. <form method="post" action="<?= htmlspecialchars(Bootstrap::url('portal/confirm.php')) ?>">
  96. <input type="hidden" name="csrf" value="<?= htmlspecialchars($csrf) ?>">
  97. <input type="hidden" name="id" value="<?= htmlspecialchars($key) ?>">
  98. <button type="submit" class="btn">Formular erhalten</button>
  99. </form>
  100. <?php endif; ?>
  101. </td>
  102. </tr>
  103. <?php endforeach; ?>
  104. </tbody>
  105. </table>
  106. </div>
  107. <?php endif; ?>
  108. </section>
  109. </main>
  110. </body>
  111. </html>