Use getFilename function for invoice PDF export
This commit is contained in:
@@ -199,7 +199,7 @@ public static function getDueInvoices()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function preview($id)
|
public function preview(int $id)
|
||||||
{
|
{
|
||||||
$invoice = self::single($id);
|
$invoice = self::single($id);
|
||||||
$giroCode = $this->generateGiroCode(
|
$giroCode = $this->generateGiroCode(
|
||||||
@@ -222,7 +222,7 @@ public function preview($id)
|
|||||||
|
|
||||||
|
|
||||||
// https://www.itsolutionstuff.com/post/laravel-dompdf-table-with-page-break-exampleexample.html
|
// https://www.itsolutionstuff.com/post/laravel-dompdf-table-with-page-break-exampleexample.html
|
||||||
public function exportPdf($id)
|
public function exportPdf(int $id)
|
||||||
{
|
{
|
||||||
$invoice = self::single($id);
|
$invoice = self::single($id);
|
||||||
$giroCode = $this->generateGiroCode(
|
$giroCode = $this->generateGiroCode(
|
||||||
@@ -259,7 +259,7 @@ public function exportPdf($id)
|
|||||||
$pdf->setOptions($options, true);
|
$pdf->setOptions($options, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $pdf->stream($invoice['nr'] . '.pdf');
|
return $pdf->stream($this->getFilename($invoice) . '.pdf');
|
||||||
// return $pdf->download($this->getFilename($invoice) . '.pdf');
|
// return $pdf->download($this->getFilename($invoice) . '.pdf');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -831,10 +831,10 @@ protected function transliterateString($string)
|
|||||||
* Generate a filename for the invoice export
|
* Generate a filename for the invoice export
|
||||||
* Format: YYYY-MM-DD {invoice.nr} {invoice.title}
|
* Format: YYYY-MM-DD {invoice.nr} {invoice.title}
|
||||||
*/
|
*/
|
||||||
protected function getFilename($invoice)
|
protected function getFilename(array $invoice)
|
||||||
{
|
{
|
||||||
$date = \DateTime::createFromFormat("Y-m-d", $invoice['invoiceDate']);
|
$date = DateTime::createFromFormat("Y-m-d", $invoice['invoiceDate']);
|
||||||
$formattedDate = $date ? $date->format('Y-m-d') : (new DateTime())->format('Y-m-d');
|
$formattedDate = $date ? $date->format('Y-m-d') : (new DateTime())->format('Y-m-d');
|
||||||
return "{$formattedDate} {$invoice['nr']} {$invoice['title']}";
|
return "{$formattedDate} Rechnung {$invoice['nr']} {$invoice['title']}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user