diff --git a/app/Jobs/Entity/CreateEntityPdf.php b/app/Jobs/Entity/CreateEntityPdf.php index f76711a8e03b..62420894ffaf 100644 --- a/app/Jobs/Entity/CreateEntityPdf.php +++ b/app/Jobs/Entity/CreateEntityPdf.php @@ -64,7 +64,7 @@ class CreateEntityPdf implements ShouldQueue * * @param $invitation */ - public function __construct($invitation) + public function __construct($invitation, $disk = 'public') { $this->invitation = $invitation; @@ -86,7 +86,7 @@ class CreateEntityPdf implements ShouldQueue $this->contact = $invitation->contact; - $this->disk = 'public'; + $this->disk = $disk; // $this->disk = $disk ?? config('filesystems.default'); } @@ -194,12 +194,12 @@ class CreateEntityPdf implements ShouldQueue try{ Storage::disk($this->disk)->put($file_path, $pdf); - + } catch(\Exception $e) { - throw new FilePermissionsFailure('Could not write the PDF, permission issues!'); + throw new FilePermissionsFailure($e->getMessage()); } } @@ -211,8 +211,5 @@ class CreateEntityPdf implements ShouldQueue { } - // public function failed(\Exception $exception) - // { - // nlog("help!"); - // } + } diff --git a/app/Models/Credit.php b/app/Models/Credit.php index 72b8dd0674ac..50511b171834 100644 --- a/app/Models/Credit.php +++ b/app/Models/Credit.php @@ -251,7 +251,7 @@ class Credit extends BaseModel $this->save(); } - public function pdf_file_path($invitation = null, string $type = 'path') + public function pdf_file_path($invitation = null, string $type = 'path', bool $portal = false) { if (! $invitation) { @@ -267,11 +267,15 @@ class Credit extends BaseModel if(!$invitation) throw new \Exception('Hard fail, could not create an invitation - is there a valid contact?'); + $file_path = $this->client->credit_filepath().$this->numberFormatter().'.pdf'; + + 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); } - public function markInvitationsSent() { $this->invitations->each(function ($invitation) { diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 6011f93e46c0..34ad4c655da8 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -392,7 +392,7 @@ class Invoice extends BaseModel return $invoice_calc->build(); } - public function pdf_file_path($invitation = null, string $type = 'path') + public function pdf_file_path($invitation = null, string $type = 'path', bool $portal = false) { if (! $invitation) { @@ -408,6 +408,11 @@ class Invoice extends BaseModel if(!$invitation) throw new \Exception('Hard fail, could not create an invitation - is there a valid contact?'); + $file_path = $this->client->invoice_filepath().$this->numberFormatter().'.pdf'; + + 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); diff --git a/app/Models/Quote.php b/app/Models/Quote.php index c2a11d9986aa..886b2e62b4fc 100644 --- a/app/Models/Quote.php +++ b/app/Models/Quote.php @@ -207,7 +207,7 @@ class Quote extends BaseModel } - public function pdf_file_path($invitation = null, string $type = 'path') + public function pdf_file_path($invitation = null, string $type = 'path', bool $portal = false) { if (! $invitation) { @@ -223,13 +223,16 @@ class Quote extends BaseModel if(!$invitation) throw new \Exception('Hard fail, could not create an invitation - is there a valid contact?'); + $file_path = $this->client->quote_filepath().$this->numberFormatter().'.pdf'; + + 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); } - - /** * @param int $status * @return string diff --git a/resources/views/portal/ninja2020/credits/show.blade.php b/resources/views/portal/ninja2020/credits/show.blade.php index 32f15ae58472..fd792226c636 100644 --- a/resources/views/portal/ninja2020/credits/show.blade.php +++ b/resources/views/portal/ninja2020/credits/show.blade.php @@ -2,7 +2,7 @@ @section('meta_title', ctrans('texts.entity_number_placeholder', ['entity' => ctrans('texts.credit'), 'entity_number' => $credit->number])) @push('head') - + @endpush diff --git a/resources/views/portal/ninja2020/invoices/show-fullscreen.blade.php b/resources/views/portal/ninja2020/invoices/show-fullscreen.blade.php index d1f3c80d6831..f08c3dcff56b 100644 --- a/resources/views/portal/ninja2020/invoices/show-fullscreen.blade.php +++ b/resources/views/portal/ninja2020/invoices/show-fullscreen.blade.php @@ -1,2 +1,2 @@ - diff --git a/resources/views/portal/ninja2020/invoices/show.blade.php b/resources/views/portal/ninja2020/invoices/show.blade.php index d998ff1ba914..047c23d99063 100644 --- a/resources/views/portal/ninja2020/invoices/show.blade.php +++ b/resources/views/portal/ninja2020/invoices/show.blade.php @@ -2,7 +2,7 @@ @section('meta_title', ctrans('texts.view_invoice')) @push('head') - + @@ -174,7 +174,7 @@ - +
diff --git a/resources/views/portal/ninja2020/quotes/show-fullscreen.blade.php b/resources/views/portal/ninja2020/quotes/show-fullscreen.blade.php index c927cb641a98..0cfa59fec10b 100644 --- a/resources/views/portal/ninja2020/quotes/show-fullscreen.blade.php +++ b/resources/views/portal/ninja2020/quotes/show-fullscreen.blade.php @@ -1,2 +1,2 @@ - diff --git a/resources/views/portal/ninja2020/quotes/show.blade.php b/resources/views/portal/ninja2020/quotes/show.blade.php index e1450ee7a05b..070c94246c1f 100644 --- a/resources/views/portal/ninja2020/quotes/show.blade.php +++ b/resources/views/portal/ninja2020/quotes/show.blade.php @@ -2,7 +2,7 @@ @section('meta_title', ctrans('texts.entity_number_placeholder', ['entity' => ctrans('texts.quote'), 'entity_number' => $quote->number])) @push('head') - + @@ -78,7 +78,7 @@
- + @include('portal.ninja2020.invoices.includes.terms', ['entities' => [$quote], 'entity_type' => ctrans('texts.quote')]) @include('portal.ninja2020.invoices.includes.signature') diff --git a/resources/views/themes/ninja2020/view_entity/index.blade.php b/resources/views/themes/ninja2020/view_entity/index.blade.php index cd88399d9b34..8aec9ecf0d05 100644 --- a/resources/views/themes/ninja2020/view_entity/index.blade.php +++ b/resources/views/themes/ninja2020/view_entity/index.blade.php @@ -1,7 +1,7 @@ @extends('portal.ninja2020.layout.clean') @push('head') - + @endpush @@ -39,7 +39,7 @@