# Info Board — Layout Design

## Current state (implemented)

| Section | Content |
|---|---|
| KPI row | Active MOs · Late MOs · Completed this month · Planned hrs (week) · Downtime (week) · Scrap pending · Scrap qty · Scrap cost |
| Workstation Overview | Per WS: Active MOs · Late · Planned hrs · DT mins (filtered to active/late only) |
| Capacity Grid | Next 10 working days × WS — colour-coded fill % |
| Operation Tracking Log | Paginated optracking entries with filters (WS / MO / User / Date range) |
| Scrap | Pending confirm rows + booked rows for period |

---

## Proposed additions (inspired by daily Excel production report)

### Section D — Daily Performance table

Per workstation, per day (date range from global filter).  
Data sources: `llx_planning_schedule`, `llx_mrp_mo`, `llx_product_extrafields`, `llx_mrp_mo_optracking`, `llx_planning_downtime`, `llx_scrap`.

| Column | Source | Notes |
|---|---|---|
| WS | `llx_workstation_workstation` | row header |
| Date | days in filter range (working days only) | col header |
| Planned qty | `SUM(ps.planned_hours × IF(ws.ref LIKE 'FM%', pe.qty_per_hour_form, pe.qty_per_hour_trim))` | JOIN: `planning_schedule ps` → `mrp_mo mo ON mo.rowid=ps.fk_mo` → `product_extrafields pe ON pe.fk_object=mo.fk_product` — calculated per row, then summed per WS+day |
| Actual qty | `SUM(qty_delta)` from `llx_mrp_mo_optracking` grouped by `fk_ws` + `DATE(date_entry)` | |
| Performance % | `actual / planned × 100` | <60% red · 60–90% amber · ≥90% green |
| Downtime (min) | `SUM(duration_minutes)` from `llx_planning_downtime` grouped by `fk_ws` + `downtime_date` | |
| Scrap qty | `SUM(qty)` from `llx_scrap` grouped by `fk_ws` + `DATE(scrap_date)` | |
| Quality % | `(actual - scrap) / actual × 100` | same color thresholds; N/A if actual=0 |

WS filter: only `FM*`, `CNC*`, `LASER*` refs — others have no `qty_per_hour` and are excluded.  
If `qty_per_hour_form` / `qty_per_hour_trim` is NULL for a product → that schedule row contributes 0 to planned qty.

---

### Section E — Shift breakdown (optional / future)

If `scanstation_log` contains `shift_code` data:  
rows = WS × shift (C1 / C2 / C3), same Performance + Quality columns.

Currently shift data is sparse — mark as **deferred** until ScanStation records shift consistently.

---

### Section F — OEE summary row (future)

Requires OEE module data. Deferred — depends on `oee` module implementation.

---

## Layout order (target)

```
[ KPI row ]
[ Section A — Workstation Overview table ]
[ Section D — Daily Performance table ]    ← NEW
[ Section C — Capacity Grid ]
[ Operation Tracking Log ]
[ Scrap ]
```

---

## Decisions

- **qty_per_hour field**: mapped by WS `ref` prefix:
  - `FM*` (FM2–FM9) → `qty_per_hour_form`
  - `CNC*` (CNC4, CNC5) / `LASER*` (LASER1, LASER2) → `qty_per_hour_trim`
  - All others (CHEMI, DESPATCH, DRILL, INSPECTION, PACKING, PLASMA, PRE-HEAT) → no qty_per_hour → skip from Section D (planned qty = N/A)
- **Planned qty formula**: `SUM(planned_hours) × qty_per_hour` is correct — no BOM query needed.
- **Date range**: Section D respects the global filter (date_from / date_to).
