# ANPR Reads App (PHP + MySQL)

## What this does
- Ingest ANPR reads via `public/webhook_listener.php` (expects JSON with `RecordCreated`, `Direction`, `Registration`, `AssetId`)
- Map cameras (AssetId) to Sites
- Users can be restricted to one/many Sites
- Dashboard auto-updates every 3 seconds (polling)
- Admin UI for Users / Sites / Assets

## Install
1) Create a MySQL database (utf8mb4).
2) Import `install.sql`.
3) Copy `includes/config.php` to `includes/config.local.php` and edit DB creds + secrets.
4) Upload the folder so the webroot points to `/public` (or access pages under `/public/...`).

### Default admin login
- Email: `admin@example.com`
- Password: `Admin123!`
**Change this immediately.**

## Webhook
POST to:
- `/public/webhook_listener.php`

Header:
- `X-Webhook-Token: <your token>` (set in config.local.php `webhook_token`)

Body example:
```json
{"RecordCreated":"2026-02-03T12:16:24Z","Direction":"TOW-DIR","Registration":"LE69EOS","AssetId":"<camera-id>"}
```

## Notes
- Unmapped AssetIds seen in reads appear in Admin → Assets so you can quickly create/assign them.
- When you assign an Asset to sites, it also backfills historical reads to link them to that Asset.
