Fixes for client portal PDF display

This commit is contained in:
David Bomba 2021-05-15 17:14:31 +10:00
parent 372471b267
commit ae74f5a9d8
9 changed files with 16 additions and 19 deletions

View File

@ -251,7 +251,7 @@ class Credit extends BaseModel
$this->save(); $this->save();
} }
public function pdf_file_path($invitation = null, string $type = 'url') public function pdf_file_path($invitation = null, string $type = 'path')
{ {
if (! $invitation) { if (! $invitation) {
@ -267,13 +267,11 @@ class Credit extends BaseModel
if(!$invitation) if(!$invitation)
throw new \Exception('Hard fail, could not create an invitation - is there a valid contact?'); throw new \Exception('Hard fail, could not create an invitation - is there a valid contact?');
$file_path = CreateEntityPdf::dispatchNow($invitation); $file_path = CreateEntityPdf::dispatchNow($invitation);
return Storage::disk('public')->path($file_path); return Storage::disk('public')->{$type}($file_path);
} }
public function markInvitationsSent() public function markInvitationsSent()
{ {
$this->invitations->each(function ($invitation) { $this->invitations->each(function ($invitation) {

View File

@ -392,7 +392,7 @@ class Invoice extends BaseModel
return $invoice_calc->build(); return $invoice_calc->build();
} }
public function pdf_file_path($invitation = null, string $type = 'url') public function pdf_file_path($invitation = null, string $type = 'path')
{ {
if (! $invitation) { if (! $invitation) {
@ -408,10 +408,9 @@ class Invoice extends BaseModel
if(!$invitation) if(!$invitation)
throw new \Exception('Hard fail, could not create an invitation - is there a valid contact?'); throw new \Exception('Hard fail, could not create an invitation - is there a valid contact?');
$file_path = CreateEntityPdf::dispatchNow($invitation); $file_path = CreateEntityPdf::dispatchNow($invitation);
return Storage::disk('public')->path($file_path); return Storage::disk('public')->{$type}($file_path);
} }
public function markInvitationsSent() public function markInvitationsSent()

View File

@ -207,7 +207,7 @@ class Quote extends BaseModel
} }
public function pdf_file_path($invitation = null, string $type = 'url') public function pdf_file_path($invitation = null, string $type = 'path')
{ {
if (! $invitation) { if (! $invitation) {
@ -223,13 +223,13 @@ class Quote extends BaseModel
if(!$invitation) if(!$invitation)
throw new \Exception('Hard fail, could not create an invitation - is there a valid contact?'); throw new \Exception('Hard fail, could not create an invitation - is there a valid contact?');
$file_path = CreateEntityPdf::dispatchNow($invitation); $file_path = CreateEntityPdf::dispatchNow($invitation);
return Storage::disk('public')->path($file_path); return Storage::disk('public')->{$type}($file_path);
} }
/** /**
* @param int $status * @param int $status
* @return string * @return string

View File

@ -2,7 +2,7 @@
@section('meta_title', ctrans('texts.entity_number_placeholder', ['entity' => ctrans('texts.credit'), 'entity_number' => $credit->number])) @section('meta_title', ctrans('texts.entity_number_placeholder', ['entity' => ctrans('texts.credit'), 'entity_number' => $credit->number]))
@push('head') @push('head')
<meta name="pdf-url" content="{{ $credit->pdf_file_path() }}"> <meta name="pdf-url" content="{{ $credit->pdf_file_path(null, 'url') }}">
<script src="{{ asset('js/vendor/pdf.js/pdf.min.js') }}"></script> <script src="{{ asset('js/vendor/pdf.js/pdf.min.js') }}"></script>
@endpush @endpush

View File

@ -1,2 +1,2 @@
<iframe src="{{ $invoice->pdf_file_path() }}" <iframe src="{{ $invoice->pdf_file_path(null, 'url') }}"
style="position:fixed; top:0; left:0; bottom:0; right:0; width:100%; height:100%; border:none; margin:0; padding:0; overflow:hidden; z-index:999999;"></iframe> style="position:fixed; top:0; left:0; bottom:0; right:0; width:100%; height:100%; border:none; margin:0; padding:0; overflow:hidden; z-index:999999;"></iframe>

View File

@ -2,7 +2,7 @@
@section('meta_title', ctrans('texts.view_invoice')) @section('meta_title', ctrans('texts.view_invoice'))
@push('head') @push('head')
<meta name="pdf-url" content="{{ $invoice->pdf_file_path() }}"> <meta name="pdf-url" content="{{ $invoice->pdf_file_path(null, 'url') }}">
<meta name="show-invoice-terms" content="{{ $settings->show_accept_invoice_terms ? true : false }}"> <meta name="show-invoice-terms" content="{{ $settings->show_accept_invoice_terms ? true : false }}">
<meta name="require-invoice-signature" content="{{ $client->user->account->hasFeature(\App\Models\Account::FEATURE_INVOICE_SETTINGS) && $settings->require_invoice_signature }}"> <meta name="require-invoice-signature" content="{{ $client->user->account->hasFeature(\App\Models\Account::FEATURE_INVOICE_SETTINGS) && $settings->require_invoice_signature }}">
<script src="{{ asset('js/vendor/pdf.js/pdf.min.js') }}"></script> <script src="{{ asset('js/vendor/pdf.js/pdf.min.js') }}"></script>
@ -174,7 +174,7 @@
</section> </section>
</div> </div>
<iframe src="{{ $invoice->pdf_file_path() }}" class="h-screen w-full border-0 hidden lg:block mt-4"></iframe> <iframe src="{{ $invoice->pdf_file_path(null, 'url') }}" class="h-screen w-full border-0 hidden lg:block mt-4"></iframe>
<div class="flex justify-center"> <div class="flex justify-center">
<canvas id="pdf-placeholder" class="shadow rounded-lg bg-white lg:hidden mt-4 p-4"></canvas> <canvas id="pdf-placeholder" class="shadow rounded-lg bg-white lg:hidden mt-4 p-4"></canvas>

View File

@ -1,2 +1,2 @@
<iframe src="{{ $quote->pdf_file_path() }}" <iframe src="{{ $quote->pdf_file_path(null,'url') }}"
style="position:fixed; top:0; left:0; bottom:0; right:0; width:100%; height:100%; border:none; margin:0; padding:0; overflow:hidden; z-index:999999;"></iframe> style="position:fixed; top:0; left:0; bottom:0; right:0; width:100%; height:100%; border:none; margin:0; padding:0; overflow:hidden; z-index:999999;"></iframe>

View File

@ -2,7 +2,7 @@
@section('meta_title', ctrans('texts.entity_number_placeholder', ['entity' => ctrans('texts.quote'), 'entity_number' => $quote->number])) @section('meta_title', ctrans('texts.entity_number_placeholder', ['entity' => ctrans('texts.quote'), 'entity_number' => $quote->number]))
@push('head') @push('head')
<meta name="pdf-url" content="{{ asset($quote->pdf_file_path()) }}"> <meta name="pdf-url" content="{{ asset($quote->pdf_file_path(null, 'url')) }}">
<script src="{{ asset('js/vendor/pdf.js/pdf.min.js') }}"></script> <script src="{{ asset('js/vendor/pdf.js/pdf.min.js') }}"></script>
<meta name="show-quote-terms" content="{{ $settings->show_accept_quote_terms ? true : false }}"> <meta name="show-quote-terms" content="{{ $settings->show_accept_quote_terms ? true : false }}">
@ -78,7 +78,7 @@
<canvas id="pdf-placeholder" class="shadow rounded-lg bg-white lg:hidden mt-4 p-4"></canvas> <canvas id="pdf-placeholder" class="shadow rounded-lg bg-white lg:hidden mt-4 p-4"></canvas>
</div> </div>
<iframe src="{{ $quote->pdf_file_path() }}" class="h-screen w-full border-0 hidden lg:block mt-4"></iframe> <iframe src="{{ $quote->pdf_file_path(null, 'url') }}" class="h-screen w-full border-0 hidden lg:block mt-4"></iframe>
@include('portal.ninja2020.invoices.includes.terms', ['entities' => [$quote], 'entity_type' => ctrans('texts.quote')]) @include('portal.ninja2020.invoices.includes.terms', ['entities' => [$quote], 'entity_type' => ctrans('texts.quote')])
@include('portal.ninja2020.invoices.includes.signature') @include('portal.ninja2020.invoices.includes.signature')

View File

@ -1,7 +1,7 @@
@extends('portal.ninja2020.layout.clean') @extends('portal.ninja2020.layout.clean')
@push('head') @push('head')
<meta name="pdf-url" content="{{ asset($entity->pdf_file_path()) }}"> <meta name="pdf-url" content="{{ asset($entity->pdf_file_path(null, 'url')) }}">
<script src="{{ asset('js/vendor/pdf.js/pdf.min.js') }}"></script> <script src="{{ asset('js/vendor/pdf.js/pdf.min.js') }}"></script>
<script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.7.x/dist/alpine.min.js" defer></script> <script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.7.x/dist/alpine.min.js" defer></script>
@endpush @endpush
@ -39,7 +39,7 @@
<div x-show="open" x-transition:enter="transition ease-out duration-100" x-transition:enter-start="transform opacity-0 scale-95" x-transition:enter-end="transform opacity-100 scale-100" x-transition:leave="transition ease-in duration-75" x-transition:leave-start="transform opacity-100 scale-100" x-transition:leave-end="transform opacity-0 scale-95" class="origin-top-right absolute right-0 mt-2 w-56 rounded-md shadow-lg"> <div x-show="open" x-transition:enter="transition ease-out duration-100" x-transition:enter-start="transform opacity-0 scale-95" x-transition:enter-end="transform opacity-100 scale-100" x-transition:leave="transition ease-in duration-75" x-transition:leave-start="transform opacity-100 scale-100" x-transition:leave-end="transform opacity-0 scale-95" class="origin-top-right absolute right-0 mt-2 w-56 rounded-md shadow-lg">
<div class="rounded-md bg-white shadow-xs"> <div class="rounded-md bg-white shadow-xs">
<div class="py-1"> <div class="py-1">
<a target="_blank" href="{{ asset($entity->pdf_file_path()) }}" class="block px-4 py-2 text-sm leading-5 text-gray-700 hover:bg-gray-100 hover:text-gray-900 focus:outline-none focus:bg-gray-100 focus:text-gray-900">{{ ctrans('texts.open_in_new_tab') }}</a> <a target="_blank" href="{{ asset($entity->pdf_file_path(null, 'url')) }}" class="block px-4 py-2 text-sm leading-5 text-gray-700 hover:bg-gray-100 hover:text-gray-900 focus:outline-none focus:bg-gray-100 focus:text-gray-900">{{ ctrans('texts.open_in_new_tab') }}</a>
</div> </div>
</div> </div>
</div> </div>