From ddbc254d4b2c35d084e46761d1012c6a62718ff0 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 22 Mar 2016 15:17:46 +0200 Subject: [PATCH] Add link to payments from invoice page --- app/Http/Controllers/InvoiceController.php | 10 +++++++++- app/Ninja/Presenters/PaymentPresenter.php | 11 +++++++++++ resources/lang/en/texts.php | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index dc9cc501db74..5a14ea624449 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -89,7 +89,7 @@ class InvoiceController extends BaseController { $account = Auth::user()->account; $invoice = Invoice::scope($publicId) - ->with('invitations', 'account.country', 'client.contacts', 'client.country', 'invoice_items') + ->with('invitations', 'account.country', 'client.contacts', 'client.country', 'invoice_items', 'payments') ->withTrashed() ->firstOrFail(); @@ -155,6 +155,14 @@ class InvoiceController extends BaseController if (!$invoice->is_recurring && $invoice->balance > 0) { $actions[] = ['url' => 'javascript:onPaymentClick()', 'label' => trans('texts.enter_payment')]; } + + foreach ($invoice->payments as $payment) { + $label = trans("texts.view_payment"); + if (count($invoice->payments) > 1) { + $label .= ' - ' . $account->formatMoney($payment->amount, $invoice->client); + } + $actions[] = ['url' => $payment->present()->url, 'label' => $label]; + } } if (count($actions) > 3) { diff --git a/app/Ninja/Presenters/PaymentPresenter.php b/app/Ninja/Presenters/PaymentPresenter.php index a0a58663e5a7..a1c3692991fe 100644 --- a/app/Ninja/Presenters/PaymentPresenter.php +++ b/app/Ninja/Presenters/PaymentPresenter.php @@ -1,5 +1,6 @@ entity->public_id . '/edit'); + } + + public function link() + { + return link_to('/payments/' . $this->entity->public_id . '/edit', $this->entity->getDisplayName()); + } + } \ No newline at end of file diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 02fe26bece12..c59c22b37045 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -1082,7 +1082,7 @@ $LANG = array( 'create_all_help' => 'Allow user to create and modify records', 'view_all_help' => 'Allow user to view records they didn\'t create', 'edit_all_help' => 'Allow user to modify records they didn\'t create', - + 'view_payment' => 'View Payment', );