@extends('layouts.app')
@section('title','Audit Trail') @section('page_title','Audit Trail')
@section('content')<div class="page-header"><div><h1>Immutable Audit Trail</h1><p class="muted">Track financial posting, approvals, reversals, settings, permissions and operational changes.</p></div>@if(auth()->user()->hasPermission('audit_logs.export'))<a class="btn btn-secondary" href="{{ route('audit.export',request()->query()) }}">Export CSV</a>@endif</div>
<div class="card"><div class="card-header"><form class="filter-bar" method="get"><input class="control" name="search" value="{{ request('search') }}" placeholder="User, record or reason"><select class="control" name="module"><option value="">All modules</option>@foreach($modules as $module)<option value="{{ $module }}" @selected(request('module')===$module)>{{ $module }}</option>@endforeach</select><input class="control" type="date" name="from" value="{{ request('from') }}"><input class="control" type="date" name="to" value="{{ request('to') }}"><button class="btn btn-secondary">Filter</button></form></div><div class="table-wrap"><table><thead><tr><th>Date/Time</th><th>User</th><th>Action</th><th>Module</th><th>Record</th><th>IP</th><th></th></tr></thead><tbody>@forelse($logs as $log)<tr><td>{{ $log->occurred_at?->format('d M Y H:i:s') }}</td><td>{{ $log->user?->name }}<div class="muted">{{ $log->user?->email }}</div></td><td><span class="badge">{{ $log->action }}</span></td><td>{{ $log->module }}</td><td>{{ class_basename($log->record_type) }} #{{ $log->record_id }}</td><td>{{ $log->ip_address }}</td><td><a class="btn btn-secondary btn-sm" href="{{ route('audit.show',$log) }}">Details</a></td></tr>@empty<tr><td colspan="7" class="empty">No audit events match these filters.</td></tr>@endforelse</tbody></table></div><div class="card-footer">{{ $logs->links() }}</div></div>
@endsection
