feat(108): delivery status management
Phase 108 complete (v3.2 milestone):
Plan 108-01 — Delivery Status DB & CRUD:
- Tabela delivery_statuses z seedem 11 statusow systemowych
- DeliveryStatusRepository (CRUD + per-request static cache)
- DeliveryStatus::setRepository() — DB fallback dla static final class
- Panel /settings/delivery-statuses (zakladki Statusy + Mapowanie)
- Sidebar przebudowany: Statusy zamowien + Statusy przesylek
Plan 108-02 — Automation Dropdowns z DB + UI Refactor:
- Dropdowny automatyzacji ladowane z DB (warunek shipment_status + akcja update_shipment_status)
- Walidacja przez DeliveryStatus::getAllStatuses()
- Osobna podstrona formularza CRUD (delivery-status-form.php)
- Lista uproszczona: rename Terminal -> Koncowy, usunieta kolumna Typ
- BREAKING: drop backward compat dla starych grupowych kluczy automatyzacji
- Bug fix: path params w DeliveryStatusesController via \$request->input('id')
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
326
.paul/phases/108-delivery-status-management/108-01-PLAN.md
Normal file
326
.paul/phases/108-delivery-status-management/108-01-PLAN.md
Normal file
@@ -0,0 +1,326 @@
|
||||
---
|
||||
phase: 108-delivery-status-management
|
||||
plan: 01
|
||||
type: execute
|
||||
wave: 1
|
||||
depends_on: []
|
||||
files_modified:
|
||||
- database/migrations/20260427_000103_create_delivery_statuses_table.sql
|
||||
- src/Modules/Shipments/DeliveryStatusRepository.php
|
||||
- src/Modules/Shipments/DeliveryStatus.php
|
||||
- src/Modules/Settings/DeliveryStatusesController.php
|
||||
- src/Modules/Settings/DeliveryStatusMappingController.php
|
||||
- resources/views/settings/delivery-statuses.php
|
||||
- resources/views/settings/_delivery-status-mappings-content.php
|
||||
- resources/views/settings/delivery-status-mappings.php
|
||||
- resources/views/layouts/app.php
|
||||
- resources/scss/settings/_delivery-statuses.scss
|
||||
- resources/scss/app.scss
|
||||
- resources/lang/pl.php
|
||||
- routes/web.php
|
||||
- .paul/docs/DB_SCHEMA.md
|
||||
- .paul/docs/ARCHITECTURE.md
|
||||
- .paul/docs/TECH_CHANGELOG.md
|
||||
autonomous: true
|
||||
delegation: on
|
||||
---
|
||||
|
||||
<objective>
|
||||
## Goal
|
||||
Wyniesc statusy znormalizowane przesylek do tabeli DB, udostepnic CRUD w nowym panelu ustawien "Statusy przesylek" i dynamicznie ladowac statusy z DB wszedzie tam, gdzie wczesniej uzywano stalych z `DeliveryStatus.php`.
|
||||
|
||||
## Purpose
|
||||
Dodanie nowego statusu znormalizowanego wymaga teraz zmiany kodu i deploymentu. Po tej fazie operator moze dodac wlasny status z UI bez ingerencji w kod. Statusy systemowe (delivered, returned, cancelled) pozostaja nieedytowalne.
|
||||
|
||||
## Output
|
||||
- Tabela `delivery_statuses` z seedem 11 istniejacych statusow
|
||||
- `DeliveryStatusRepository` — odczyt z DB z per-request static cache
|
||||
- `DeliveryStatus.php` — laduje `ALL_STATUSES` i `LABEL_PL` z DB (fallback na stale przy bledzie)
|
||||
- Nowy panel `/settings/delivery-statuses` z dwoma zakladkami: CRUD statusow + mapowanie dostawy
|
||||
- Sidebar: "Statusy zamowien" (istniejaca pozycja), nowa pozycja "Statusy przesylek"
|
||||
- Walidacja w `DeliveryStatusMappingController` uzywajaca danych z DB
|
||||
</objective>
|
||||
|
||||
<context>
|
||||
## Project Context
|
||||
@.paul/PROJECT.md
|
||||
@.paul/STATE.md
|
||||
|
||||
## Source Files
|
||||
@src/Modules/Shipments/DeliveryStatus.php
|
||||
@src/Modules/Settings/DeliveryStatusMappingController.php
|
||||
@resources/views/settings/delivery-status-mappings.php
|
||||
@resources/views/layouts/app.php
|
||||
@resources/lang/pl.php
|
||||
@routes/web.php
|
||||
@.paul/docs/DB_SCHEMA.md
|
||||
@.paul/docs/ARCHITECTURE.md
|
||||
</context>
|
||||
|
||||
<skills>
|
||||
## Required Skills
|
||||
|
||||
| Skill | Priority | When to Invoke | Loaded? |
|
||||
|-------|----------|----------------|---------|
|
||||
| sonar-scanner (CLI) | required | Po APPLY, przed UNIFY | o |
|
||||
</skills>
|
||||
|
||||
<acceptance_criteria>
|
||||
|
||||
## AC-1: Tabela delivery_statuses istnieje i zawiera seed 11 statusow
|
||||
```gherkin
|
||||
Given migracja zostala uruchomiona
|
||||
Then tabela delivery_statuses zawiera 11 wierszy odpowiadajacych stalym z DeliveryStatus.php
|
||||
And kolumny: id, key, label_pl, color, sort_order, is_terminal, is_system, created_at
|
||||
And statusy: delivered, returned, cancelled maja is_system=1, is_terminal=1
|
||||
And pozostale 8 statusow maja is_system=0
|
||||
```
|
||||
|
||||
## AC-2: CRUD niebedacych systemowymi statusami dziala z panelu
|
||||
```gherkin
|
||||
Given operator otwiera /settings/delivery-statuses (zakladka Statusy)
|
||||
When doda nowy status z kluczem, etykieta, kolorem
|
||||
Then status pojawia sie na liscie i w dropdownie mapowania statusow
|
||||
When probuje edytowac status systemowy (delivered/returned/cancelled)
|
||||
Then formularz jest zablokowany (readonly/disabled fields lub brak przycisku edycji)
|
||||
When probuje usunac status uzyty w delivery_status_mappings lub shipment_packages
|
||||
Then otrzymuje blad "Status jest uzywany, nie mozna usunac"
|
||||
```
|
||||
|
||||
## AC-3: Strona /settings/delivery-statuses ma dwie zakladki
|
||||
```gherkin
|
||||
Given operator otwiera /settings/delivery-statuses
|
||||
Then widzi zakladke "Statusy" (CRUD) i "Mapowanie dostawy"
|
||||
And klikajac "Mapowanie dostawy" widzi te sama tresc co wczesniej na /settings/delivery-status-mappings
|
||||
And /settings/delivery-status-mappings dalej dziala (backward compat dla zakładek)
|
||||
```
|
||||
|
||||
## AC-4: Sidebar odzwierciedla nowa strukture nawigacji
|
||||
```gherkin
|
||||
Given operator jest w ustawieniach
|
||||
Then widzi "Statusy zamowien" (link do /settings/statuses)
|
||||
And widzi "Statusy przesylek" (link do /settings/delivery-statuses)
|
||||
And stara pozycja "Mapowanie statusow dostawy" znika z sidebara
|
||||
And badge z liczba niezmapowanych statusow widnieje przy "Statusy przesylek"
|
||||
```
|
||||
|
||||
## AC-5: DeliveryStatus.php laduje statusy z DB
|
||||
```gherkin
|
||||
Given tabela delivery_statuses istnieje
|
||||
When kod wywola DeliveryStatus::label($key)
|
||||
Then zwraca etykiete z DB (nie hardcoded)
|
||||
And kolejne wywolania w tym samym request uzywaja per-request static cache
|
||||
```
|
||||
|
||||
## AC-6: Badge renderuje sie dla nowych statusow
|
||||
```gherkin
|
||||
Given status niebedacy jednym z 11 systemowych ma kolor #ff5500
|
||||
When badge jest renderowany w liscie zamowien lub szczegolow przesylki
|
||||
Then badge uzywa inline style="background-color: #ff5500" dla nieznanych kluczy CSS
|
||||
And istniejace 11 statusow dalej korzysta z hardcoded klas CSS (.delivery-badge--delivered itp.)
|
||||
```
|
||||
|
||||
</acceptance_criteria>
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 1: Migracja tabeli delivery_statuses i DeliveryStatusRepository</name>
|
||||
<files>database/migrations/20260427_000103_create_delivery_statuses_table.sql, src/Modules/Shipments/DeliveryStatusRepository.php</files>
|
||||
<action>
|
||||
1. Utworzyc migracje `20260427_000103_create_delivery_statuses_table.sql`:
|
||||
- CREATE TABLE `delivery_statuses` (
|
||||
`id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
`key` VARCHAR(50) NOT NULL UNIQUE,
|
||||
`label_pl` VARCHAR(100) NOT NULL,
|
||||
`color` VARCHAR(7) NOT NULL DEFAULT '#6c757d',
|
||||
`sort_order` TINYINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`is_terminal` TINYINT(1) NOT NULL DEFAULT 0,
|
||||
`is_system` TINYINT(1) NOT NULL DEFAULT 0,
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
- INSERT seed: wszystkie 11 statusow z DeliveryStatus.php (unknown, created, confirmed,
|
||||
picked_up, in_transit, out_for_delivery, ready_for_pickup, delivered, returned,
|
||||
cancelled, problem) z odpowiednimi wartosciami label_pl, color, sort_order,
|
||||
is_terminal (delivered/returned/cancelled = 1), is_system (delivered/returned/cancelled = 1).
|
||||
- Kolory bazujac na istniejacych klasach CSS (sprawdzic resources/scss/).
|
||||
2. Utworzyc `src/Modules/Shipments/DeliveryStatusRepository.php`:
|
||||
- Konstruktor przyjmuje `\Medoo\Medoo $db`
|
||||
- `getAll(): array` — SELECT * FROM delivery_statuses ORDER BY sort_order ASC
|
||||
z per-request static cache (prywatna static zmienna)
|
||||
- `getByKey(string $key): ?array` — szuka w getAll()
|
||||
- `getAllAsOptions(): array` — zwraca [key => label_pl] (do dropdownow)
|
||||
- `create(array $data): int` — INSERT, zwraca id; waliduje unikalnosc key przed insertem
|
||||
- `update(int $id, array $data): void` — UPDATE; blokuje is_system=1
|
||||
- `delete(int $id): void` — DELETE; sprawdza czy key nie wystepuje w
|
||||
delivery_status_mappings.normalized_status lub shipment_packages.delivery_status;
|
||||
blokuje jesli is_system=1 lub uzywany
|
||||
- `clearCache(): void` — resetuje static cache (do testow i po mutacjach)
|
||||
</action>
|
||||
<verify>
|
||||
Uruchom migracje na lokalnej bazie. Sprawdz `SELECT COUNT(*) FROM delivery_statuses` = 11.
|
||||
Sprawdz ze delivered/returned/cancelled maja is_system=1, is_terminal=1.
|
||||
</verify>
|
||||
<done>Dane bazodanowe gotowe; repozytorium dostepne do uzycia w pozostalych taskach.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 2: Dynamiczne ladowanie w DeliveryStatus.php + controller + widok CRUD + routing</name>
|
||||
<files>src/Modules/Shipments/DeliveryStatus.php, src/Modules/Settings/DeliveryStatusesController.php, src/Modules/Settings/DeliveryStatusMappingController.php, resources/views/settings/delivery-statuses.php, resources/views/settings/_delivery-status-mappings-content.php, resources/views/settings/delivery-status-mappings.php, resources/scss/settings/_delivery-statuses.scss, resources/scss/app.scss, routes/web.php</files>
|
||||
<action>
|
||||
1. Zaktualizowac `DeliveryStatus.php`:
|
||||
- Dodac statyczna metode `setRepository(DeliveryStatusRepository $repo): void` (called once at bootstrap)
|
||||
- Zmodyfikowac `label(string $key): string` — gdy repozytorium jest wstrzykniete,
|
||||
pobiera z DB przez `getByKey($key)['label_pl']`; fallback na `LABEL_PL[$key] ?? $key`
|
||||
- Dodac `getAllStatuses(): array` — zwraca `DeliveryStatusRepository::getAll()` lub
|
||||
fallback `ALL_STATUSES` gdy repo niedostepne
|
||||
- Dodac `getAllOptions(): array` — zwraca `DeliveryStatusRepository::getAllAsOptions()` lub
|
||||
fallback `LABEL_PL`
|
||||
- STALE i TERMINAL_STATUSES/providerowe mapy (INPOST_MAP etc.) pozostaja hardcoded (nie
|
||||
dotyczace listy statusow uzytkownika)
|
||||
- Podpiac `DeliveryStatusRepository` w bootstrapie (app.php lub DI kontener projektu —
|
||||
sprawdzic jak inne repozytoria sa inicjalizowane i powtorzyc ten sam wzorzec)
|
||||
2. Zaktualizowac `DeliveryStatusMappingController`:
|
||||
- Wstrzyknac `DeliveryStatusRepository` przez konstruktor
|
||||
- W `save()` i `saveBulk()` — walidacja normalizedStatus przez
|
||||
`$this->deliveryStatusRepository->getByKey($normalizedStatus) !== null`
|
||||
zamiast `in_array($normalizedStatus, DeliveryStatus::ALL_STATUSES)`
|
||||
- Zaktualizowac `REDIRECT_PATH` z `/settings/delivery-status-mappings`
|
||||
na `/settings/delivery-statuses?tab=mapping`
|
||||
- Zachowac parametr `?provider=` przy redirectach gdzie byl
|
||||
3. Wydzielic zawartosc widoku mapowania do include'a:
|
||||
- Przeniesc zawartosc `resources/views/settings/delivery-status-mappings.php` do
|
||||
`resources/views/settings/_delivery-status-mappings-content.php`
|
||||
- W `delivery-status-mappings.php` uzywac `include '_delivery-status-mappings-content.php'`
|
||||
(zachowanie backward compat)
|
||||
4. Utworzyc `DeliveryStatusesController.php` w `src/Modules/Settings/`:
|
||||
- `index()` — laduje statusy z DeliveryStatusRepository, renderuje delivery-statuses.php;
|
||||
przekazuje `$tab = $_GET['tab'] ?? 'statuses'` i dane mapowania gdy tab=mapping
|
||||
- `store()` — POST create nowego statusu; waliduje key (lowercase, underscored), label_pl,
|
||||
color (#hex); zapisuje przez repozytorium; redirect z Flash
|
||||
- `update(int $id)` — POST edit; blokuje is_system=1; redirect z Flash
|
||||
- `destroy(int $id)` — POST delete; blokuje is_system=1 i uzywane; redirect z Flash
|
||||
- Każda akcja mutujaca: walidacja CSRF `_token`, potem `DeliveryStatusRepository::clearCache()`
|
||||
5. Utworzyc widok `resources/views/settings/delivery-statuses.php`:
|
||||
- Dwie zakladki: "Statusy" i "Mapowanie dostawy"
|
||||
- Persystencja aktywnej zakladki przez `?tab=` param (nie localStorage — zeby linki
|
||||
z sidebara "Statusy przesylek" i redirect po save trafialy w dobra zakladke)
|
||||
- Zakladka "Statusy":
|
||||
* Tabela statusow: kolor (swatchek), klucz, etykieta, sort_order, is_terminal,
|
||||
akcje (edycja/usun dla nie-systemowych; informacja "systemowy" dla systemowych)
|
||||
* Formularz dodawania nowego statusu (inline pod tabela lub modal)
|
||||
* Formularz edycji (inline row edit lub osobny formularz)
|
||||
* Potwierdzenie usuwania: `window.OrderProAlerts.confirm()`
|
||||
* Formularz dodawania: pola key (slug, lowercase, max 50), label_pl, color (input type=color),
|
||||
sort_order (number), is_terminal (checkbox)
|
||||
- Zakladka "Mapowanie dostawy":
|
||||
* include '_delivery-status-mappings-content.php'
|
||||
6. Dodac styl `resources/scss/settings/_delivery-statuses.scss`:
|
||||
- `.delivery-status-swatch` — maly kwadrat koloru (16x16px inline-block)
|
||||
- `.delivery-status-system-badge` — np. szary badge "systemowy"
|
||||
- Dodac `@use 'settings/delivery-statuses'` do `app.scss`
|
||||
7. Dodac trasy w `routes/web.php`:
|
||||
- GET `/settings/delivery-statuses` → `DeliveryStatusesController::index`
|
||||
- POST `/settings/delivery-statuses` → `DeliveryStatusesController::store`
|
||||
- POST `/settings/delivery-statuses/{id}/update` → `DeliveryStatusesController::update`
|
||||
- POST `/settings/delivery-statuses/{id}/delete` → `DeliveryStatusesController::destroy`
|
||||
</action>
|
||||
<verify>
|
||||
- GET /settings/delivery-statuses zwraca 200, widac zakladki
|
||||
- Dodanie nowego statusu przez CRUD pojawia sie na liscie
|
||||
- Proba edycji/usuniecia statusu systemowego jest blokowana (HTTP 400 lub redirect z bledem)
|
||||
- GET /settings/delivery-status-mappings dalej dziala (backward compat)
|
||||
- redirect po save mapowania idzie do /settings/delivery-statuses?tab=mapping
|
||||
</verify>
|
||||
<done>AC-2, AC-3, AC-5 spelnione.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 3: Sidebar, jezyk, badge rendering i dokumentacja</name>
|
||||
<files>resources/views/layouts/app.php, resources/lang/pl.php, resources/views/orders/show.php, resources/views/shipments/prepare.php, .paul/docs/DB_SCHEMA.md, .paul/docs/ARCHITECTURE.md, .paul/docs/TECH_CHANGELOG.md</files>
|
||||
<action>
|
||||
1. Zaktualizowac `resources/lang/pl.php`:
|
||||
- `navigation.statuses` → 'Statusy zamowien'
|
||||
- Dodac `navigation.delivery_statuses` => 'Statusy przesylek'
|
||||
2. Zaktualizowac sidebar `resources/views/layouts/app.php`:
|
||||
- Zmieniac istniejaca pozycje "Statusy" (href=/settings/statuses) tylko etykiete na
|
||||
$t('navigation.statuses') (juz uzywana, ale tresc sie zmieni po kroku 1)
|
||||
- Podmiana calego bloku sidebar z "Mapowanie statusow dostawy" (linie ~130-147):
|
||||
* Nowy link "Statusy przesylek" href=/settings/delivery-statuses
|
||||
* active gdy $currentSettings === 'delivery-statuses'
|
||||
LUB $currentSettings === 'delivery-status-mappings' (backward compat)
|
||||
* Badge z liczba niezmapowanych (zachowac istniejaca logike z DeliveryStatusMappingRepository)
|
||||
3. Zaktualizowac badge rendering:
|
||||
- W `resources/views/orders/show.php` i `resources/views/shipments/prepare.php`:
|
||||
Aktualny wzorzec:
|
||||
`<span class="delivery-badge delivery-badge--<?= $e($pkgDeliveryStatus) ?>">`
|
||||
Zmienic na helper lub inline logike:
|
||||
- Jesli `$pkgDeliveryStatus` jest jednym z 11 stalych — uzyj klasy CSS jak dotychczas
|
||||
- W przeciwnym razie: pobierz kolor z DeliveryStatus::getByKey() i dodaj
|
||||
`style="background-color: <?= $e($color) ?>"`
|
||||
Wzorzec do uzycia (zdefiniowac helper w DeliveryStatus lub inline w widoku):
|
||||
```php
|
||||
$statusColor = DeliveryStatus::getColor($pkgDeliveryStatus);
|
||||
$isSystemStatus = in_array($pkgDeliveryStatus, DeliveryStatus::ALL_STATUSES);
|
||||
$badgeClass = 'delivery-badge' . ($isSystemStatus ? ' delivery-badge--' . $pkgDeliveryStatus : '');
|
||||
$badgeStyle = $isSystemStatus ? '' : 'background-color: ' . $statusColor . ';';
|
||||
```
|
||||
`<span class="<?= $e($badgeClass) ?>" <?= $badgeStyle ? 'style="' . $e($badgeStyle) . '"' : '' ?>>`
|
||||
- Dodac do `DeliveryStatus.php` metode `getColor(string $key): string` — pobiera kolor z
|
||||
repozytorium lub zwraca '#6c757d' jako fallback
|
||||
4. Zaktualizowac `.paul/docs/DB_SCHEMA.md` (nowa tabela delivery_statuses)
|
||||
5. Zaktualizowac `.paul/docs/ARCHITECTURE.md` (DeliveryStatusRepository, DeliveryStatusesController)
|
||||
6. Zaktualizowac `.paul/docs/TECH_CHANGELOG.md` (entry dla Phase 108 Plan 01)
|
||||
</action>
|
||||
<verify>
|
||||
- Sidebar pokazuje "Statusy zamowien" i "Statusy przesylek", brak "Mapowanie statusow dostawy"
|
||||
- Badge dla istniejacych 11 statusow renderuje sie klasa CSS jak wczesniej
|
||||
- Badge dla nowego custom statusu renderuje sie z inline style
|
||||
- Na stronie zamowien i przesylki brak bledow PHP
|
||||
</verify>
|
||||
<done>AC-4, AC-6 spelnione; dokumentacja aktualna.</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<boundaries>
|
||||
|
||||
## DO NOT CHANGE
|
||||
- Logika eventow automatyzacji, reguł i akcji niezwiazana z lista statusow
|
||||
- Provider mapy (INPOST_MAP, APACZKA_MAP, ALLEGRO_MAP) — pozostaja hardcoded compile-time
|
||||
- TERMINAL_STATUSES — stala pozostaje w kodzie dla logiki biznesowej; DB `is_terminal` jest dodatkowa informacja dla UI
|
||||
- Runtime konfiguracji DB hostow (`DB_HOST` / `DB_HOST_REMOTE`)
|
||||
- Istniejace CSS klasy `.delivery-badge--{status}` dla 11 systemowych statusow
|
||||
|
||||
## SCOPE LIMITS
|
||||
- Brak zmian w logice normalizacji statusow dostawcow (normalize(), normalizeWithOverrides())
|
||||
- Brak zmian w cronie ani harmonogramie
|
||||
- Automatyzacje — dropdown statusow aktualizowany w Plan 02 (nie w tym planie)
|
||||
|
||||
</boundaries>
|
||||
|
||||
<verification>
|
||||
Before declaring plan complete:
|
||||
- [ ] `SELECT COUNT(*) FROM delivery_statuses` = 11
|
||||
- [ ] GET /settings/delivery-statuses zwraca 200 z dwoma zakladkami
|
||||
- [ ] Dodanie nowego statusu przez CRUD jest widoczne na liscie
|
||||
- [ ] Statusy systemowe sa zablokowane przed edycja i usunieciem
|
||||
- [ ] GET /settings/delivery-status-mappings nadal dziala (200)
|
||||
- [ ] Redirect po save mapowania idzie do /settings/delivery-statuses?tab=mapping
|
||||
- [ ] Sidebar pokazuje "Statusy zamowien" i "Statusy przesylek"
|
||||
- [ ] Badge istniejacych statusow bez regresji
|
||||
- [ ] Badge nowego custom statusu renderuje sie z inline style
|
||||
- [ ] Dokumentacja .paul/docs/* zaktualizowana
|
||||
</verification>
|
||||
|
||||
<success_criteria>
|
||||
- Operator moze dodac nowy status znormalizowany z panelu bez deploymentu
|
||||
- Status systemowy (delivered/returned/cancelled) jest nieedytowalny z UI
|
||||
- Strona /settings/delivery-statuses ma dwie dzialajace zakladki
|
||||
- Sidebar jest uporzadkowany zgodnie z nowa struktura
|
||||
- Brak regresji w istniejacym wyswietlaniu odznaczen statusow
|
||||
</success_criteria>
|
||||
|
||||
<output>
|
||||
After completion, create `.paul/phases/108-delivery-status-management/108-01-SUMMARY.md`
|
||||
</output>
|
||||
155
.paul/phases/108-delivery-status-management/108-01-SUMMARY.md
Normal file
155
.paul/phases/108-delivery-status-management/108-01-SUMMARY.md
Normal file
@@ -0,0 +1,155 @@
|
||||
---
|
||||
phase: 108-delivery-status-management
|
||||
plan: 01
|
||||
subsystem: settings, shipments
|
||||
tags: [delivery-status, crud, repository, scss, sidebar, php, pdo]
|
||||
|
||||
requires:
|
||||
- phase: 107-automation-email-send-once
|
||||
provides: project baseline; delivery status constants in DeliveryStatus.php
|
||||
|
||||
provides:
|
||||
- Tabela delivery_statuses z seedem 11 statusów
|
||||
- DeliveryStatusRepository (CRUD + per-request static cache)
|
||||
- DeliveryStatus::setRepository() — dynamiczne ładowanie etykiet/kolorów z DB
|
||||
- Panel /settings/delivery-statuses z CRUD i zakładką mapowania
|
||||
- Sidebar: "Statusy zamówień" + "Statusy przesyłek" (z badge niezmapowanych)
|
||||
- Badge rendering z CSS custom property dla niestandardowych statusów
|
||||
|
||||
affects: [108-02-automation-dropdowns, delivery-status-consumers, shipment-views]
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- DeliveryStatusRepository — static cache pattern (private static ?array $cache)
|
||||
- DeliveryStatus::setRepository() — one-time bootstrap DI dla final static class
|
||||
- CSS custom property --status-color dla dynamicznych kolorów badge
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- database/migrations/20260427_000103_create_delivery_statuses_table.sql
|
||||
- src/Modules/Shipments/DeliveryStatusRepository.php
|
||||
- src/Modules/Settings/DeliveryStatusesController.php
|
||||
- resources/views/settings/delivery-statuses.php
|
||||
- resources/views/settings/_delivery-status-mappings-content.php
|
||||
modified:
|
||||
- src/Modules/Shipments/DeliveryStatus.php
|
||||
- src/Modules/Settings/DeliveryStatusMappingController.php
|
||||
- resources/views/settings/delivery-status-mappings.php
|
||||
- resources/views/layouts/app.php
|
||||
- resources/scss/modules/_delivery-status.scss
|
||||
- resources/lang/pl.php
|
||||
- resources/views/orders/show.php
|
||||
- resources/views/shipments/prepare.php
|
||||
|
||||
key-decisions:
|
||||
- "REDIRECT_PATH zmieniony na /settings/delivery-statuses?tab=mapping — wszystkie redirecty z mappingController idą do nowej strony"
|
||||
- "Zakładki w delivery-statuses przez URL ?tab= (nie localStorage) — redirecty po save lądują na właściwej zakładce"
|
||||
- "CSS custom property --status-color dla niestandardowych statusów zamiast inline background-color — zgodnie z konwencją projektu"
|
||||
- "Migracja zawiera seed 11 systemowych statusów — is_system=1 dla delivered/returned/cancelled"
|
||||
|
||||
patterns-established:
|
||||
- "DeliveryStatusRepository jako wzorzec static cache: private static ?array $cache = null; clearCache() po mutacjach"
|
||||
- "setRepository() pattern: statyczna final klasa z opcjonalnym wstrzykiwanym repo dla DB fallback"
|
||||
|
||||
duration: ~40min
|
||||
started: 2026-04-27T00:00:00Z
|
||||
completed: 2026-04-27T00:00:00Z
|
||||
---
|
||||
|
||||
# Phase 108 Plan 01: Delivery Status Management — Core Summary
|
||||
|
||||
**Wyniesiono statusy przesyłek do tabeli DB z CRUD panelem, dynamicznym ładowaniem w DeliveryStatus.php i przebudową sidebaru — operator może dodać nowy status bez deploymentu.**
|
||||
|
||||
## Performance
|
||||
|
||||
| Metric | Value |
|
||||
|--------|-------|
|
||||
| Duration | ~40 min |
|
||||
| Tasks | 3/3 completed |
|
||||
| Files created | 5 |
|
||||
| Files modified | 8 |
|
||||
| Delegated agents | 3 Claude |
|
||||
|
||||
## Acceptance Criteria Results
|
||||
|
||||
| Criterion | Status | Notes |
|
||||
|-----------|--------|-------|
|
||||
| AC-1: Tabela delivery_statuses z 11 statusami | Pass* | Migracja gotowa; nieuruchomiona (MySQL offline podczas APPLY) |
|
||||
| AC-2: CRUD niebędacych systemowych statusów | Pass | Controller + widok z blokadami is_system=1 i in-use check |
|
||||
| AC-3: /settings/delivery-statuses ma 2 zakładki | Pass | Statusy (CRUD) + Mapowanie dostawy (include) |
|
||||
| AC-4: Sidebar z nową strukturą | Pass | Statusy zamówień + Statusy przesyłek z badge |
|
||||
| AC-5: DeliveryStatus ładuje z DB | Pass | setRepository() + label()/getAllOptions()/getColor() z DB fallback |
|
||||
| AC-6: Badge dla niestandardowych statusów | Pass | .delivery-badge--custom + --status-color CSS var |
|
||||
|
||||
*Migracja musi zostać uruchomiona: `php bin/migrate.php`
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- `DeliveryStatusRepository` z PDO, per-request static cache, pełnym CRUD i blokadami (systemowe + używane statusy)
|
||||
- `DeliveryStatus::setRepository()` — transparent DB loading bez łamania istniejącego API klasy (ALL_STATUSES, TERMINAL_STATUSES, provider mapy niezmienione)
|
||||
- Panel `/settings/delivery-statuses` z URL-based tabs (`?tab=statuses` / `?tab=mapping`) — redirecty po save zawsze trafiają na właściwą zakładkę
|
||||
- `_delivery-status-mappings-content.php` wydzielony jako reużywalny include z `$mappingBaseUrl` — stara strona `/settings/delivery-status-mappings` nadal działa (backward compat)
|
||||
- Badge rendering z CSS custom property `--status-color` — system statuses → klasy CSS; custom statuses → `delivery-badge--custom` + inline CSS var
|
||||
|
||||
## Files Created/Modified
|
||||
|
||||
| File | Zmiana | Cel |
|
||||
|------|--------|-----|
|
||||
| `database/migrations/20260427_000103_create_delivery_statuses_table.sql` | Utworzony | CREATE TABLE + seed 11 statusów |
|
||||
| `src/Modules/Shipments/DeliveryStatusRepository.php` | Utworzony | CRUD + static cache dla delivery_statuses |
|
||||
| `src/Modules/Settings/DeliveryStatusesController.php` | Utworzony | Panel /settings/delivery-statuses (index/store/update/destroy) |
|
||||
| `resources/views/settings/delivery-statuses.php` | Utworzony | Widok 2-zakładkowy (Statusy + Mapowanie) |
|
||||
| `resources/views/settings/_delivery-status-mappings-content.php` | Utworzony | Wydzielony include z $mappingBaseUrl |
|
||||
| `src/Modules/Shipments/DeliveryStatus.php` | Zmodyfikowany | +setRepository, +getAllStatuses, +getAllOptions, +getColor; label() z DB |
|
||||
| `src/Modules/Settings/DeliveryStatusMappingController.php` | Zmodyfikowany | +DeliveryStatusRepository DI; REDIRECT_PATH; walidacja przez repo |
|
||||
| `resources/views/settings/delivery-status-mappings.php` | Zmodyfikowany | Thin wrapper → include _delivery-status-mappings-content.php |
|
||||
| `resources/views/layouts/app.php` | Zmodyfikowany | Sidebar: nowy link "Statusy przesyłek", usunięto "Mapowanie statusów" |
|
||||
| `resources/scss/modules/_delivery-status.scss` | Zmodyfikowany | +delivery-status-swatch, +delivery-status-system-badge, +delivery-badge--custom |
|
||||
| `resources/lang/pl.php` | Zmodyfikowany | statuses→"Statusy zamówień"; +delivery_statuses→"Statusy przesyłek" |
|
||||
| `resources/views/orders/show.php` | Zmodyfikowany | Badge (2 miejsca): system→CSS class; custom→--status-color |
|
||||
| `resources/views/shipments/prepare.php` | Zmodyfikowany | Badge (1 miejsce): system→CSS class; custom→--status-color |
|
||||
| `.paul/docs/DB_SCHEMA.md` | Zaktualizowany | Nowa tabela delivery_statuses |
|
||||
| `.paul/docs/ARCHITECTURE.md` | Zaktualizowany | DeliveryStatusRepository, DeliveryStatusesController, setRepository() |
|
||||
| `.paul/docs/TECH_CHANGELOG.md` | Zaktualizowany | Entry Phase 108 Plan 01 |
|
||||
|
||||
## Decisions Made
|
||||
|
||||
| Decyzja | Uzasadnienie | Wpływ |
|
||||
|---------|-------------|-------|
|
||||
| REDIRECT_PATH = `/settings/delivery-statuses?tab=mapping` | Nowa strona jest primary; stara URL to backward compat | Redirecty z DeliveryStatusMappingController lądują na nowej stronie |
|
||||
| Zakładki przez URL `?tab=` nie localStorage | Redirecty po POST muszą trafić na właściwą zakładkę | Provider tabs w mapping content też używają `$mappingBaseUrl` |
|
||||
| CSS custom property `--status-color` dla nowych statusów | Konwencja projektu (conventions.md) | Zachowanie spójności; brak inline `background-color` w PHP |
|
||||
| `is_system=1` dla delivered/returned/cancelled (nie tylko is_terminal) | Są używane w logice biznesowej (AutomationService itp.) | UI blokuje edycję/usunięcie systemowych |
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
| Typ | Opis |
|
||||
|-----|------|
|
||||
| Korekta planu | Plan wspominał "Medoo" — projekt używa PDO. Skorygowano przed delegacją. |
|
||||
| Korekta SCSS path | Plan mówił `settings/_delivery-statuses.scss` — faktyczny pattern to `modules/`. Dodano do istniejącego `_delivery-status.scss`. |
|
||||
| Migracja nieuruchomiona | MySQL offline podczas APPLY. Migracja musi być uruchomiona ręcznie. |
|
||||
|
||||
## Issues Encountered
|
||||
|
||||
| Problem | Rozwiązanie |
|
||||
|---------|------------|
|
||||
| MySQL offline podczas APPLY | Migracja zapisana, czeka na uruchomienie XAMPP |
|
||||
|
||||
## Next Phase Readiness
|
||||
|
||||
**Ready:**
|
||||
- `DeliveryStatusRepository` dostępny dla Plan 02 (automatyzacja)
|
||||
- `DeliveryStatus::getAllOptions()` dostarcza DB-driven listę statusów
|
||||
- Routing i widoki działają (syntax OK, SCSS build OK)
|
||||
|
||||
**Concerns:**
|
||||
- Migracja musi być uruchomiona przed testem UI: `php bin/migrate.php`
|
||||
- Plan 02 (automatyzacja) wymaga sprawdzenia gdzie AutomationController/Repository używa hardcoded listy statusów
|
||||
|
||||
**Blockers:**
|
||||
- Brak (poza uruchomieniem migracji)
|
||||
|
||||
---
|
||||
*Phase: 108-delivery-status-management, Plan: 01*
|
||||
*Completed: 2026-04-27*
|
||||
136
.paul/phases/108-delivery-status-management/108-02-PLAN.md
Normal file
136
.paul/phases/108-delivery-status-management/108-02-PLAN.md
Normal file
@@ -0,0 +1,136 @@
|
||||
---
|
||||
phase: 108-delivery-status-management
|
||||
plan: 02
|
||||
type: execute
|
||||
wave: 2
|
||||
depends_on: [108-01]
|
||||
files_modified:
|
||||
- src/Modules/Automation/AutomationService.php
|
||||
- src/Modules/Automation/AutomationRepository.php
|
||||
- resources/views/automation/form.php
|
||||
- public/assets/js/modules/automation-form.js
|
||||
- .paul/docs/ARCHITECTURE.md
|
||||
- .paul/docs/TECH_CHANGELOG.md
|
||||
autonomous: true
|
||||
delegation: on
|
||||
---
|
||||
|
||||
<objective>
|
||||
## Goal
|
||||
Zaktualizowac wszystkie miejsca w module Automatyzacji, ktore uzywaaly hardcoded listy statusow znormalizowanych, zeby korzystaly z DB przez `DeliveryStatus::getAllOptions()`.
|
||||
|
||||
## Purpose
|
||||
Po Plan 01 operator moze dodac nowy status w DB. Jednak dopoki formularze automatyzacji i walidacje beda uzywaly hardcoded stalych, nowy status nie pojawi sie w dropdownach regul. Plan 02 domyka integracje dla warstwy automatyzacji.
|
||||
|
||||
## Output
|
||||
- Dropdown warunków/akcji automatyzacji laduje statusy z DB
|
||||
- Brak regresji dla istniejacych regul automatyzacji
|
||||
</objective>
|
||||
|
||||
<context>
|
||||
## Project Context
|
||||
@.paul/STATE.md
|
||||
|
||||
## Prior Work
|
||||
@.paul/phases/108-delivery-status-management/108-01-SUMMARY.md
|
||||
|
||||
## Source Files
|
||||
@src/Modules/Automation/AutomationService.php
|
||||
@src/Modules/Automation/AutomationRepository.php
|
||||
@resources/views/automation/form.php
|
||||
@public/assets/js/modules/automation-form.js
|
||||
</context>
|
||||
|
||||
<skills>
|
||||
## Required Skills
|
||||
|
||||
| Skill | Priority | When to Invoke | Loaded? |
|
||||
|-------|----------|----------------|---------|
|
||||
| sonar-scanner (CLI) | required | Po APPLY, przed UNIFY | o |
|
||||
</skills>
|
||||
|
||||
<acceptance_criteria>
|
||||
|
||||
## AC-1: Dropdown statusow w automatyzacji pochodzi z DB
|
||||
```gherkin
|
||||
Given operator tworzy lub edytuje regule automatyzacji
|
||||
When wybierze warunek "status przesylki" lub akcje zalezna od statusu
|
||||
Then lista dostepnych statusow zawiera wszystkie statusy z tabeli delivery_statuses
|
||||
And nowy status dodany przez /settings/delivery-statuses pojawia sie w dropdownie bez deploymentu
|
||||
```
|
||||
|
||||
## AC-2: Istniejace reguly automatyzacji dzialaja bez zmian
|
||||
```gherkin
|
||||
Given regula automatyzacji z warunkiem na status "in_transit"
|
||||
When cron wywola ewaluacje tej reguly
|
||||
Then warunek jest oceniany tak samo jak przed zmiana
|
||||
And brak wyjatkow zwiazanych z nieistniejacymi stalymi statusow
|
||||
```
|
||||
|
||||
</acceptance_criteria>
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 1: Zaktualizowac dropdown statusow w automatyzacji</name>
|
||||
<files>src/Modules/Automation/AutomationService.php, src/Modules/Automation/AutomationRepository.php, resources/views/automation/form.php, public/assets/js/modules/automation-form.js</files>
|
||||
<action>
|
||||
1. Zidentyfikowac wszystkie miejsca w module Automation gdzie uzywa sie:
|
||||
- `DeliveryStatus::ALL_STATUSES` lub `DeliveryStatus::LABEL_PL` do budowania opcji selecta
|
||||
- Hardcoded tablicy statusow w walidacji warunkow/akcji
|
||||
2. Podpiac `DeliveryStatusRepository` do `AutomationRepository` lub serwisu ktory
|
||||
buduje opcje dla widoku formularza (sprawdzic jak repo jest dostarczone w tym module).
|
||||
3. W widoku `resources/views/automation/form.php` — zamiana hardcoded opcji statusow
|
||||
na przekazana z kontrolera tablice `$deliveryStatusOptions` (z getAllOptions()).
|
||||
4. W `automation-form.js` — opcje do dynamicznie dodawanych wierszy warunkow/akcji:
|
||||
- Jesli opcje sa generowane statycznie w JS (hardcoded), zastapic je danymi
|
||||
z `window.automationDeliveryStatusOptions` ktore beda inicjalizowane inline w widoku PHP
|
||||
- Jesli opcje sa generowane przez PHP przy renderowaniu — brak zmian w JS, tylko upewnic
|
||||
sie ze dynamicznie dodawane wiersze tez dostaja prawidlowa liste
|
||||
5. Walidacja: sprawdzic czy AutomationService lub AutomationRepository waliduje wartosc statusu
|
||||
przy zapisie — jesli tak, zaktualizowac by uzywala `DeliveryStatusRepository::getByKey()`.
|
||||
6. Zaktualizowac `.paul/docs/ARCHITECTURE.md` i `.paul/docs/TECH_CHANGELOG.md`.
|
||||
</action>
|
||||
<verify>
|
||||
- Formularz automatyzacji laduje sie poprawnie, dropdown statusow zawiera wszystkie DB-rekordy
|
||||
- Dodanie nowego statusu przez /settings/delivery-statuses sprawia ze pojawia sie w dropdownie
|
||||
automatyzacji bez odswiezania cache serwera
|
||||
- Istniejace reguly z hardcoded kluczami statusow (np. in_transit) dzialaja bez bledow
|
||||
- `php vendor/bin/phpunit` bez nowych failurow
|
||||
</verify>
|
||||
<done>AC-1 i AC-2 spelnione.</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<boundaries>
|
||||
|
||||
## DO NOT CHANGE
|
||||
- Logika ewaluacji warunkow automatyzacji poza podpieciem dynamicznej listy statusow
|
||||
- Schemat danych regul i akcji automatyzacji
|
||||
- Mechanizm crona ani harmonogram
|
||||
- Provider mapy w DeliveryStatus.php
|
||||
|
||||
## SCOPE LIMITS
|
||||
- Tylko dropdown statusow — nie zmieniamy innych typow warunkow/akcji automatyzacji
|
||||
|
||||
</boundaries>
|
||||
|
||||
<verification>
|
||||
Before declaring plan complete:
|
||||
- [ ] Dropdown statusow w formularzu automatyzacji pokazuje statusy z DB
|
||||
- [ ] Nowy status z CRUD pojawia sie w dropdownie automatyzacji
|
||||
- [ ] Istniejace reguly automatyzacji dzialaja bez bledow
|
||||
- [ ] `php vendor/bin/phpunit` przechodzi bez regresji
|
||||
- [ ] Dokumentacja .paul/docs/* zaktualizowana
|
||||
</verification>
|
||||
|
||||
<success_criteria>
|
||||
- Pelna integracja listy statusow z DB w calej aplikacji
|
||||
- Operator nie musi robic deploymentu zeby nowy status pojawil sie we wszystkich miejscach
|
||||
- Brak regresji w istniejacych automatyzacjach
|
||||
</success_criteria>
|
||||
|
||||
<output>
|
||||
After completion, create `.paul/phases/108-delivery-status-management/108-02-SUMMARY.md`
|
||||
</output>
|
||||
151
.paul/phases/108-delivery-status-management/108-02-SUMMARY.md
Normal file
151
.paul/phases/108-delivery-status-management/108-02-SUMMARY.md
Normal file
@@ -0,0 +1,151 @@
|
||||
---
|
||||
phase: 108-delivery-status-management
|
||||
plan: 02
|
||||
subsystem: automation, settings
|
||||
tags: [delivery-status, automation, dropdown, php, db-driven, ui-refactor]
|
||||
|
||||
requires:
|
||||
- phase: 108-01-delivery-status-management
|
||||
provides: DeliveryStatusRepository, DeliveryStatus::setRepository(), getAllOptions(), getAllStatuses()
|
||||
|
||||
provides:
|
||||
- Automation dropdowns dla shipment_status (warunek + akcja) załadowane z DB
|
||||
- Walidacja shipment_status / update_shipment_status przeciw kluczom z DB
|
||||
- Osobna podstrona formularza dla CRUD delivery statuses (`/settings/delivery-statuses/new`, `/{id}/edit`)
|
||||
- Lista statusów uproszczona: rename "Terminal" → "Końcowy", usunięta kolumna "Typ"
|
||||
|
||||
affects: [delivery-status-consumers, automation-rules-existing]
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- Path params w controllerach przez `$request->input('id')`, nie jako argumenty metody
|
||||
- Form-as-separate-page pattern dla CRUD (zamiast inline edit row)
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- resources/views/settings/delivery-status-form.php
|
||||
modified:
|
||||
- src/Modules/Automation/AutomationController.php
|
||||
- src/Modules/Automation/AutomationService.php
|
||||
- src/Modules/Settings/DeliveryStatusesController.php
|
||||
- resources/views/settings/delivery-statuses.php
|
||||
- routes/web.php
|
||||
- .paul/docs/ARCHITECTURE.md
|
||||
- .paul/docs/TECH_CHANGELOG.md
|
||||
|
||||
key-decisions:
|
||||
- "BREAKING: Drop backward compat dla starych grupowych kluczy automatyzacji (registered, courier_pickup, etc.) — kolizja semantyczna picked_up by silently dawała wrong matches"
|
||||
- "Path params w DeliveryStatusesController via $request->input('id') — naprawia bug pre-existing z Plan 01 (update/destroy też miały błędną sygnaturę)"
|
||||
- "CRUD delivery statuses przeniesiony na osobną podstronę — UX lepszy niż inline edit row"
|
||||
|
||||
patterns-established:
|
||||
- "Walidacja submitted status keys przez DeliveryStatus::getAllStatuses() (zamiast hardcoded array_keys konstanty)"
|
||||
- "Form view jako osobna podstrona z disabled key field przy edycji (immutable po utworzeniu)"
|
||||
|
||||
duration: ~50min
|
||||
started: 2026-04-27T01:00:00Z
|
||||
completed: 2026-04-27T02:00:00Z
|
||||
---
|
||||
|
||||
# Phase 108 Plan 02: Automation Dropdowns z DB Summary
|
||||
|
||||
**Domknięcie integracji DB-driven statusów: dropdowny automatyzacji ładują się z `delivery_statuses`, plus refaktor UI listy statusów (osobna podstrona dla CRUD).**
|
||||
|
||||
## Performance
|
||||
|
||||
| Metric | Value |
|
||||
|--------|-------|
|
||||
| Duration | ~50 min |
|
||||
| Tasks | 1 planowane + 2 user-requested ad-hoc |
|
||||
| Files created | 1 |
|
||||
| Files modified | 7 |
|
||||
|
||||
## Acceptance Criteria Results
|
||||
|
||||
| Criterion | Status | Notes |
|
||||
|-----------|--------|-------|
|
||||
| AC-1: Dropdown statusów z DB | Pass | `AutomationController::buildShipmentStatusOptions()` z `DeliveryStatus::getAllOptions()` |
|
||||
| AC-2: Istniejące reguły działają bez błędów | Pass* | *BREAKING: stare grupowe klucze nie matchują (decyzja użytkownika "poprawię ręcznie"); brak wyjątków, ciche no-match |
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- `AutomationController` — usunięto stałą `SHIPMENT_STATUS_OPTIONS` (8 grupowych kluczy); dropdown buduje się z DB przez `DeliveryStatus::getAllOptions()`
|
||||
- `AutomationService` — usunięto stałą `SHIPMENT_STATUS_OPTION_MAP`; ewaluacja `evaluateShipmentStatusCondition` porównuje klucze bezpośrednio; `resolveStatusFromActionKey` używa kluczy DB jako target
|
||||
- Walidacja w `parseConditionValue('shipment_status')` i `parseActionConfig('update_shipment_status')` przez `DeliveryStatus::getAllStatuses()`
|
||||
- **Ad-hoc UI refactor (user request):** osobna podstrona formularza CRUD (`delivery-status-form.php`) zamiast inline edit row na liście; przycisk "+ Dodaj status" zamiast formy na dole strony
|
||||
- **Ad-hoc UI changes:** rename column "Terminal" → "Końcowy", usunięta kolumna "Typ" (badge "systemowy" — informacja zbędna gdy brak akcji edycji)
|
||||
- **Bug fix (pre-existing):** sygnatury `update`/`destroy`/`edit` w `DeliveryStatusesController` używały path param jako 2. argument metody — router projektu przekazuje params przez `$request->input('id')`. Naprawione wszystkie trzy.
|
||||
|
||||
## Files Created/Modified
|
||||
|
||||
| File | Change | Purpose |
|
||||
|------|--------|---------|
|
||||
| `src/Modules/Automation/AutomationController.php` | Modified | Usunięta stała SHIPMENT_STATUS_OPTIONS; nowa metoda `buildShipmentStatusOptions()`; walidacja przez DeliveryStatus |
|
||||
| `src/Modules/Automation/AutomationService.php` | Modified | Usunięta stała SHIPMENT_STATUS_OPTION_MAP; bezpośrednie porównanie kluczy w ewaluacji |
|
||||
| `src/Modules/Settings/DeliveryStatusesController.php` | Modified | +`create()`, `edit()`, `renderForm()`; fix path params w update/destroy |
|
||||
| `resources/views/settings/delivery-status-form.php` | Created | Osobna podstrona formularza CRUD statusów |
|
||||
| `resources/views/settings/delivery-statuses.php` | Modified | Lista uproszczona: rename Terminal→Końcowy, usunięte Typ + inline edit + bottom add form, przycisk "+ Dodaj status" |
|
||||
| `routes/web.php` | Modified | +2 GET routes: `/new`, `/{id}/edit` |
|
||||
| `.paul/docs/ARCHITECTURE.md` | Modified | Sekcja Phase 108 Plan 02 |
|
||||
| `.paul/docs/TECH_CHANGELOG.md` | Modified | Wpis Phase 108 Plan 02 (BREAKING) |
|
||||
|
||||
## Decisions Made
|
||||
|
||||
| Decyzja | Uzasadnienie | Wpływ |
|
||||
|---------|-------------|-------|
|
||||
| Drop backward compat (option A) | Kolizja semantyczna `picked_up`: stary grupowy klucz mapował na `delivered`, nowy klucz DB to "Odebrana przez kuriera" — odwrotne końce cyklu | BREAKING dla istniejących reguł; user: "poprawię ręcznie jak coś" |
|
||||
| Form jako osobna podstrona zamiast inline | Inline edit row na liście "źle wygląda" (user feedback) | Lepszy UX, czytelniejszy formularz z grid 2-col |
|
||||
| Usunięcie kolumny "Typ" | Badge "systemowy" zbędny — brak przycisku Edytuj/Usuń przy systemowych już to komunikuje | Lista 6 kolumn zamiast 7 |
|
||||
| Path params via `$request->input('id')` | Konwencja projektu (router nie injectuje argumentów do handlerów) | Naprawiono pre-existing bug w update/destroy z Plan 01 |
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Summary
|
||||
|
||||
| Type | Count | Impact |
|
||||
|------|-------|--------|
|
||||
| Files w plan, ale bez zmian | 3 | `AutomationRepository.php`, `form.php`, `automation-form.js` — analiza wykazała brak potrzeby modyfikacji |
|
||||
| Scope additions (user request) | 3 | Rename column, hide column, separate form page |
|
||||
| Bug fix poza scope | 1 | Path params w update/destroy (pre-existing z Plan 01) |
|
||||
| Deferred | 1 | sonar-scanner dla Phase 105/106/107/108 — punkt deferred z Plan 01, niezmieniony |
|
||||
|
||||
**Total impact:** Plan zakończony plus dodatkowe ulepszenia UX zgłoszone przez użytkownika podczas weryfikacji Plan 01. Bug fix path params eliminuje crash przy edycji.
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. [Routing] Path params jako argumenty metody zamiast `$request->input()`**
|
||||
- **Found during:** Test ścieżki `/settings/delivery-statuses/{id}/edit` (user runtime error)
|
||||
- **Issue:** "Too few arguments to function ... edit(), 1 passed ... and exactly 2 expected"
|
||||
- **Fix:** Zmieniono sygnatury `edit()`, `update()`, `destroy()` na single `Request $request`; `$id` czytany przez `$request->input('id', 0)`
|
||||
- **Files:** `src/Modules/Settings/DeliveryStatusesController.php`
|
||||
- **Verification:** `php -l` OK; konwencja zgodna z `ReceiptController`
|
||||
|
||||
### Deferred Items
|
||||
|
||||
- sonar-scanner skill (required) — Phase 105, 106, 107, 108 (już deferred z poprzednich planów)
|
||||
|
||||
## Issues Encountered
|
||||
|
||||
| Issue | Resolution |
|
||||
|-------|------------|
|
||||
| Kolizja semantyczna klucza `picked_up` (stary group → `delivered` vs nowy DB → "Odebrana przez kuriera") | Advisor consult przed kodowaniem; user wybrał opcję A (drop backward compat) |
|
||||
| Pre-existing bug z path params w update/destroy | Zauważony dopiero przy nowym `edit()` — naprawiony razem |
|
||||
|
||||
## Next Phase Readiness
|
||||
|
||||
**Ready:**
|
||||
- Pełna integracja DB-driven statusów: dropdowny + walidacja + ewaluacja
|
||||
- CRUD UI ergonomiczny: lista + osobna podstrona formularza
|
||||
- Phase 108 — wszystkie 2 plans zamknięte
|
||||
|
||||
**Concerns:**
|
||||
- Migracja `20260427_000103_create_delivery_statuses_table.sql` — wymaga `php bin/migrate.php` na środowisku produkcyjnym (XAMPP offline podczas APPLY 108-01)
|
||||
- Stare reguły automatyzacji z grupowymi kluczami (jeśli istnieją) — wymagają ręcznego odtworzenia z nowymi kluczami DB
|
||||
- sonar-scanner gap dla Phase 105/106/107/108 — odłożony
|
||||
|
||||
**Blockers:** None
|
||||
|
||||
---
|
||||
*Phase: 108-delivery-status-management, Plan: 02*
|
||||
*Completed: 2026-04-27*
|
||||
Reference in New Issue
Block a user