From 06df80e4db377969b16e26b8403dccfaf508d8a3 Mon Sep 17 00:00:00 2001 From: Lars Date: Mon, 26 Oct 2026 17:07:11 +0100 Subject: [PATCH] Mandantenabschluss: Marken, Vertragsdateien und Archive trennen --- app/Console/Commands/ImportSiteBrand.php | 58 ++++++ app/Documents/RentalContract.php | 3 +- .../Resources/Sites/Schemas/SiteForm.php | 6 +- app/Tenancy/TenantArchive.php | 60 +++++- app/Tenancy/TenantConfig.php | 1 + docs/BETRIEB.md | 2 +- docs/DEPLOYMENT.md | 2 +- docs/MANDANTEN-PLAN.md | 6 +- docs/STATUS.md | 12 +- docs/ZUSAMMENARBEIT.md | 1 + phpunit.xml | 3 - pipeline.toml | 2 +- .../ostsee/svg/icon-apartment.svg | 9 + .../image-worlds/ostsee/svg/icon-location.svg | 10 + .../image-worlds/ostsee/svg/icon-sea.svg | 5 + .../image-worlds/ostsee/svg/icon-terrace.svg | 11 ++ resources/image-worlds/ostsee/world.json | 5 + .../ostsee-licht/views/layouts/app.blade.php | 5 +- .../views/partials/brand.blade.php | 24 +-- .../views/partials/header.blade.php | 3 +- .../views/partials/image.blade.php | 2 +- resources/themes/seebad/README.md | 4 +- .../themes/seebad/views/layouts/app.blade.php | 5 +- .../seebad/views/partials/logo.blade.php | 11 +- .../seebad/views/partials/motif.blade.php | 33 +--- .../views/mail/arrival-information.blade.php | 2 +- .../views/mail/booking-confirmed.blade.php | 2 +- .../views/mail/booking-declined.blade.php | 2 +- .../views/mail/channel-conflict.blade.php | 2 +- .../views/mail/channel-sync-alert.blade.php | 2 +- resources/views/mail/channel-tasks.blade.php | 2 +- .../mail/marketing-consent-request.blade.php | 2 +- .../views/mail/new-reservation.blade.php | 2 +- resources/views/mail/new-review.blade.php | 2 +- resources/views/mail/offer-answered.blade.php | 2 +- resources/views/mail/offer-made.blade.php | 2 +- .../views/mail/payment-reminder.blade.php | 2 +- resources/views/mail/portal-mail.blade.php | 2 +- .../views/mail/reservation-expired.blade.php | 2 +- .../views/mail/reservation-received.blade.php | 2 +- resources/views/mail/review-request.blade.php | 2 +- .../views/vendor/mail/html/message.blade.php | 27 +++ .../views/vendor/mail/text/message.blade.php | 23 +++ tests/Feature/TenantBrandRenderingTest.php | 178 ++++++++++++++++++ tests/Feature/TenantFilesTest.php | 148 +++++++++++++++ 45 files changed, 592 insertions(+), 99 deletions(-) create mode 100644 app/Console/Commands/ImportSiteBrand.php create mode 100644 resources/image-worlds/ostsee/svg/icon-apartment.svg create mode 100644 resources/image-worlds/ostsee/svg/icon-location.svg create mode 100644 resources/image-worlds/ostsee/svg/icon-sea.svg create mode 100644 resources/image-worlds/ostsee/svg/icon-terrace.svg create mode 100644 resources/views/vendor/mail/html/message.blade.php create mode 100644 resources/views/vendor/mail/text/message.blade.php create mode 100644 tests/Feature/TenantBrandRenderingTest.php create mode 100644 tests/Feature/TenantFilesTest.php diff --git a/app/Console/Commands/ImportSiteBrand.php b/app/Console/Commands/ImportSiteBrand.php new file mode 100644 index 0000000..d75bc35 --- /dev/null +++ b/app/Console/Commands/ImportSiteBrand.php @@ -0,0 +1,58 @@ +with('tenant')->find($this->argument('site')); + + if ($site === null || $site->tenant?->slug !== 'stommer') { + $this->error('Nur die bestehende Stommer-Website darf diese Marke übernehmen.'); + + return self::FAILURE; + } + + $seebad = $site->theme === 'seebad'; + $sources = [ + Site::BRAND_LOGO => $seebad ? resource_path('themes/seebad/img/logo-bildmarke-720.webp') : public_path('brand/logo.svg'), + Site::BRAND_FAVICON => $seebad ? resource_path('themes/seebad/img/favicon.svg') : public_path('brand/favicon.svg'), + Site::BRAND_DOCUMENT_LOGO => public_path('brand/logo-600.png'), + ]; + + foreach ($sources as $collection => $path) { + if (! $site->hasMedia($collection) && ! is_file($path)) { + $this->error('Markenquelle fehlt: '.$path); + + return self::FAILURE; + } + } + + app(TenantContext::class)->run($site->tenant, function () use ($site, $sources): void { + foreach ($sources as $collection => $path) { + if ($site->hasMedia($collection)) { + $this->line($collection.': vorhandene Grafik beibehalten.'); + + continue; + } + + $site->addMedia($path)->preservingOriginal()->toMediaCollection($collection); + $this->info($collection.': übernommen.'); + } + }); + + return self::SUCCESS; + } +} diff --git a/app/Documents/RentalContract.php b/app/Documents/RentalContract.php index 7514f43..fc0c268 100644 --- a/app/Documents/RentalContract.php +++ b/app/Documents/RentalContract.php @@ -19,9 +19,10 @@ class RentalContract public function generate(Booking $booking, bool $draft = false): string { $booking->loadMissing(['guest', 'property']); - $path = $draft + $filename = $draft ? "contracts/Angebot-{$booking->reference}-v{$booking->offer_version}.pdf" : "contracts/Mietvertrag-{$booking->reference}.pdf"; + $path = "contracts/tenants/{$booking->tenant_id}/bookings/{$booking->id}/".basename($filename); // The logo is embedded as a file: the PDF is rendered on the server and must not depend on // fetching anything over the network. Each website has its own (A14). diff --git a/app/Filament/Resources/Sites/Schemas/SiteForm.php b/app/Filament/Resources/Sites/Schemas/SiteForm.php index 3159e7d..4144ebe 100644 --- a/app/Filament/Resources/Sites/Schemas/SiteForm.php +++ b/app/Filament/Resources/Sites/Schemas/SiteForm.php @@ -68,12 +68,12 @@ public static function configure(Schema $schema): Schema SpatieMediaLibraryFileUpload::make('logo') ->label('Logo') ->collection(Site::BRAND_LOGO) - ->acceptedFileTypes(['image/svg+xml', 'image/png', 'image/webp']) - ->helperText('SVG bevorzugt – bleibt in jeder Größe scharf.'), + ->acceptedFileTypes(['image/png', 'image/webp']) + ->helperText('PNG oder WebP. SVG-Dateien werden nur aus geprüften Quellen übernommen.'), SpatieMediaLibraryFileUpload::make('favicon') ->label('Favicon') ->collection(Site::BRAND_FAVICON) - ->acceptedFileTypes(['image/svg+xml', 'image/png', 'image/x-icon']) + ->acceptedFileTypes(['image/png', 'image/x-icon']) ->helperText('Das kleine Zeichen im Browser-Tab.'), SpatieMediaLibraryFileUpload::make('document_logo') ->label('Logo für E-Mail und Vertrag') diff --git a/app/Tenancy/TenantArchive.php b/app/Tenancy/TenantArchive.php index 36e42cf..89e401d 100644 --- a/app/Tenancy/TenantArchive.php +++ b/app/Tenancy/TenantArchive.php @@ -2,13 +2,16 @@ namespace App\Tenancy; +use App\Models\Booking; use App\Models\Photo; +use App\Models\Site; use App\Models\Tenant; use App\Models\User; use Illuminate\Support\Collection; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Schema; +use Illuminate\Support\Facades\Storage; use RuntimeException; use Spatie\MediaLibrary\MediaCollections\Models\Media; use ZipArchive; @@ -192,25 +195,39 @@ private function rowsOf(string $table, Tenant $tenant): array } /** - * Photos keep their files through Spatie's media library; they hang off the photo, not off the landlord, - * so they are collected through the photos of this landlord. + * Include media metadata, original files, conversions and every retained document version. */ private function addFiles(ZipArchive $zip, Tenant $tenant): void { - foreach ($this->mediaOf($tenant) as $media) { + $mediaItems = $this->mediaOf($tenant); + $zip->addFromString('daten/media.json', (string) $mediaItems->toJson(JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); + + foreach ($mediaItems as $media) { $path = $media->getPath(); if (is_string($path) && File::exists($path)) { - $zip->addFile($path, 'dateien/'.$media->id.'-'.$media->file_name); + $directory = dirname($path); + foreach (File::allFiles($directory) as $file) { + $relative = str_replace('\\', '/', substr($file->getPathname(), strlen($directory) + 1)); + $zip->addFile($file->getPathname(), 'dateien/'.$media->id.'-'.$relative); + } } } + + foreach ($this->documentPaths($tenant) as $path) { + $zip->addFile(Storage::disk('local')->path($path), 'dateien/local/'.$path); + } } private function deleteFiles(Tenant $tenant): void { + $documents = $this->documentPaths($tenant); + foreach ($this->mediaOf($tenant) as $media) { $media->delete(); // removes the stored file as well } + + Storage::disk('local')->delete($documents); } /** @@ -220,10 +237,43 @@ private function mediaOf(Tenant $tenant): Collection { return app(TenantContext::class)->run( $tenant, - fn () => Photo::query()->with('media')->get()->flatMap(fn (Photo $photo) => $photo->media), + fn () => Photo::query()->with('media')->get()->flatMap(fn (Photo $photo) => $photo->media) + ->concat(Site::query()->with('media')->get()->flatMap(fn (Site $site) => $site->media)), ); } + /** + * New documents have a tenant directory, including earlier offer versions. Existing installations + * also have flat paths: accept only those explicitly referenced by this tenant and never a shared file. + * + * @return list + */ + private function documentPaths(Tenant $tenant): array + { + $disk = Storage::disk('local'); + $paths = $disk->allFiles('contracts/tenants/'.$tenant->id); + $bookings = Booking::withoutGlobalScope('tenant')->where('tenant_id', $tenant->id)->get(['contract_path', 'offer_path']); + + foreach ($bookings as $booking) { + foreach ([$booking->contract_path, $booking->offer_path] as $path) { + if (! is_string($path) || ! preg_match('~\Acontracts/[^/\\\\]+\.pdf\z~', $path) || ! $disk->exists($path)) { + continue; + } + + $shared = Booking::withoutGlobalScope('tenant')->where('tenant_id', '!=', $tenant->id) + ->where(fn ($query) => $query->where('contract_path', $path)->orWhere('offer_path', $path))->exists(); + + if ($shared) { + throw new RuntimeException('Vertragsdatei ist mehreren Mandanten zugeordnet: '.$path); + } + + $paths[] = $path; + } + } + + return array_values(array_unique($paths)); + } + private function hasTenantColumn(string $table): bool { static $known = []; diff --git a/app/Tenancy/TenantConfig.php b/app/Tenancy/TenantConfig.php index 8c6c4d9..dd982b7 100644 --- a/app/Tenancy/TenantConfig.php +++ b/app/Tenancy/TenantConfig.php @@ -59,6 +59,7 @@ class TenantConfig * @var array */ private const OWNED = [ + 'app.name' => 'name', 'fewo.owner.name' => 'owner_name', 'fewo.owner.street' => 'owner_street', 'fewo.owner.city' => 'owner_city', diff --git a/docs/BETRIEB.md b/docs/BETRIEB.md index a42b3b7..71382bb 100644 --- a/docs/BETRIEB.md +++ b/docs/BETRIEB.md @@ -1,6 +1,6 @@ # Betrieb: Umgebungen, Zugänge, Einrichtung -Stand: 22.10.2026. Dieses Dokument beschreibt den **tatsächlichen Stand** der Installationen, damit jede neue Arbeitssitzung (Mensch oder KI) ohne Vorwissen weitermachen kann. Allgemeine Abläufe des Deployments stehen in [DEPLOYMENT.md](DEPLOYMENT.md), das fachliche Konzept in [KONZEPT.md](KONZEPT.md). +Stand: 26.10.2026. Aktuell bestätigt: Test unter **www.stommer.info** und `stommer.info`, SSH-Serverpfad **`test.fewo-stommer.de/`**. `dev.fewo-stommer.de/` existiert nicht. Produktion ist noch nicht eingerichtet: ein vorhandener leerer Ordner ist keine fertige Umgebung; eigene MariaDB, `.env`, persistente Daten und Domainzuordnung fehlen. Produktion bleibt in `pipeline.toml` gesperrt. Entwicklung und Testdeploy laufen über `develop` und PipelineManager; die manuellen Skripte unten sind Wartungswerkzeuge. Weitere Abläufe: [DEPLOYMENT.md](DEPLOYMENT.md). > **Geheimnisse stehen nie im Repository und nie im Chat.** Passwörter (Datenbank, E-Mail), `APP_KEY`, Tokens und private SSH-Schlüssel liegen nur in `shared/.env` auf dem Server bzw. im Vaultwarden von Lars. Hier ist nur dokumentiert, *wo* sie liegen. diff --git a/docs/DEPLOYMENT.md b/docs/DEPLOYMENT.md index 7198157..19b53ac 100644 --- a/docs/DEPLOYMENT.md +++ b/docs/DEPLOYMENT.md @@ -21,7 +21,7 @@ ## 1. Prinzip Auf dem Server werden nur **bash, tar und PHP-CLI** gebraucht – kein Composer, kein Node, kein Git, kein rsync. -Die Werkzeugumgebung wird im eigenen Repository `C:\dev\pipelinemanager` entwickelt und als lokales Image `pipeline-manager:0.1.0` auf dem Pi freigegeben. Das Image bleibt nach dem Entfernen eines Job-Containers erhalten. Der Ablauf folgt Tsumugus Docker-Aufträgen auf dem vorhandenen Host-Runner (`ubuntu-latest`), führt Tests jedoch am exakten Commit vor dem Upload aus. Keine PHP-/Node-Installation auf dem Host und kein Build auf dem Entwicklungsrechner für automatische Deployments. +Die Werkzeugumgebung wird im eigenen Repository `C:\dev\pipelinemanager` entwickelt und als lokales Image `pipeline-manager:0.1.1` auf dem Pi freigegeben. Das Image bleibt nach dem Entfernen eines Job-Containers erhalten. Der Ablauf folgt Tsumugus Docker-Aufträgen auf dem vorhandenen Host-Runner (`ubuntu-latest`), führt Tests jedoch am exakten Commit vor dem Upload aus. Keine PHP-/Node-Installation auf dem Host und kein Build auf dem Entwicklungsrechner für automatische Deployments. FeWo definiert nur seine prepare/test/finalize-Befehle, erforderlichen Dateien, Laravel-Hooks, persistenten Pfade und Ziele in `pipeline.toml`. Gemeinsame Paket-, Sicherungs-, Upload- und Rückfalllogik liegt im PipelineManager. Der bisherige manuelle Weg über `scripts/deploy.sh` bleibt als bestehender Wartungsweg erhalten, bis die neue Anbindung vollständig auf Test bestätigt ist. diff --git a/docs/MANDANTEN-PLAN.md b/docs/MANDANTEN-PLAN.md index 6df3ef6..a2f19be 100644 --- a/docs/MANDANTEN-PLAN.md +++ b/docs/MANDANTEN-PLAN.md @@ -1,6 +1,6 @@ # Mandantenfähigkeit – Umbauplan -Stand: 26.10.2026 · **Phasen 1 bis 5, Anwendungsseite von Phase 6 und Kern von Phase 7 umgesetzt und ausgeliefert.** Offen: der Theme-Teil von Phase 6 (§6 der Zusammenarbeit); optionale neue Wohnungsübersichts-/Suchbausteine sind nicht Teil des abgeschlossenen Phase-7-Kerns · Anforderungen: [MANDANTEN-ANFORDERUNGEN.md](MANDANTEN-ANFORDERUNGEN.md) · Design: [DESIGN-KONZEPT.md](DESIGN-KONZEPT.md) §7 · Übergabe: [STATUS.md](STATUS.md) Abschnitt 7 +Stand: 26.10.2026 · **Phasen 1–6 und Kern von Phase 7 umgesetzt.** Abschließender Testdeploy des Theme-/Dateiabschlusses ausstehend, siehe STATUS. Neue Wohnungsübersichts-/Suchbausteine und Subscription/Abrechnung gehören zur funktionalen Weiterentwicklung. Anforderungen: [MANDANTEN-ANFORDERUNGEN.md](MANDANTEN-ANFORDERUNGEN.md). Kein Portal, kein Marktplatz. Das Produkt bleibt die eigene Website eines Vermieters mit Vermietung. Wenige Mandanten, eine gemeinsame Datenbank, Laravel und Filament bleiben die Basis. Ein Python-Dienst ist nicht Teil dieses Umbaus. @@ -261,7 +261,7 @@ ### Phase 5 – Abnahme der Trennung und Kündigung · umgesetzt Tests: Nach der Löschung von A ist B vollständig da, inklusive Dateien und Buchungsnummern. Export von A enthält keine Zeile von B. -### Phase 6 – Marke und Bildwelt · Anwendungsseite umgesetzt (24.10.), Theme-Teil offen +### Phase 6 – Marke und Bildwelt · vollständig umgesetzt (26.10.) A14, A18, A19, A20, A22. Nicht zusammen mit Phase 1–5, und nicht solange der Branch `theme/` die Vorlagen noch nicht nachziehen kann. @@ -271,7 +271,7 @@ ### Phase 6 – Marke und Bildwelt · Anwendungsseite umgesetzt (24.10.), Theme- **Umgesetzt am 24.10. (ohne eine Theme-Datei zu ändern):** Bildwelten als Pakete in `resources/image-worlds//`, Registry, Auswahl an der Website, Überschreibung an der Wohnung; `$theme->motif()`/`hasMotif()`/`imageWorld()` als Platz-API; `image-worlds:check`. Marke als Medien der Website mit `$theme->brand()`, eingebettet im Mietvertrag. Die Ostsee-Grafiken wurden **kopiert**, nicht verschoben. -**Offen und ein Vertragsfall (ZUSAMMENARBEIT.md §6):** `ostsee-licht` von `partials/brand` auf Plätze umstellen, das Favicon in beiden Themes zuerst bei `$theme->brand('favicon')` erfragen, und Seebads `motifs/`-Ordner gegen die Bildwelt tauschen. `public/brand/` entfällt erst danach. +**Abschluss 26.10.:** Beide Themes nutzen Website-Marke und Bildwelt-Plätze; ohne Marke wird keine fremde Identität angezeigt. Alte Grafikdateien bleiben nur als Importquellen erhalten. `sites:import-stommer-brand ` übernimmt die vorhandene Stommer-Marke ohne Überschreiben. Auch HTML-/Textmails sind mandanteneigen. Verträge und Angebote haben getrennte Speicherpfade; Export/Löschung schließen Website-Medien und Vertragsdateien ein. Regressionstests: `TenantBrandRenderingTest`, `TenantFilesTest`. Der Vorlagenvertrag ist in ZUSAMMENARBEIT §6 eingetragen. ### Phase 7 – Mehrere Wohnungen je Website · Kern umgesetzt und ausgeliefert (26.10.) diff --git a/docs/STATUS.md b/docs/STATUS.md index d800400..15110a2 100644 --- a/docs/STATUS.md +++ b/docs/STATUS.md @@ -1,9 +1,17 @@ # Projektstand -Stand: 26.10.2026 · automatischer PipelineManager-Testdeploy erfolgreich (erster Nachweis: Lauf 4656, Commit `e7f79e4`) · 285 Feature-Tests grün +Stand: 26.10.2026 · Mandantenabschluss auf `feature/mandanten-abschluss` umgesetzt; abschließender Pipeline-Testdeploy noch ausstehend. Bisheriger Serverstand: `86374b1`. > Dieses Dokument ist der Einstieg für jede neue Arbeitssitzung. Bitte bei größeren Änderungen fortschreiben (Abschnitte „Fertig“, „Offen“, „Nächste Schritte“). +**Fachliche Funktionsdokumentation (26.10.2026):** [docs/architecture/README.md](architecture/README.md) führt durch die vorhandenen Funktionen nach fachlichen Ebenen und Bereichen. [Planung und offene Punkte](architecture/planung-und-offene-punkte.md) trennt geplante Erweiterungen, Optionen und noch nötige Inbetriebnahme. Abgeglichen mit dem lokalen Anwendungsstand; keine Auslieferung durch diese Dokumentationsarbeit. Neu festgehaltene offene Abweichung: Sonderangebote können im aktuellen Preisrechner die absolute Mindestnächtezahl umgehen (Details: [Preise und Angebote](architecture/preise-und-angebote.md)). + +**Mandantenabschluss (26.10.):** Beide Themes nutzen Website-Logo/Favicon und die gewählte Bildwelt, auch für Bildplatzhalter. HTML- und Textmails tragen den eigenen Namen; HTML bettet das Dokumentlogo ein. Vertragsdateien liegen getrennt unter `contracts/tenants//bookings//`; Export/Löschung berücksichtigen Website-Medien, Bildkonvertierungen und Dokumentversionen. Bestehende flache Vertragsdateien bleiben lesbar; mehrdeutig von mehreren Mandanten referenzierte Altdateien stoppen die Löschung. Marken-Uploads erlauben PNG/WebP bzw. PNG/ICO; SVG wird ausschließlich aus geprüften Repository-Quellen importiert. `sites:import-stommer-brand ` übernimmt die bisherige Marke nur für Stommer, wiederholbar und ohne vorhandene Uploads zu ersetzen. + +**Abnahme lokal:** 303 Feature-Tests / 1409 Assertions grün (18 zusätzliche Fälle), beide Themes mit `themes:check` geprüft, `image-worlds:check` erfolgreich, Vite-Build und Pint erfolgreich. Die leere Unit-Suite aus `phpunit.xml` entfernt; der normale PHPUnit-Aufruf funktioniert damit wieder. Keine neue Migration, Abhängigkeit oder lokale Datenbank. Die bestehenden Nutzerdateien unter `styles/` und ein parallel entstandener Ordner `docs/architecture/` bleiben unberührt. + +**Verbindliche Umgebung:** Test unter **https://www.stommer.info** (auch `stommer.info`), Serverpfad **`test.fewo-stommer.de/`**, nur per SSH verwaltet. `dev.fewo-stommer.de/` existiert nicht (SSH-Prüfung und Bestätigung Lars 26.10.). Der Produktionsordner ist höchstens eine leere Vorbereitung; Produktion bleibt gesperrt. Vor deren Aufbau ist eine eigene MariaDB-Datenbank zusätzlich zur Testdatenbank einzurichten, keine Datenbank pro Mandant. Weiterhin bestehender PipelineManager-Ablauf: `develop` → Staging; kein zusätzlicher MariaDB-Testjob und keine neue lokale Umgebung. + ## 1. Fertig (umgesetzt, getestet, auf stommer.info) **Vermietung** @@ -167,7 +175,7 @@ ### Phase 7: Kern umgesetzt und ausgeliefert ### Ebenfalls offen -- **Theme-Teil von Phase 6:** Favicon und `partials/brand` in beiden Themes auf `$theme->brand()` bzw. Plätze umstellen, Seebads `motifs/`-Ordner gegen die Bildwelt tauschen. Steht als Aufgabe in ZUSAMMENARBEIT.md §6 und gehört der Theme-Sitzung. +- **Theme-Teil von Phase 6:** im Mandantenabschluss umgesetzt; bestehende Stommer-Marke nach Auslieferung einmal mit `sites:import-stommer-brand ` übernehmen. Abnahme und Deploymentnachweis stehen am Dokumentanfang. - **Subscription und Abrechnung** – nicht Teil des Mandanten-Plans (§9 schließt sie aus). `service_usages` liegt als Grundlage bereit und zählt nichts. - **Zertifikatsfrage bei Strato:** Ob eine Domain eines Mandanten aufgeschaltet werden kann **und** ein Zertifikat bekommt. Eine Subdomain bekommt keines. Davon hängt ab, ob „Mandant bringt seine Domain mit“ auf diesem Hosting trägt – das ist keine Code-Frage. diff --git a/docs/ZUSAMMENARBEIT.md b/docs/ZUSAMMENARBEIT.md index 8420503..e305a1c 100644 --- a/docs/ZUSAMMENARBEIT.md +++ b/docs/ZUSAMMENARBEIT.md @@ -84,6 +84,7 @@ ## 6. Änderungsprotokoll Vorlagen-Vertrag | Datum | Änderung | Betrifft | |---|---|---| +| 26.10.2026 | **Mandantenabschluss:** Beide Themes beziehen Logo und Favicon ausschließlich aus der Website-Marke; ohne Marke bleibt die Darstellung neutral. Dekoration und Bild-Platzhalter kommen aus Bildwelt-Plätzen. `partials/brand` bleibt als kompatible Platz-Zuordnung erhalten; Seebads `partials/motif` nutzt die Bildwelt-API. Bestehende Stommer-Marken werden vor Aktivierung ausdrücklich für diese Website importiert. | layouts/app, partials/brand, partials/logo, partials/motif, partials/image, header | | 22.10.2026 | `theme-base.css` (Schriften, Token-Mapping, Basis-Klassen) von `theme.css` getrennt – Child-Themes importieren `theme-base.css` | theme.css | | 22.10.2026 | Markengrafiken: `@include('theme::partials.brand', ['name' => 'mark', 'class' => '…'])` (mark, logo, wave-divider, icon-apartment/-sea/-terrace/-location); Farben über `--brand-navy/-teal/-wave/-sun` (navy = Textfarbe) | header, footer, facts, location, image | | 22.10.2026 | `hero`: `$featuredOffer` (wichtigstes hervorgehobenes Angebot oder null) | sections/hero | diff --git a/phpunit.xml b/phpunit.xml index e7f0a48..5b09ead 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -5,9 +5,6 @@ colors="true" > - - tests/Unit - tests/Feature diff --git a/pipeline.toml b/pipeline.toml index eb8fa87..1a44a3c 100644 --- a/pipeline.toml +++ b/pipeline.toml @@ -61,7 +61,7 @@ storage = "storage" [targets.staging] branch = "develop" path = "test.fewo-stommer.de" -url = "https://stommer.info" +url = "https://www.stommer.info" php = "/opt/RZphp84/bin/php-cli" enabled = true diff --git a/resources/image-worlds/ostsee/svg/icon-apartment.svg b/resources/image-worlds/ostsee/svg/icon-apartment.svg new file mode 100644 index 0000000..7bb50f8 --- /dev/null +++ b/resources/image-worlds/ostsee/svg/icon-apartment.svg @@ -0,0 +1,9 @@ + + Ferienwohnung + + + + + + + diff --git a/resources/image-worlds/ostsee/svg/icon-location.svg b/resources/image-worlds/ostsee/svg/icon-location.svg new file mode 100644 index 0000000..c6a1522 --- /dev/null +++ b/resources/image-worlds/ostsee/svg/icon-location.svg @@ -0,0 +1,10 @@ + + Lage + + + + + + + + diff --git a/resources/image-worlds/ostsee/svg/icon-sea.svg b/resources/image-worlds/ostsee/svg/icon-sea.svg new file mode 100644 index 0000000..2ab8794 --- /dev/null +++ b/resources/image-worlds/ostsee/svg/icon-sea.svg @@ -0,0 +1,5 @@ + + Ostsee + + + diff --git a/resources/image-worlds/ostsee/svg/icon-terrace.svg b/resources/image-worlds/ostsee/svg/icon-terrace.svg new file mode 100644 index 0000000..4e6125f --- /dev/null +++ b/resources/image-worlds/ostsee/svg/icon-terrace.svg @@ -0,0 +1,11 @@ + + Terrasse und Strand + + + + + + + + + diff --git a/resources/image-worlds/ostsee/world.json b/resources/image-worlds/ostsee/world.json index 6729300..ed6dab9 100644 --- a/resources/image-worlds/ostsee/world.json +++ b/resources/image-worlds/ostsee/world.json @@ -2,6 +2,11 @@ "name": "Ostsee", "description": "Bänder, Vignetten und Ornamente der Ostseeküste: Sonne, Seebrücke, Möwen, Molli.", "slots": { + "placeholder": "vignette-strand", + "icon-apartment": "icon-apartment", + "icon-sea": "icon-sea", + "icon-terrace": "icon-terrace", + "icon-location": "icon-location", "divider": "band-sonne", "closing": "band-seebruecke", "crest": "gaube", diff --git a/resources/themes/ostsee-licht/views/layouts/app.blade.php b/resources/themes/ostsee-licht/views/layouts/app.blade.php index a54d041..58df278 100644 --- a/resources/themes/ostsee-licht/views/layouts/app.blade.php +++ b/resources/themes/ostsee-licht/views/layouts/app.blade.php @@ -20,8 +20,9 @@ @endisset - - + @if ($favicon = $theme->brand('favicon')) + + @endif @if ($theme->isPreview || ! app()->isProduction()) @endif diff --git a/resources/themes/ostsee-licht/views/partials/brand.blade.php b/resources/themes/ostsee-licht/views/partials/brand.blade.php index 14c1e9f..171858a 100644 --- a/resources/themes/ostsee-licht/views/partials/brand.blade.php +++ b/resources/themes/ostsee-licht/views/partials/brand.blade.php @@ -1,16 +1,8 @@ -{{-- - Inline brand graphic from public/brand/.svg (mark, logo, wave-divider, icon-apartment, icon-sea, - icon-terrace, icon-location). Inline, so the colours follow the CSS variables --brand-navy/-teal/-wave/-sun - (theme-base.css maps navy to the text colour, so it stays visible in dark appearances). - Variables: $name, $class (optional), $label (optional; without it the graphic is decorative). ---}} -@php - static $brandSvgs = []; - $brandSvgs[$name] ??= is_file(public_path("brand/{$name}.svg")) ? file_get_contents(public_path("brand/{$name}.svg")) : ''; - $brandUid = 'b'.\Illuminate\Support\Str::lower(\Illuminate\Support\Str::random(6)); - $brandSvg = preg_replace(['/\s(role|aria-label)="[^"]*"/', '/.*?<\/title>/s'], '', $brandSvgs[$name]); - $brandSvg = preg_replace(['/id="([^"]+)"/', '/url\(#([^)]+)\)/'], ['id="$1-'.$brandUid.'"', 'url(#$1-'.$brandUid.')'], $brandSvg); - $brandAttributes = 'class="'.e($class ?? '').'" '.(isset($label) ? 'role="img" aria-label="'.e($label).'"' : 'aria-hidden="true" focusable="false"'); - $brandSvg = preg_replace('/<svg\s/', '<svg '.$brandAttributes.' ', $brandSvg, 1); -@endphp -{!! $brandSvg !!} +{{-- Identity comes from the website, decoration from picture-world slots. --}} +@if (in_array($name, ['mark', 'logo'], true)) + @if ($logo = $theme->brand('logo')) + <img src="{{ $logo }}" alt="{{ $label ?? '' }}" class="{{ $class ?? '' }}" decoding="async"> + @endif +@else + {!! $theme->motif($name === 'wave-divider' ? 'divider' : $name, $class ?? null, $label ?? null) !!} +@endif diff --git a/resources/themes/ostsee-licht/views/partials/header.blade.php b/resources/themes/ostsee-licht/views/partials/header.blade.php index f5e264b..019450c 100644 --- a/resources/themes/ostsee-licht/views/partials/header.blade.php +++ b/resources/themes/ostsee-licht/views/partials/header.blade.php @@ -3,8 +3,7 @@ <a href="{{ route('home') }}" class="flex items-center gap-3 leading-tight" aria-label="{{ $theme->site->name }} – Startseite"> @include('theme::partials.brand', ['name' => 'mark', 'class' => 'h-11 w-auto shrink-0 sm:h-12']) <span class="flex flex-col"> - <span class="font-display text-[1.875rem] font-semibold tracking-wide">{{ str($theme->site->name)->afterLast(' ') }}</span> - <span class="text-[11px] tracking-[0.24em] text-muted uppercase">Ferienwohnung · Kühlungsborn</span> + <span class="font-display text-[1.875rem] font-semibold tracking-wide">{{ $theme->site->name }}</span> </span> </a> diff --git a/resources/themes/ostsee-licht/views/partials/image.blade.php b/resources/themes/ostsee-licht/views/partials/image.blade.php index 02e8357..f1ccbf1 100644 --- a/resources/themes/ostsee-licht/views/partials/image.blade.php +++ b/resources/themes/ostsee-licht/views/partials/image.blade.php @@ -11,6 +11,6 @@ class="{{ $class ?? '' }}"> @else <div class="{{ $class ?? '' }} flex items-center justify-center bg-surface" role="img" aria-label="Bild folgt"> - <img src="{{ asset('brand/coastal-illustration-1200.webp') }}" alt="" loading="lazy" decoding="async" class="h-full max-h-full w-full object-contain p-6 opacity-90"> + {!! $theme->motif('placeholder', 'h-full max-h-full w-full p-6 opacity-90') !!} </div> @endif diff --git a/resources/themes/seebad/README.md b/resources/themes/seebad/README.md index 6db7237..836ef5d 100644 --- a/resources/themes/seebad/README.md +++ b/resources/themes/seebad/README.md @@ -22,8 +22,8 @@ ## Gestaltung ## Bildwelt -Grafiken liegen in `motifs/` (Quelle: `styles/satz3/svg/`) und werden nur über Plätze eingebunden: -`@include('theme::partials.motif', ['slot' => 'divider', 'class' => '…'])`. Plätze: `divider`, `closing`, `crest` (Rundbogengaube), `railing` (Balkongeländer), `bracket` (Kopfband), `gulls`, `vignette.beach|pier|train|bike|forest`. Die Bildmarke des Logos kommt als Bild über `partials/logo` (Illustration – als Inline-SVG zu groß). Die Zuordnung Platz → Datei steht nur in `partials/motif.blade.php`, damit ein späteres Bildwelt-System (MANDANTEN-ANFORDERUNGEN A18/A19) sie ersetzen kann. Farben über `--brand-navy` (= Textfarbe), `--brand-paper` (= Flächen), `--brand-teal`, `--brand-wave`, `--brand-sun`, `--brand-reed`, `--brand-brick`. +Die Website waehlt ihre Bildwelt; eine Wohnung kann sie ueberschreiben. `partials/motif` delegiert an `$theme->motif()`. Dekoration kommt ausschliesslich aus `resources/image-worlds/<key>/`. Logo und Favicon kommen aus der Website-Marke. Die bisherigen Dateien in `img/` und `motifs/` bleiben Quellen; die Vorlagen verwenden sie nicht mehr direkt. + ## Eigene Vorlagen diff --git a/resources/themes/seebad/views/layouts/app.blade.php b/resources/themes/seebad/views/layouts/app.blade.php index 7fc412a..8898b07 100644 --- a/resources/themes/seebad/views/layouts/app.blade.php +++ b/resources/themes/seebad/views/layouts/app.blade.php @@ -20,8 +20,9 @@ <meta property="og:image" content="{{ $ogImage }}"> @endisset <link rel="canonical" href="{{ url()->current() }}"> - <link rel="icon" href="{{ Vite::asset('resources/themes/seebad/img/favicon.svg') }}" type="image/svg+xml"> - <link rel="apple-touch-icon" href="{{ Vite::asset('resources/themes/seebad/img/apple-touch-icon.png') }}"> + @if ($favicon = $theme->brand('favicon')) + <link rel="icon" href="{{ $favicon }}"> + @endif @if ($theme->isPreview || ! app()->isProduction()) <meta name="robots" content="noindex"> @endif diff --git a/resources/themes/seebad/views/partials/logo.blade.php b/resources/themes/seebad/views/partials/logo.blade.php index 0689a90..19f6999 100644 --- a/resources/themes/seebad/views/partials/logo.blade.php +++ b/resources/themes/seebad/views/partials/logo.blade.php @@ -1,7 +1,4 @@ -{{-- - Picture mark of the logo (styles/satz4: traced master SVG, WebP renditions for the web). - Variables: $class, $sizes (default: 10rem), $label (optional; without it the mark is decorative next to the name). ---}} -<img src="{{ Vite::asset('resources/themes/seebad/img/logo-bildmarke-360.webp') }}" - srcset="{{ Vite::asset('resources/themes/seebad/img/logo-bildmarke-360.webp') }} 360w, {{ Vite::asset('resources/themes/seebad/img/logo-bildmarke-720.webp') }} 720w, {{ Vite::asset('resources/themes/seebad/img/logo-bildmarke-1440.webp') }} 1440w" - sizes="{{ $sizes ?? '10rem' }}" width="360" height="154" alt="{{ $label ?? '' }}" decoding="async" class="{{ $class ?? '' }}"> +{{-- A website without a logo never inherits another landlord's identity. --}} +@if ($logo = $theme->brand('logo')) + <img src="{{ $logo }}" alt="{{ $label ?? '' }}" decoding="async" class="{{ $class ?? '' }}"> +@endif diff --git a/resources/themes/seebad/views/partials/motif.blade.php b/resources/themes/seebad/views/partials/motif.blade.php index e98b88a..3343bbd 100644 --- a/resources/themes/seebad/views/partials/motif.blade.php +++ b/resources/themes/seebad/views/partials/motif.blade.php @@ -1,31 +1,2 @@ -{{-- - Inline graphic of the theme's picture world ("Bildwelt", docs/DESIGN-KONZEPT.md §7, MANDANTEN-ANFORDERUNGEN A18/A19). - Templates ask for a slot, never for a file, so a later picture-world system can replace the mapping below. - Variables: $slot (divider, closing, crest, railing, bracket, gulls, vignette.beach|pier|train|bike|forest), $class (optional), - $label (optional; without it the graphic is decorative). ---}} -@php - $motifFiles = [ - 'divider' => 'band-sonne', - 'closing' => 'band-seebruecke', - 'crest' => 'gaube', - 'railing' => 'gelaender', - 'bracket' => 'kopfband', - 'gulls' => 'moewen', - 'vignette.beach' => 'vignette-strand', - 'vignette.pier' => 'vignette-seebruecke', - 'vignette.train' => 'vignette-molli', - 'vignette.bike' => 'vignette-rad', - 'vignette.forest' => 'vignette-wald', - ]; - static $motifSvgs = []; - $motifFile = $motifFiles[$slot] ?? null; - $motifPath = $motifFile ? resource_path("themes/seebad/motifs/{$motifFile}.svg") : null; - $motifSvgs[$slot] ??= $motifPath && is_file($motifPath) ? file_get_contents($motifPath) : ''; - $motifUid = 'm'.\Illuminate\Support\Str::lower(\Illuminate\Support\Str::random(6)); - $motifSvg = preg_replace(['/\s(role|aria-label|aria-hidden)="[^"]*"/', '/<title>.*?<\/title>/s'], '', $motifSvgs[$slot]); - $motifSvg = preg_replace(['/id="([^"]+)"/', '/url\(#([^)]+)\)/'], ['id="$1-'.$motifUid.'"', 'url(#$1-'.$motifUid.')'], $motifSvg); - $motifAttributes = 'class="'.e($class ?? '').'" '.(isset($label) ? 'role="img" aria-label="'.e($label).'"' : 'aria-hidden="true" focusable="false"'); - $motifSvg = preg_replace('/<svg\s/', '<svg '.$motifAttributes.' ', $motifSvg, 1); -@endphp -{!! $motifSvg !!} +{{-- Decoration follows the website, overridden by the current apartment. --}} +{!! $theme->motif($slot, $class ?? null, $label ?? null) !!} diff --git a/resources/views/mail/arrival-information.blade.php b/resources/views/mail/arrival-information.blade.php index f365908..3e8a2d0 100644 --- a/resources/views/mail/arrival-information.blade.php +++ b/resources/views/mail/arrival-information.blade.php @@ -1,4 +1,4 @@ -<x-mail::message> +<x-mail::message :site="$booking->website()" :message="$message ?? null"> # Bald sind Sie an der Ostsee! Guten Tag {{ $booking->guest->full_name }}, diff --git a/resources/views/mail/booking-confirmed.blade.php b/resources/views/mail/booking-confirmed.blade.php index 02ba611..757de2c 100644 --- a/resources/views/mail/booking-confirmed.blade.php +++ b/resources/views/mail/booking-confirmed.blade.php @@ -1,4 +1,4 @@ -<x-mail::message> +<x-mail::message :site="$booking->website()" :message="$message ?? null"> # Ihre Buchung ist bestätigt! Guten Tag {{ $booking->guest->full_name }}, diff --git a/resources/views/mail/booking-declined.blade.php b/resources/views/mail/booking-declined.blade.php index 795986d..55e090f 100644 --- a/resources/views/mail/booking-declined.blade.php +++ b/resources/views/mail/booking-declined.blade.php @@ -1,4 +1,4 @@ -<x-mail::message> +<x-mail::message :site="$booking->website()" :message="$message ?? null"> # Ihre Anfrage {{ $booking->reference }} Guten Tag {{ $booking->guest->full_name }}, diff --git a/resources/views/mail/channel-conflict.blade.php b/resources/views/mail/channel-conflict.blade.php index 4eab79b..d5865f2 100644 --- a/resources/views/mail/channel-conflict.blade.php +++ b/resources/views/mail/channel-conflict.blade.php @@ -1,4 +1,4 @@ -<x-mail::message> +<x-mail::message :site="$channel->property?->site" :message="$message ?? null"> # Mögliche Doppelbuchung Beim Kalender-Abgleich mit **{{ $channel->name }}** wurde eine neue Belegung gefunden, die sich mit einer bestehenden Belegung überschneidet: diff --git a/resources/views/mail/channel-sync-alert.blade.php b/resources/views/mail/channel-sync-alert.blade.php index c30775b..c19460c 100644 --- a/resources/views/mail/channel-sync-alert.blade.php +++ b/resources/views/mail/channel-sync-alert.blade.php @@ -1,4 +1,4 @@ -<x-mail::message> +<x-mail::message :site="$channel->property?->site" :message="$message ?? null"> # Kalender-Abgleich gestört Der Kalender von **{{ $channel->name }}** konnte seit diff --git a/resources/views/mail/channel-tasks.blade.php b/resources/views/mail/channel-tasks.blade.php index d360ce5..111204e 100644 --- a/resources/views/mail/channel-tasks.blade.php +++ b/resources/views/mail/channel-tasks.blade.php @@ -1,4 +1,4 @@ -<x-mail::message> +<x-mail::message :site="($tasks[0] ?? null)?->channel?->property?->site" :message="$message ?? null"> # {{ $reminder ? 'Noch offen: ' : '' }}Bitte Portal-Kalender anpassen @if ($reminder) diff --git a/resources/views/mail/marketing-consent-request.blade.php b/resources/views/mail/marketing-consent-request.blade.php index f1d86fd..a6a7ccd 100644 --- a/resources/views/mail/marketing-consent-request.blade.php +++ b/resources/views/mail/marketing-consent-request.blade.php @@ -1,4 +1,4 @@ -<x-mail::message> +<x-mail::message :site="$guest->website()" :message="$message ?? null"> # Bitte bestätigen Sie Ihre Anmeldung Guten Tag {{ $guest->full_name }}, diff --git a/resources/views/mail/new-reservation.blade.php b/resources/views/mail/new-reservation.blade.php index b786c44..8c97a2e 100644 --- a/resources/views/mail/new-reservation.blade.php +++ b/resources/views/mail/new-reservation.blade.php @@ -1,4 +1,4 @@ -<x-mail::message> +<x-mail::message :site="$booking->website()" :message="$message ?? null"> # Neue Anfrage {{ $booking->reference }} **{{ $booking->guest->full_name }}** möchte die **{{ $booking->property->name }}** buchen. diff --git a/resources/views/mail/new-review.blade.php b/resources/views/mail/new-review.blade.php index 48accf8..8df5142 100644 --- a/resources/views/mail/new-review.blade.php +++ b/resources/views/mail/new-review.blade.php @@ -1,4 +1,4 @@ -<x-mail::message> +<x-mail::message :site="$review->property?->site" :message="$message ?? null"> # Neue Bewertung **{{ $review->display_name }}** hat {{ $review->rating }} von 5 Sternen vergeben. diff --git a/resources/views/mail/offer-answered.blade.php b/resources/views/mail/offer-answered.blade.php index 89d6f1b..b6788ca 100644 --- a/resources/views/mail/offer-answered.blade.php +++ b/resources/views/mail/offer-answered.blade.php @@ -1,4 +1,4 @@ -<x-mail::message> +<x-mail::message :site="$booking->website()" :message="$message ?? null"> @if ($accepted) # Angebot angenommen diff --git a/resources/views/mail/offer-made.blade.php b/resources/views/mail/offer-made.blade.php index 05db821..fe63f43 100644 --- a/resources/views/mail/offer-made.blade.php +++ b/resources/views/mail/offer-made.blade.php @@ -1,4 +1,4 @@ -<x-mail::message> +<x-mail::message :site="$booking->website()" :message="$message ?? null"> # Ihr Angebot für die {{ $booking->property->name }} Guten Tag {{ $booking->guest->full_name }}, diff --git a/resources/views/mail/payment-reminder.blade.php b/resources/views/mail/payment-reminder.blade.php index 99cddb5..6df0d4d 100644 --- a/resources/views/mail/payment-reminder.blade.php +++ b/resources/views/mail/payment-reminder.blade.php @@ -1,4 +1,4 @@ -<x-mail::message> +<x-mail::message :site="$booking->website()" :message="$message ?? null"> @if ($kind === \App\Mail\PaymentReminder::BALANCE_REQUEST) # Ihre Restzahlung diff --git a/resources/views/mail/portal-mail.blade.php b/resources/views/mail/portal-mail.blade.php index 2c7acb8..d6f4c63 100644 --- a/resources/views/mail/portal-mail.blade.php +++ b/resources/views/mail/portal-mail.blade.php @@ -1,4 +1,4 @@ -<x-mail::message> +<x-mail::message :site="$portalEmail->channel?->property?->site" :message="$message ?? null"> # {{ $portalEmail->status->getLabel() }} Zur E-Mail von **{{ $portalEmail->channel->name }}** („{{ $portalEmail->subject }}“, eingegangen {{ $portalEmail->received_at->format('d.m.Y, H:i') }} Uhr): diff --git a/resources/views/mail/reservation-expired.blade.php b/resources/views/mail/reservation-expired.blade.php index 8ae5a1b..d034781 100644 --- a/resources/views/mail/reservation-expired.blade.php +++ b/resources/views/mail/reservation-expired.blade.php @@ -1,4 +1,4 @@ -<x-mail::message> +<x-mail::message :site="$booking->website()" :message="$message ?? null"> # {{ $booking->offer_version > 0 ? 'Angebot abgelaufen' : 'Vormerkung abgelaufen' }} Die Anfrage **{{ $booking->reference }}** von {{ $booking->guest->full_name }} ({{ $booking->arrival->format('d.m.Y') }} – {{ $booking->departure->format('d.m.Y') }}) {{ $booking->offer_version > 0 ? 'wurde vom Gast nicht rechtzeitig angenommen' : 'wurde nicht rechtzeitig beantwortet' }}. Der Zeitraum ist im Kalender wieder frei. diff --git a/resources/views/mail/reservation-received.blade.php b/resources/views/mail/reservation-received.blade.php index 5ff8e83..6525d8b 100644 --- a/resources/views/mail/reservation-received.blade.php +++ b/resources/views/mail/reservation-received.blade.php @@ -1,4 +1,4 @@ -<x-mail::message> +<x-mail::message :site="$booking->website()" :message="$message ?? null"> # Vielen Dank für Ihre Anfrage! Guten Tag {{ $booking->guest->full_name }}, diff --git a/resources/views/mail/review-request.blade.php b/resources/views/mail/review-request.blade.php index 346c2e3..996542b 100644 --- a/resources/views/mail/review-request.blade.php +++ b/resources/views/mail/review-request.blade.php @@ -1,4 +1,4 @@ -<x-mail::message> +<x-mail::message :site="$booking->website()" :message="$message ?? null"> # Wie war Ihr Aufenthalt? Guten Tag {{ $booking->guest->full_name }}, diff --git a/resources/views/vendor/mail/html/message.blade.php b/resources/views/vendor/mail/html/message.blade.php new file mode 100644 index 0000000..ce02d49 --- /dev/null +++ b/resources/views/vendor/mail/html/message.blade.php @@ -0,0 +1,27 @@ +@props(['site' => null, 'message' => null]) +@php + $name = $site?->name ?: (config('fewo.owner.name') ?: 'Vermietung'); + $origin = $site?->origin() ?: config('app.url'); + $logo = $site?->brandPath(\App\Models\Site::BRAND_DOCUMENT_LOGO); +@endphp +<x-mail::layout> +<x-slot:header> +<x-mail::header :url="$origin">{{ $name }}</x-mail::header> +</x-slot:header> + +@if ($logo && $message instanceof \Illuminate\Mail\Message) +<p><img src="{{ $message->embed($logo) }}" alt="{{ $name }}" style="max-width: 240px; max-height: 100px;"></p> +@endif + +{!! $slot !!} + +@isset($subcopy) +<x-slot:subcopy> +<x-mail::subcopy>{!! $subcopy !!}</x-mail::subcopy> +</x-slot:subcopy> +@endisset + +<x-slot:footer> +<x-mail::footer>© {{ date('Y') }} {{ $name }}. Alle Rechte vorbehalten.</x-mail::footer> +</x-slot:footer> +</x-mail::layout> diff --git a/resources/views/vendor/mail/text/message.blade.php b/resources/views/vendor/mail/text/message.blade.php new file mode 100644 index 0000000..5a1de50 --- /dev/null +++ b/resources/views/vendor/mail/text/message.blade.php @@ -0,0 +1,23 @@ +@props(['site' => null, 'message' => null]) +@php + $name = $site?->name ?: (config('fewo.owner.name') ?: 'Vermietung'); + $origin = $site?->origin() ?: config('app.url'); +@endphp +<x-mail::layout> +<x-slot:header> +<x-mail::header :url="$origin">{{ $name }}</x-mail::header> +</x-slot:header> + + +{{ $slot }} + +@isset($subcopy) +<x-slot:subcopy> +<x-mail::subcopy>{{ $subcopy }}</x-mail::subcopy> +</x-slot:subcopy> +@endisset + +<x-slot:footer> +<x-mail::footer>© {{ date('Y') }} {{ $name }}. Alle Rechte vorbehalten.</x-mail::footer> +</x-slot:footer> +</x-mail::layout> diff --git a/tests/Feature/TenantBrandRenderingTest.php b/tests/Feature/TenantBrandRenderingTest.php new file mode 100644 index 0000000..66ebed8 --- /dev/null +++ b/tests/Feature/TenantBrandRenderingTest.php @@ -0,0 +1,178 @@ +<?php + +namespace Tests\Feature; + +use App\Enums\UserRole; +use App\Filament\Resources\Sites\Pages\EditSite; +use App\ImageWorlds\ImageWorldRegistry; +use App\Mail\BookingConfirmed; +use App\Models\Booking; +use App\Models\Page; +use App\Models\Property; +use App\Models\Site; +use App\Models\Tenant; +use App\Models\User; +use App\Tenancy\TenantContext; +use Illuminate\Foundation\Testing\RefreshDatabase; +use Illuminate\Http\UploadedFile; +use Illuminate\Support\Facades\File; +use Illuminate\Support\Facades\Storage; +use Livewire\Livewire; +use PHPUnit\Framework\Attributes\TestWith; +use Tests\TestCase; + +class TenantBrandRenderingTest extends TestCase +{ + use RefreshDatabase; + + #[TestWith(['ostsee-licht'])] + #[TestWith(['seebad'])] + public function test_both_themes_show_only_the_current_websites_brand(string $theme): void + { + Storage::fake('public'); + $this->withoutVite(); + $first = $this->website('Nordhaus', 'nord.test', $theme); + $second = $this->website('Südheim', 'sued.test', $theme); + $first->addMedia(UploadedFile::fake()->image('nord-logo.png'))->toMediaCollection(Site::BRAND_LOGO); + $first->addMedia(UploadedFile::fake()->image('nord-icon.png'))->toMediaCollection(Site::BRAND_FAVICON); + $second->addMedia(UploadedFile::fake()->image('sued-logo.png'))->toMediaCollection(Site::BRAND_LOGO); + $second->addMedia(UploadedFile::fake()->image('sued-icon.png'))->toMediaCollection(Site::BRAND_FAVICON); + + $this->get('https://nord.test/')->assertOk()->assertSee('nord-logo.png')->assertSee('nord-icon.png') + ->assertDontSee('sued-logo.png')->assertDontSee('sued-icon.png'); + $this->get('https://sued.test/')->assertOk()->assertSee('sued-logo.png')->assertSee('sued-icon.png') + ->assertDontSee('nord-logo.png')->assertDontSee('nord-icon.png'); + } + + #[TestWith(['ostsee-licht'])] + #[TestWith(['seebad'])] + public function test_a_website_without_a_brand_does_not_inherit_stommers_identity(string $theme): void + { + $this->withoutVite(); + $this->website('Berghaus Alpenblick', 'berge.test', $theme); + + $this->get('https://berge.test/')->assertOk()->assertSee('Berghaus Alpenblick') + ->assertDontSee('logo-bildmarke')->assertDontSee('brand/favicon')->assertDontSee('img/favicon') + ->assertDontSee('Ferienwohnung · Kühlungsborn'); + } + + #[TestWith(['ostsee-licht'])] + #[TestWith(['seebad'])] + public function test_the_selected_picture_world_supplies_decoration_and_placeholder_in_both_themes(string $theme): void + { + $this->withoutVite(); + $directory = storage_path('framework/testing/brand-worlds'); + File::ensureDirectoryExists($directory.'/berge/svg'); + File::put($directory.'/berge/world.json', json_encode([ + 'name' => 'Berge', 'slots' => ['divider' => 'berg', 'placeholder' => 'berg'], + ])); + File::put($directory.'/berge/svg/berg.svg', '<svg viewBox="0 0 10 10" data-world="berge"><path d="M0 10L5 0L10 10"/></svg>'); + config(['image-worlds.paths' => [$directory], 'image-worlds.default' => null]); + app()->forgetInstance(ImageWorldRegistry::class); + $site = $this->website('Berghaus', 'berge.test', $theme); + $site->update(['image_world' => 'berge']); + + try { + $this->get('https://berge.test/')->assertOk()->assertSee('data-world="berge"', escape: false) + ->assertDontSee('coastal-illustration')->assertDontSee('brand/mark.svg'); + } finally { + File::deleteDirectory($directory); + } + } + + public function test_booking_mail_embeds_only_the_logo_of_its_website(): void + { + Storage::fake('public'); + $first = $this->website('Nordhaus', 'nord.test', 'seebad'); + $second = $this->website('Südheim', 'sued.test', 'seebad'); + $firstLogo = $first->addMedia(UploadedFile::fake()->image('nord-mail.png', 300, 100))->toMediaCollection(Site::BRAND_DOCUMENT_LOGO); + $secondLogo = $second->addMedia(UploadedFile::fake()->image('sued-mail.png', 400, 150))->toMediaCollection(Site::BRAND_DOCUMENT_LOGO); + + app(TenantContext::class)->run($first->tenant, function () use ($first, $firstLogo, $secondLogo): void { + $booking = Booking::factory()->for($first->primaryProperty())->create(['deposit_due_on' => now()->addWeek()]); + $mail = new BookingConfirmed($booking); + $html = $mail->render(); + + $this->assertSame(1, preg_match('/src="data:image\/png;base64,([^"]+)"/s', $html, $image)); + $this->assertSame(File::get($firstLogo->getPath()), base64_decode($image[1], strict: true)); + $this->assertNotSame(File::get($secondLogo->getPath()), base64_decode($image[1], strict: true)); + $this->assertStringContainsString('Nordhaus', $html); + $this->assertStringNotContainsString('Südheim', $html); + $this->assertStringNotContainsString('Ferienwohnung Stommer', $html); + $mail->assertSeeInText('Nordhaus'); + $mail->assertDontSeeInText('Ferienwohnung Stommer'); + }); + } + + public function test_the_legacy_brand_import_preserves_uploads_and_refuses_other_landlords(): void + { + Storage::fake('public'); + $site = $this->website('Stommer', 'stommer.test', 'seebad'); + $site->tenant->update(['slug' => 'stommer']); + $custom = $site->addMedia(UploadedFile::fake()->image('eigenes-logo.png'))->toMediaCollection(Site::BRAND_LOGO); + $other = $this->website('Anderer Vermieter', 'andere.test', 'seebad'); + + $this->artisan('sites:import-stommer-brand', ['site' => $site->id])->assertSuccessful(); + $this->artisan('sites:import-stommer-brand', ['site' => $site->id])->assertSuccessful(); + $this->artisan('sites:import-stommer-brand', ['site' => $other->id])->assertFailed(); + + $this->assertSame($custom->id, $site->fresh()->getFirstMedia(Site::BRAND_LOGO)->id); + $this->assertCount(3, $site->fresh()->media); + $this->assertCount(0, $other->fresh()->media); + } + + #[TestWith(['logo'])] + #[TestWith(['favicon'])] + public function test_the_admin_rejects_unchecked_svg_uploads(string $field): void + { + Storage::fake('public'); + $site = $this->website('Nordhaus', 'nord.test', 'seebad'); + $user = User::factory()->role(UserRole::Admin)->create(); + $user->tenants()->syncWithoutDetaching([$site->tenant_id => ['role' => UserRole::Admin->value]]); + app(TenantContext::class)->set($site->tenant); + $this->actingAs($user); + $upload = UploadedFile::fake()->createWithContent('unsicher.svg', '<svg xmlns="http://www.w3.org/2000/svg"><script>alert(1)</script></svg>'); + + Livewire::test(EditSite::class, ['record' => $site->getRouteKey()]) + ->fillForm([$field => [$upload]])->call('save')->assertHasFormErrors([$field]); + + $this->assertCount(0, $site->fresh()->media); + } + + #[TestWith(['logo'])] + #[TestWith(['favicon'])] + #[TestWith(['document_logo'])] + public function test_the_admin_saves_brand_images_on_the_public_disk(string $field): void + { + Storage::fake('public'); + $site = $this->website('Nordhaus', 'nord.test', 'seebad'); + $user = User::factory()->role(UserRole::Admin)->create(); + $user->tenants()->syncWithoutDetaching([$site->tenant_id => ['role' => UserRole::Admin->value]]); + app(TenantContext::class)->set($site->tenant); + $this->actingAs($user); + + Livewire::test(EditSite::class, ['record' => $site->getRouteKey()]) + ->fillForm([$field => [UploadedFile::fake()->image('marke.png')]])->call('save')->assertHasNoFormErrors(); + + $media = $site->fresh()->getFirstMedia($field); + $this->assertNotNull($media); + $this->assertSame('public', $media->disk); + $this->assertFileExists($media->getPath()); + $this->assertStringContainsString('/storage/', $site->fresh()->brandUrl($field)); + } + + private function website(string $name, string $host, string $theme): Site + { + $tenant = Tenant::factory()->create(['name' => $name, 'owner_name' => $name]); + + return app(TenantContext::class)->run($tenant, function () use ($name, $host, $theme): Site { + $site = Site::factory()->create(['name' => $name, 'domain' => $host, 'theme' => $theme, 'is_default' => true]); + Property::factory()->create(['site_id' => $site->id]); + Page::factory()->create(['site_id' => $site->id, 'slug' => Page::HOME, 'sections' => [ + ['type' => 'hero', 'data' => ['title' => $name]], + ]]); + + return $site; + }); + } +} diff --git a/tests/Feature/TenantFilesTest.php b/tests/Feature/TenantFilesTest.php new file mode 100644 index 0000000..6a8714c --- /dev/null +++ b/tests/Feature/TenantFilesTest.php @@ -0,0 +1,148 @@ +<?php + +namespace Tests\Feature; + +use App\Documents\RentalContract; +use App\Models\Booking; +use App\Models\Property; +use App\Models\Site; +use App\Models\Tenant; +use App\Tenancy\TenantArchive; +use App\Tenancy\TenantContext; +use Illuminate\Foundation\Testing\RefreshDatabase; +use Illuminate\Http\UploadedFile; +use Illuminate\Support\Facades\File; +use Illuminate\Support\Facades\Storage; +use PHPUnit\Framework\Attributes\TestWith; +use Tests\TestCase; +use ZipArchive; + +class TenantFilesTest extends TestCase +{ + use RefreshDatabase; + + #[TestWith([false])] + #[TestWith([true])] + public function test_equal_booking_numbers_do_not_overwrite_another_tenants_document(bool $draft): void + { + Storage::fake('local'); + $first = $this->booking('Nordhaus'); + $second = $this->booking('Südheim'); + $contracts = app(RentalContract::class); + + $firstPath = $contracts->generate($first, $draft); + $firstContent = Storage::disk('local')->get($firstPath); + $secondPath = $contracts->generate($second, $draft); + + $this->assertSame($first->reference, $second->reference); + $this->assertNotSame($firstPath, $secondPath); + $this->assertSame($firstContent, Storage::disk('local')->get($firstPath)); + Storage::disk('local')->assertExists($secondPath); + } + + public function test_export_and_deletion_include_website_media_and_all_document_versions_only_of_that_tenant(): void + { + Storage::fake('public'); + Storage::fake('local'); + $gone = $this->booking('Geht'); + $stays = $this->booking('Bleibt'); + $site = $gone->website(); + $otherSite = $stays->website(); + $logo = $site->addMedia(UploadedFile::fake()->image('geht.png'))->toMediaCollection(Site::BRAND_LOGO); + $otherLogo = $otherSite->addMedia(UploadedFile::fake()->image('bleibt.png'))->toMediaCollection(Site::BRAND_LOGO); + $contracts = app(RentalContract::class); + $oldOffer = $contracts->generate($gone, draft: true); + $gone->update(['offer_version' => 2]); + $newOffer = $contracts->generate($gone, draft: true); + $contract = $contracts->generate($gone); + $otherContract = $contracts->generate($stays); + $otherBytes = Storage::disk('local')->get($otherContract); + $directory = storage_path('framework/testing/tenant-files'); + + try { + $archive = app(TenantArchive::class); + $path = $archive->export($site->tenant, $directory); + $zip = new ZipArchive; + $this->assertTrue($zip->open($path)); + $this->assertNotFalse($zip->locateName('dateien/'.$logo->id.'-geht.png')); + $this->assertFalse($zip->locateName('dateien/'.$otherLogo->id.'-bleibt.png')); + foreach ([$oldOffer, $newOffer, $contract] as $document) { + $this->assertSame(Storage::disk('local')->get($document), $zip->getFromName('dateien/local/'.$document)); + } + $this->assertFalse($zip->locateName('dateien/local/'.$otherContract)); + $media = json_decode($zip->getFromName('daten/media.json'), true, flags: JSON_THROW_ON_ERROR); + $this->assertSame([$logo->id], array_column($media, 'id')); + $zip->close(); + + $archive->delete($site->tenant); + + $this->assertFileDoesNotExist($logo->getPath()); + $this->assertFileExists($otherLogo->getPath()); + $this->assertDatabaseMissing('media', ['id' => $logo->id]); + $this->assertDatabaseHas('media', ['id' => $otherLogo->id]); + Storage::disk('local')->assertMissing([$oldOffer, $newOffer, $contract]); + $this->assertSame($otherBytes, Storage::disk('local')->get($otherContract)); + } finally { + File::deleteDirectory($directory); + } + } + + public function test_existing_document_paths_remain_readable_and_are_exported_and_deleted(): void + { + Storage::fake('local'); + $booking = $this->booking('Altbestand'); + $path = 'contracts/Mietvertrag-2026-0001.pdf'; + Storage::disk('local')->put($path, '%PDF-alter-vertrag'); + $booking->update(['contract_path' => $path]); + $directory = storage_path('framework/testing/legacy-tenant-files'); + + try { + $this->assertSame(Storage::disk('local')->path($path), app(RentalContract::class)->absolutePath($booking)); + $archive = app(TenantArchive::class); + $zip = new ZipArchive; + $this->assertTrue($zip->open($archive->export($booking->tenant, $directory))); + $this->assertSame('%PDF-alter-vertrag', $zip->getFromName('dateien/local/'.$path)); + $zip->close(); + + $archive->delete($booking->tenant); + + Storage::disk('local')->assertMissing($path); + } finally { + File::deleteDirectory($directory); + } + } + + public function test_ambiguous_legacy_documents_prevent_deletion_of_either_tenant(): void + { + Storage::fake('local'); + $first = $this->booking('Erster'); + $second = $this->booking('Zweiter'); + $path = 'contracts/Mietvertrag-2026-0001.pdf'; + Storage::disk('local')->put($path, '%PDF-mehrdeutig'); + $first->update(['contract_path' => $path]); + $second->update(['contract_path' => $path]); + + try { + app(TenantArchive::class)->delete($first->tenant); + $this->fail('Mehrdeutige Altbestände dürfen nicht automatisch gelöscht werden.'); + } catch (\RuntimeException $exception) { + $this->assertSame('Vertragsdatei ist mehreren Mandanten zugeordnet: '.$path, $exception->getMessage()); + } + + $this->assertModelExists($first->tenant); + $this->assertModelExists($second->tenant); + Storage::disk('local')->assertExists($path); + } + + private function booking(string $name): Booking + { + $tenant = Tenant::factory()->create(['name' => $name]); + + return app(TenantContext::class)->run($tenant, function () use ($name): Booking { + $site = Site::factory()->create(['name' => $name]); + + return Booking::factory()->for(Property::factory()->create(['site_id' => $site->id])) + ->create(['reference' => '2026-0001', 'offer_version' => 1]); + }); + } +}