This commit is contained in:
David Bomba 2023-11-16 08:55:16 +11:00
parent e725c9a444
commit ce4f808945

View File

@ -527,10 +527,11 @@ class InvoiceController extends BaseController
if ($action == 'download' && $invoices->count() >=1 && $user->can('view', $invoices->first())) { if ($action == 'download' && $invoices->count() >=1 && $user->can('view', $invoices->first())) {
$file = $invoices->first()->service()->getInvoicePdf(); $file = $invoices->first()->service()->getInvoicePdf();
$filename = $invoices->first()->getFileName();
nlog($filename);
return response()->streamDownload(function () use ($file) { return response()->streamDownload(function () use ($file) {
echo Storage::get($file); echo Storage::get($file);
}, basename($file), ['Content-Type' => 'application/pdf']); }, $filename, ['Content-Type' => 'application/pdf']);
} }
if ($action == 'bulk_print' && $user->can('view', $invoices->first())) { if ($action == 'bulk_print' && $user->can('view', $invoices->first())) {
@ -701,10 +702,11 @@ class InvoiceController extends BaseController
case 'download': case 'download':
$file = $invoice->service()->getInvoicePdf(); $file = $invoice->service()->getInvoicePdf();
$filename = $invoice->getFileName();
return response()->streamDownload(function () use ($file) { return response()->streamDownload(function () use ($file) {
echo Storage::get($file); echo $file;
}, basename($file), ['Content-Type' => 'application/pdf']); }, $filename, ['Content-Type' => 'application/pdf']);
case 'restore': case 'restore':
$this->invoice_repo->restore($invoice); $this->invoice_repo->restore($invoice);
@ -937,14 +939,11 @@ class InvoiceController extends BaseController
public function deliveryNote(ShowInvoiceRequest $request, Invoice $invoice) public function deliveryNote(ShowInvoiceRequest $request, Invoice $invoice)
{ {
$file = $invoice->service()->getInvoiceDeliveryNote($invoice, $invoice->invitations->first()->contact); $file = $invoice->service()->getInvoiceDeliveryNote($invoice, $invoice->invitations->first()->contact);
$file_name = ctrans('texts.delivery_note'). " " .$invoice->getFileName();
return response()->streamDownload(function () use ($file) { return response()->streamDownload(function () use ($file) {
echo $file; echo $file;
}, basename($file), ['Content-Type' => 'application/pdf']); }, $file_name, ['Content-Type' => 'application/pdf']);
// return response()->streamDownload(function () use ($file) {
// echo Storage::get($file);
// }, basename($file), ['Content-Type' => 'application/pdf']);
} }
/** /**