1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-13 22:54:25 +01:00

Merge pull request #5722 from turbo124/v5-develop

Fixes for delivering PDFs over the wire
This commit is contained in:
David Bomba 2021-05-16 16:27:17 +10:00 committed by GitHub
commit f2f0e1883f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 13 deletions

View File

@ -269,13 +269,21 @@ class Credit extends BaseModel
$file_path = $this->client->credit_filepath().$this->numberFormatter().'.pdf';
if(Ninja::isHosted() && $portal && Storage::disk(config('filesystems.default'))->exists($file_path)){
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
}
elseif(Ninja::isHosted() && $portal){
$file_path = CreateEntityPdf::dispatchNow($invitation,config('filesystems.default'));
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
}
if(Storage::disk('public')->exists($file_path))
return Storage::disk('public')->{$type}($file_path);
$file_path = CreateEntityPdf::dispatchNow($invitation);
return Storage::disk('public')->{$type}($file_path);
return Storage::disk('public')->{$type}($file_path);
}
public function markInvitationsSent()
{
$this->invitations->each(function ($invitation) {

View File

@ -410,12 +410,19 @@ class Invoice extends BaseModel
$file_path = $this->client->invoice_filepath().$this->numberFormatter().'.pdf';
if(Ninja::isHosted() && $portal && Storage::disk(config('filesystems.default'))->exists($file_path)){
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
}
elseif(Ninja::isHosted() && $portal){
$file_path = CreateEntityPdf::dispatchNow($invitation,config('filesystems.default'));
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
}
if(Storage::disk('public')->exists($file_path))
return Storage::disk('public')->{$type}($file_path);
$file_path = CreateEntityPdf::dispatchNow($invitation);
return Storage::disk('public')->{$type}($file_path);
return Storage::disk('public')->{$type}($file_path);
}
public function markInvitationsSent()

View File

@ -225,12 +225,19 @@ class Quote extends BaseModel
$file_path = $this->client->quote_filepath().$this->numberFormatter().'.pdf';
if(Ninja::isHosted() && $portal && Storage::disk(config('filesystems.default'))->exists($file_path)){
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
}
elseif(Ninja::isHosted() && $portal){
$file_path = CreateEntityPdf::dispatchNow($invitation,config('filesystems.default'));
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
}
if(Storage::disk('public')->exists($file_path))
return Storage::disk('public')->{$type}($file_path);
$file_path = CreateEntityPdf::dispatchNow($invitation);
return Storage::disk('public')->{$type}($file_path);
return Storage::disk('public')->{$type}($file_path);
}
/**

View File

@ -16,6 +16,7 @@ use App\Factory\CreditInvitationFactory;
use App\Models\Credit;
use App\Models\CreditInvitation;
use App\Services\AbstractService;
use Illuminate\Support\Str;
class CreateInvitations extends AbstractService
{

View File

@ -41,19 +41,12 @@ class GetInvoicePdf extends AbstractService
$disk = 'public';
// $disk = config('filesystems.default');
$file = Storage::disk($disk)->exists($file_path);
if (! $file) {
$file_path = CreateEntityPdf::dispatchNow($invitation);
}
// /* Copy from remote disk to local when using cloud file storage. */
// if(config('filesystems.default') == 's3')
// return TempFile::path(Storage::disk($disk)->url($file_path));
// return Storage::disk($disk)->url($file_path);
return Storage::disk($disk)->path($file_path);
}
}