|
@@ -4,6 +4,8 @@ declare(strict_types=1);
|
|
|
|
|
|
|
|
use App\App\Bootstrap;
|
|
use App\App\Bootstrap;
|
|
|
use App\Admin\Auth;
|
|
use App\Admin\Auth;
|
|
|
|
|
+use App\Form\FormSchema;
|
|
|
|
|
+use App\Mail\SubmissionFormatter;
|
|
|
use App\Security\Csrf;
|
|
use App\Security\Csrf;
|
|
|
use App\Storage\JsonStore;
|
|
use App\Storage\JsonStore;
|
|
|
|
|
|
|
@@ -24,6 +26,16 @@ if ($submission === null) {
|
|
|
exit;
|
|
exit;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+$schema = new FormSchema();
|
|
|
|
|
+$formatter = new SubmissionFormatter($schema);
|
|
|
|
|
+$formattedSteps = $formatter->formatSteps($submission);
|
|
|
|
|
+$uploadFields = $schema->getUploadFields();
|
|
|
|
|
+
|
|
|
|
|
+$formData = (array) ($submission['form_data'] ?? []);
|
|
|
|
|
+$uploads = (array) ($submission['uploads'] ?? []);
|
|
|
|
|
+$firstName = (string) ($formData['vorname'] ?? '');
|
|
|
|
|
+$lastName = (string) ($formData['nachname'] ?? '');
|
|
|
|
|
+
|
|
|
$csrf = Csrf::token();
|
|
$csrf = Csrf::token();
|
|
|
?><!doctype html>
|
|
?><!doctype html>
|
|
|
<html lang="de">
|
|
<html lang="de">
|
|
@@ -46,44 +58,111 @@ $csrf = Csrf::token();
|
|
|
<main class="container">
|
|
<main class="container">
|
|
|
<section class="card">
|
|
<section class="card">
|
|
|
<p><a href="<?= htmlspecialchars(Bootstrap::url('admin/index.php')) ?>">Zur Übersicht</a></p>
|
|
<p><a href="<?= htmlspecialchars(Bootstrap::url('admin/index.php')) ?>">Zur Übersicht</a></p>
|
|
|
- <h1>Antragsdetails</h1>
|
|
|
|
|
- <p><strong>E-Mail:</strong> <?= htmlspecialchars((string) ($submission['email'] ?? '')) ?></p>
|
|
|
|
|
- <p><strong>Eingereicht:</strong> <?= htmlspecialchars((string) ($submission['submitted_at'] ?? '')) ?></p>
|
|
|
|
|
|
|
|
|
|
- <h2>Formulardaten</h2>
|
|
|
|
|
|
|
+ <div class="admin-detail-header">
|
|
|
|
|
+ <h1>Antragsdetails</h1>
|
|
|
|
|
+ <div class="admin-inline-actions">
|
|
|
|
|
+ <form method="get" action="<?= htmlspecialchars(Bootstrap::url('admin/export-pdf.php')) ?>">
|
|
|
|
|
+ <input type="hidden" name="id" value="<?= htmlspecialchars((string) ($submission['application_key'] ?? '')) ?>">
|
|
|
|
|
+ <button type="submit" class="btn btn-small">Export als PDF</button>
|
|
|
|
|
+ </form>
|
|
|
|
|
+ <?php if (!empty($uploads)): ?>
|
|
|
|
|
+ <form method="get" action="<?= htmlspecialchars(Bootstrap::url('admin/download-zip.php')) ?>">
|
|
|
|
|
+ <input type="hidden" name="id" value="<?= htmlspecialchars((string) ($submission['application_key'] ?? '')) ?>">
|
|
|
|
|
+ <button type="submit" class="btn btn-small">Alle Uploads als ZIP herunterladen</button>
|
|
|
|
|
+ </form>
|
|
|
|
|
+ <?php endif; ?>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
<div class="table-responsive">
|
|
<div class="table-responsive">
|
|
|
- <table class="table-compact">
|
|
|
|
|
|
|
+ <table class="table-compact table-dense admin-meta-table">
|
|
|
<tbody>
|
|
<tbody>
|
|
|
- <?php foreach ((array) ($submission['form_data'] ?? []) as $key => $value): ?>
|
|
|
|
|
- <tr>
|
|
|
|
|
- <th><?= htmlspecialchars((string) $key) ?></th>
|
|
|
|
|
- <td><?= htmlspecialchars(is_scalar($value) ? (string) $value : json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)) ?></td>
|
|
|
|
|
- </tr>
|
|
|
|
|
- <?php endforeach; ?>
|
|
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <th>Vorname</th>
|
|
|
|
|
+ <td><?= htmlspecialchars($firstName !== '' ? $firstName : '-') ?></td>
|
|
|
|
|
+ <th>Nachname</th>
|
|
|
|
|
+ <td><?= htmlspecialchars($lastName !== '' ? $lastName : '-') ?></td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <th>E-Mail</th>
|
|
|
|
|
+ <td><?= htmlspecialchars((string) ($submission['email'] ?? '')) ?></td>
|
|
|
|
|
+ <th>Eingereicht</th>
|
|
|
|
|
+ <td><?= htmlspecialchars((string) ($submission['submitted_at'] ?? '')) ?></td>
|
|
|
|
|
+ </tr>
|
|
|
</tbody>
|
|
</tbody>
|
|
|
</table>
|
|
</table>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
+ <h2>Formulardaten</h2>
|
|
|
|
|
+ <?php if ($formattedSteps === []): ?>
|
|
|
|
|
+ <p>Keine Formulardaten vorhanden.</p>
|
|
|
|
|
+ <?php else: ?>
|
|
|
|
|
+ <?php foreach ($formattedSteps as $step): ?>
|
|
|
|
|
+ <section class="admin-step-block">
|
|
|
|
|
+ <h3><?= htmlspecialchars((string) ($step['title'] ?? '')) ?></h3>
|
|
|
|
|
+ <div class="table-responsive">
|
|
|
|
|
+ <table class="table-compact table-dense admin-form-data-table">
|
|
|
|
|
+ <tbody>
|
|
|
|
|
+ <?php foreach ((array) ($step['fields'] ?? []) as $field): ?>
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <th><?= htmlspecialchars((string) ($field['label'] ?? '')) ?></th>
|
|
|
|
|
+ <td><?= nl2br(htmlspecialchars((string) ($field['value'] ?? '')), false) ?></td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ <?php endforeach; ?>
|
|
|
|
|
+ </tbody>
|
|
|
|
|
+ </table>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </section>
|
|
|
|
|
+ <?php endforeach; ?>
|
|
|
|
|
+ <?php endif; ?>
|
|
|
|
|
+
|
|
|
<h2>Uploads</h2>
|
|
<h2>Uploads</h2>
|
|
|
- <?php if (empty($submission['uploads'])): ?>
|
|
|
|
|
|
|
+ <?php if ($uploads === []): ?>
|
|
|
<p>Keine Uploads vorhanden.</p>
|
|
<p>Keine Uploads vorhanden.</p>
|
|
|
<?php else: ?>
|
|
<?php else: ?>
|
|
|
- <p><a href="<?= htmlspecialchars(Bootstrap::url('admin/download-zip.php?id=' . urlencode((string) ($submission['application_key'] ?? '')))) ?>">Alle Uploads als ZIP herunterladen</a></p>
|
|
|
|
|
- <?php foreach ((array) $submission['uploads'] as $field => $files): ?>
|
|
|
|
|
- <h3><?= htmlspecialchars((string) $field) ?></h3>
|
|
|
|
|
- <ul>
|
|
|
|
|
- <?php foreach ((array) $files as $idx => $file): ?>
|
|
|
|
|
- <li>
|
|
|
|
|
- <?= htmlspecialchars((string) ($file['original_filename'] ?? 'Datei')) ?>
|
|
|
|
|
- - <a href="<?= htmlspecialchars(Bootstrap::url('admin/download.php?id=' . urlencode((string) ($submission['application_key'] ?? '')) . '&field=' . urlencode((string) $field) . '&index=' . urlencode((string) $idx))) ?>">Download</a>
|
|
|
|
|
- </li>
|
|
|
|
|
- <?php endforeach; ?>
|
|
|
|
|
- </ul>
|
|
|
|
|
|
|
+ <?php $shownUploadKeys = []; ?>
|
|
|
|
|
+ <?php foreach ($uploadFields as $fieldKey => $fieldDef):
|
|
|
|
|
+ $files = $uploads[$fieldKey] ?? [];
|
|
|
|
|
+ if (!is_array($files) || $files === []) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ $shownUploadKeys[] = $fieldKey;
|
|
|
|
|
+ $uploadLabel = (string) ($fieldDef['label'] ?? $fieldKey);
|
|
|
|
|
+ ?>
|
|
|
|
|
+ <div class="admin-upload-group">
|
|
|
|
|
+ <h3><?= htmlspecialchars($uploadLabel) ?></h3>
|
|
|
|
|
+ <ul class="admin-uploads-list">
|
|
|
|
|
+ <?php foreach ($files as $idx => $file): ?>
|
|
|
|
|
+ <li>
|
|
|
|
|
+ <?= htmlspecialchars((string) ($file['original_filename'] ?? 'Datei')) ?>
|
|
|
|
|
+ - <a href="<?= htmlspecialchars(Bootstrap::url('admin/download.php?id=' . urlencode((string) ($submission['application_key'] ?? '')) . '&field=' . urlencode((string) $fieldKey) . '&index=' . urlencode((string) $idx))) ?>">Download</a>
|
|
|
|
|
+ </li>
|
|
|
|
|
+ <?php endforeach; ?>
|
|
|
|
|
+ </ul>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <?php endforeach; ?>
|
|
|
|
|
+ <?php foreach ($uploads as $fieldKey => $files):
|
|
|
|
|
+ if (in_array((string) $fieldKey, $shownUploadKeys, true) || !is_array($files) || $files === []) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ ?>
|
|
|
|
|
+ <div class="admin-upload-group">
|
|
|
|
|
+ <h3><?= htmlspecialchars((string) $fieldKey) ?></h3>
|
|
|
|
|
+ <ul class="admin-uploads-list">
|
|
|
|
|
+ <?php foreach ($files as $idx => $file): ?>
|
|
|
|
|
+ <li>
|
|
|
|
|
+ <?= htmlspecialchars((string) ($file['original_filename'] ?? 'Datei')) ?>
|
|
|
|
|
+ - <a href="<?= htmlspecialchars(Bootstrap::url('admin/download.php?id=' . urlencode((string) ($submission['application_key'] ?? '')) . '&field=' . urlencode((string) $fieldKey) . '&index=' . urlencode((string) $idx))) ?>">Download</a>
|
|
|
|
|
+ </li>
|
|
|
|
|
+ <?php endforeach; ?>
|
|
|
|
|
+ </ul>
|
|
|
|
|
+ </div>
|
|
|
<?php endforeach; ?>
|
|
<?php endforeach; ?>
|
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
<h2>Löschen</h2>
|
|
<h2>Löschen</h2>
|
|
|
- <form method="post" action="<?= htmlspecialchars(Bootstrap::url('admin/delete.php')) ?>" onsubmit="return confirm('Antrag wirklich löschen?');">
|
|
|
|
|
|
|
+ <form method="post" action="<?= htmlspecialchars(Bootstrap::url('admin/delete.php')) ?>" onsubmit="return confirm('Antrag wirklich löschen? Der Antrag wird für alle Benutzer unwiederbringlich entfernt.');">
|
|
|
<input type="hidden" name="csrf" value="<?= htmlspecialchars($csrf) ?>">
|
|
<input type="hidden" name="csrf" value="<?= htmlspecialchars($csrf) ?>">
|
|
|
<input type="hidden" name="id" value="<?= htmlspecialchars((string) ($submission['application_key'] ?? '')) ?>">
|
|
<input type="hidden" name="id" value="<?= htmlspecialchars((string) ($submission['application_key'] ?? '')) ?>">
|
|
|
<button type="submit" class="btn">Antrag löschen</button>
|
|
<button type="submit" class="btn">Antrag löschen</button>
|