| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <?php
- declare(strict_types=1);
- use App\App\Bootstrap;
- use App\Security\EntraAuth;
- use App\Security\Csrf;
- use App\Storage\JsonStore;
- require dirname(__DIR__) . '/src/autoload.php';
- Bootstrap::init();
- $app = Bootstrap::config('app');
- $auth = new EntraAuth();
- $auth->requireLogin();
- $currentUser = $auth->user() ?? ['email' => '', 'name' => ''];
- $store = new JsonStore();
- $list = array_values(array_filter(
- $store->listSubmissions(),
- static fn (array $item): bool => (bool) ($item['is_minor_submission'] ?? false)
- ));
- $flash = '';
- if (($_GET['done'] ?? '') === '1') {
- $flash = 'Eingang des unterschriebenen Formulars wurde bestätigt und die Empfänger wurden benachrichtigt.';
- } elseif (($_GET['done'] ?? '') === 'already') {
- $flash = 'Für diesen Antrag war der Eingang bereits bestätigt.';
- }
- $formatDate = static function (string $value): string {
- $ts = strtotime($value);
- return $ts !== false ? date('d.m.Y H:i', $ts) : $value;
- };
- $csrf = Csrf::token();
- ?><!doctype html>
- <html lang="de">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>Jugendwart-Portal</title>
- <link rel="stylesheet" href="<?= htmlspecialchars(Bootstrap::url('assets/css/tokens.css')) ?>">
- <link rel="stylesheet" href="<?= htmlspecialchars(Bootstrap::url('assets/css/base.css')) ?>">
- </head>
- <body class="admin-page">
- <header class="site-header">
- <div class="container header-inner">
- <a class="brand" href="<?= htmlspecialchars(Bootstrap::url('portal/index.php')) ?>">
- <img class="brand-logo" src="<?= htmlspecialchars(Bootstrap::url('assets/images/feuerwehr-logo-invers.webp')) ?>" alt="Feuerwehr Logo">
- <div class="brand-title"><?= htmlspecialchars((string) ($app['project_name'] ?? 'Jugendwart-Portal')) ?></div>
- </a>
- </div>
- </header>
- <main class="container">
- <section class="card">
- <div class="admin-toolbar">
- <div>
- <h1>Unterschriebene Formulare (Minderjährige)</h1>
- <p>Angemeldet als <?= htmlspecialchars($currentUser['name'] !== '' ? $currentUser['name'] : $currentUser['email']) ?>
- · <a href="<?= htmlspecialchars(Bootstrap::url('portal/login.php?logout=1')) ?>">Abmelden</a></p>
- </div>
- </div>
- <?php if ($flash !== ''): ?>
- <p class="alert alert-success"><?= htmlspecialchars($flash) ?></p>
- <?php endif; ?>
- <p>Bitte bestätigen Sie hier den Eingang des handschriftlich unterschriebenen Formulars
- (Einverständniserklärung Minderjährige). Dadurch werden die Empfänger des Antrags automatisch informiert.</p>
- <?php if (empty($list)): ?>
- <p>Keine minderjährigen Anträge vorhanden.</p>
- <?php else: ?>
- <div class="table-responsive">
- <table class="responsive-table table-dense admin-submissions-table">
- <thead>
- <tr>
- <th>Vorname</th>
- <th>Nachname</th>
- <th>E-Mail</th>
- <th>Eingereicht</th>
- <th>Status</th>
- </tr>
- </thead>
- <tbody>
- <?php foreach ($list as $item):
- $formData = (array) ($item['form_data'] ?? []);
- $received = (array) ($item['signed_form_received'] ?? []);
- $isReceived = $received !== [];
- $key = (string) ($item['application_key'] ?? '');
- ?>
- <tr>
- <td data-label="Vorname"><?= htmlspecialchars((string) ($formData['vorname'] ?? '')) ?></td>
- <td data-label="Nachname"><?= htmlspecialchars((string) ($formData['nachname'] ?? '')) ?></td>
- <td data-label="E-Mail"><?= htmlspecialchars((string) ($item['email'] ?? '')) ?></td>
- <td data-label="Eingereicht"><?= htmlspecialchars($formatDate((string) ($item['submitted_at'] ?? ''))) ?></td>
- <td data-label="Status">
- <?php if ($isReceived): ?>
- Erhalten am <?= htmlspecialchars($formatDate((string) ($received['received_at'] ?? ''))) ?>
- <?php $rBy = trim((string) ($received['received_by'] ?? ($received['received_by_email'] ?? '')));
- if ($rBy !== ''): ?>
- durch <?= htmlspecialchars($rBy) ?>
- <?php endif; ?>
- <?php else: ?>
- <form method="post" action="<?= htmlspecialchars(Bootstrap::url('portal/confirm.php')) ?>">
- <input type="hidden" name="csrf" value="<?= htmlspecialchars($csrf) ?>">
- <input type="hidden" name="id" value="<?= htmlspecialchars($key) ?>">
- <button type="submit" class="btn">Formular erhalten</button>
- </form>
- <?php endif; ?>
- </td>
- </tr>
- <?php endforeach; ?>
- </tbody>
- </table>
- </div>
- <?php endif; ?>
- </section>
- </main>
- </body>
- </html>
|