# Lesotho Livestock Device/User Tracking Patch

Deploy these files over the current PHP system, then run:

```sql
SOURCE sql/patch_device_tracking.sql;
```

If your database name is not `aia_lscensus`, edit the first line of the SQL file.

## What this adds
- A `devices` table.
- Each offline record includes `device_id`, `device_name`, `app_version`, `sync_guid`.
- Each synced owner record stores who captured it and which device captured it.
- Devices can be blocked from future sync.
- `devices.php` shows device/user visibility.

## Important files
- `config.php` adds `register_device()` and `check_device_allowed()`.
- `api/login.php` registers/checks devices during login.
- `api/sync_upload.php` registers/checks devices during sync and logs clear failure messages.
- `capture.php` generates a stable `LS-...` device id in browser local storage.
- `devices.php` is the device admin screen.
