Cleaned up date-time navigation, added some stuff to accounts, expanded JSON response for transactions.

This commit is contained in:
Sander Dorigo 2014-10-09 07:24:47 +02:00
parent 3cba673a9c
commit a687140056
8 changed files with 154 additions and 138 deletions

View File

@ -44,7 +44,8 @@ class HomeController extends BaseController
/** @var \Firefly\Helper\Toolkit\ToolkitInterface $toolkit */
$toolkit = App::make('Firefly\Helper\Toolkit\ToolkitInterface');
$toolkit->prev();
return Redirect::route('index');
return Redirect::back();
//return Redirect::route('index');
}
/*
@ -54,7 +55,8 @@ class HomeController extends BaseController
/** @var \Firefly\Helper\Toolkit\ToolkitInterface $toolkit */
$toolkit = App::make('Firefly\Helper\Toolkit\ToolkitInterface');
$toolkit->next();
return Redirect::route('index');
return Redirect::back();
//return Redirect::route('index');
}
/**

View File

@ -167,10 +167,13 @@ class Json implements JsonInterface
/*
* Loop set and create entries to return.
*/
/** @var \TransactionJournal $entry */
foreach ($set as $entry) {
$from = $entry->transactions[0]->account;
$to = $entry->transactions[1]->account;
$data['data'][] = [
$budget = $entry->budgets()->first();
$category = $entry->categories()->first();
$arr = [
'date' => $entry->date->format('j F Y'),
'description' => [
'description' => $entry->description,
@ -179,11 +182,31 @@ class Json implements JsonInterface
'amount' => floatval($entry->amount),
'from' => ['name' => $from->name, 'url' => route('accounts.show', $from->id)],
'to' => ['name' => $to->name, 'url' => route('accounts.show', $to->id)],
'components' => [
'budget_id' => 0,
'budget_url' => '',
'budget_name' => '',
'category_id' => 0,
'category_url' => '',
'category_name' => ''
],
'id' => [
'edit' => route('transactions.edit', $entry->id),
'delete' => route('transactions.delete', $entry->id)
]
];
if($budget) {
$arr['components']['budget_id'] = $budget->id;
$arr['components']['budget_name'] = $budget->name;
$arr['components']['budget_url'] = route('budgets.show',$budget->id);
}
if($category) {
$arr['components']['category_id'] = $category->id;
$arr['components']['category_name'] = $category->name;
$arr['components']['category_url'] = route('categories.show',$category->id);
}
$data['data'][] = $arr;
}
return $data;

View File

@ -1,88 +1,105 @@
@extends('layouts.default')
@section('content')
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<div id="chart"></div>
<div class="col-lg-8 col-md-6 col-sm-12">
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa {{$subTitleIcon}} fa-fw"></i> {{{$account->name}}}
</div>
<div class="panel-body">
<div id="chart"></div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<h4>Summary <small>For selected account and period</small></h4>
<div class="col-lg-4 col-md-6 col-sm-12">
<!-- time based navigation -->
@include('partials.date_nav')
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-12">
<table class="table table-striped table-condensed">
<tr>
<th></th>
<th>Expense / income</th>
<th>Transfers</th>
</tr>
<tr>
<td>Out</td>
<td>
{{mf($show['statistics']['period']['out'])}}
<a href="{{route('accounts.show',$account->id)}}?type=transactions&amp;show=expenses"><span class="glyphicon glyphicon-circle-arrow-right"></span></a>
</td>
<td>
{{mf($show['statistics']['period']['t_out'])}}
<a href="{{route('accounts.show',$account->id)}}?type=transfers&amp;show=out"><span class="glyphicon glyphicon-circle-arrow-right"></span></a>
</td>
</tr>
<tr>
<td>In</td>
<td>
{{mf($show['statistics']['period']['in'])}}
<a href="{{route('accounts.show',$account->id)}}?type=transactions&amp;show=income"><span class="glyphicon glyphicon-circle-arrow-right"></span></a>
</td>
<td>
{{mf($show['statistics']['period']['t_in'])}}
<a href="{{route('accounts.show',$account->id)}}?type=transfers&amp;show=in"><span class="glyphicon glyphicon-circle-arrow-right"></span></a>
</td>
</tr>
<tr>
<td>Difference</td>
<td>{{mf($show['statistics']['period']['diff'])}}</td>
<td>{{mf($show['statistics']['period']['t_diff'])}}</td>
</tr>
</table>
<div class="panel panel-default">
<div class="panel-heading">
Summary
</div>
<div class="panel-body">
<table class="table table-striped table-condensed">
<tr>
<th></th>
<th>Expense / income</th>
<th>Transfers</th>
</tr>
<tr>
<td>Out</td>
<td>
{{mf($show['statistics']['period']['out'])}}
<a href="{{route('accounts.show',$account->id)}}?type=transactions&amp;show=expenses"><span class="glyphicon glyphicon-circle-arrow-right"></span></a>
</td>
<td>
{{mf($show['statistics']['period']['t_out'])}}
<a href="{{route('accounts.show',$account->id)}}?type=transfers&amp;show=out"><span class="glyphicon glyphicon-circle-arrow-right"></span></a>
</td>
</tr>
<tr>
<td>In</td>
<td>
{{mf($show['statistics']['period']['in'])}}
<a href="{{route('accounts.show',$account->id)}}?type=transactions&amp;show=income"><span class="glyphicon glyphicon-circle-arrow-right"></span></a>
</td>
<td>
{{mf($show['statistics']['period']['t_in'])}}
<a href="{{route('accounts.show',$account->id)}}?type=transfers&amp;show=in"><span class="glyphicon glyphicon-circle-arrow-right"></span></a>
</td>
</tr>
<tr>
<td>Difference</td>
<td>{{mf($show['statistics']['period']['diff'])}}</td>
<td>{{mf($show['statistics']['period']['t_diff'])}}</td>
</tr>
</table>
</div>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-12">
<table class="table table-striped table-condensed">
@if(count($show['statistics']['accounts']) > 0)
<tr>
<td style="width:30%;">Related accounts</td>
<td>
@foreach($show['statistics']['accounts'] as $acct)
<a href="{{route('accounts.show',$acct->id)}}" class="btn btn-default btn-xs">{{{$acct->name}}}</a>
@endforeach
</td>
</tr>
@endif
@if(isset($show['statistics']['Category']) && count($show['statistics']['Category']) > 0)
<tr>
<td>Related categories</td>
<td>
@foreach($show['statistics']['Category'] as $cat)
<a href="{{route('categories.show',$cat->id)}}" class="btn btn-default btn-xs">{{{$cat->name}}}</a>
@endforeach
</td>
</tr>
@endif
@if(isset($show['statistics']['Budget']) && count($show['statistics']['Budget']) > 0)
<tr>
<td>Related budgets</td>
<td>
@foreach($show['statistics']['Budget'] as $bud)
<a href="{{route('budgets.show',$bud->id)}}?useSession=true" class="btn btn-default btn-xs">{{{$bud->name}}}</a>
@endforeach
</td>
</tr>
@endif
</table>
<div class="panel panel-default">
<div class="panel-heading">
Related
</div>
<div class="panel-body">
<table class="table table-striped table-condensed">
@if(count($show['statistics']['accounts']) > 0)
<tr>
<td style="width:30%;">Related accounts</td>
<td>
@foreach($show['statistics']['accounts'] as $acct)
<a href="{{route('accounts.show',$acct->id)}}" class="btn btn-default btn-xs">{{{$acct->name}}}</a>
@endforeach
</td>
</tr>
@endif
@if(isset($show['statistics']['Category']) && count($show['statistics']['Category']) > 0)
<tr>
<td>Related categories</td>
<td>
@foreach($show['statistics']['Category'] as $cat)
<a href="{{route('categories.show',$cat->id)}}" class="btn btn-default btn-xs">{{{$cat->name}}}</a>
@endforeach
</td>
</tr>
@endif
@if(isset($show['statistics']['Budget']) && count($show['statistics']['Budget']) > 0)
<tr>
<td>Related budgets</td>
<td>
@foreach($show['statistics']['Budget'] as $bud)
<a href="{{route('budgets.show',$bud->id)}}?useSession=true" class="btn btn-default btn-xs">{{{$bud->name}}}</a>
@endforeach
</td>
</tr>
@endif
</table>
</div>
</div>
</div>
</div>

View File

@ -63,18 +63,7 @@
</div>
<div class="col-lg-4 col-md-6 col-sm-12">
<!-- time based navigation -->
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-clock-o fa-fw"></i>
{{{\Session::get('period')}}}
</div>
<div class="panel-body">
<div class="btn-group btn-group-sm btn-group-justified">
<a class="btn btn-default" href="{{route('sessionPrev')}}"><i class="fa fa-arrow-left"></i> {{{\Session::get('prev')}}}</a>
<a class="btn btn-default" href="{{route('sessionNext')}}">{{{\Session::get('next')}}} <i class="fa fa-arrow-right"></i></a>
</div>
</div>
</div>
@include('partials.date_nav')
<!-- TRANSACTIONS -->
@foreach($transactions as $data)

View File

@ -96,18 +96,25 @@
@endif
@endforeach
@if(isset($sum) && $sum == true)
@if($expenses != 0)
<tr>
<td colspan="4">Expenses:</td>
<td colspan="4">{{mf($expenses)}}</td>
</tr>
@endif
@if($incomes != 0)
<tr>
<td colspan="4">Incomes:</td>
<td colspan="4">{{mf($incomes)}}</td>
</tr>
@endif
@if($transfers != 0)
<tr>
<td colspan="4">Transfers:</td>
<td colspan="4" class="text-info">{{mf($transfers,false)}}</td>
</tr>
@endif
@endif
</table>

View File

@ -1,52 +1,12 @@
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<form role="form" method="GET" action="{{Request::url()}}">
<?php $r = Session::get('range', '1M'); ?>
<div class="row">
<div class="col-lg-2 col-md-2 col-sm-2">
<button name="action" value="prev" class="btn btn-default @if($r=='1D') btn-info @endif btn-sm"
type="submit">&laquo; Previous {{Config::get('firefly.range_to_text.'.$r)}}
</button>
</div>
<div class="col-lg-3 col-md-3 col-sm-3">
<div class="btn-group btn-group-sm">
<button name="range" value="1D" class="btn btn-default @if($r=='1D') btn-info @endif btn-sm"
type="submit">1D
</button>
<button name="range" value="1W" class="btn btn-default @if($r=='1W') btn-info @endif btn-sm"
type="submit">1W
</button>
<button name="range" value="1M" class="btn btn-default @if($r=='1M') btn-info @endif btn-sm"
type="submit">1M
</button>
<button name="range" value="3M" class="btn btn-default @if($r=='3M') btn-info @endif btn-sm"
type="submit">3M
</button>
<button name="range" value="6M" class="btn btn-default @if($r=='6M') btn-info @endif btn-sm"
type="submit">6M
</button>
</div>
</div>
<div class="col-lg-2 col-md-2 col-sm-2">
<input value="{{Session::get('start')->format('Y-m-d')}}" name="start" type="date"
class="form-control input-sm">
</div>
<div class="col-lg-2 col-md-2 col-sm-2">
<input value="{{Session::get('end')->format('Y-m-d')}}" name="end" type="date"
class="form-control input-sm">
</div>
<div class="col-lg-1 col-md-1 col-sm-1">
<button class="btn btn-default btn-sm @if($r=='custom') btn-info @endif" type="submit" name="range"
value="custom">Custom
</button>
</div>
<div class="col-lg-2 col-md-2 col-sm-2" style="text-align:right;">
<button name="action" value="next" class="btn btn-default @if($r=='1D') btn-info @endif btn-sm"
type="submit">&raquo; Next {{Config::get('firefly.range_to_text.'.$r)}}
</button>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-clock-o fa-fw"></i>
{{{\Session::get('period')}}}
</div>
<div class="panel-body">
<div class="btn-group btn-group-sm btn-group-justified">
<a class="btn btn-default" href="{{route('sessionPrev')}}"><i class="fa fa-arrow-left"></i> {{{\Session::get('prev')}}}</a>
<a class="btn btn-default" href="{{route('sessionNext')}}">{{{\Session::get('next')}}} <i class="fa fa-arrow-right"></i></a>
</div>
</form>
</div>
</div>

View File

@ -15,6 +15,7 @@
<th>Amount (&euro;)</th>
<th>From</th>
<th>To</th>
<th>Budget / category</th>
<th>ID</th>
</tr>
</thead>

View File

@ -81,6 +81,23 @@ $(document).ready(function () {
return '<a href="' + data.url + '" title="' + data.name + '">' + data.name + '</a>';
}
},
{
name: 'components',
data: 'components',
searchable: true,
sortable: false,
title: '',
render: function (data, type, full, meta) {
var html = '';
if (data.budget_id > 0) {
html += '<a href="' + data.budget_url + '" title="' + data.budget_name + '"><i class="fa fa-tasks fa-fw"></i></a> ';
}
if (data.category_id > 0) {
html += '<a href="' + data.category_url + '" title="' + data.category_name + '"><i class="fa fa-bar-chart fa-fw"></i></a> ';
}
return html;
}
},
{
name: 'id',
data: 'id',