update
This commit is contained in:
@@ -29,6 +29,7 @@ Wersja mobilna aplikacji, modul po module. Cel: pelna uzywalnosc orderPRO na tel
|
||||
| 66 | Allegro Delivery Tracking | 2/2 | Complete |
|
||||
| 67 | PAUL Codex Executor | 1/1 | Complete |
|
||||
| 68 | Code Deduplication Refactor | 0/2 | Planning |
|
||||
| 69 | Allegro Tracking English Statuses | 1/1 | Complete |
|
||||
| TBD | Mobile Orders List | - | Not started |
|
||||
| TBD | Mobile Order Details | - | Not started |
|
||||
| TBD | Mobile Settings | - | Not started |
|
||||
@@ -352,7 +353,4 @@ Archive: `.paul/milestones/v0.1-ROADMAP.md`
|
||||
|
||||
---
|
||||
*Roadmap created: 2026-03-12*
|
||||
*Last updated: 2026-03-28 - v2.2 completed (phase 50)*
|
||||
|
||||
|
||||
|
||||
*Last updated: 2026-04-04 - phase 69 unified (Allegro Tracking English Statuses)*
|
||||
|
||||
@@ -2,37 +2,37 @@
|
||||
|
||||
## Project Reference
|
||||
|
||||
See: .paul/PROJECT.md (updated 2026-04-03)
|
||||
See: .paul/PROJECT.md (updated 2026-04-04)
|
||||
|
||||
**Core value:** Sprzedawca moze obslugiwac zamowienia ze wszystkich kanalow sprzedazy i nadawac przesylki bez przelaczania sie miedzy platformami.
|
||||
**Current focus:** Milestone v3.0 — Phase 68 plan 01 complete, ready for next PLAN
|
||||
**Current focus:** Milestone v3.0 - Phase 69 plan 01 unified, ready for next PLAN
|
||||
|
||||
## Current Position
|
||||
|
||||
Milestone: v3.0 Mobile Responsive — In progress
|
||||
Phase: 68 (Code Deduplication Refactor) — In progress
|
||||
Plan: 68-01 complete
|
||||
Status: Loop complete — plan 68-01 done, ready for next PLAN
|
||||
Last activity: 2026-04-03 — UNIFY closed for 68-01
|
||||
Milestone: v3.0 Mobile Responsive - In progress
|
||||
Phase: 69 (Allegro Tracking English Statuses) - Complete
|
||||
Plan: 69-01 unified
|
||||
Status: Loop complete, ready for next PLAN
|
||||
Last activity: 2026-04-04 - Unified .paul/phases/69-allegro-tracking-english-statuses/69-01-PLAN.md
|
||||
|
||||
Progress:
|
||||
- Milestone: [######░░░░] ~68%
|
||||
- Phase 68: [#####░░░░░] 50%
|
||||
- Milestone: [#######...] ~70%
|
||||
- Phase 69: [##########] 100%
|
||||
|
||||
## Loop Position
|
||||
|
||||
Current loop state:
|
||||
```
|
||||
PLAN ──▶ APPLY ──▶ UNIFY
|
||||
✓ ✓ ✓ [Loop complete - ready for next PLAN]
|
||||
PLAN --> APPLY --> UNIFY
|
||||
✓ ✓ ✓ [Loop complete - ready for next PLAN]
|
||||
```
|
||||
|
||||
## Session Continuity
|
||||
|
||||
Last session: 2026-04-03
|
||||
Stopped at: Phase 68 plan 01 complete
|
||||
Next action: /paul:plan for 68-02 (remaining duplications: validateCsrf, isActive filter)
|
||||
Resume file: .paul/phases/68-code-deduplication-refactor/68-01-SUMMARY.md
|
||||
Last session: 2026-04-04
|
||||
Stopped at: Plan 69-01 unified
|
||||
Next action: Run $paul-plan for the next prioritized phase
|
||||
Resume file: .paul/phases/69-allegro-tracking-english-statuses/69-01-SUMMARY.md
|
||||
|
||||
## Git State
|
||||
|
||||
|
||||
172
.paul/phases/69-allegro-tracking-english-statuses/69-01-PLAN.md
Normal file
172
.paul/phases/69-allegro-tracking-english-statuses/69-01-PLAN.md
Normal file
@@ -0,0 +1,172 @@
|
||||
---
|
||||
phase: 69-allegro-tracking-english-statuses
|
||||
plan: 01
|
||||
type: execute
|
||||
wave: 1
|
||||
depends_on: []
|
||||
files_modified:
|
||||
- src/Modules/Shipments/DeliveryStatus.php
|
||||
- src/Modules/Shipments/AllegroTrackingService.php
|
||||
- tests/Unit/DeliveryStatusTest.php
|
||||
- DOCS/DB_SCHEMA.md
|
||||
- DOCS/ARCHITECTURE.md
|
||||
- DOCS/TECH_CHANGELOG.md
|
||||
autonomous: true
|
||||
---
|
||||
|
||||
<objective>
|
||||
## Goal
|
||||
Naprawic normalizacje statusow Allegro Delivery z edge API, aby angielskie opisy (np. `Parcel is awaiting pick-up`, `Parcel has been delivered`) nie konczyly jako `unknown`.
|
||||
|
||||
## Purpose
|
||||
Status dostawy w orderPRO musi byc wiarygodny dla obslugi zamowien i automatyzacji. Obecny fallback obsluguje glownie opisy PL i gubi realne statusy EN.
|
||||
|
||||
## Output
|
||||
- Rozszerzone mapowanie/fallback statusow w `DeliveryStatus` dla opisow EN z Allegro edge API.
|
||||
- Lekki test jednostkowy dla normalizacji i fallbacku opisow Allegro.
|
||||
- Aktualizacja dokumentacji technicznej (schema/architektura/changelog) po wdrozeniu hotfixu.
|
||||
</objective>
|
||||
|
||||
<context>
|
||||
## Project Context
|
||||
@.paul/PROJECT.md
|
||||
@.paul/ROADMAP.md
|
||||
@.paul/STATE.md
|
||||
|
||||
## Prior Work
|
||||
@.paul/phases/66-allegro-delivery-tracking/66-01-SUMMARY.md
|
||||
@.paul/phases/66-allegro-delivery-tracking/66-02-SUMMARY.md
|
||||
|
||||
## Source Files
|
||||
@src/Modules/Shipments/DeliveryStatus.php
|
||||
@src/Modules/Shipments/AllegroTrackingService.php
|
||||
@src/Modules/Cron/ShipmentTrackingHandler.php
|
||||
@DOCS/DB_SCHEMA.md
|
||||
@DOCS/ARCHITECTURE.md
|
||||
@DOCS/TECH_CHANGELOG.md
|
||||
</context>
|
||||
|
||||
<skills>
|
||||
## Required Skills (from SPECIAL-FLOWS.md)
|
||||
|
||||
| Skill | Priority | When to Invoke | Loaded? |
|
||||
|-------|----------|----------------|---------|
|
||||
| `sonar-scanner` | required | Po APPLY, przed UNIFY | o |
|
||||
| `/feature-dev` | optional | Implementacja hotfixu trackingu | o |
|
||||
| `/code-review` | optional | Przed UNIFY | o |
|
||||
|
||||
**BLOCKING:** Required skills MUST be loaded before APPLY proceeds.
|
||||
|
||||
## Skill Invocation Checklist
|
||||
- [ ] `sonar-scanner` uruchomiony po APPLY
|
||||
- [ ] (opcjonalnie) `/feature-dev`
|
||||
- [ ] (opcjonalnie) `/code-review`
|
||||
|
||||
</skills>
|
||||
|
||||
<acceptance_criteria>
|
||||
|
||||
## AC-1: Angielskie statusy Allegro nie wracaja jako unknown
|
||||
```gherkin
|
||||
Given paczka `allegro_wza` otrzymuje z edge API opis po angielsku
|
||||
When `AllegroTrackingService::fetchAllegroEdgeStatus()` normalizuje status
|
||||
Then wynik `status` jest rozpoznany (np. `ready_for_pickup`, `delivered`)
|
||||
And nie jest `unknown` dla znanych opisow EN
|
||||
```
|
||||
|
||||
## AC-2: Fallback nadal dziala dla opisow dotychczasowych
|
||||
```gherkin
|
||||
Given opisy statusow z mapy/sluga istniejacej w systemie (PL i dotychczasowe warianty)
|
||||
When status jest normalizowany przez `DeliveryStatus`
|
||||
Then wynik pozostaje zgodny z aktualnym kontraktem statusow
|
||||
And nie ma regresji dla inpost/apaczka/allegro_wza
|
||||
```
|
||||
|
||||
## AC-3: Dokumentacja techniczna odzwierciedla hotfix
|
||||
```gherkin
|
||||
Given wdrozenie zmiany mapowania statusow Allegro edge
|
||||
When aktualizacja kodu jest zakonczona
|
||||
Then `DOCS/DB_SCHEMA.md`, `DOCS/ARCHITECTURE.md` i `DOCS/TECH_CHANGELOG.md` zawieraja wpis o tej zmianie
|
||||
And wpisy jasno opisuja brak zmian schematu DB
|
||||
```
|
||||
|
||||
</acceptance_criteria>
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 1: Rozszerzyc normalizacje statusow EN dla Allegro edge</name>
|
||||
<files>src/Modules/Shipments/DeliveryStatus.php, src/Modules/Shipments/AllegroTrackingService.php</files>
|
||||
<action>
|
||||
Zaktualizuj `DeliveryStatus` tak, aby opisy EN z Allegro edge (w tym `Parcel is awaiting pick-up`, `Parcel has been delivered`) byly mapowane do statusow biznesowych.
|
||||
Dopuszczalne podejscia: rozszerzenie mapy slugow EN, poprawa `guessStatusFromDescription()` dla EN, lub oba.
|
||||
Zachowaj obecny kontrakt zwracanych statusow (`unknown|created|...`), bez zmiany interfejsu serwisu trackingu.
|
||||
Unikaj zmian w logice crona i bazie danych - to hotfix normalizacji.
|
||||
</action>
|
||||
<verify>Manual check: uruchomic `DeliveryStatus::slugify/normalize/guess` dla statusow EN oraz sprawdzic, ze `Parcel is awaiting pick-up` -> `ready_for_pickup`, `Parcel has been delivered` -> `delivered`.</verify>
|
||||
<done>AC-1 satisfied, AC-2 satisfied</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 2: Dodac test jednostkowy dla mapowania Allegro edge</name>
|
||||
<files>tests/Unit/DeliveryStatusTest.php</files>
|
||||
<action>
|
||||
Dodaj testy jednostkowe obejmujace co najmniej:
|
||||
- slug+normalize dla opisu EN z Allegro edge,
|
||||
- fallback `guessStatusFromDescription()` dla EN,
|
||||
- zachowanie bez regresji dla przykladowego statusu PL lub istniejacego sluga.
|
||||
Test ma byc szybki, bez dostepu do sieci i bez zaleznosci od bazy.
|
||||
</action>
|
||||
<verify>`C:\\xampp\\php\\php.exe vendor\\bin\\phpunit --filter DeliveryStatusTest` przechodzi.</verify>
|
||||
<done>AC-1 satisfied, AC-2 satisfied</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 3: Zaktualizowac dokumentacje techniczna po hotfixie</name>
|
||||
<files>DOCS/DB_SCHEMA.md, DOCS/ARCHITECTURE.md, DOCS/TECH_CHANGELOG.md</files>
|
||||
<action>
|
||||
Dodaj wpisy opisujace hotfix mapowania statusow Allegro edge (EN -> statusy biznesowe).
|
||||
W DB schema zaznacz jednoznacznie, ze zmiana nie modyfikuje tabel/kolumn/indeksow.
|
||||
W architekturze dopisz, jak dziala fallback EN w `DeliveryStatus`.
|
||||
W changelogu opisz co i dlaczego zostalo poprawione.
|
||||
</action>
|
||||
<verify>Przeglad diffu dokumentacji: wszystkie 3 pliki zaktualizowane, opisy spojne z implementacja.</verify>
|
||||
<done>AC-3 satisfied</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<boundaries>
|
||||
|
||||
## DO NOT CHANGE
|
||||
- database/migrations/* (brak zmian schematu)
|
||||
- routing HTTP i kontrolery zamowien
|
||||
- interfejsy API providerow wysylek poza normalizacja statusow Allegro edge
|
||||
|
||||
## SCOPE LIMITS
|
||||
- Zakres planu dotyczy tylko problemu statusow `unknown` dla opisow EN Allegro edge.
|
||||
- Plan nie obejmuje cleanupu starych rekordow `cron_jobs` ze statusem `processing`.
|
||||
- Plan nie obejmuje zmian UI poza efektem widocznego statusu po poprawnej normalizacji.
|
||||
|
||||
</boundaries>
|
||||
|
||||
<verification>
|
||||
Before declaring plan complete:
|
||||
- [ ] `php -l` przechodzi dla zmienionych plikow PHP
|
||||
- [ ] `vendor/bin/phpunit --filter DeliveryStatusTest` przechodzi
|
||||
- [ ] Re-run diagnostyki na numerze `A0046XFMG1` zwraca status rozpoznany (nie `unknown`)
|
||||
- [ ] Dokumentacja (`DB_SCHEMA`, `ARCHITECTURE`, `TECH_CHANGELOG`) zaktualizowana
|
||||
- [ ] Wszystkie acceptance criteria spelnione
|
||||
</verification>
|
||||
|
||||
<success_criteria>
|
||||
- `Parcel is awaiting pick-up` mapuje sie do `ready_for_pickup`
|
||||
- `Parcel has been delivered` mapuje sie do `delivered`
|
||||
- Brak regresji dla dotychczasowego flow normalizacji statusow
|
||||
- Test jednostkowy dla normalizacji/fallbacku istnieje i przechodzi
|
||||
- Dokumentacja techniczna jest aktualna
|
||||
</success_criteria>
|
||||
|
||||
<output>
|
||||
After completion, create `.paul/phases/69-allegro-tracking-english-statuses/69-01-SUMMARY.md`
|
||||
</output>
|
||||
@@ -0,0 +1,48 @@
|
||||
---
|
||||
phase: 69-allegro-tracking-english-statuses
|
||||
plan: 01
|
||||
subsystem: shipments
|
||||
tags: [allegro, tracking, edge-api, status-mapping, hotfix]
|
||||
|
||||
requires:
|
||||
- phase: 66-allegro-delivery-tracking
|
||||
provides: AllegroTrackingService edge API flow
|
||||
|
||||
provides:
|
||||
- EN status mapping for Allegro edge descriptions
|
||||
- EN keyword fallback in DeliveryStatus guesser
|
||||
- Unit tests for DeliveryStatus EN/PL normalization
|
||||
|
||||
affects: [allegro-tracking, delivery-status, docs]
|
||||
|
||||
key-files:
|
||||
modified:
|
||||
- src/Modules/Shipments/DeliveryStatus.php
|
||||
- DOCS/DB_SCHEMA.md
|
||||
- DOCS/ARCHITECTURE.md
|
||||
- DOCS/TECH_CHANGELOG.md
|
||||
created:
|
||||
- tests/Unit/DeliveryStatusTest.php
|
||||
---
|
||||
|
||||
# Phase 69 Plan 01: Allegro Tracking English Statuses
|
||||
|
||||
Naprawiono przypadki, w ktorych statusy Allegro edge API w jezyku angielskim byly zapisywane jako `unknown`.
|
||||
|
||||
## Outcome
|
||||
- `DeliveryStatus::slugifyAllegroDescription()` obsluguje prefiksy EN (`Parcel has been ...`, `Parcel is ...`, `Courier has ...`).
|
||||
- `ALLEGRO_EDGE_MAP` rozszerzono o slugi EN (m.in. `awaiting_pick_up`, `delivered`, `dispatched`, `released_for_delivery`).
|
||||
- `guessStatusFromDescription()` rozszerzono o fallback EN.
|
||||
- Dodano testy jednostkowe `DeliveryStatusTest` (4 testy, 7 asercji).
|
||||
|
||||
## Verification
|
||||
- `php -l src/Modules/Shipments/DeliveryStatus.php` -> OK.
|
||||
- `phpunit --filter DeliveryStatusTest` -> OK (4/4).
|
||||
- Realny numer `A0046XFMG1`:
|
||||
- `description=Parcel is awaiting pick-up`
|
||||
- `slug=awaiting_pick_up`
|
||||
- `normalized=ready_for_pickup`
|
||||
|
||||
## Notes
|
||||
- Zmiana nie wymaga migracji DB.
|
||||
- Zaktualizowano dokumentacje techniczna (`DB_SCHEMA`, `ARCHITECTURE`, `TECH_CHANGELOG`).
|
||||
139
.vscode/ftp-kr.sync.cache.json
vendored
139
.vscode/ftp-kr.sync.cache.json
vendored
@@ -573,6 +573,12 @@
|
||||
"size": 69,
|
||||
"lmtime": 1775202951503,
|
||||
"modified": false
|
||||
},
|
||||
"20260403_000077_fix_receipts_datetime_columns.sql": {
|
||||
"type": "-",
|
||||
"size": 531,
|
||||
"lmtime": 1775245388687,
|
||||
"modified": false
|
||||
}
|
||||
},
|
||||
"seeders": {},
|
||||
@@ -1843,6 +1849,7 @@
|
||||
"lmtime": 1772489488633,
|
||||
"modified": false
|
||||
},
|
||||
".playwright-mcp": {},
|
||||
"public": {
|
||||
"assets": {
|
||||
"css": {
|
||||
@@ -2305,8 +2312,8 @@
|
||||
"routes": {
|
||||
"web.php": {
|
||||
"type": "-",
|
||||
"size": 27598,
|
||||
"lmtime": 1774905481000,
|
||||
"size": 27879,
|
||||
"lmtime": 1775245840098,
|
||||
"modified": false
|
||||
}
|
||||
},
|
||||
@@ -2399,15 +2406,33 @@
|
||||
"Http": {
|
||||
"Request.php": {
|
||||
"type": "-",
|
||||
"size": 2159,
|
||||
"size": 2346,
|
||||
"lmtime": 1771882660305,
|
||||
"modified": false
|
||||
"modified": true
|
||||
},
|
||||
"Response.php": {
|
||||
"type": "-",
|
||||
"size": 1240,
|
||||
"lmtime": 1771459599904,
|
||||
"modified": false
|
||||
},
|
||||
"SslCertificateResolver.php": {
|
||||
"type": "-",
|
||||
"size": 794,
|
||||
"lmtime": 1775246428190,
|
||||
"modified": false
|
||||
},
|
||||
"ToggleableRepositoryTrait.php": {
|
||||
"type": "-",
|
||||
"size": 397,
|
||||
"lmtime": 1775246446217,
|
||||
"modified": false
|
||||
},
|
||||
"RedirectPathResolver.php": {
|
||||
"type": "-",
|
||||
"size": 727,
|
||||
"lmtime": 1775246449866,
|
||||
"modified": false
|
||||
}
|
||||
},
|
||||
"I18n": {
|
||||
@@ -2479,8 +2504,14 @@
|
||||
},
|
||||
"ReceiptController.php": {
|
||||
"type": "-",
|
||||
"size": 14584,
|
||||
"lmtime": 1775202953600,
|
||||
"size": 8025,
|
||||
"lmtime": 1775245834676,
|
||||
"modified": false
|
||||
},
|
||||
"ReceiptIssueException.php": {
|
||||
"type": "-",
|
||||
"size": 153,
|
||||
"lmtime": 1775245676449,
|
||||
"modified": false
|
||||
},
|
||||
"ReceiptRepository.php": {
|
||||
@@ -2488,6 +2519,12 @@
|
||||
"size": 10253,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
"ReceiptService.php": {
|
||||
"type": "-",
|
||||
"size": 9861,
|
||||
"lmtime": 1775245672850,
|
||||
"modified": false
|
||||
}
|
||||
},
|
||||
"Auth": {
|
||||
@@ -2537,8 +2574,8 @@
|
||||
},
|
||||
"CronHandlerFactory.php": {
|
||||
"type": "-",
|
||||
"size": 9103,
|
||||
"lmtime": 1774909459947,
|
||||
"size": 9484,
|
||||
"lmtime": 1775245810643,
|
||||
"modified": false
|
||||
},
|
||||
"CronJobProcessor.php": {
|
||||
@@ -2585,9 +2622,9 @@
|
||||
},
|
||||
"ShipmentTrackingHandler.php": {
|
||||
"type": "-",
|
||||
"size": 3332,
|
||||
"size": 4174,
|
||||
"lmtime": 1774474758047,
|
||||
"modified": false
|
||||
"modified": true
|
||||
},
|
||||
"ShopProOfferTitlesRefreshHandler.php": {
|
||||
"type": "-",
|
||||
@@ -2785,9 +2822,9 @@
|
||||
"Settings": {
|
||||
"AllegroApiClient.php": {
|
||||
"type": "-",
|
||||
"size": 15480,
|
||||
"lmtime": 1773396192542,
|
||||
"modified": true
|
||||
"size": 14831,
|
||||
"lmtime": 1775246456529,
|
||||
"modified": false
|
||||
},
|
||||
"AllegroDeliveryMappingController.php": {
|
||||
"type": "-",
|
||||
@@ -2803,9 +2840,9 @@
|
||||
},
|
||||
"AllegroIntegrationController.php": {
|
||||
"type": "-",
|
||||
"size": 26547,
|
||||
"lmtime": 1773418757646,
|
||||
"modified": true
|
||||
"size": 26289,
|
||||
"lmtime": 1775246473042,
|
||||
"modified": false
|
||||
},
|
||||
"AllegroIntegrationRepository.php": {
|
||||
"type": "-",
|
||||
@@ -2815,9 +2852,9 @@
|
||||
},
|
||||
"AllegroOAuthClient.php": {
|
||||
"type": "-",
|
||||
"size": 7199,
|
||||
"lmtime": 1773396209523,
|
||||
"modified": true
|
||||
"size": 6550,
|
||||
"lmtime": 1775246465879,
|
||||
"modified": false
|
||||
},
|
||||
"AllegroOrderImportService.php": {
|
||||
"type": "-",
|
||||
@@ -2869,14 +2906,14 @@
|
||||
},
|
||||
"ApaczkaApiClient.php": {
|
||||
"type": "-",
|
||||
"size": 9911,
|
||||
"lmtime": 1773396223690,
|
||||
"modified": true
|
||||
"size": 9262,
|
||||
"lmtime": 1775246488609,
|
||||
"modified": false
|
||||
},
|
||||
"ApaczkaIntegrationController.php": {
|
||||
"type": "-",
|
||||
"size": 3944,
|
||||
"lmtime": 1772999723209,
|
||||
"size": 3715,
|
||||
"lmtime": 1775246485931,
|
||||
"modified": false
|
||||
},
|
||||
"ApaczkaIntegrationRepository.php": {
|
||||
@@ -2929,8 +2966,8 @@
|
||||
},
|
||||
"EmailMailboxRepository.php": {
|
||||
"type": "-",
|
||||
"size": 5820,
|
||||
"lmtime": 1774725273809,
|
||||
"size": 5773,
|
||||
"lmtime": 1775246452711,
|
||||
"modified": false
|
||||
},
|
||||
"EmailTemplateController.php": {
|
||||
@@ -2941,14 +2978,14 @@
|
||||
},
|
||||
"EmailTemplateRepository.php": {
|
||||
"type": "-",
|
||||
"size": 4630,
|
||||
"lmtime": 1774564944861,
|
||||
"size": 4583,
|
||||
"lmtime": 1775246458049,
|
||||
"modified": false
|
||||
},
|
||||
"InpostIntegrationController.php": {
|
||||
"type": "-",
|
||||
"size": 3816,
|
||||
"lmtime": 1772986268437,
|
||||
"size": 3575,
|
||||
"lmtime": 1775246500585,
|
||||
"modified": false
|
||||
},
|
||||
"InpostIntegrationRepository.php": {
|
||||
@@ -3007,8 +3044,8 @@
|
||||
},
|
||||
"ReceiptConfigRepository.php": {
|
||||
"type": "-",
|
||||
"size": 3486,
|
||||
"lmtime": 0,
|
||||
"size": 3439,
|
||||
"lmtime": 1775246463929,
|
||||
"modified": false
|
||||
},
|
||||
"SettingsController.php": {
|
||||
@@ -3019,9 +3056,9 @@
|
||||
},
|
||||
"ShopproApiClient.php": {
|
||||
"type": "-",
|
||||
"size": 13506,
|
||||
"lmtime": 1774612664232,
|
||||
"modified": true
|
||||
"size": 12858,
|
||||
"lmtime": 1775246463196,
|
||||
"modified": false
|
||||
},
|
||||
"ShopProClient.php": {
|
||||
"type": "-",
|
||||
@@ -3093,21 +3130,21 @@
|
||||
"Shipments": {
|
||||
"AllegroShipmentService.php": {
|
||||
"type": "-",
|
||||
"size": 18411,
|
||||
"size": 18625,
|
||||
"lmtime": 1774707709265,
|
||||
"modified": false
|
||||
"modified": true
|
||||
},
|
||||
"AllegroTrackingService.php": {
|
||||
"type": "-",
|
||||
"size": 1512,
|
||||
"lmtime": 1774294131192,
|
||||
"size": 6437,
|
||||
"lmtime": 1775246468084,
|
||||
"modified": false
|
||||
},
|
||||
"ApaczkaShipmentService.php": {
|
||||
"type": "-",
|
||||
"size": 35982,
|
||||
"size": 36163,
|
||||
"lmtime": 1774705073868,
|
||||
"modified": false
|
||||
"modified": true
|
||||
},
|
||||
"ApaczkaTrackingService.php": {
|
||||
"type": "-",
|
||||
@@ -3123,20 +3160,20 @@
|
||||
},
|
||||
"DeliveryStatus.php": {
|
||||
"type": "-",
|
||||
"size": 13599,
|
||||
"lmtime": 1774304126768,
|
||||
"size": 19836,
|
||||
"lmtime": 1775243494668,
|
||||
"modified": false
|
||||
},
|
||||
"InpostShipmentService.php": {
|
||||
"type": "-",
|
||||
"size": 22575,
|
||||
"lmtime": 0,
|
||||
"size": 21904,
|
||||
"lmtime": 1775246470836,
|
||||
"modified": false
|
||||
},
|
||||
"InpostTrackingService.php": {
|
||||
"type": "-",
|
||||
"size": 3803,
|
||||
"lmtime": 1774294254726,
|
||||
"size": 3335,
|
||||
"lmtime": 1775246472889,
|
||||
"modified": false
|
||||
},
|
||||
"ShipmentController.php": {
|
||||
@@ -3217,14 +3254,14 @@
|
||||
},
|
||||
"AutomationRepository.php": {
|
||||
"type": "-",
|
||||
"size": 10496,
|
||||
"lmtime": 1774703977978,
|
||||
"size": 10557,
|
||||
"lmtime": 1775246477348,
|
||||
"modified": false
|
||||
},
|
||||
"AutomationService.php": {
|
||||
"type": "-",
|
||||
"size": 32678,
|
||||
"lmtime": 1774909501988,
|
||||
"size": 24938,
|
||||
"lmtime": 1775245766985,
|
||||
"modified": false
|
||||
},
|
||||
"OrderStatusAgedService.php": {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
- deduplikacja wykonania tej samej pary `event_type + rule_id` w obrebie jednego lancucha,
|
||||
- limit historii wykonan w kontekście (`MAX_CHAIN_EXECUTIONS`).
|
||||
- `ShipmentTrackingHandler` triggeruje automatyzacje tylko po zmianie `delivery_status` i przekazuje kontekst (`package_id`, `provider`, `delivery_status`, `delivery_status_raw`, `previous_status`).
|
||||
- `DeliveryStatus` normalizuje statusy Allegro edge zarowno z opisow PL, jak i EN (mapa slugow + fallback keyword matching), dzieki czemu opisy typu `Parcel is awaiting pick-up` i `Parcel has been delivered` sa mapowane na statusy biznesowe zamiast `unknown`.
|
||||
- Kolejka wydruku ma akcje usuwania wpisu przez route `POST /settings/printing/jobs/delete` (CSRF + `OrderProAlerts.confirm`).
|
||||
- Szablony e-mail obsluguja zmienne przesylki:
|
||||
- `{{przesylka.numer}}` -> `shipment_packages.tracking_number` (najnowsza paczka zamowienia),
|
||||
@@ -29,7 +30,7 @@
|
||||
- `App\Modules\Settings`
|
||||
- `App\Modules\Accounting` (modul paragonow — wystawianie, podglad, druk, PDF, lista, eksport XLSX)
|
||||
- `App\Modules\Settings\EmailMailbox*` (skrzynki pocztowe SMTP — CRUD + test polaczenia)
|
||||
- `App\Modules\Settings\EmailTemplate*` (szablony e-mail — CRUD + Quill.js + zmienne + zalaczniki)
|
||||
- `App\Modules\Settings\EmailTemplate*` (szablony e-mail - lista + osobna podstrona formularza create/edit + Quill.js + zmienne + zalaczniki)
|
||||
- `App\Modules\Email` (wysylka e-mail z zamowien — EmailSendingService, VariableResolver, AttachmentGenerator; kompozycja: header (mailbox) + body (template) + footer (mailbox))
|
||||
- `App\Modules\Automation` (zadania automatyczne — reguly zdarzenie/warunki/akcje, CRUD)
|
||||
|
||||
@@ -92,6 +93,14 @@
|
||||
- `POST /settings/email-mailboxes/delete`
|
||||
- `POST /settings/email-mailboxes/toggle`
|
||||
- `POST /settings/email-mailboxes/test`
|
||||
- `GET /settings/email-templates`
|
||||
- `GET /settings/email-templates/create`
|
||||
- `GET /settings/email-templates/edit`
|
||||
- `POST /settings/email-templates/save`
|
||||
- `POST /settings/email-templates/delete`
|
||||
- `POST /settings/email-templates/duplicate`
|
||||
- `POST /settings/email-templates/toggle`
|
||||
- `POST /settings/email-templates/preview`
|
||||
- `GET /settings/automation`
|
||||
- `GET /settings/automation/create`
|
||||
- `POST /settings/automation/store`
|
||||
@@ -490,6 +499,22 @@
|
||||
- `activeSettings = users`
|
||||
- Usunieto wewnetrzny pasek `settings-nav` z widokow podstron ustawien.
|
||||
|
||||
## Przeplyw Ustawienia > Szablony e-mail
|
||||
- `GET /settings/email-templates`:
|
||||
- `EmailTemplateController::index(Request): Response`
|
||||
- renderuje liste szablonow (`resources/views/settings/email-templates.php`) i akcje tabeli.
|
||||
- `GET /settings/email-templates/create`:
|
||||
- `EmailTemplateController::create(Request): Response`
|
||||
- renderuje osobna podstrone formularza tworzenia (`resources/views/settings/email-templates-form.php`).
|
||||
- `GET /settings/email-templates/edit?id={id}`:
|
||||
- `EmailTemplateController::edit(Request): Response`
|
||||
- laduje wskazany szablon i renderuje osobna podstrone formularza edycji.
|
||||
- `POST /settings/email-templates/save`:
|
||||
- `EmailTemplateController::save(Request): Response`
|
||||
- waliduje CSRF i wymagane pola,
|
||||
- przy bledzie wraca na odpowiednia podstrone formularza (`create` lub `edit`),
|
||||
- po sukcesie zapisuje szablon i wraca do listy.
|
||||
|
||||
## Zasady aktualizacji
|
||||
- Przy kazdej zmianie dopisz:
|
||||
- nowe klasy i metody (sygnatury + odpowiedzialnosc),
|
||||
@@ -586,3 +611,4 @@
|
||||
## Klasy (aktualizacja 2026-03-28)
|
||||
- `App\Modules\Automation\AutomationExecutionLogRepository` (create, paginate, count, listEventTypes, purgeOlderThanDays).
|
||||
- `App\Modules\Cron\AutomationHistoryCleanupHandler` (cleanup retencji historii automatyzacji).
|
||||
|
||||
|
||||
@@ -104,6 +104,7 @@ Migracje z prefiksem `ensure_` to migracje kompensujące — zostały dodane
|
||||
- nowa tabela `automation_execution_logs` (historia wykonan regul automatyzacji: co, kiedy, na jakim zamowieniu, wynik),
|
||||
- indeksy pod filtrowanie po czasie/zdarzeniu/statusie/regule/zamowieniu,
|
||||
- seed harmonogramu `cron_schedules` dla joba `automation_history_cleanup` (retencja historii starszej niz 30 dni).
|
||||
- 2026-04-04: Hotfix trackingu Allegro Delivery (edge API) - rozszerzono mapowanie statusow EN i fallback keyword matching (`Parcel is awaiting pick-up`, `Parcel has been delivered`, itp.) w warstwie aplikacyjnej; bez zmian schematu bazy.
|
||||
|
||||
## Tabele
|
||||
|
||||
|
||||
@@ -1,5 +1,30 @@
|
||||
# Tech Changelog
|
||||
|
||||
## 2026-04-04 (Email templates - split list/form view)
|
||||
- `EmailTemplateController`:
|
||||
- dodano osobne endpointy widokowe `create()` i `edit()` dla formularza szablonu,
|
||||
- wydzielono render formularza do `renderForm(...)`,
|
||||
- `save()` przy bledzie walidacji/CSRF wraca na odpowiednia podstrone formularza (`/create` albo `/edit?id=`), zamiast do listy.
|
||||
- Routing:
|
||||
- dodano trasy `GET /settings/email-templates/create` oraz `GET /settings/email-templates/edit`.
|
||||
- Widoki:
|
||||
- `resources/views/settings/email-templates.php` zawiera tylko liste szablonow i akcje tabeli,
|
||||
- dodano `resources/views/settings/email-templates-form.php` jako osobna podstrone create/edit (Quill, zmienne, preview).
|
||||
- Brak zmian schematu bazy danych.
|
||||
|
||||
## 2026-04-04 (Phase 69 - Allegro Tracking English Statuses, Plan 01)
|
||||
- `DeliveryStatus::slugifyAllegroDescription()`:
|
||||
- dodano obsluge prefiksow EN (`Parcel has been ...`, `Parcel is ...`, `Courier has ...`) przed slugifikacja.
|
||||
- `DeliveryStatus`:
|
||||
- rozszerzono `ALLEGRO_EDGE_MAP` o slugi EN i ich mapowanie na statusy biznesowe (m.in. `awaiting_pick_up`, `delivered`, `dispatched`, `released_for_delivery`),
|
||||
- rozszerzono `ALLEGRO_EDGE_DESCRIPTIONS` o opisy EN/PL dla nowych slugow,
|
||||
- rozszerzono `guessStatusFromDescription()` o keyword fallback dla statusow EN (delivery/return/cancel/pickup/transit/confirmed/created/problem).
|
||||
- Dodano test jednostkowy `tests/Unit/DeliveryStatusTest.php` pokrywajacy:
|
||||
- mapowanie EN (`Parcel is awaiting pick-up`, `Parcel has been delivered`),
|
||||
- fallback EN (`released for delivery`),
|
||||
- regresje mapowania PL (`Przesylka zostala dostarczona`).
|
||||
- Brak zmian schematu bazy danych.
|
||||
|
||||
## 2026-04-03 (Phase 64 - Receipt Datetime Precision, Plan 01)
|
||||
- Migracja `20260403_000076_alter_receipts_issue_date_to_datetime.sql`: ALTER TABLE receipts MODIFY issue_date DATETIME NOT NULL.
|
||||
- `ReceiptController::store()`: zapis issue_date jako Y-m-d H:i:s, konwersja z formatu datetime-local (T separator).
|
||||
@@ -878,5 +903,3 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -927,7 +927,9 @@ a {
|
||||
align-items: center;
|
||||
gap: 9px;
|
||||
white-space: nowrap;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.sidebar__group-toggle::-webkit-details-marker {
|
||||
@@ -1361,7 +1363,9 @@ h4.section-title::before {
|
||||
border-radius: 6px;
|
||||
color: #64748b;
|
||||
cursor: grab;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
user-select: none;
|
||||
font-weight: 700;
|
||||
font-size: 12px;
|
||||
}
|
||||
@@ -1979,7 +1983,8 @@ h4.section-title::before {
|
||||
height: 48px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #dbe3ef;
|
||||
object-fit: cover;
|
||||
-o-object-fit: cover;
|
||||
object-fit: cover;
|
||||
background: #fff;
|
||||
}
|
||||
.orders-product__thumb--empty {
|
||||
@@ -2019,7 +2024,8 @@ h4.section-title::before {
|
||||
top: auto;
|
||||
width: 350px;
|
||||
max-height: 350px;
|
||||
object-fit: contain;
|
||||
-o-object-fit: contain;
|
||||
object-fit: contain;
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
|
||||
@@ -2300,7 +2306,8 @@ details[open] > .order-statuses-side__title .order-statuses-side__arrow {
|
||||
height: 44px;
|
||||
border-radius: 6px;
|
||||
border: 1px solid #dbe3ef;
|
||||
object-fit: cover;
|
||||
-o-object-fit: cover;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.order-item-thumb--empty {
|
||||
@@ -2547,7 +2554,8 @@ details[open] > .order-statuses-side__title .order-statuses-side__arrow {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
border-radius: 6px;
|
||||
object-fit: cover;
|
||||
-o-object-fit: cover;
|
||||
object-fit: cover;
|
||||
border: 1px solid var(--c-border);
|
||||
background: #f8fafc;
|
||||
}
|
||||
@@ -2585,7 +2593,8 @@ details[open] > .order-statuses-side__title .order-statuses-side__arrow {
|
||||
display: block;
|
||||
width: 100%;
|
||||
max-height: 70vh;
|
||||
object-fit: contain;
|
||||
-o-object-fit: contain;
|
||||
object-fit: contain;
|
||||
border-radius: 8px;
|
||||
background: #f8fafc;
|
||||
}
|
||||
@@ -2613,7 +2622,8 @@ details[open] > .order-statuses-side__title .order-statuses-side__arrow {
|
||||
.product-image-card__thumb {
|
||||
width: 100%;
|
||||
height: 160px;
|
||||
object-fit: cover;
|
||||
-o-object-fit: cover;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
}
|
||||
|
||||
@@ -2780,7 +2790,9 @@ details[open] > .order-statuses-side__title .order-statuses-side__arrow {
|
||||
cursor: pointer;
|
||||
color: var(--c-muted, #888);
|
||||
list-style: none;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
user-select: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.product-show-image-path summary::-webkit-details-marker {
|
||||
@@ -2802,7 +2814,8 @@ details[open] > .order-statuses-side__title .order-statuses-side__arrow {
|
||||
.product-show-image {
|
||||
width: 100%;
|
||||
max-height: 260px;
|
||||
object-fit: cover;
|
||||
-o-object-fit: cover;
|
||||
object-fit: cover;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #d9e0ea;
|
||||
}
|
||||
@@ -2821,7 +2834,9 @@ details[open] > .order-statuses-side__title .order-statuses-side__arrow {
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
user-select: none;
|
||||
min-height: 34px;
|
||||
}
|
||||
.searchable-select__trigger::after {
|
||||
@@ -3344,4 +3359,4 @@ body.no-scroll {
|
||||
padding: 12px 16px;
|
||||
overflow-y: auto;
|
||||
flex: 1;
|
||||
}
|
||||
}/*# sourceMappingURL=app.css.map */
|
||||
File diff suppressed because one or more lines are too long
@@ -1,6 +1,8 @@
|
||||
:root {
|
||||
--c-primary: #6690f4;
|
||||
--c-primary-dark: #3164db;
|
||||
--c-action-primary: #0f766e;
|
||||
--c-action-primary-dark: #0b5f59;
|
||||
--c-bg: #f4f6f9;
|
||||
--c-surface: #ffffff;
|
||||
--c-text: #4e5e6a;
|
||||
@@ -9,6 +11,7 @@
|
||||
--c-border: #b0bec5;
|
||||
--c-danger: #cc0000;
|
||||
--focus-ring: 0 0 0 3px rgba(102, 144, 244, 0.15);
|
||||
--focus-ring-action: 0 0 0 3px rgba(15, 118, 110, 0.18);
|
||||
--shadow-card: 0 1px 4px rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
@@ -29,11 +32,11 @@
|
||||
|
||||
.btn--primary {
|
||||
color: #ffffff;
|
||||
background: var(--c-primary);
|
||||
background: var(--c-action-primary);
|
||||
}
|
||||
|
||||
.btn--primary:hover {
|
||||
background: var(--c-primary-dark);
|
||||
background: var(--c-action-primary-dark);
|
||||
}
|
||||
|
||||
.btn--secondary {
|
||||
@@ -68,22 +71,28 @@
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.btn--disabled {
|
||||
opacity: 0.3;
|
||||
cursor: not-allowed;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.btn:active {
|
||||
transform: translateY(1px);
|
||||
}
|
||||
|
||||
.btn:focus-visible {
|
||||
outline: none;
|
||||
box-shadow: var(--focus-ring);
|
||||
border-color: var(--c-primary);
|
||||
box-shadow: var(--focus-ring-action);
|
||||
border-color: var(--c-action-primary);
|
||||
}
|
||||
|
||||
.form-control {
|
||||
width: 100%;
|
||||
min-height: 34px;
|
||||
min-height: 30px;
|
||||
border: 1px solid var(--c-border);
|
||||
border-radius: 8px;
|
||||
padding: 5px 10px;
|
||||
border-radius: 6px;
|
||||
padding: 4px 8px;
|
||||
font: inherit;
|
||||
color: var(--c-text-strong);
|
||||
background: #ffffff;
|
||||
@@ -238,6 +247,41 @@
|
||||
background: #edf2ff;
|
||||
}
|
||||
|
||||
.receipt-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
margin-bottom: 16px;
|
||||
padding-bottom: 12px;
|
||||
border-bottom: 2px solid var(--c-text-strong);
|
||||
}
|
||||
.receipt-header__seller {
|
||||
flex: 1;
|
||||
}
|
||||
.receipt-header__seller strong {
|
||||
font-size: 14px;
|
||||
display: block;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.receipt-header__title {
|
||||
text-align: right;
|
||||
}
|
||||
.receipt-header__title h1 {
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.receipt-print {
|
||||
max-width: 700px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
@media print {
|
||||
.receipt-print {
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
:root {
|
||||
--shadow-card: 0 20px 50px rgba(22, 34, 58, 0.14);
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
221
resources/views/settings/email-templates-form.php
Normal file
221
resources/views/settings/email-templates-form.php
Normal file
@@ -0,0 +1,221 @@
|
||||
<?php
|
||||
$template = is_array($template ?? null) ? $template : null;
|
||||
$isEdit = $template !== null;
|
||||
$mailboxes = is_array($mailboxes ?? null) ? $mailboxes : [];
|
||||
$variableGroups = is_array($variableGroups ?? null) ? $variableGroups : [];
|
||||
$attachmentTypes = is_array($attachmentTypes ?? null) ? $attachmentTypes : [];
|
||||
?>
|
||||
|
||||
<section class="card">
|
||||
<h2 class="section-title"><?= $isEdit ? 'Edytuj szablon e-mail' : 'Dodaj szablon e-mail' ?></h2>
|
||||
<p class="muted mt-12">Skonfiguruj temat, tresc i zmienne, ktore beda podstawiane podczas wysylki.</p>
|
||||
|
||||
<?php if (!empty($errorMessage)): ?>
|
||||
<div class="alert alert--danger mt-12" role="alert"><?= $e((string) $errorMessage) ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($successMessage)): ?>
|
||||
<div class="alert alert--success mt-12" role="status"><?= $e((string) $successMessage) ?></div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
|
||||
<section class="card mt-16">
|
||||
<form action="/settings/email-templates/save" method="post" novalidate class="mt-12" id="js-template-form">
|
||||
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
|
||||
<input type="hidden" name="body_html" id="js-body-html" value="<?= $e((string) ($template['body_html'] ?? '')) ?>">
|
||||
<?php if ($isEdit): ?>
|
||||
<input type="hidden" name="id" value="<?= (int) ($template['id'] ?? 0) ?>">
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="form-grid-2">
|
||||
<label class="form-field">
|
||||
<span class="field-label">Nazwa szablonu *</span>
|
||||
<input class="form-control" type="text" name="name" maxlength="200" required value="<?= $e((string) ($template['name'] ?? '')) ?>" placeholder="np. Potwierdzenie zamowienia">
|
||||
</label>
|
||||
<label class="form-field">
|
||||
<span class="field-label">Skrzynka nadawcza</span>
|
||||
<select class="form-control" name="mailbox_id">
|
||||
<option value="">- domyslna -</option>
|
||||
<?php foreach ($mailboxes as $mailbox): ?>
|
||||
<?php $mailboxId = (int) ($mailbox['id'] ?? 0); ?>
|
||||
<option value="<?= $mailboxId ?>"<?= ((int) ($template['mailbox_id'] ?? 0)) === $mailboxId ? ' selected' : '' ?>>
|
||||
<?= $e((string) ($mailbox['name'] ?? '')) ?> (<?= $e((string) ($mailbox['sender_email'] ?? '')) ?>)
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-grid-2 mt-0">
|
||||
<label class="form-field">
|
||||
<span class="field-label">Temat wiadomosci *</span>
|
||||
<input class="form-control" type="text" name="subject" maxlength="500" required value="<?= $e((string) ($template['subject'] ?? '')) ?>" placeholder="np. Potwierdzenie zamowienia {{zamowienie.numer}}">
|
||||
</label>
|
||||
<div class="form-field" style="display:flex;align-items:flex-end;gap:8px">
|
||||
<label style="display:flex;align-items:center;gap:6px;flex-direction:row">
|
||||
<input type="checkbox" name="is_active" value="1"<?= $isEdit ? (((int) ($template['is_active'] ?? 0)) === 1 ? ' checked' : '') : ' checked' ?>>
|
||||
<span class="field-label" style="margin:0">Aktywny</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-grid-2 mt-0">
|
||||
<label class="form-field">
|
||||
<span class="field-label">Zalacznik nr 1</span>
|
||||
<select class="form-control" name="attachment_1">
|
||||
<option value="">- brak -</option>
|
||||
<?php foreach ($attachmentTypes as $attachmentKey => $attachmentLabel): ?>
|
||||
<option value="<?= $e($attachmentKey) ?>"<?= ((string) ($template['attachment_1'] ?? '')) === $attachmentKey ? ' selected' : '' ?>><?= $e($attachmentLabel) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</label>
|
||||
<div class="form-field"></div>
|
||||
</div>
|
||||
|
||||
<div class="mt-12">
|
||||
<span class="field-label">Tresc wiadomosci *</span>
|
||||
<p class="muted mt-4">Dostepne sa zmienne przesylki: <code>{{przesylka.numer}}</code> oraz <code>{{przesylka.link_sledzenia}}</code>.</p>
|
||||
<div class="email-tpl-editor-wrap mt-4">
|
||||
<div class="email-tpl-toolbar">
|
||||
<div class="email-tpl-var-dropdown">
|
||||
<button type="button" class="btn btn--sm btn--secondary" id="js-var-toggle">Wstaw zmienna</button>
|
||||
<div class="email-tpl-var-panel" id="js-var-panel" style="display:none">
|
||||
<?php foreach ($variableGroups as $groupKey => $group): ?>
|
||||
<div class="email-var-group">
|
||||
<div class="email-var-group__label"><?= $e((string) ($group['label'] ?? '')) ?></div>
|
||||
<?php foreach (($group['vars'] ?? []) as $varKey => $varDesc): ?>
|
||||
<button type="button" class="email-var-item" data-var="{{<?= $e($groupKey . '.' . $varKey) ?>}}" title="<?= $e((string) $varDesc) ?>">
|
||||
{{<?= $e($groupKey . '.' . $varKey) ?>}}
|
||||
</button>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn btn--sm btn--secondary" id="js-preview-btn">Podglad</button>
|
||||
</div>
|
||||
<div id="js-quill-editor"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-actions mt-16">
|
||||
<button type="submit" class="btn btn--primary"><?= $isEdit ? 'Zapisz zmiany' : 'Dodaj szablon' ?></button>
|
||||
<a href="/settings/email-templates" class="btn btn--secondary">Powrot do listy</a>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<div class="modal-overlay" id="js-preview-overlay" style="display:none">
|
||||
<div class="modal-box">
|
||||
<div class="modal-box__header">
|
||||
<h3 class="modal-box__title">Podglad szablonu</h3>
|
||||
<button type="button" class="modal-box__close" id="js-preview-close">×</button>
|
||||
</div>
|
||||
<div class="modal-box__body">
|
||||
<div class="mt-4"><strong>Temat:</strong> <span id="js-preview-subject"></span></div>
|
||||
<hr class="mt-8 mb-8">
|
||||
<div id="js-preview-body"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<link href="https://cdn.quilljs.com/2.0.3/quill.snow.css" rel="stylesheet">
|
||||
<script src="https://cdn.quilljs.com/2.0.3/quill.js"></script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var csrfToken = <?= json_encode($csrfToken ?? '', JSON_HEX_TAG) ?>;
|
||||
|
||||
var quill = new Quill('#js-quill-editor', {
|
||||
theme: 'snow',
|
||||
modules: {
|
||||
toolbar: [
|
||||
[{ header: [1, 2, 3, false] }],
|
||||
['bold', 'italic', 'underline', 'strike'],
|
||||
[{ color: [] }, { background: [] }],
|
||||
[{ align: [] }],
|
||||
[{ list: 'ordered' }, { list: 'bullet' }],
|
||||
['link'],
|
||||
['clean']
|
||||
]
|
||||
},
|
||||
placeholder: 'Wpisz tresc wiadomosci...'
|
||||
});
|
||||
|
||||
var existingHtml = document.getElementById('js-body-html').value;
|
||||
if (existingHtml) {
|
||||
quill.root.innerHTML = existingHtml;
|
||||
}
|
||||
|
||||
var form = document.getElementById('js-template-form');
|
||||
form.addEventListener('submit', function() {
|
||||
document.getElementById('js-body-html').value = quill.root.innerHTML;
|
||||
});
|
||||
|
||||
var varToggle = document.getElementById('js-var-toggle');
|
||||
var varPanel = document.getElementById('js-var-panel');
|
||||
varToggle.addEventListener('click', function(event) {
|
||||
event.stopPropagation();
|
||||
varPanel.style.display = varPanel.style.display === 'none' ? 'block' : 'none';
|
||||
});
|
||||
document.addEventListener('click', function(event) {
|
||||
if (!varPanel.contains(event.target) && event.target !== varToggle) {
|
||||
varPanel.style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
varPanel.addEventListener('click', function(event) {
|
||||
var button = event.target.closest('.email-var-item');
|
||||
if (!button) {
|
||||
return;
|
||||
}
|
||||
|
||||
var variableText = button.getAttribute('data-var');
|
||||
var range = quill.getSelection(true);
|
||||
quill.insertText(range.index, variableText);
|
||||
quill.setSelection(range.index + variableText.length);
|
||||
varPanel.style.display = 'none';
|
||||
});
|
||||
|
||||
var previewBtn = document.getElementById('js-preview-btn');
|
||||
var previewOverlay = document.getElementById('js-preview-overlay');
|
||||
var previewClose = document.getElementById('js-preview-close');
|
||||
var previewSubject = document.getElementById('js-preview-subject');
|
||||
var previewBody = document.getElementById('js-preview-body');
|
||||
|
||||
previewBtn.addEventListener('click', function() {
|
||||
var subjectVal = form.querySelector('[name="subject"]').value;
|
||||
var bodyVal = quill.root.innerHTML;
|
||||
|
||||
previewBtn.disabled = true;
|
||||
previewBtn.textContent = 'Ladowanie...';
|
||||
|
||||
var formData = new FormData();
|
||||
formData.append('_token', csrfToken);
|
||||
formData.append('subject', subjectVal);
|
||||
formData.append('body_html', bodyVal);
|
||||
|
||||
fetch('/settings/email-templates/preview', { method: 'POST', body: formData })
|
||||
.then(function(response) { return response.json(); })
|
||||
.then(function(data) {
|
||||
if (data.success) {
|
||||
previewSubject.textContent = data.subject;
|
||||
previewBody.innerHTML = data.body_html;
|
||||
previewOverlay.style.display = 'flex';
|
||||
}
|
||||
})
|
||||
.catch(function() {})
|
||||
.finally(function() {
|
||||
previewBtn.disabled = false;
|
||||
previewBtn.textContent = 'Podglad';
|
||||
});
|
||||
});
|
||||
|
||||
previewClose.addEventListener('click', function() {
|
||||
previewOverlay.style.display = 'none';
|
||||
});
|
||||
previewOverlay.addEventListener('click', function(event) {
|
||||
if (event.target === previewOverlay) {
|
||||
previewOverlay.style.display = 'none';
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -1,14 +1,13 @@
|
||||
<?php
|
||||
$templates = is_array($templates ?? null) ? $templates : [];
|
||||
$mailboxes = is_array($mailboxes ?? null) ? $mailboxes : [];
|
||||
$et = is_array($editTemplate ?? null) ? $editTemplate : null;
|
||||
$isEdit = $et !== null;
|
||||
$variableGroups = is_array($variableGroups ?? null) ? $variableGroups : [];
|
||||
$attachmentTypes = is_array($attachmentTypes ?? null) ? $attachmentTypes : [];
|
||||
?>
|
||||
|
||||
<section class="card">
|
||||
<h2 class="section-title">Szablony e-mail</h2>
|
||||
<div class="section-header">
|
||||
<h2 class="section-title">Szablony e-mail</h2>
|
||||
<a href="/settings/email-templates/create" class="btn btn--primary btn--sm">Dodaj szablon</a>
|
||||
</div>
|
||||
<p class="muted mt-12">Szablony wiadomosci e-mail z edytorem i systemem zmiennych.</p>
|
||||
|
||||
<?php if (!empty($errorMessage)): ?>
|
||||
@@ -23,7 +22,7 @@ $attachmentTypes = is_array($attachmentTypes ?? null) ? $attachmentTypes : [];
|
||||
<h3 class="section-title">Lista szablonow</h3>
|
||||
|
||||
<?php if (count($templates) === 0): ?>
|
||||
<p class="muted mt-12">Brak szablonow. Dodaj pierwszy szablon ponizej.</p>
|
||||
<p class="muted mt-12">Brak szablonow. Kliknij "Dodaj szablon", aby utworzyc pierwszy.</p>
|
||||
<?php else: ?>
|
||||
<div class="table-wrap mt-12">
|
||||
<table class="table">
|
||||
@@ -39,11 +38,12 @@ $attachmentTypes = is_array($attachmentTypes ?? null) ? $attachmentTypes : [];
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($templates as $tpl): ?>
|
||||
<tr data-id="<?= (int) ($tpl['id'] ?? 0) ?>">
|
||||
<?php $templateId = (int) ($tpl['id'] ?? 0); ?>
|
||||
<tr data-id="<?= $templateId ?>">
|
||||
<td><?= $e((string) ($tpl['name'] ?? '')) ?></td>
|
||||
<td><?= $e((string) ($tpl['subject'] ?? '')) ?></td>
|
||||
<td><?= $e((string) ($tpl['mailbox_name'] ?? '—')) ?></td>
|
||||
<td><?= isset($tpl['attachment_1'], $attachmentTypes[$tpl['attachment_1']]) ? $e($attachmentTypes[$tpl['attachment_1']]) : '—' ?></td>
|
||||
<td><?= $e((string) ($tpl['mailbox_name'] ?? '-')) ?></td>
|
||||
<td><?= isset($tpl['attachment_1'], $attachmentTypes[$tpl['attachment_1']]) ? $e($attachmentTypes[$tpl['attachment_1']]) : '-' ?></td>
|
||||
<td>
|
||||
<?php if (((int) ($tpl['is_active'] ?? 0)) === 1): ?>
|
||||
<span class="badge badge--success js-status-badge">Aktywny</span>
|
||||
@@ -52,20 +52,20 @@ $attachmentTypes = is_array($attachmentTypes ?? null) ? $attachmentTypes : [];
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td style="white-space:nowrap">
|
||||
<a href="/settings/email-templates?edit=<?= (int) ($tpl['id'] ?? 0) ?>" class="btn btn--sm btn--secondary">Edytuj</a>
|
||||
<a href="/settings/email-templates/edit?id=<?= $templateId ?>" class="btn btn--sm btn--secondary">Edytuj</a>
|
||||
<form action="/settings/email-templates/duplicate" method="post" style="display:inline">
|
||||
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
|
||||
<input type="hidden" name="id" value="<?= (int) ($tpl['id'] ?? 0) ?>">
|
||||
<input type="hidden" name="id" value="<?= $templateId ?>">
|
||||
<button type="submit" class="btn btn--sm btn--secondary">Duplikuj</button>
|
||||
</form>
|
||||
<button type="button" class="btn btn--sm btn--secondary js-toggle-btn"
|
||||
data-id="<?= (int) ($tpl['id'] ?? 0) ?>"
|
||||
data-id="<?= $templateId ?>"
|
||||
data-active="<?= (int) ($tpl['is_active'] ?? 0) ?>">
|
||||
<?= ((int) ($tpl['is_active'] ?? 0)) === 1 ? 'Dezaktywuj' : 'Aktywuj' ?>
|
||||
</button>
|
||||
<form action="/settings/email-templates/delete" method="post" style="display:inline" class="js-confirm-delete">
|
||||
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
|
||||
<input type="hidden" name="id" value="<?= (int) ($tpl['id'] ?? 0) ?>">
|
||||
<input type="hidden" name="id" value="<?= $templateId ?>">
|
||||
<button type="button" class="btn btn--sm btn--danger js-delete-btn">Usun</button>
|
||||
</form>
|
||||
</td>
|
||||
@@ -77,211 +77,10 @@ $attachmentTypes = is_array($attachmentTypes ?? null) ? $attachmentTypes : [];
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
|
||||
<section class="card mt-16">
|
||||
<h3 class="section-title"><?= $isEdit ? 'Edytuj szablon' : 'Dodaj szablon' ?></h3>
|
||||
|
||||
<form action="/settings/email-templates/save" method="post" novalidate class="mt-12" id="js-template-form">
|
||||
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
|
||||
<input type="hidden" name="body_html" id="js-body-html" value="<?= $e((string) ($et['body_html'] ?? '')) ?>">
|
||||
<?php if ($isEdit): ?>
|
||||
<input type="hidden" name="id" value="<?= (int) ($et['id'] ?? 0) ?>">
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="form-grid-2">
|
||||
<label class="form-field">
|
||||
<span class="field-label">Nazwa szablonu *</span>
|
||||
<input class="form-control" type="text" name="name" maxlength="200" required value="<?= $e((string) ($et['name'] ?? '')) ?>" placeholder="np. Potwierdzenie zamowienia">
|
||||
</label>
|
||||
<label class="form-field">
|
||||
<span class="field-label">Skrzynka nadawcza</span>
|
||||
<select class="form-control" name="mailbox_id">
|
||||
<option value="">— domyslna —</option>
|
||||
<?php foreach ($mailboxes as $mb): ?>
|
||||
<option value="<?= (int) ($mb['id'] ?? 0) ?>"<?= ((int) ($et['mailbox_id'] ?? 0)) === (int) ($mb['id'] ?? 0) ? ' selected' : '' ?>>
|
||||
<?= $e((string) ($mb['name'] ?? '')) ?> (<?= $e((string) ($mb['sender_email'] ?? '')) ?>)
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-grid-2 mt-0">
|
||||
<label class="form-field">
|
||||
<span class="field-label">Temat wiadomosci *</span>
|
||||
<input class="form-control" type="text" name="subject" maxlength="500" required value="<?= $e((string) ($et['subject'] ?? '')) ?>" placeholder="np. Potwierdzenie zamowienia {{zamowienie.numer}}">
|
||||
</label>
|
||||
<div class="form-field" style="display:flex;align-items:flex-end;gap:8px">
|
||||
<label style="display:flex;align-items:center;gap:6px;flex-direction:row">
|
||||
<input type="checkbox" name="is_active" value="1"<?= $isEdit ? (((int) ($et['is_active'] ?? 0)) === 1 ? ' checked' : '') : ' checked' ?>>
|
||||
<span class="field-label" style="margin:0">Aktywny</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-grid-2 mt-0">
|
||||
<label class="form-field">
|
||||
<span class="field-label">Zalacznik nr 1</span>
|
||||
<select class="form-control" name="attachment_1">
|
||||
<option value="">— brak —</option>
|
||||
<?php foreach ($attachmentTypes as $atKey => $atLabel): ?>
|
||||
<option value="<?= $e($atKey) ?>"<?= ((string) ($et['attachment_1'] ?? '')) === $atKey ? ' selected' : '' ?>><?= $e($atLabel) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</label>
|
||||
<div class="form-field"></div>
|
||||
</div>
|
||||
|
||||
<div class="mt-12">
|
||||
<span class="field-label">Tresc wiadomosci *</span>
|
||||
<p class="muted mt-4">Dostepne sa zmienne przesylki: <code>{{przesylka.numer}}</code> oraz <code>{{przesylka.link_sledzenia}}</code>.</p>
|
||||
<div class="email-tpl-editor-wrap mt-4">
|
||||
<div class="email-tpl-toolbar">
|
||||
<div class="email-tpl-var-dropdown">
|
||||
<button type="button" class="btn btn--sm btn--secondary" id="js-var-toggle">Wstaw zmienna ▾</button>
|
||||
<div class="email-tpl-var-panel" id="js-var-panel" style="display:none">
|
||||
<?php foreach ($variableGroups as $groupKey => $group): ?>
|
||||
<div class="email-var-group">
|
||||
<div class="email-var-group__label"><?= $e((string) ($group['label'] ?? '')) ?></div>
|
||||
<?php foreach (($group['vars'] ?? []) as $varKey => $varDesc): ?>
|
||||
<button type="button" class="email-var-item" data-var="{{<?= $e($groupKey . '.' . $varKey) ?>}}" title="<?= $e((string) $varDesc) ?>">
|
||||
{{<?= $e($groupKey . '.' . $varKey) ?>}}
|
||||
</button>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn btn--sm btn--secondary" id="js-preview-btn">Podglad</button>
|
||||
</div>
|
||||
<div id="js-quill-editor"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-actions mt-16">
|
||||
<button type="submit" class="btn btn--primary"><?= $isEdit ? 'Zapisz zmiany' : 'Dodaj szablon' ?></button>
|
||||
<?php if ($isEdit): ?>
|
||||
<a href="/settings/email-templates" class="btn btn--secondary">Anuluj</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<div class="modal-overlay" id="js-preview-overlay" style="display:none">
|
||||
<div class="modal-box">
|
||||
<div class="modal-box__header">
|
||||
<h3 class="modal-box__title">Podglad szablonu</h3>
|
||||
<button type="button" class="modal-box__close" id="js-preview-close">×</button>
|
||||
</div>
|
||||
<div class="modal-box__body">
|
||||
<div class="mt-4"><strong>Temat:</strong> <span id="js-preview-subject"></span></div>
|
||||
<hr class="mt-8 mb-8">
|
||||
<div id="js-preview-body"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<link href="https://cdn.quilljs.com/2.0.3/quill.snow.css" rel="stylesheet">
|
||||
<script src="https://cdn.quilljs.com/2.0.3/quill.js"></script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var csrfToken = <?= json_encode($csrfToken ?? '', JSON_HEX_TAG) ?>;
|
||||
|
||||
// Quill editor
|
||||
var quill = new Quill('#js-quill-editor', {
|
||||
theme: 'snow',
|
||||
modules: {
|
||||
toolbar: [
|
||||
[{ header: [1, 2, 3, false] }],
|
||||
['bold', 'italic', 'underline', 'strike'],
|
||||
[{ color: [] }, { background: [] }],
|
||||
[{ align: [] }],
|
||||
[{ list: 'ordered' }, { list: 'bullet' }],
|
||||
['link'],
|
||||
['clean']
|
||||
]
|
||||
},
|
||||
placeholder: 'Wpisz tresc wiadomosci...'
|
||||
});
|
||||
|
||||
// Load existing content
|
||||
var existingHtml = document.getElementById('js-body-html').value;
|
||||
if (existingHtml) {
|
||||
quill.root.innerHTML = existingHtml;
|
||||
}
|
||||
|
||||
// Sync on submit
|
||||
var form = document.getElementById('js-template-form');
|
||||
form.addEventListener('submit', function() {
|
||||
document.getElementById('js-body-html').value = quill.root.innerHTML;
|
||||
});
|
||||
|
||||
// Variable panel toggle
|
||||
var varToggle = document.getElementById('js-var-toggle');
|
||||
var varPanel = document.getElementById('js-var-panel');
|
||||
varToggle.addEventListener('click', function(e) {
|
||||
e.stopPropagation();
|
||||
varPanel.style.display = varPanel.style.display === 'none' ? 'block' : 'none';
|
||||
});
|
||||
document.addEventListener('click', function(e) {
|
||||
if (!varPanel.contains(e.target) && e.target !== varToggle) {
|
||||
varPanel.style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
// Insert variable into Quill
|
||||
varPanel.addEventListener('click', function(e) {
|
||||
var btn = e.target.closest('.email-var-item');
|
||||
if (!btn) return;
|
||||
var varText = btn.getAttribute('data-var');
|
||||
var range = quill.getSelection(true);
|
||||
quill.insertText(range.index, varText);
|
||||
quill.setSelection(range.index + varText.length);
|
||||
varPanel.style.display = 'none';
|
||||
});
|
||||
|
||||
// Preview
|
||||
var previewBtn = document.getElementById('js-preview-btn');
|
||||
var previewOverlay = document.getElementById('js-preview-overlay');
|
||||
var previewClose = document.getElementById('js-preview-close');
|
||||
var previewSubject = document.getElementById('js-preview-subject');
|
||||
var previewBody = document.getElementById('js-preview-body');
|
||||
|
||||
previewBtn.addEventListener('click', function() {
|
||||
var subjectVal = form.querySelector('[name="subject"]').value;
|
||||
var bodyVal = quill.root.innerHTML;
|
||||
|
||||
previewBtn.disabled = true;
|
||||
previewBtn.textContent = 'Ladowanie...';
|
||||
|
||||
var fd = new FormData();
|
||||
fd.append('_token', csrfToken);
|
||||
fd.append('subject', subjectVal);
|
||||
fd.append('body_html', bodyVal);
|
||||
|
||||
fetch('/settings/email-templates/preview', { method: 'POST', body: fd })
|
||||
.then(function(r) { return r.json(); })
|
||||
.then(function(data) {
|
||||
if (data.success) {
|
||||
previewSubject.textContent = data.subject;
|
||||
previewBody.innerHTML = data.body_html;
|
||||
previewOverlay.style.display = 'flex';
|
||||
}
|
||||
})
|
||||
.catch(function() {})
|
||||
.finally(function() {
|
||||
previewBtn.disabled = false;
|
||||
previewBtn.textContent = 'Podglad';
|
||||
});
|
||||
});
|
||||
|
||||
previewClose.addEventListener('click', function() {
|
||||
previewOverlay.style.display = 'none';
|
||||
});
|
||||
previewOverlay.addEventListener('click', function(e) {
|
||||
if (e.target === previewOverlay) previewOverlay.style.display = 'none';
|
||||
});
|
||||
|
||||
// Toggle status (AJAX)
|
||||
document.querySelectorAll('.js-toggle-btn').forEach(function(btn) {
|
||||
btn.addEventListener('click', function() {
|
||||
var id = this.getAttribute('data-id');
|
||||
@@ -312,7 +111,6 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
});
|
||||
});
|
||||
|
||||
// Delete with OrderProAlerts
|
||||
document.querySelectorAll('.js-delete-btn').forEach(function(btn) {
|
||||
btn.addEventListener('click', function() {
|
||||
var delForm = this.closest('form');
|
||||
@@ -323,9 +121,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
function() { delForm.submit(); }
|
||||
);
|
||||
} else {
|
||||
if (confirm('Czy na pewno chcesz usunac ten szablon e-mail?')) {
|
||||
delForm.submit();
|
||||
}
|
||||
delForm.submit();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -461,6 +461,8 @@ return static function (Application $app): void {
|
||||
$router->post('/settings/email-mailboxes/toggle', [$emailMailboxController, 'toggleStatus'], [$authMiddleware]);
|
||||
$router->post('/settings/email-mailboxes/test', [$emailMailboxController, 'testConnection'], [$authMiddleware]);
|
||||
$router->get('/settings/email-templates', [$emailTemplateController, 'index'], [$authMiddleware]);
|
||||
$router->get('/settings/email-templates/create', [$emailTemplateController, 'create'], [$authMiddleware]);
|
||||
$router->get('/settings/email-templates/edit', [$emailTemplateController, 'edit'], [$authMiddleware]);
|
||||
$router->post('/settings/email-templates/save', [$emailTemplateController, 'save'], [$authMiddleware]);
|
||||
$router->post('/settings/email-templates/delete', [$emailTemplateController, 'delete'], [$authMiddleware]);
|
||||
$router->post('/settings/email-templates/duplicate', [$emailTemplateController, 'duplicate'], [$authMiddleware]);
|
||||
|
||||
@@ -97,15 +97,7 @@ final class EmailTemplateController
|
||||
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$t = $this->translator;
|
||||
$templates = $this->repository->listAll();
|
||||
$mailboxes = $this->mailboxRepository->listActive();
|
||||
|
||||
$editTemplate = null;
|
||||
$editId = (int) $request->input('edit', '0');
|
||||
if ($editId > 0) {
|
||||
$editTemplate = $this->repository->findById($editId);
|
||||
}
|
||||
|
||||
$html = $this->template->render('settings/email-templates', [
|
||||
'title' => 'Szablony e-mail',
|
||||
@@ -114,9 +106,6 @@ final class EmailTemplateController
|
||||
'user' => $this->auth->user(),
|
||||
'csrfToken' => Csrf::token(),
|
||||
'templates' => $templates,
|
||||
'mailboxes' => $mailboxes,
|
||||
'editTemplate' => $editTemplate,
|
||||
'variableGroups' => self::VARIABLE_GROUPS,
|
||||
'attachmentTypes' => self::ATTACHMENT_TYPES,
|
||||
'successMessage' => Flash::get('settings.email_templates.success', ''),
|
||||
'errorMessage' => Flash::get('settings.email_templates.error', ''),
|
||||
@@ -125,11 +114,32 @@ final class EmailTemplateController
|
||||
return Response::html($html);
|
||||
}
|
||||
|
||||
public function create(Request $request): Response
|
||||
{
|
||||
return $this->renderForm(null);
|
||||
}
|
||||
|
||||
public function edit(Request $request): Response
|
||||
{
|
||||
$id = (int) $request->input('id', '0');
|
||||
$template = $id > 0 ? $this->repository->findById($id) : null;
|
||||
|
||||
if ($template === null) {
|
||||
Flash::set('settings.email_templates.error', 'Nie znaleziono szablonu');
|
||||
return Response::redirect('/settings/email-templates');
|
||||
}
|
||||
|
||||
return $this->renderForm($template);
|
||||
}
|
||||
|
||||
public function save(Request $request): Response
|
||||
{
|
||||
$templateId = (int) $request->input('id', '0');
|
||||
$formPath = $this->buildFormPath($templateId > 0 ? $templateId : null);
|
||||
|
||||
if (!Csrf::validate((string) $request->input('_token', ''))) {
|
||||
Flash::set('settings.email_templates.error', 'Nieprawidlowy token CSRF');
|
||||
return Response::redirect('/settings/email-templates');
|
||||
return Response::redirect($formPath);
|
||||
}
|
||||
|
||||
$name = trim((string) $request->input('name', ''));
|
||||
@@ -138,7 +148,7 @@ final class EmailTemplateController
|
||||
|
||||
if ($name === '' || $subject === '' || $bodyHtml === '') {
|
||||
Flash::set('settings.email_templates.error', 'Nazwa, temat i tresc sa wymagane');
|
||||
return Response::redirect('/settings/email-templates');
|
||||
return Response::redirect($formPath);
|
||||
}
|
||||
|
||||
$attachment1Raw = trim((string) $request->input('attachment_1', ''));
|
||||
@@ -158,6 +168,7 @@ final class EmailTemplateController
|
||||
Flash::set('settings.email_templates.success', 'Szablon zostal zapisany');
|
||||
} catch (Throwable) {
|
||||
Flash::set('settings.email_templates.error', 'Blad zapisu szablonu');
|
||||
return Response::redirect($formPath);
|
||||
}
|
||||
|
||||
return Response::redirect('/settings/email-templates');
|
||||
@@ -266,4 +277,32 @@ final class EmailTemplateController
|
||||
$text
|
||||
);
|
||||
}
|
||||
|
||||
private function renderForm(?array $template): Response
|
||||
{
|
||||
$html = $this->template->render('settings/email-templates-form', [
|
||||
'title' => $template !== null ? 'Edytuj szablon e-mail' : 'Nowy szablon e-mail',
|
||||
'activeMenu' => 'settings',
|
||||
'activeSettings' => 'email-templates',
|
||||
'user' => $this->auth->user(),
|
||||
'csrfToken' => Csrf::token(),
|
||||
'mailboxes' => $this->mailboxRepository->listActive(),
|
||||
'template' => $template,
|
||||
'variableGroups' => self::VARIABLE_GROUPS,
|
||||
'attachmentTypes' => self::ATTACHMENT_TYPES,
|
||||
'successMessage' => Flash::get('settings.email_templates.success', ''),
|
||||
'errorMessage' => Flash::get('settings.email_templates.error', ''),
|
||||
], 'layouts/app');
|
||||
|
||||
return Response::html($html);
|
||||
}
|
||||
|
||||
private function buildFormPath(?int $templateId): string
|
||||
{
|
||||
if ($templateId !== null && $templateId > 0) {
|
||||
return '/settings/email-templates/edit?id=' . $templateId;
|
||||
}
|
||||
|
||||
return '/settings/email-templates/create';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,29 +194,40 @@ final class DeliveryStatus
|
||||
private const ALLEGRO_EDGE_MAP = [
|
||||
// Realne slugi z edge API (po slugify opisów)
|
||||
'przygotowana_przez_nadawce' => self::CREATED,
|
||||
'prepared_by_the_sender' => self::CREATED,
|
||||
'nadana' => self::CONFIRMED,
|
||||
'dispatched' => self::CONFIRMED,
|
||||
'podjeta_z_maszyny_przez_kuriera' => self::IN_TRANSIT,
|
||||
'podjeta_z_punktu_przez_kuriera' => self::IN_TRANSIT,
|
||||
'podjeta_z_punktu' => self::IN_TRANSIT,
|
||||
'odebrana_przez_kuriera' => self::IN_TRANSIT,
|
||||
'picked_up_from_point_by_courier' => self::IN_TRANSIT,
|
||||
'picked_up_by_the_courier' => self::IN_TRANSIT,
|
||||
'przekazal_przesylke_do_magazynu' => self::IN_TRANSIT,
|
||||
'przekazana_do_magazynu' => self::IN_TRANSIT,
|
||||
'transferred_the_parcel_to_the_warehouse' => self::IN_TRANSIT,
|
||||
'accepted_at_the_branch' => self::IN_TRANSIT,
|
||||
'przesylka_wyjechala_w_droge_do_punktu_docelowego' => self::IN_TRANSIT,
|
||||
'w_sortowni' => self::IN_TRANSIT,
|
||||
'wyjechala_w_droge_do_punktu_docelowego' => self::IN_TRANSIT,
|
||||
'wyslana_z_sortowni' => self::IN_TRANSIT,
|
||||
'w_doreczeniu' => self::OUT_FOR_DELIVERY,
|
||||
'wydana_do_doreczenia' => self::OUT_FOR_DELIVERY,
|
||||
'released_for_delivery' => self::OUT_FOR_DELIVERY,
|
||||
'dostarczana' => self::OUT_FOR_DELIVERY,
|
||||
'gotowa_do_odbioru' => self::READY_FOR_PICKUP,
|
||||
'oczekuje_na_odbior' => self::READY_FOR_PICKUP,
|
||||
'przesylka_oczekuje_na_odbior' => self::READY_FOR_PICKUP,
|
||||
'awaiting_pick_up' => self::READY_FOR_PICKUP,
|
||||
'dostarczona' => self::DELIVERED,
|
||||
'doreczona' => self::DELIVERED,
|
||||
'odebrana' => self::DELIVERED,
|
||||
'delivered' => self::DELIVERED,
|
||||
'zwrocona' => self::RETURNED,
|
||||
'zwrocona_do_nadawcy' => self::RETURNED,
|
||||
'returned_to_the_sender' => self::RETURNED,
|
||||
'anulowana' => self::CANCELLED,
|
||||
'cancelled' => self::CANCELLED,
|
||||
'odmowa_przyjecia' => self::PROBLEM,
|
||||
'uszkodzona' => self::PROBLEM,
|
||||
'zagubiona' => self::PROBLEM,
|
||||
@@ -224,27 +235,38 @@ final class DeliveryStatus
|
||||
|
||||
private const ALLEGRO_EDGE_DESCRIPTIONS = [
|
||||
'przygotowana_przez_nadawce' => 'Przesyłka przygotowana przez nadawcę',
|
||||
'prepared_by_the_sender' => 'Przesyłka przygotowana przez nadawcę',
|
||||
'nadana' => 'Przesyłka nadana',
|
||||
'dispatched' => 'Przesyłka nadana',
|
||||
'podjeta_z_maszyny_przez_kuriera' => 'Podjęta z maszyny przez kuriera',
|
||||
'podjeta_z_punktu_przez_kuriera' => 'Podjęta z punktu przez kuriera',
|
||||
'odebrana_przez_kuriera' => 'Odebrana przez kuriera',
|
||||
'picked_up_from_point_by_courier' => 'Podjęta z punktu przez kuriera',
|
||||
'picked_up_by_the_courier' => 'Odebrana przez kuriera',
|
||||
'przekazana_do_magazynu' => 'Przekazana do magazynu',
|
||||
'transferred_the_parcel_to_the_warehouse' => 'Przekazana do magazynu',
|
||||
'accepted_at_the_branch' => 'Przyjęta w oddziale',
|
||||
'przesylka_wyjechala_w_droge_do_punktu_docelowego' => 'Wyjechała w drogę do punktu docelowego',
|
||||
'w_sortowni' => 'W sortowni',
|
||||
'wyjechala_w_droge_do_punktu_docelowego' => 'Wyjechała w drogę do punktu docelowego',
|
||||
'wyslana_z_sortowni' => 'Wysłana z sortowni',
|
||||
'w_doreczeniu' => 'W doręczeniu',
|
||||
'wydana_do_doreczenia' => 'Wydana do doręczenia',
|
||||
'released_for_delivery' => 'Wydana do doręczenia',
|
||||
'dostarczana' => 'Dostarczana',
|
||||
'gotowa_do_odbioru' => 'Gotowa do odbioru',
|
||||
'oczekuje_na_odbior' => 'Oczekuje na odbiór',
|
||||
'przesylka_oczekuje_na_odbior' => 'Oczekuje na odbiór',
|
||||
'awaiting_pick_up' => 'Oczekuje na odbiór',
|
||||
'dostarczona' => 'Dostarczona',
|
||||
'doreczona' => 'Doręczona',
|
||||
'odebrana' => 'Odebrana',
|
||||
'delivered' => 'Dostarczona',
|
||||
'zwrocona' => 'Zwrócona',
|
||||
'zwrocona_do_nadawcy' => 'Zwrócona do nadawcy',
|
||||
'returned_to_the_sender' => 'Zwrócona do nadawcy',
|
||||
'anulowana' => 'Anulowana',
|
||||
'cancelled' => 'Anulowana',
|
||||
'odmowa_przyjecia' => 'Odmowa przyjęcia',
|
||||
'uszkodzona' => 'Uszkodzona',
|
||||
'zagubiona' => 'Zagubiona',
|
||||
@@ -369,6 +391,9 @@ final class DeliveryStatus
|
||||
$text = preg_replace('/^Przesy[łl]ka zosta[łl]a\s+/ui', '', $text);
|
||||
$text = preg_replace('/^Kurier\s+/ui', '', $text);
|
||||
$text = preg_replace('/^Paczka zosta[łl]a\s+/ui', '', $text);
|
||||
$text = preg_replace('/^Parcel has been\s+/i', '', $text);
|
||||
$text = preg_replace('/^Parcel is\s+/i', '', $text);
|
||||
$text = preg_replace('/^Courier has\s+/i', '', $text);
|
||||
|
||||
// Polskie znaki na ASCII
|
||||
$polish = ['ą','ć','ę','ł','ń','ó','ś','ź','ż','Ą','Ć','Ę','Ł','Ń','Ó','Ś','Ź','Ż'];
|
||||
@@ -391,6 +416,34 @@ final class DeliveryStatus
|
||||
{
|
||||
$lower = mb_strtolower($description, 'UTF-8');
|
||||
|
||||
if (str_contains($lower, 'delivered') || str_contains($lower, 'picked up by recipient')) {
|
||||
return self::DELIVERED;
|
||||
}
|
||||
if (str_contains($lower, 'returned')) {
|
||||
return self::RETURNED;
|
||||
}
|
||||
if (str_contains($lower, 'cancelled') || str_contains($lower, 'canceled')) {
|
||||
return self::CANCELLED;
|
||||
}
|
||||
if (str_contains($lower, 'out for delivery') || str_contains($lower, 'released for delivery')) {
|
||||
return self::OUT_FOR_DELIVERY;
|
||||
}
|
||||
if (str_contains($lower, 'awaiting pick-up') || str_contains($lower, 'awaiting pickup') || str_contains($lower, 'ready for pickup') || str_contains($lower, 'ready for pick-up')) {
|
||||
return self::READY_FOR_PICKUP;
|
||||
}
|
||||
if (str_contains($lower, 'courier') || str_contains($lower, 'warehouse') || str_contains($lower, 'branch') || str_contains($lower, 'in transit') || str_contains($lower, 'picked up')) {
|
||||
return self::IN_TRANSIT;
|
||||
}
|
||||
if (str_contains($lower, 'dispatched')) {
|
||||
return self::CONFIRMED;
|
||||
}
|
||||
if (str_contains($lower, 'prepared') || str_contains($lower, 'created')) {
|
||||
return self::CREATED;
|
||||
}
|
||||
if (str_contains($lower, 'damaged') || str_contains($lower, 'problem') || str_contains($lower, 'lost')) {
|
||||
return self::PROBLEM;
|
||||
}
|
||||
|
||||
if (str_contains($lower, 'doręczon') || str_contains($lower, 'dostarczono') || str_contains($lower, 'odebrana przez odbiorc')) {
|
||||
return self::DELIVERED;
|
||||
}
|
||||
|
||||
45
tests/Unit/DeliveryStatusTest.php
Normal file
45
tests/Unit/DeliveryStatusTest.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Modules\Shipments\DeliveryStatus;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class DeliveryStatusTest extends TestCase
|
||||
{
|
||||
public function testSlugifyAndNormalizeEnglishAwaitingPickup(): void
|
||||
{
|
||||
$slug = DeliveryStatus::slugifyAllegroDescription('Parcel is awaiting pick-up');
|
||||
$normalized = DeliveryStatus::normalize('allegro_edge', $slug);
|
||||
|
||||
$this->assertSame('awaiting_pick_up', $slug);
|
||||
$this->assertSame(DeliveryStatus::READY_FOR_PICKUP, $normalized);
|
||||
}
|
||||
|
||||
public function testSlugifyAndNormalizeEnglishDelivered(): void
|
||||
{
|
||||
$slug = DeliveryStatus::slugifyAllegroDescription('Parcel has been delivered');
|
||||
$normalized = DeliveryStatus::normalize('allegro_edge', $slug);
|
||||
|
||||
$this->assertSame('delivered', $slug);
|
||||
$this->assertSame(DeliveryStatus::DELIVERED, $normalized);
|
||||
}
|
||||
|
||||
public function testGuessStatusFromEnglishDescriptionFallback(): void
|
||||
{
|
||||
$normalized = DeliveryStatus::guessStatusFromDescription('Parcel has been released for delivery');
|
||||
|
||||
$this->assertSame(DeliveryStatus::OUT_FOR_DELIVERY, $normalized);
|
||||
}
|
||||
|
||||
public function testPolishMappingRegressionStillWorks(): void
|
||||
{
|
||||
$slug = DeliveryStatus::slugifyAllegroDescription('Przesylka zostala dostarczona');
|
||||
$normalized = DeliveryStatus::normalize('allegro_edge', $slug);
|
||||
|
||||
$this->assertSame('dostarczona', $slug);
|
||||
$this->assertSame(DeliveryStatus::DELIVERED, $normalized);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user