Quelltext des aktuellen Standes
<?php $this->layout('layouts/admin', [
'page_title' => 'Audit-Berichte',
'current_admin_page' => 'audit'
]); ?>
<div class="audit-reports">
<!-- Berichtsauswahl -->
<div class="report-selector">
<form action="/admin/audit/reports" method="GET" class="filter-form">
<div class="filter-group">
<label for="f-9353-type"><?= $this->te('Berichtstyp') ?></label>
<select id="f-9353-type" name="type" class="form-control" onchange="this.form.submit()">
<option value="summary" <?= $report_type === 'summary' ? 'selected' : '' ?>><?= $this->te('Zusammenfassung') ?></option>
<option value="user_activity" <?= $report_type === 'user_activity' ? 'selected' : '' ?>><?= $this->te('Benutzeraktivität') ?></option>
<option value="security_events" <?= $report_type === 'security_events' ? 'selected' : '' ?>><?= $this->te('Sicherheitsereignisse') ?></option>
<option value="content_changes" <?= $report_type === 'content_changes' ? 'selected' : '' ?>><?= $this->te('Inhaltsänderungen') ?></option>
<option value="permission_changes" <?= $report_type === 'permission_changes' ? 'selected' : '' ?>><?= $this->te('Berechtigungsänderungen') ?></option>
</select>
</div>
<div class="filter-group">
<label><?= $this->te('Zeitraum') ?></label>
<div class="date-range">
<input type="date" name="date_from" class="form-control" value="<?= $this->e($date_from) ?>">
<span><?= $this->te('bis') ?></span>
<input type="date" name="date_to" class="form-control" value="<?= $this->e($date_to) ?>">
</div>
</div>
<button type="submit" class="btn btn-secondary"><?= $this->te('Aktualisieren') ?></button>
</form>
</div>
<!-- Bericht: Zusammenfassung -->
<?php if ($report_type === 'summary'): ?>
<div class="report-content summary-report">
<h2><?= $this->t('Zusammenfassung') ?> (<?= date('d.m.Y', strtotime($date_from)) ?> - <?= date('d.m.Y', strtotime($date_to)) ?>)</h2>
<!-- Statistik-Karten -->
<div class="stats-row">
<div class="stat-card">
<div class="stat-value"><?= number_format($report_data['totals']['total_entries'] ?? 0) ?></div>
<div class="stat-label"><?= $this->te('Gesamte Einträge') ?></div>
</div>
<div class="stat-card">
<div class="stat-value"><?= number_format($report_data['totals']['unique_users'] ?? 0) ?></div>
<div class="stat-label"><?= $this->te('Aktive Benutzer') ?></div>
</div>
<div class="stat-card">
<div class="stat-value"><?= number_format($report_data['totals']['active_days'] ?? 0) ?></div>
<div class="stat-label"><?= $this->te('Aktive Tage') ?></div>
</div>
</div>
<div class="report-grid">
<!-- Nach Kategorie -->
<section class="report-section">
<h3><?= $this->te('Nach Kategorie') ?></h3>
<table class="data-table data-table-compact">
<thead>
<tr>
<th scope="col"><?= $this->te('Kategorie') ?></th>
<th scope="col" class="text-right"><?= $this->te('Anzahl') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($report_data['by_category'] ?? [] as $row): ?>
<tr>
<td>
<span class="action-badge category-<?= $this->e($row['action_category']) ?>">
<?= $this->e(ucfirst($row['action_category'])) ?>
</span>
</td>
<td class="text-right"><?= number_format($row['count']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</section>
<!-- Nach Schweregrad -->
<section class="report-section">
<h3><?= $this->te('Nach Schweregrad') ?></h3>
<table class="data-table data-table-compact">
<thead>
<tr>
<th scope="col"><?= $this->te('Schweregrad') ?></th>
<th scope="col" class="text-right"><?= $this->te('Anzahl') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($report_data['by_severity'] ?? [] as $row): ?>
<tr>
<td>
<span class="severity-badge severity-<?= $this->e($row['risk_level'] ?? 'low') ?>">
<?= $this->e(ucfirst($row['risk_level'] ?? 'low')) ?>
</span>
</td>
<td class="text-right"><?= number_format($row['count']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</section>
<!-- Top Aktionen -->
<section class="report-section">
<h3><?= $this->te('Häufigste Aktionen') ?></h3>
<table class="data-table data-table-compact">
<thead>
<tr>
<th scope="col"><?= $this->te('Aktion') ?></th>
<th scope="col" class="text-right"><?= $this->te('Anzahl') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($report_data['top_actions'] ?? [] as $row): ?>
<tr>
<td><?= $this->e($row['action_type']) ?></td>
<td class="text-right"><?= number_format($row['count']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</section>
</div>
</div>
<?php endif; ?>
<!-- Bericht: Benutzeraktivität -->
<?php if ($report_type === 'user_activity'): ?>
<div class="report-content activity-report">
<h2><?= $this->te('Benutzeraktivität') ?></h2>
<section class="report-section">
<h3><?= $this->te('Aktivität pro Benutzer') ?></h3>
<table class="data-table">
<thead>
<tr>
<th scope="col"><?= $this->te('Benutzer') ?></th>
<th scope="col" class="text-right"><?= $this->te('Aktionen') ?></th>
<th scope="col"><?= $this->te('Erste Aktion') ?></th>
<th scope="col"><?= $this->te('Letzte Aktion') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($report_data['user_activity'] ?? [] as $row): ?>
<tr>
<td>
<a href="/admin/users/<?= $row['id'] ?>"><?= $this->e($row['display_name']) ?></a>
</td>
<td class="text-right"><?= number_format($row['total_actions']) ?></td>
<td><?= date('d.m.Y H:i', strtotime($row['first_action'])) ?></td>
<td><?= date('d.m.Y H:i', strtotime($row['last_action'])) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</section>
<section class="report-section">
<h3><?= $this->te('Login-Statistiken') ?></h3>
<table class="data-table">
<thead>
<tr>
<th scope="col"><?= $this->te('Benutzer') ?></th>
<th scope="col" class="text-right"><?= $this->te('Logins') ?></th>
<th scope="col" class="text-right"><?= $this->te('Logouts') ?></th>
<th scope="col" class="text-right"><?= $this->te('Fehlversuche') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($report_data['login_stats'] ?? [] as $row): ?>
<tr>
<td><?= $this->e($row['display_name']) ?></td>
<td class="text-right"><?= number_format($row['logins']) ?></td>
<td class="text-right"><?= number_format($row['logouts']) ?></td>
<td class="text-right <?= $row['failed_attempts'] > 0 ? 'text-danger' : '' ?>">
<?= number_format($row['failed_attempts']) ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</section>
<?php if (!empty($report_data['inactive_users'])): ?>
<section class="report-section">
<h3><?= $this->te('Inaktive Benutzer (kein Login im Zeitraum)') ?></h3>
<table class="data-table">
<thead>
<tr>
<th scope="col"><?= $this->te('Benutzer') ?></th>
<th scope="col"><?= $this->t('E-Mail') ?></th>
<th scope="col"><?= $this->te('Letzter Login') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($report_data['inactive_users'] as $row): ?>
<tr>
<td><?= $this->e($row['display_name']) ?></td>
<td><?= $this->e($row['email']) ?></td>
<td>
<?php if ($row['last_login']): ?>
<?= date('d.m.Y H:i', strtotime($row['last_login'])) ?>
<?php else: ?>
<span class="text-muted"><?= $this->te('Nie') ?></span>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</section>
<?php endif; ?>
</div>
<?php endif; ?>
<!-- Bericht: Sicherheitsereignisse -->
<?php if ($report_type === 'security_events'): ?>
<div class="report-content security-report">
<h2><?= $this->te('Sicherheitsereignisse') ?></h2>
<?php if (!empty($report_data['security_events'])): ?>
<section class="report-section">
<h3><?= $this->te('Kritische und hohe Ereignisse') ?></h3>
<table class="data-table">
<thead>
<tr>
<th scope="col"><?= $this->te('Zeit') ?></th>
<th scope="col"><?= $this->te('Benutzer') ?></th>
<th scope="col"><?= $this->te('Aktion') ?></th>
<th scope="col"><?= $this->te('Schweregrad') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($report_data['security_events'] as $row): ?>
<tr>
<td>
<a href="/admin/audit/<?= $row['id'] ?>">
<?= date('d.m.Y H:i', strtotime($row['created_at'])) ?>
</a>
</td>
<td><?= $this->e($row['display_name'] ?? 'System') ?></td>
<td><?= $this->e($row['action_type']) ?></td>
<td>
<span class="severity-badge severity-<?= $this->e($row['severity']) ?>">
<?= $this->e(ucfirst($row['severity'])) ?>
</span>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</section>
<?php endif; ?>
<?php if (!empty($report_data['suspicious_ips'])): ?>
<section class="report-section">
<h3><?= $this->te('Verdächtige IP-Adressen (mehrere Benutzer)') ?></h3>
<table class="data-table">
<thead>
<tr>
<th scope="col"><?= $this->te('IP-Adresse') ?></th>
<th scope="col"><?= $this->te('Benutzer') ?></th>
<th scope="col"><?= $this->te('Anzahl') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($report_data['suspicious_ips'] as $row): ?>
<tr>
<td><code><?= $this->e($row['ip_address']) ?></code></td>
<td><?= $this->e($row['users']) ?></td>
<td><?= $row['user_count'] ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</section>
<?php endif; ?>
</div>
<?php endif; ?>
<!-- Bericht: Inhaltsänderungen -->
<?php if ($report_type === 'content_changes'): ?>
<div class="report-content content-report">
<h2><?= $this->te('Inhaltsänderungen') ?></h2>
<section class="report-section">
<h3><?= $this->te('Am häufigsten geänderte Seiten') ?></h3>
<table class="data-table">
<thead>
<tr>
<th scope="col"><?= $this->te('Seite') ?></th>
<th scope="col" class="text-right"><?= $this->te('Änderungen') ?></th>
<th scope="col"><?= $this->te('Letzte Änderung') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($report_data['page_changes'] ?? [] as $row): ?>
<tr>
<td>
<a href="/pages/<?= $row['entity_id'] ?>"><?= $this->e($row['entity_name']) ?></a>
</td>
<td class="text-right"><?= number_format($row['change_count']) ?></td>
<td><?= date('d.m.Y H:i', strtotime($row['last_change'])) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</section>
<?php if (!empty($report_data['new_pages'])): ?>
<section class="report-section">
<h3><?= $this->te('Neue Seiten') ?></h3>
<table class="data-table">
<thead>
<tr>
<th scope="col"><?= $this->te('Seite') ?></th>
<th scope="col"><?= $this->te('Erstellt von') ?></th>
<th scope="col"><?= $this->te('Datum') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($report_data['new_pages'] as $row): ?>
<tr>
<td><?= $this->e($row['entity_name']) ?></td>
<td><?= $this->e($row['display_name']) ?></td>
<td><?= date('d.m.Y H:i', strtotime($row['created_at'])) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</section>
<?php endif; ?>
</div>
<?php endif; ?>
<!-- Bericht: Berechtigungsänderungen -->
<?php if ($report_type === 'permission_changes'): ?>
<div class="report-content permission-report">
<h2><?= $this->te('Berechtigungsänderungen') ?></h2>
<section class="report-section">
<h3><?= $this->te('Alle Änderungen') ?></h3>
<table class="data-table">
<thead>
<tr>
<th scope="col"><?= $this->te('Zeit') ?></th>
<th scope="col"><?= $this->te('Administrator') ?></th>
<th scope="col"><?= $this->te('Aktion') ?></th>
<th scope="col"><?= $this->te('Betroffen') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($report_data['changes'] ?? [] as $row): ?>
<tr>
<td>
<a href="/admin/audit/<?= $row['id'] ?>">
<?= date('d.m.Y H:i', strtotime($row['created_at'])) ?>
</a>
</td>
<td><?= $this->e($row['actor_name'] ?? 'System') ?></td>
<td><?= $this->e($row['action_type']) ?></td>
<td><?= $this->e($row['entity_name'] ?? '-') ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</section>
</div>
<?php endif; ?>
</div>