motorradig2027/motorradig/views/admin/applications.php

93 lines
5.5 KiB
PHP

<?php
$count = count($applications);
$flashStatus = flash_pull('status');
$flashError = flash_pull('error');
?>
<div class="container text-light mt-5">
<div class="row justify-content-center">
<div class="col-lg-11">
<div class="d-flex justify-content-between align-items-center mb-3">
<h1 class="mb-0">Anträge</h1>
<a href="/" class="btn btn-sm btn-outline-light">Zur Startseite</a>
</div>
<div class="card text-dark">
<div class="card-body">
<?php if ($flashStatus !== null): ?>
<div class="alert alert-success" role="alert"><?= e($flashStatus) ?></div>
<?php endif; ?>
<?php if ($flashError !== null): ?>
<div class="alert alert-danger" role="alert"><?= e($flashError) ?></div>
<?php endif; ?>
<p class="text-muted mb-3">
<?= $count === 1 ? '1 eingereichter Antrag' : $count . ' eingereichte Anträge' ?>
</p>
<div class="table-responsive">
<table class="table table-hover table-sm align-middle mb-0">
<thead class="thead-light">
<tr>
<th scope="col">Eingang</th>
<th scope="col">Name</th>
<th scope="col">E-Mail</th>
<th scope="col">Telefon</th>
<th scope="col">Status</th>
<th scope="col" class="text-right">Aktion</th>
</tr>
</thead>
<tbody>
<?php if ($applications === []): ?>
<tr>
<td colspan="6" class="text-muted">Es sind noch keine Anträge eingegangen.</td>
</tr>
<?php else: ?>
<?php foreach ($applications as $application): ?>
<tr>
<td class="text-nowrap">
<?= e($application->created_at ? date('d.m.Y H:i', strtotime($application->created_at)) : '') ?>
</td>
<td><?= e(trim($application->vorname . ' ' . $application->nachname)) ?></td>
<td><?= e($application->email) ?></td>
<td><?= e($application->telefon) ?></td>
<td class="text-nowrap">
<?php if (!empty($application->accepted_at)): ?>
<span class="badge badge-success badge-pill">Angenommen</span>
<?php else: ?>
<span class="badge badge-warning badge-pill">Offen</span>
<?php endif; ?>
</td>
<td class="text-right text-nowrap">
<a href="/admin/antraege/<?= e($application->id) ?>" class="btn btn-sm btn-primary">
Ansehen
</a>
<?php if (empty($application->accepted_at)): ?>
<form action="/admin/antraege/<?= e($application->id) ?>/accept"
method="POST"
style="display:inline;"
onsubmit="return confirm('Diesen Antrag annehmen und den Benutzer zum Mitglied machen?');">
<?= csrf_field() ?>
<button type="submit" class="btn btn-sm btn-success">Annehmen</button>
</form>
<?php endif; ?>
<form action="/admin/antraege/<?= e($application->id) ?>/delete"
method="POST"
style="display:inline;"
onsubmit="return confirm('Diesen Antrag wirklich löschen? Die Unterschriften werden ebenfalls entfernt.');">
<?= csrf_field() ?>
<button type="submit" class="btn btn-sm btn-outline-danger">Löschen</button>
</form>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>