---
phase: 21-order-source-display
plan: 01
subsystem: ui
tags: [orders, integrations, display]

requires:
  - phase: none
    provides: n/a
provides:
  - integration name display on orders list
  - integration name display on order detail page
affects: []

tech-stack:
  added: []
  patterns: [integration name fallback pattern]

key-files:
  created: []
  modified:
    - src/Modules/Orders/OrdersRepository.php
    - src/Modules/Orders/OrdersController.php
    - resources/views/orders/show.php

key-decisions:
  - "Fallback: integration_name → sourceLabel() dla Allegro/Erli/starych danych"

patterns-established:
  - "Integration name resolution: prefer integrations.name, fallback to sourceLabel(source)"

duration: 5min
started: 2026-03-22T00:00:00Z
completed: 2026-03-22T00:00:00Z
---

# Phase 21 Plan 01: Order Source Display Summary

**LEFT JOIN integrations w query zamowien — lista i szczegoly pokazuja nazwe integracji zamiast generycznego "shopPRO"**

## Performance

| Metric | Value |
|--------|-------|
| Duration | ~5min |
| Tasks | 2 completed |
| Files modified | 3 |

## Acceptance Criteria Results

| Criterion | Status | Notes |
|-----------|--------|-------|
| AC-1: Integration name on list | Pass | LEFT JOIN integrations, fallback na sourceLabel |
| AC-2: Integration name on detail | Pass | show.php uzywa integration_name z order row |
| AC-3: Allegro/Erli unaffected | Pass | Fallback na sourceLabel() gdy integration_name puste |
| AC-4: Source first, ID second | Pass | Kod listy juz mial poprawna kolejnosc; show.php poprawiony |

## Accomplishments

- Query listy zamowien i szczegulow dolacza tabele `integrations` (LEFT JOIN) i zwraca `integration_name`
- Lista zamowien wyswietla nazwe integracji (np. "Moj Sklep") zamiast generycznego "shopPRO"
- Strona szczegulow zamowienia rozdzielona na dwa spany z prefiksem "ID:"

## Files Created/Modified

| File | Change | Purpose |
|------|--------|---------|
| `src/Modules/Orders/OrdersRepository.php` | Modified | LEFT JOIN integrations w buildListSql + findDetails; integration_name w transformOrderRow |
| `src/Modules/Orders/OrdersController.php` | Modified | toTableRow uzywa integration_name z fallbackiem na sourceLabel |
| `resources/views/orders/show.php` | Modified | Naglowek: osobne spany, nazwa integracji + prefiks "ID:" |

## Decisions Made

| Decision | Rationale | Impact |
|----------|-----------|--------|
| Fallback na sourceLabel() gdy integration_name puste | Allegro/Erli nie maja wpisow w integrations dla kazdego zamowienia; stare zamowienia moga miec NULL integration_id | Brak regresji |

## Deviations from Plan

None — plan executed exactly as written.

## Issues Encountered

None.

## Next Phase Readiness

**Ready:**
- Todo #15 i #17 zrealizowane
- Milestone v0.8 gotowy do zamkniecia

**Concerns:**
- None

**Blockers:**
- None

---
*Phase: 21-order-source-display, Plan: 01*
*Completed: 2026-03-22*
