mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 17:24:29 -04:00
Fixes for download routes
This commit is contained in:
parent
86015c66e0
commit
adfff8e090
@ -701,12 +701,9 @@ class InvoiceController extends BaseController
|
|||||||
break;
|
break;
|
||||||
case 'download':
|
case 'download':
|
||||||
|
|
||||||
$file = $invoice->service()->getInvoicePdf();
|
return response()->streamDownload(function () use ($invoice) {
|
||||||
$filename = $invoice->getFileName();
|
echo $invoice->service()->getInvoicePdf();
|
||||||
|
}, $invoice->getFileName(), ['Content-Type' => 'application/pdf']);
|
||||||
return response()->streamDownload(function () use ($file) {
|
|
||||||
echo $file;
|
|
||||||
}, $filename, ['Content-Type' => 'application/pdf']);
|
|
||||||
|
|
||||||
case 'restore':
|
case 'restore':
|
||||||
$this->invoice_repo->restore($invoice);
|
$this->invoice_repo->restore($invoice);
|
||||||
|
@ -720,11 +720,9 @@ class QuoteController extends BaseController
|
|||||||
break;
|
break;
|
||||||
case 'download':
|
case 'download':
|
||||||
|
|
||||||
$file = $quote->service()->getQuotePdf();
|
return response()->streamDownload(function () use ($quote) {
|
||||||
|
echo $quote->service()->getQuotePdf();
|
||||||
return response()->streamDownload(function () use ($file) {
|
}, $quote->getFileName(), ['Content-Type' => 'application/pdf']);
|
||||||
echo $file;
|
|
||||||
}, $quote->numberFormatter().".pdf", ['Content-Type' => 'application/pdf']);
|
|
||||||
|
|
||||||
case 'restore':
|
case 'restore':
|
||||||
$this->quote_repo->restore($quote);
|
$this->quote_repo->restore($quote);
|
||||||
@ -833,11 +831,9 @@ class QuoteController extends BaseController
|
|||||||
$headers = array_merge($headers, ['Content-Disposition' => 'inline']);
|
$headers = array_merge($headers, ['Content-Disposition' => 'inline']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = $quote->service()->getQuotePdf($contact);
|
return response()->streamDownload(function () use ($quote,$contact) {
|
||||||
|
echo $quote->service()->getQuotePdf($contact);
|
||||||
return response()->streamDownload(function () use ($file) {
|
}, $quote->getFileName(), $headers);
|
||||||
echo $file;
|
|
||||||
}, $quote->numberFormatter().".pdf", $headers);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,7 +249,6 @@ class BaseModel extends Model
|
|||||||
|
|
||||||
return \Illuminate\Support\Str::ascii($formatted_number);
|
return \Illuminate\Support\Str::ascii($formatted_number);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,6 +82,34 @@ class DownloadHistoricalInvoiceTest extends TestCase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDownloadQuoteRoute()
|
||||||
|
{
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->get("/api/v1/quotes/{$this->quote->hashed_id}/download");
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
$response->assertDownload();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDownloadQuoteBulkActionRoute()
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
'action' => 'download',
|
||||||
|
'ids' => [$this->quote->hashed_id],
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->post("/api/v1/quotes/bulk", $data);
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private function mockActivity()
|
private function mockActivity()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user