---
phase: 03-registration-form-settings
plan: 01
subsystem: ui
tags: [php, smarty, wp_setup, mf_parameters, admin, registration, pricing]

requires:
  - phase: 02-registration-dictionary-phrases
    provides: dictionary-backed phrase system for registration text

provides:
  - RegistrationFormSettings helper (centralized editable day/price values)
  - Admin "Ustawienia formularza" page with full CRUD for days and prices
  - Public registration form reading all values from settings (no hardcoded prices)
  - SQL + PHP deployment seed for new wp_setup variables

affects: [any future phase touching registration pricing or public form flow]

tech-stack:
  added: []
  patterns: [wp_setup as key-value store for scalar/list settings, mf_parameters for price rows]

key-files:
  created:
    - _rejestracja/core/class/RegistrationFormSettings.class.php
    - _rejestracja/Admin/controller/FormSettingsController.php
    - _rejestracja/Admin/template/partial/FormSettings/Index.tpl
    - _rejestracja/sql/2026-04-24-registration-form-settings.sql
    - _rejestracja/sql/apply-2026-04-24-registration-form-settings.php
  modified:
    - _rejestracja/Admin/controller/DictionaryController.php
    - _rejestracja/Admin/controller/SetupController.php
    - _rejestracja/controller/IndexController.php
    - _rejestracja/template/partial/Index/Index.tpl

key-decisions:
  - "Day labels stored as newline-separated text in wp_setup — avoids schema changes"
  - "One-day prices stored in wp_setup; full conf/surcharge prices kept in mf_parameters rows (IDs 1–5)"
  - "Gross price in JS computed as net * VAT multiplier — not hardcoded"

patterns-established:
  - "wp_setup used for new scalar/list settings with registration_form_ prefix"
  - "mf_parameters rows referenced by stable IDs 1–5 for existing calculator prices"

duration: ~2h
started: 2026-04-24T21:00:00Z
completed: 2026-04-24T23:04:32Z
---

# Phase 3 Plan 01: Registration Form Settings Summary

**Admin "Ustawienia formularza" page built with RegistrationFormSettings helper; public form and server-side pricing fully driven by configurable values from wp_setup and mf_parameters.**

## Performance

| Metric | Value |
|--------|-------|
| Duration | ~2h |
| Started | 2026-04-24T21:00:00Z |
| Completed | 2026-04-24T23:04:32Z |
| Tasks | 3 completed |
| Files modified | 9 |

## Acceptance Criteria Results

| Criterion | Status | Notes |
|-----------|--------|-------|
| AC-1: Admin Menu Entry | Pass | "Ustawienia formularza" added to Dictionary, Setup, and FormSettings controllers |
| AC-2: Editable Participation Days | Pass | Day labels from wp_setup drive Smarty loops in Index.tpl |
| AC-3: Editable Calculation Prices | Pass | JS calculatePrice and server-side saved price use configured values |
| AC-4: Deployment Seed | Pass | SQL + PHP runner inserts defaults only when missing (idempotent) |

## Accomplishments

- Created `RegistrationFormSettings` (211 lines) centralizing day lists, VAT multiplier, one-day prices, and mf_parameters price rows
- Built admin `FormSettingsController` + `Index.tpl` grouped by participation days, main prices, surcharges, one-day prices, VAT
- Replaced all hardcoded day labels and prices in public `Index.tpl` and `IndexController.php` with settings-driven values
- Added SQL seed + guarded PHP runner for production deployment

## Task Commits

| Task | Commit | Type | Description |
|------|--------|------|-------------|
| Task 1: Shared Settings Helper | `ed2f895` | feat | RegistrationFormSettings + SQL seed files |
| Task 2: Admin Form Settings Page | `ed2f895` | feat | FormSettingsController, Index.tpl, menu links |
| Task 3: Public Form Settings Use | `ed2f895` | feat | IndexController + Index.tpl using settings |

All three tasks landed in single commit `ed2f895` (committed together as part of manual apply session).

## Files Created/Modified

| File | Change | Purpose |
|------|--------|---------|
| `_rejestracja/core/class/RegistrationFormSettings.class.php` | Created (211 lines) | Centralized read/write helper for all editable form values |
| `_rejestracja/Admin/controller/FormSettingsController.php` | Created (61 lines) | GET/POST handler for the new admin settings page |
| `_rejestracja/Admin/template/partial/FormSettings/Index.tpl` | Created (72 lines) | Admin form UI grouped by value category |
| `_rejestracja/sql/2026-04-24-registration-form-settings.sql` | Created (22 lines) | Raw SQL seed for wp_setup variables |
| `_rejestracja/sql/apply-2026-04-24-registration-form-settings.php` | Created (145 lines) | Guarded PHP runner for production deployment |
| `_rejestracja/Admin/controller/DictionaryController.php` | Modified | Added "Ustawienia formularza" menu entry |
| `_rejestracja/Admin/controller/SetupController.php` | Modified | Added "Ustawienia formularza" menu entry |
| `_rejestracja/controller/IndexController.php` | Modified | Loads settings, passes to Smarty/JS, saves one-day price from settings |
| `_rejestracja/template/partial/Index/Index.tpl` | Modified | Smarty foreach loops for day options; JS prices from settings |

## Decisions Made

| Decision | Rationale | Impact |
|----------|-----------|--------|
| Day labels as newline-separated text in wp_setup | Avoids schema changes while supporting list values | Admin edits plain text area; split on render |
| Keep IDs 1–5 in mf_parameters for full conf/surcharge prices | Preserves compatibility with existing calculator/admin | No migration needed for prices already stored |
| Gross = net × VAT multiplier (computed) | VAT multiplier now configurable; no hardcoded gross values | Changing VAT multiplier updates JS preview automatically |

## Deviations from Plan

### Summary

| Type | Count | Impact |
|------|-------|--------|
| Auto-fixed | 0 | — |
| Scope additions | 1 | Minor — KSeF ID helper note added under NIP field |
| Deferred | 0 | — |

**Total impact:** Minimal — single cosmetic addition, no scope creep on core functionality.

### Scope Addition

**KSeF NIP helper note** (in-plan follow-up noted in APPLY.md)
- A small informational note was added under the public NIP field
- Did not change field names or form behavior
- Committed as part of Task 3

## Issues Encountered

None — plan executed cleanly.

## Next Phase Readiness

**Ready:**
- All four ACs satisfied; admin page fully functional
- SQL seed and PHP runner ready for production deployment (`_rejestracja/sql/apply-2026-04-24-registration-form-settings.php?run=20260424`)
- Public form completely decoupled from hardcoded day/price values
- Phase 3 plan 01 complete; plan 02 (codebase map) also complete

**Concerns:**
- Production must apply the seed runner before new wp_setup settings are visible/editable

**Blockers:**
- None (same production note applies as Phase 2)

---
*Phase: 03-registration-form-settings, Plan: 01*
*Completed: 2026-04-24*
