# Dienstplan and Schichtplan Template Migration

**Last Updated:** 2026-02-15

Migration log for replacing dedicated `templates_dienstplan.php` and `templates_schichtplan.php` with generator-driven `templates_template.php`.

## Summary

- **Before:** Monolithic PHP files (~1,900 lines each) using custom `generate_excel.php` (PhpSpreadsheet from scratch)
- **After:** Dynamic `templates_template.php?template_id=...` with pre-generated .xlsx from Excel template generator

## URLs (Preserved)

| URL | Template ID | Status |
|-----|-------------|--------|
| /vorlagen/dienstplan-excel-vorlage | dienstplan-excel-vorlage | Migrated |
| /vorlagen/schichtplan-excel-vorlage | schichtplan-excel-vorlage | Migrated |
| /vorlagen/dienstplan-excel | Redirects to dienstplan-excel-vorlage (301, QSA) |
| /vorlagen/dienstplan | Redirects to dienstplan-excel-vorlage (301, QSA) |
| /vorlagen/schichtplan-excel | Redirects to schichtplan-excel-vorlage (301, QSA) |
| /vorlagen/schichtplan | Redirects to schichtplan-excel-vorlage (301, QSA) |

## Implementation (2026-02-15)

1. **Template registry:** Added `dienstplan-excel-vorlage` and `schichtplan-excel-vorlage` with `meta_title` for SEO parity
2. **Excel generation:** Generated .xlsx via template-cli from dienstplan-basic.json and shift-planning-basic.json
3. **Download API:** Created `v2/api/download-template.php` to serve pre-generated .xlsx
4. **Routing:** Updated .htaccess to route both URLs to `templates_template.php?template_id=...`
5. **FAQs:** Created `template-faqs.json` with 10 Dienstplan and 6 Schichtplan FAQs
6. **Index data:** Removed hardcoded dedicatedPages; templates now come from registry
7. **Deprecation:** `templates_dienstplan.php` and `templates_schichtplan.php` removed (no longer routed)

## Files Changed

- `.htaccess` – routing
- `v2/systems/excel-template-generator/data/template-registry.json` – registry entries
- `v2/systems/excel-template-generator/data/template-faqs.json` – FAQ content (new)
- `v2/api/download-template.php` – download API (new)
- `v2/pages/templates_template.php` – download flow (try download-template.php first)
- `v2/config/template-page-config.php` – meta_title support
- `v2/data/templates_index_data.php` – removed dedicatedPages
- `v2/data/template-cta-messages.json` – schichtplan override (optional, uses category_defaults if not set)

## Post-Deployment Checklist

After deploying to production:

1. **Schema validation:** Run [Google Rich Results Test](https://search.google.com/test/rich-results) on:
   - https://www.ordio.com/vorlagen/dienstplan-excel-vorlage
   - https://www.ordio.com/vorlagen/schichtplan-excel-vorlage
2. **Download test:** Submit lead form on both pages, verify correct .xlsx downloads
3. **Redirect test:** Visit /vorlagen/dienstplan?utm_source=test and /vorlagen/schichtplan?utm_source=test, confirm 301 with QSA preserved

## Reference

- **Audit:** `docs/systems/templates/DEDICATED_TEMPLATES_AUDIT_REFERENCE.md`
- **Plan:** `.cursor/plans/replace_dienstplan_schichtplan_template_pages_*.plan.md`
