Fix: Rechnungs-PDF in Belegansicht inline anzeigen statt herunterladen
This commit is contained in:
parent
d72f9077a0
commit
81682841a8
1 changed files with 21 additions and 2 deletions
|
|
@ -230,9 +230,28 @@ class BelegController
|
|||
$beleg = Beleg::find((int)$params['id']);
|
||||
if (!$beleg) { http_response_code(404); return; }
|
||||
|
||||
// Beleg ohne physische Datei → PDF der verknüpften Rechnung ausliefern
|
||||
// Beleg ohne physische Datei → PDF der verknüpften Rechnung inline ausliefern
|
||||
if (empty($beleg['storage_path']) && !empty($beleg['invoice_id'])) {
|
||||
header('Location: /invoices/' . (int)$beleg['invoice_id'] . '/pdf');
|
||||
$invoice = \Steuerkram\Models\Invoice::find((int)$beleg['invoice_id']);
|
||||
if (!$invoice) { http_response_code(404); return; }
|
||||
|
||||
if (!empty($invoice['storno_of_id'])) {
|
||||
$original = \Steuerkram\Models\Invoice::find((int)$invoice['storno_of_id']);
|
||||
if ($original) {
|
||||
$invoice['original_rechnungs_nr'] = $original['rechnungs_nr'];
|
||||
$invoice['original_rechnungs_datum'] = $original['rechnungs_datum'];
|
||||
}
|
||||
}
|
||||
|
||||
$lines = \Steuerkram\Models\Invoice::lines((int)$invoice['id']);
|
||||
$settings = \Steuerkram\Models\Setting::get();
|
||||
$svc = new \Steuerkram\Services\PdfInvoiceService();
|
||||
$pdf = $svc->renderToString($invoice, $lines, $settings);
|
||||
|
||||
header('Content-Type: application/pdf');
|
||||
header('Content-Disposition: inline; filename="' . $beleg['filename'] . '"');
|
||||
header('Content-Length: ' . strlen($pdf));
|
||||
echo $pdf;
|
||||
exit;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue