SYSTEM AUDIT TRAIL SETUP

INSTALL
1. Copy the updated files from api1/api into the matching api folder in skill_end:
   - session_auth.php (replace existing)
   - users.php (replace existing)
   - system_audit.php (new)
   - system_audit_schema.sql (new; run in pgAdmin 4)
2. In pgAdmin 4, select the same database used by skill_end and run system_audit_schema.sql after the normal application tables have been created.
3. Keep the project's existing config/database.php in place. The endpoint uses the same PostgreSQL connection.
4. The Flutter panel requests {ApiClient.baseUrl}/api/system_audit.php.

STAFF ACTIVITY VIEW
- The first API view returns a staff directory with today's activity count, this month's activity count, all-time count, latest activity and campus.
- Selecting a staff card requests that person's activity in the same panel. The detail view can show today, this month, or all records and groups entries by date.
- Every activity entry includes the campus captured when the operation happened.
- Administrators can see staff activity across campuses. Staff can see staff accounts and event records for their own campus only.

WHAT IS RECORDED
- Successful sign-ins and sign-outs are written by users.php.
- Authenticated INSERT, UPDATE and DELETE operations on existing database tables are recorded by PostgreSQL triggers. The log stores table, record id, action, actor, campus, time and IP address. It does not copy row contents or passwords.
- The SQL migration attaches triggers to tables that exist when it runs. Run it again after adding new database tables.

API ROUTES
- GET /api/system_audit.php?view=staff&q=search-text
- GET /api/system_audit.php?view=events&actor_id=ID&period=day|month|all&page=1
- The endpoint returns JSON errors when setup is incomplete; it does not render an HTML page.
