Expanded on categories.

This commit is contained in:
James Cole 2014-11-14 11:56:45 +01:00
parent 9adbbd872c
commit eb8f8fa935
5 changed files with 30 additions and 14 deletions

View File

@ -78,7 +78,14 @@ class CategoryController extends BaseController
*/ */
public function show(Category $category) public function show(Category $category)
{ {
return View::make('categories.show', compact('category')); $hideCategory = true;
/** @var \FireflyIII\Database\Category $repos */
$repos = App::make('FireflyIII\Database\Category');
$journals = $repos->getTransactionJournals($category, 50);
return View::make('categories.show', compact('category','journals','hideCategory'));
} }
/** /**

View File

@ -170,6 +170,20 @@ class Category implements CUD, CommonDatabaseCalls, CategoryInterface
throw new NotImplementedException; throw new NotImplementedException;
} }
public function getTransactionJournals(\Category $category, $limit = 50)
{
$offset = intval(\Input::get('page')) > 0 ? intval(\Input::get('page')) * $limit : 0;
$set = $category->transactionJournals()->withRelevantData()->take($limit)->offset($offset)->orderBy('date', 'DESC')->get(['transaction_journals.*']);
$count = $category->transactionJournals()->count();
$items = [];
foreach ($set as $entry) {
$items[] = $entry;
}
return \Paginator::make($items, $count, $limit);
}
/** /**
* @param \Category $budget * @param \Category $budget
* @param Carbon $date * @param Carbon $date

View File

@ -17,7 +17,7 @@
Transactions Transactions
</div> </div>
<div class="panel-body"> <div class="panel-body">
<div id="transactions"></div> @include('list.journals-full')
</div> </div>
</div> </div>
</div> </div>

View File

@ -13,7 +13,9 @@
@if(!isset($hideBudget) || (isset($hideBudget) && $hideBudget=== false)) @if(!isset($hideBudget) || (isset($hideBudget) && $hideBudget=== false))
<th><i class="fa fa-tasks fa-fw" title="Budget"></i></th> <th><i class="fa fa-tasks fa-fw" title="Budget"></i></th>
@endif @endif
<th><i class="fa fa-bar-chart fa-fw" title="Category"></i></th> @if(!isset($hideCategory) || (isset($hideCategory) && $hideCategory=== false))
<th><i class="fa fa-bar-chart fa-fw" title="Category"></i></th>
@endif
<th><i class="fa fa-fw fa-rotate-right" title="Recurring transaction"></i></th> <th><i class="fa fa-fw fa-rotate-right" title="Recurring transaction"></i></th>
</tr> </tr>
@foreach($journals as $journal) @foreach($journals as $journal)
@ -89,12 +91,14 @@
@endif @endif
</td> </td>
@endif @endif
@if(!isset($hideCategory) || (isset($hideCategory) && $hideCategory=== false))
<td> <td>
<?php $category = isset($journal->categories[0]) ? $journal->categories[0] : null; ?> <?php $category = isset($journal->categories[0]) ? $journal->categories[0] : null; ?>
@if($category) @if($category)
<a href="{{route('categories.show',$category->id)}}">{{{$category->name}}}</a> <a href="{{route('categories.show',$category->id)}}">{{{$category->name}}}</a>
@endif @endif
</td> </td>
@endif
<td> <td>
@if($journal->recurringTransaction) @if($journal->recurringTransaction)
<a href="{{route('recurring.show',$journal->recurring_transaction_id)}}">{{{$journal->recurringTransaction->name}}}</a> <a href="{{route('recurring.show',$journal->recurring_transaction_id)}}">{{{$journal->recurringTransaction->name}}}</a>

View File

@ -1,18 +1,9 @@
$(function () { $(function () {
if (typeof googleTable == 'function') { if (typeof componentID != 'undefined' && typeof repetitionID == 'undefined') {
googleTable('table/categories', 'category-list'); googleColumnChart('chart/component/' + componentID + '/spending/' + year, 'componentOverview');
if (typeof(componentID) != 'undefined') {
googleTable('table/component/' + componentID + '/0/transactions','transactions');
if (typeof googleColumnChart == 'function') {
googleColumnChart('chart/component/' + componentID + '/spending/' + year, 'componentOverview');
}
}
} }
}); });