Quelltext des aktuellen Standes
<?php $this->layout('layouts/admin', [
'page_title' => 'Berechtigungsmatrix',
'current_admin_page' => 'permissions',
'breadcrumbs' => [
['label' => 'Berechtigungen', 'url' => '/admin/permissions'],
['label' => 'Matrix'],
],
]); ?>
<?php
$zuweisungen = 0;
foreach ($grouped as $eintrag) { $zuweisungen += count($eintrag['permissions']); }
?>
<div class="kpi-row">
<div class="kpi-col">
<div class="small-box bg-info">
<div class="inner">
<h3><?= count($grouped) ?></h3>
<p><?= $this->te('Benutzer mit Zuweisung') ?></p>
</div>
<div class="icon"><i class="fas fa-user-check"></i></div>
</div>
</div>
<div class="kpi-col">
<div class="small-box bg-primary">
<div class="inner">
<h3><?= $zuweisungen ?></h3>
<p><?= $this->te('Zuweisungen') ?></p>
</div>
<div class="icon"><i class="fas fa-key"></i></div>
</div>
</div>
</div>
<div class="card">
<div class="card-body">
<form method="GET" action="/admin/permissions/matrix" class="filter-card-body">
<div class="form-group">
<label for="pm-topic"><?= $this->te('Themengebiet') ?></label>
<select name="topic_id" id="pm-topic" class="form-control form-control-sm">
<option value="0"><?= $this->te('Alle') ?></option>
<?php foreach ($topics as $t): ?>
<option value="<?= (int)$t['id'] ?>"<?= (int)$selected_topic === (int)$t['id'] ? ' selected' : '' ?>>
<?= str_repeat('— ', max(0, (int)($t['depth'] ?? 0))) ?><?= $this->e($t['name']) ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label for="pm-role"><?= $this->te('Rolle') ?></label>
<select name="role_id" id="pm-role" class="form-control form-control-sm">
<option value="0"><?= $this->te('Alle') ?></option>
<?php foreach ($roles as $r): ?>
<option value="<?= (int)$r['id'] ?>"<?= (int)$selected_role === (int)$r['id'] ? ' selected' : '' ?>>
<?= $this->e($r['name']) ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label> </label>
<button type="submit" class="btn btn-primary btn-sm">
<i class="fas fa-filter"></i> <?= $this->te('Filtern') ?>
</button>
</div>
<?php if ((int)$selected_topic > 0 || (int)$selected_role > 0): ?>
<div class="form-group">
<label> </label>
<a href="/admin/permissions/matrix" class="btn btn-default btn-sm">
<?= $this->te('Filter zurücksetzen') ?>
</a>
</div>
<?php endif; ?>
</form>
</div>
</div>
<?php if (!empty($grouped)): ?>
<div class="table-wrapper">
<table class="data-table">
<thead>
<tr>
<th scope="col"><?= $this->te('Benutzer') ?></th>
<th scope="col"><?= $this->te('Geltungsbereich') ?></th>
<th scope="col"><?= $this->te('Rolle') ?></th>
<th scope="col"><?= $this->te('Vergeben am') ?></th>
<th scope="col"><?= $this->te('Vergeben von') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($grouped as $eintrag): ?>
<?php foreach ($eintrag['permissions'] as $i => $p): ?>
<tr>
<td>
<?php if ($i === 0): ?>
<a href="/admin/permissions/user/<?= (int)$eintrag['user']['id'] ?>" class="table-link">
<?= $this->e($eintrag['user']['display_name'] ?: $eintrag['user']['email']) ?>
</a>
<?php endif; ?>
</td>
<td><?= $this->partial('permission-scope', [
'scope_type' => $p['scope_type'] ?? '',
'topic_id' => $p['topic_id'] ?? null,
'topic_name' => $p['topic_name'] ?? '',
'location_id' => $p['location_id'] ?? null,
'location_name' => $p['location_name'] ?? '',
]) ?></td>
<td><span class="badge badge-info"><?= $this->e($p['role_name']) ?></span></td>
<td><?= $p['granted_at'] ? $this->e(date('d.m.Y', strtotime((string)$p['granted_at']))) : '–' ?></td>
<td><?= $this->e($p['granted_by_name'] ?? '–') ?></td>
</tr>
<?php endforeach; ?>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php else: ?>
<div class="empty-state">
<i class="fas fa-table"></i>
<p><?= $this->te('Keine Zuweisung passt zu diesem Filter.') ?></p>
</div>
<?php endif; ?>