Show everything on demand.

This commit is contained in:
James Cole 2014-11-27 15:42:07 +01:00
parent 2c2abe8b8e
commit 5a505c8469
3 changed files with 42 additions and 3 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -14,6 +14,20 @@
<div class="col-lg-4 col-md-6 col-sm-12">
<!-- time based navigation -->
@include('partials.date_nav')
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-clock-o fa-fw"></i> View options for {{{$account->name}}}
</div>
<div class="panel-body">
<p>
@if(Input::get('showAll') == 'true')
<a href="{{route('accounts.show',$account->id)}}" class="btn btn-default">Stick to date-range</a>
@else
<a href="{{route('accounts.show',$account->id)}}?showAll=true" class="btn btn-default">Show all transactions</a>
@endif
</p>
</div>
</div>
</div>
</div>