<?php
$admin_id = get_int('yonetici');
$q = get('q', '');
$where = '1 = 1';
$params = [];
if ($admin_id) {
$where .= ' AND admin_id = ?';
$params[] = $admin_id;
}
if ($q !== '') {
$where .= ' AND (action LIKE ? OR subject LIKE ?)';
array_push($params, "%$q%", "%$q%");
}
$total = db_value("SELECT COUNT(*) FROM activity_log WHERE $where", $params);
$pager = paginate($total, 50, get_int('sayfa', 1));
$rows = db_all("SELECT * FROM activity_log WHERE $where ORDER BY id DESC LIMIT {$pager['limit']} OFFSET {$pager['offset']}", $params);
admin_header('İşlem günlüğü');
?>
<form class="mb-6 flex flex-wrap gap-2">
<select name="yonetici" class="input w-56 py-2">
<option value="">Tüm yöneticiler</option>
<?php foreach (db_all('SELECT id, name FROM admins ORDER BY name') as $admin): ?>
<option value="<?= $admin['id'] ?>" <?= $admin_id === (int) $admin['id'] ? 'selected' : '' ?>><?= e($admin['name']) ?></option>
<?php endforeach ?>
</select>
<input name="q" value="<?= e($q) ?>" placeholder="İşlem ara" class="input w-64 py-2">
<button class="btn-light btn-sm">Filtrele</button>
</form>
<div class="card overflow-x-auto">
<table class="w-full min-w-[720px] text-left text-sm">
<thead class="border-b border-zinc-200 text-xs text-zinc-500">
<tr><th class="px-5 py-3 font-medium">Zaman</th><th class="px-5 py-3 font-medium">Yönetici</th><th class="px-5 py-3 font-medium">İşlem</th><th class="px-5 py-3 font-medium">Ayrıntı</th><th class="px-5 py-3 font-medium">IP</th></tr>
</thead>
<tbody class="divide-y divide-zinc-100">
<?php foreach ($rows as $row): ?>
<tr class="hover:bg-zinc-50">
<td class="px-5 py-3 whitespace-nowrap text-zinc-500"><?= date_tr($row['created_at'], true) ?></td>
<td class="px-5 py-3 font-medium"><?= e($row['admin_name'] ?: '—') ?></td>
<td class="px-5 py-3"><?= e($row['action']) ?></td>
<td class="px-5 py-3 text-zinc-600"><?= e($row['subject'] ?: '') ?></td>
<td class="px-5 py-3 font-mono text-xs text-zinc-400"><?= e($row['ip']) ?></td>
</tr>
<?php endforeach ?>
<?php if (!$rows): ?><tr><td colspan="5" class="px-5 py-16 text-center text-zinc-500">Kayıt yok.</td></tr><?php endif ?>
</tbody>
</table>
</div>
<?php pagination($pager) ?>
<?php admin_footer() ?>
Lisans bilgisi projenin LICENSE dosyasında.