From dc763eb6f7a1820914b5418a5f586d099ac3a697 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 8 Jan 2017 21:47:12 +0200 Subject: [PATCH] Enable viewing draft invoices with link --- app/Http/Controllers/InvoiceController.php | 2 +- app/Models/Invoice.php | 2 +- app/Ninja/Repositories/InvoiceRepository.php | 2 +- resources/views/invoices/view.blade.php | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index 9e131bed5d..dde8f27a3e 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -192,7 +192,7 @@ class InvoiceController extends BaseController } // Set the invitation data on the client's contacts - if ($invoice->is_public && ! $clone) { + if ( ! $clone) { $clients = $data['clients']; foreach ($clients as $client) { if ($client->id != $invoice->client->id) { diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index b4335aa166..eb2ede973a 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -550,7 +550,7 @@ class Invoice extends EntityModel implements BalanceAffecting public function canBePaid() { - return floatval($this->balance) > 0 && ! $this->is_deleted && $this->isInvoice(); + return floatval($this->balance) > 0 && ! $this->is_deleted && $this->isInvoice() && $this->is_public; } /** diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index acf7d80033..c70ea5dc2b 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -797,7 +797,7 @@ class InvoiceRepository extends BaseRepository } $invoice = $invitation->invoice; - if (!$invoice || $invoice->is_deleted || ! $invoice->is_public) { + if (!$invoice || $invoice->is_deleted) { return false; } diff --git a/resources/views/invoices/view.blade.php b/resources/views/invoices/view.blade.php index 77a8b28dda..b7ee9f4d0a 100644 --- a/resources/views/invoices/view.blade.php +++ b/resources/views/invoices/view.blade.php @@ -116,6 +116,8 @@ @if ($showApprove) {!! Button::success(trans('texts.approve'))->asLinkTo(URL::to('/approve/' . $invitation->invitation_key))->large() !!} @endif + @elseif ( ! $invoice->canBePaid()) + {!! Button::normal(trans('texts.download_pdf'))->withAttributes(['onclick' => 'onDownloadClick()'])->large() !!} @elseif ($invoice->client->account->isGatewayConfigured() && floatval($invoice->balance) && !$invoice->is_recurring) {!! Button::normal(trans('texts.download_pdf'))->withAttributes(['onclick' => 'onDownloadClick()'])->large() !!}   @if (count($paymentTypes) > 1)