mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Fixes for PDF paths
This commit is contained in:
parent
6e4c4fb458
commit
32036a8569
@ -19,6 +19,8 @@ class InvoiceItem
|
||||
|
||||
public $product_key = '';
|
||||
|
||||
public $product_cost = 0;
|
||||
|
||||
public $notes = '';
|
||||
|
||||
public $discount = 0;
|
||||
@ -57,6 +59,7 @@ class InvoiceItem
|
||||
'type_id' => 'string',
|
||||
'quantity' => 'float',
|
||||
'cost' => 'float',
|
||||
'product_cost' => 'float',
|
||||
'product_key' => 'string',
|
||||
'notes' => 'string',
|
||||
'discount' => 'float',
|
||||
|
@ -27,6 +27,7 @@ use Illuminate\View\View;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use ZipStream\Option\Archive;
|
||||
use ZipStream\ZipStream;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class QuoteController extends Controller
|
||||
{
|
||||
@ -89,8 +90,11 @@ class QuoteController extends Controller
|
||||
|
||||
if ($quotes->count() == 1) {
|
||||
|
||||
$file = $quotes->first()->pdf_file_path();
|
||||
return response()->download($file, basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
|
||||
$file = $quotes->first()->service()->getQuotePdf();
|
||||
// return response()->download($file, basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
|
||||
return response()->streamDownload(function () use($file) {
|
||||
echo Storage::get($file);
|
||||
}, basename($file));
|
||||
}
|
||||
|
||||
// enable output of HTTP headers
|
||||
|
@ -37,6 +37,7 @@ use App\Utils\TempFile;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\SavesDocuments;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
/**
|
||||
* Class CreditController.
|
||||
@ -536,8 +537,14 @@ class CreditController extends BaseController
|
||||
}
|
||||
break;
|
||||
case 'download':
|
||||
$file = $credit->pdf_file_path();
|
||||
return response()->download($file, basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
|
||||
// $file = $credit->pdf_file_path();
|
||||
$file = $credit->service()->getCreditPdf($credit->invitations->first());
|
||||
|
||||
// return response()->download($file, basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
|
||||
|
||||
return response()->streamDownload(function () use($file) {
|
||||
echo Storage::get($file);
|
||||
}, basename($file));
|
||||
break;
|
||||
case 'archive':
|
||||
$this->credit_repository->archive($credit);
|
||||
@ -585,9 +592,12 @@ class CreditController extends BaseController
|
||||
// $contact = $invitation->contact;
|
||||
$credit = $invitation->credit;
|
||||
|
||||
$file_path = $credit->service()->getCreditPdf($invitation);
|
||||
|
||||
return response()->download($file_path, basename($file_path), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
|
||||
$file = $credit->service()->getCreditPdf($invitation);
|
||||
|
||||
return response()->streamDownload(function () use($file) {
|
||||
echo Storage::get($file);
|
||||
}, basename($file));
|
||||
// return response()->download($file_path, basename($file_path), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -672,8 +672,17 @@ class InvoiceController extends BaseController
|
||||
break;
|
||||
case 'download':
|
||||
|
||||
$file = $invoice->pdf_file_path();
|
||||
return response()->download($file, basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
|
||||
// $file = $invoice->pdf_file_path();
|
||||
// return response()->download($file, basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
|
||||
|
||||
$file = $invoice->service()->getInvoicePdf();
|
||||
|
||||
// return response()->download(Storage::get($file), basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
|
||||
|
||||
return response()->streamDownload(function () use($file) {
|
||||
echo Storage::get($file);
|
||||
}, basename($file));
|
||||
|
||||
|
||||
break;
|
||||
case 'restore':
|
||||
@ -722,7 +731,8 @@ class InvoiceController extends BaseController
|
||||
}
|
||||
|
||||
//touch reminder1,2,3_sent + last_sent here if the email is a reminder.
|
||||
$invoice->service()->touchReminder($this->reminder_template)->deletePdf()->save();
|
||||
//$invoice->service()->touchReminder($this->reminder_template)->deletePdf()->save();
|
||||
$invoice->service()->touchReminder($this->reminder_template)->markSent()->save();
|
||||
|
||||
$invoice->invitations->load('contact.client.country', 'invoice.client.country', 'invoice.company')->each(function ($invitation) use ($invoice) {
|
||||
EmailEntity::dispatch($invitation, $invoice->company, $this->reminder_template)->delay(now()->addSeconds(30));
|
||||
@ -795,8 +805,11 @@ class InvoiceController extends BaseController
|
||||
|
||||
$file = $invoice->service()->getInvoicePdf($contact);
|
||||
|
||||
return response()->download($file, basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
|
||||
// return response()->download(Storage::get($file), basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
|
||||
|
||||
return response()->streamDownload(function () use($file) {
|
||||
echo Storage::get($file);
|
||||
}, basename($file));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -848,7 +861,10 @@ class InvoiceController extends BaseController
|
||||
|
||||
$file = $invoice->service()->getInvoiceDeliveryNote($invoice, $invoice->invitations->first()->contact);
|
||||
|
||||
return response()->download($file, basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
|
||||
// return response()->download($file, basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
|
||||
return response()->streamDownload(function () use($file) {
|
||||
echo Storage::get($file);
|
||||
}, basename($file));
|
||||
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,7 @@ use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\SavesDocuments;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
/**
|
||||
* Class QuoteController.
|
||||
@ -676,8 +677,14 @@ class QuoteController extends BaseController
|
||||
break;
|
||||
case 'download':
|
||||
|
||||
$file = $quote->pdf_file_path();
|
||||
return response()->download($file, basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
|
||||
//$file = $quote->pdf_file_path();
|
||||
$file = $quote->service()->getQuotePdf();
|
||||
|
||||
return response()->streamDownload(function () use($file) {
|
||||
echo Storage::get($file);
|
||||
}, basename($file));
|
||||
|
||||
//return response()->download($file, basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
|
||||
|
||||
break;
|
||||
case 'restore':
|
||||
@ -728,9 +735,14 @@ class QuoteController extends BaseController
|
||||
$contact = $invitation->contact;
|
||||
$quote = $invitation->quote;
|
||||
|
||||
$file_path = $quote->service()->getQuotePdf($contact);
|
||||
$file = $quote->service()->getQuotePdf($contact);
|
||||
nlog($file);
|
||||
|
||||
return response()->download($file_path, basename($file_path), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
|
||||
return response()->streamDownload(function () use($file) {
|
||||
echo Storage::get($file);
|
||||
}, basename($file));
|
||||
|
||||
// return response()->download($file_path, basename($file_path), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,7 +67,7 @@ class UpdateCompanyRequest extends Request
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
if(array_key_exists('portal_domain', $input) && strlen($input['portal_domain']) > 1)
|
||||
if(Ninja::isHosted() && array_key_exists('portal_domain', $input) && strlen($input['portal_domain']) > 1)
|
||||
$input['portal_domain'] = $this->addScheme($input['portal_domain']);
|
||||
|
||||
if (array_key_exists('settings', $input)) {
|
||||
|
@ -86,9 +86,8 @@ class CreateEntityPdf implements ShouldQueue
|
||||
|
||||
$this->contact = $invitation->contact;
|
||||
|
||||
//$this->disk = Ninja::isHosted() ? config('filesystems.default') : $disk;
|
||||
$this->disk = $disk;
|
||||
// $this->disk = $disk ?? config('filesystems.default');
|
||||
$this->disk = Ninja::isHosted() ? config('filesystems.default') : $disk;
|
||||
|
||||
}
|
||||
|
||||
public function handle()
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Mail\Engine;
|
||||
|
||||
use App\Models\Account;
|
||||
use App\Utils\HtmlEngine;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\Number;
|
||||
|
@ -41,10 +41,13 @@ class GetCreditPdf extends AbstractService
|
||||
|
||||
$file_path = $path.$this->credit->numberFormatter().'.pdf';
|
||||
|
||||
$disk = 'public';
|
||||
// $disk = 'public';
|
||||
$disk = config('filesystems.default');
|
||||
|
||||
$file_path = CreateEntityPdf::dispatchNow($this->invitation);
|
||||
|
||||
return Storage::disk($disk)->path($file_path);
|
||||
nlog($file_path);
|
||||
return $file_path;
|
||||
// return Storage::disk($disk)->path($file_path);
|
||||
}
|
||||
}
|
||||
|
@ -49,9 +49,9 @@ class GenerateDeliveryNote
|
||||
|
||||
$this->contact = $contact;
|
||||
|
||||
$this->disk = 'public';
|
||||
// $this->disk = 'public';
|
||||
|
||||
// $this->disk = $disk ?? config('filesystems.default');
|
||||
$this->disk = $disk ?? config('filesystems.default');
|
||||
}
|
||||
|
||||
public function run()
|
||||
@ -111,7 +111,8 @@ class GenerateDeliveryNote
|
||||
|
||||
Storage::disk($this->disk)->put($file_path, $pdf);
|
||||
|
||||
return Storage::disk($this->disk)->path($file_path);
|
||||
//return Storage::disk($this->disk)->path($file_path);
|
||||
|
||||
return $file_path;
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,8 @@ class GetInvoicePdf extends AbstractService
|
||||
|
||||
$file_path = $path.$this->invoice->numberFormatter().'.pdf';
|
||||
|
||||
$disk = 'public';
|
||||
// $disk = 'public';
|
||||
$disk = config('filesystems.default');
|
||||
|
||||
$file = Storage::disk($disk)->exists($file_path);
|
||||
|
||||
@ -47,6 +48,8 @@ class GetInvoicePdf extends AbstractService
|
||||
$file_path = CreateEntityPdf::dispatchNow($invitation);
|
||||
}
|
||||
|
||||
return Storage::disk($disk)->path($file_path);
|
||||
// return Storage::disk($disk)->path($file_path);
|
||||
//
|
||||
return $file_path;
|
||||
}
|
||||
}
|
||||
|
@ -39,10 +39,12 @@ class GetQuotePdf extends AbstractService
|
||||
|
||||
$file_path = $path.$this->quote->numberFormatter().'.pdf';
|
||||
|
||||
$disk = 'public';
|
||||
|
||||
// $disk = 'public';
|
||||
$disk = config('filesystems.default');
|
||||
|
||||
$file_path = CreateEntityPdf::dispatchNow($invitation);
|
||||
|
||||
return Storage::disk($disk)->path($file_path);
|
||||
return $file_path;
|
||||
//return Storage::disk($disk)->path($file_path);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user