Files
fewo-stommer/app/Http/Controllers/DocumentPreviewController.php
T
LarsandClaude Opus 5.5 cf11c8a474
Deploy FeWo mit PipelineManager / deploy (push) Successful in 3m59s
Dokumentenzusammenstellung und Vorlagensteuerung (Paket 3, Prozessarchitektur v0.10)
Eine Zusammenstellung vor jedem Dokument (Angebot, Bestaetigung, Buchungsunterlagen
extern), Dokumentart je Vorgangsart, Freigaben fuer Vorlagen und Dokumentarten,
Schutz vor unvereinbarten Bedingungen bei Portalbuchungen (E-004), kein doppelter
Versand, Absicherung Hold 0 bis Paket 7, A6-Aufenthaltsbestaetigung vorbereitet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 19:44:52 +01:00

34 lines
1.4 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Documents\DocumentComposer;
use App\Documents\RentalContract;
use App\Enums\DocumentKind;
use App\Models\Booking;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
/**
* The PDF of a document composition as it would be sent, for the landlord's preview in the admin area. Nothing is
* stored; the case is only read (and only within the current landlord, by the tenant scope of the route binding).
*/
class DocumentPreviewController extends Controller
{
public function __invoke(Request $request, Booking $booking, string $kind, DocumentComposer $composer, RentalContract $contract): Response
{
$documentKind = DocumentKind::tryFrom($kind);
abort_if($documentKind === null || ! $documentKind->isForGuests(), 404);
$changes = json_decode((string) base64_decode((string) $request->query('changes', ''), true), true);
$composition = $composer->compose($booking, $documentKind, is_array($changes) ? $changes : []);
$pdf = $contract->render($composition->draft, $documentKind, draft: $documentKind === DocumentKind::Offer);
return response($pdf, 200, [
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="Vorschau-'.$documentKind->fileName().'-'.$booking->reference.'.pdf"',
'Cache-Control' => 'no-store',
]);
}
}