# KYN POS Phase 4 — Order Workflow + KDS + Devices + Printers + Offline Sync Foundation

## Purpose

Phase 4 stabilizes the order-line workflow before payments and adds four architectural foundations that should not be patched in later:

1. Modifiers, special instructions, quantity edits, draft-line removal, and send-to-kitchen workflow.
2. KDS queue and kitchen status updates.
3. Device/station registration for POS terminals, KDS screens, tablets, manager stations, and future station-specific devices.
4. Printer profiles/routes and print job queue foundation for Wi-Fi/network and Bluetooth-capable setups.
5. Offline sync foundation for shared cPanel hosting using local browser queue → secure sync API → server staging tables.

## Important architecture decision

KYN POS does not try to run a local MySQL server and sync it directly to cPanel MySQL. On shared hosting, that would be fragile and difficult to control.

The safer direction is:

```text
Device/browser local IndexedDB event queue
→ authenticated sync API on cPanel
→ server-side idempotent event staging
→ controlled server apply/conflict processor
→ main online database
```

This phase creates the foundation, not the final conflict engine.

## New pages

- `page.php?p=pos_add_item`
- `page.php?p=kds`
- `page.php?p=setup_devices`
- `page.php?p=setup_printers`
- `page.php?p=sync_status`

## New schema

- `pos_stations`
- `pos_device_station_assignments`
- `pos_kds_line_queue`
- `pos_printers`
- `pos_printer_routes`
- `pos_print_jobs`
- `pos_sync_clients`
- `pos_sync_events`
- `pos_sync_conflicts`

## Printer note

Shared hosting generally cannot reliably print directly to a restaurant LAN printer or Bluetooth printer. The right model is to queue jobs on the server and let a local registered browser/device/native wrapper retrieve and print them.

Phase 4 stores printer profiles and test print jobs. Actual printer bridge execution should be implemented after we decide the hardware/device strategy.

## Payments intentionally excluded

Payments are still not implemented. The order-line/KDS/device/offline foundations must be stable first.
