# RAMA AG — Phase 11 — SMGV PDF Export Center

Status: **DONE** (branch `develop/v1`; not yet activated on `:3400`).

## Implemented features
- `/smgv/exports`: Basisblatt, single month, selected months, annual overview, complete annual report (14 pages per employee), separate PDFs per person as a ZIP, structured Excel.
- Options: year, employee multi-select, months, include empty months, draft or closed data (closed-only refuses if a month is not closed). Also preview, progress indicator and download history.
- Layout follows the reference: A4 portrait Basisblatt and A4 landscape monthly and annual pages, German terms verbatim, yellow input cells, grey weekends, coloured Sundays and holidays, week totals, signature lines (never pre-filled), white print-friendly background. Visually checked against the reference renders.
- Every section must be exactly one page; an overflow is refused (`layout_overflow`), never shifted.
- The 14-page structure, B M×12 J order, portrait/landscape mix (2 + 26 MediaBoxes for 2 employees) and the draft watermark are verified by tests.
- Files go to the private disk only. Download needs an Administrator plus a matching SHA-256 check and is written to the audit log.
- Excel: names are written as explicit string cells (no formula injection).

## Modified / added files
`app/Services/Smgv/SmgvExportService.php`, `app/Support/Pdf/PdfMerger.php`, `app/Http/Controllers/SmgvExportController.php`, `app/Livewire/Smgv/Exports.php`, `resources/views/pdf/smgv/{styles,basisblatt,sheets}.blade.php`

## Database changes
`smgv_exports` (history: kind, options, status, private path, SHA-256, pages, bytes).

## Test results
Unit `tests/Unit/SmgvTimeEngineTest.php` (8), feature `tests/Feature/SmgvAccountingTest.php` (8), `tests/Feature/SmgvCenterTest.php` (6). Full regression: main 562 (464 passed, 98 skipped by design), memory 97 (96 + 1 skipped), upgrade 2: **0 failures**.

## Security considerations
All user-facing actions are Administrator-only: `admin` route middleware plus a fresh database check on every Livewire request (`SmgvContext::bootSmgvContext`) and a service-level `Actor::admin()`. Audit entries never contain personal values (no AHV, address or birth date). Isolation is unchanged: RAMA database and account only, no outbound mail or HTTP, and Quality was never touched.

## Technical decisions, assumptions and limitations
Dompdf cannot mix page orientations in one document, so pages are rendered per employee and orientation and merged with a minimal merger for our own Cpdf output; a merger object-ID collision found by the tests was fixed. Synchronous generation (no queue worker). The SMGV association logo is not reproduced and needs the owner's confirmation.

## Outstanding blockers
The GAV/SMGV rule confirmations listed in `RAMA_AG_MASTER_DEVELOPMENT_TRACKER.md` remain open. Until they are answered, values are drafts (watermarked, with banners).
