# Hostiva V5 — Elite STR Ecosystem

**Additive on V3 + V4** — nothing removed.

## Activate

```sql
mysql -u root -p hostiva < database/migrations_003_v5_ecosystem.sql
```

Import V4 migration first if not done: `migrations_002_v4_str_os.sql`

## Owner portal

1. Create user with role **Owner** (Team page) or assign role_id for `owner` in DB
2. Link properties: `INSERT INTO property_owners (property_id, user_id) VALUES (1, USER_ID);`
3. Login → auto redirect to `pages/owner/dashboard.html`

## Staff features

| Page | Path |
|------|------|
| Workflow Builder | `pages/automations-builder.html` |
| System Jobs | Sidebar → System Jobs (runs OTA + background queue) |

## API routes (new)

- `owner?section=dashboard|bookings|financial|support|announcements`
- `jobs`, `jobs/run`
- `workflows` (GET/POST builder)
- `health/v5`

## Double-booking (V5)

- `reservation_locks` table + `hv5_acquire_reservation_lock` on booking create
- OTA webhooks use `hv5_process_inbound_reservation` with conflict detection
- Outbound OTA sync queued on every new booking

## Production (optional)

- `cron/run-jobs.php` via Windows Task Scheduler or Linux cron
- Set `v4.ota_mode` = `live` + API keys in `config.php`
- Redis: configure in future `v5.redis` block (file cache used on XAMPP)

## Test checklist (XAMPP)

- [ ] `api/index.php?r=ping`
- [ ] Staff login → dashboard + command center
- [ ] Owner login → owner portal
- [ ] Create booking → no double book on same dates
- [ ] OTA → process queue
- [ ] Workflow builder save
- [ ] `php cron/run-jobs.php`
