From 5a505c84696eab4aae748a264ef64f3da347b6f2 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 27 Nov 2014 15:42:07 +0100 Subject: [PATCH] Show everything on demand. --- app/controllers/AccountController.php | 8 ++++++-- app/lib/FireflyIII/Database/Account.php | 23 ++++++++++++++++++++++- app/views/accounts/show.blade.php | 14 ++++++++++++++ 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index ec775e50de..68f81e7a32 100644 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -241,8 +241,12 @@ class AccountController extends BaseController // get a paginated view of all transactions for this account: /** @var \FireflyIII\Database\Account $acct */ $acct = App::make('FireflyIII\Database\Account'); - - $journals = $acct->getTransactionJournals($account, 10); + if (Input::get('showAll') == 'true') { + + $journals = $acct->getAllTransactionJournals($account, 10); + } else { + $journals = $acct->getTransactionJournals($account, 10); + } //$data = $this->_accounts->show($account, 40); diff --git a/app/lib/FireflyIII/Database/Account.php b/app/lib/FireflyIII/Database/Account.php index cde242e623..0bca22a5e4 100644 --- a/app/lib/FireflyIII/Database/Account.php +++ b/app/lib/FireflyIII/Database/Account.php @@ -445,6 +445,26 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface } + public function getAllTransactionJournals(\Account $account, $limit = 50) + { + $offset = intval(\Input::get('page')) > 0 ? intval(\Input::get('page')) * $limit : 0; + $set = $this->getUser()->transactionJournals()->withRelevantData()->leftJoin( + 'transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id' + )->where('transactions.account_id', $account->id)->take($limit)->offset($offset)->orderBy('date', 'DESC')->get( + ['transaction_journals.*'] + ); + $count = $this->getUser()->transactionJournals()->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') + ->orderBy('date', 'DESC')->where('transactions.account_id', $account->id)->count(); + $items = []; + foreach ($set as $entry) { + $items[] = $entry; + } + + return \Paginator::make($items, $count, $limit); + + + } + public function getTransactionJournals(\Account $account, $limit = 50) { $start = \Session::get('start'); @@ -476,11 +496,12 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface */ public function getTransactionJournalsInRange(\Account $account, Carbon $start, Carbon $end) { - $set = $this->getUser()->transactionJournals()->transactionTypes(['Withdrawal'])->withRelevantData()->leftJoin( + $set = $this->getUser()->transactionJournals()->transactionTypes(['Withdrawal'])->withRelevantData()->leftJoin( 'transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id' )->where('transactions.account_id', $account->id)->before($end)->after($start)->orderBy('date', 'DESC')->get( ['transaction_journals.*'] ); + return $set; } diff --git a/app/views/accounts/show.blade.php b/app/views/accounts/show.blade.php index e96f37cd3b..ca7c1dd86d 100644 --- a/app/views/accounts/show.blade.php +++ b/app/views/accounts/show.blade.php @@ -14,6 +14,20 @@
@include('partials.date_nav') +
+
+ View options for {{{$account->name}}} +
+
+

+ @if(Input::get('showAll') == 'true') + Stick to date-range + @else + Show all transactions + @endif +

+
+