Some bugfixes and cleanup.

This commit is contained in:
Sander Dorigo 2014-11-06 20:33:37 +01:00
parent ddea7d696a
commit 44705f0e18
7 changed files with 8 additions and 345 deletions

View File

@ -382,7 +382,7 @@ class AccountController extends BaseController
if ($data['post_submit_action'] == 'create_another') {
return Redirect::route('accounts.edit', $account->id);
} else {
return Redirect::route('accounts.edit', $account->id);
return Redirect::route('accounts.index',$data['what']);
}
case 'validate_only':
$messageBags = $acct->validate($data);

View File

@ -335,12 +335,12 @@ class BudgetController extends BaseController
}
// store!
$repos->update($budget, $data);
Session::flash('success', 'Account updated!');
Session::flash('success', 'Budget updated!');
if ($data['post_submit_action'] == 'create_another') {
return Redirect::route('budgets.edit', $budget->id);
} else {
return Redirect::route('budgets.edit', $budget->id);
return Redirect::route('budgets.index');
}
case 'validate_only':
$messageBags = $repos->validate($data);

View File

@ -91,10 +91,13 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
} else {
$errors->add('name', 'Name is mandatory');
}
$validator = \Validator::make([$model], \Budget::$rules);
$validator = \Validator::make($model, \Component::$rules);
if ($validator->invalid()) {
$errors->merge($errors);
$errors->merge($validator->errors());
}
if(!$errors->has('name')) {
$successes->add('name','OK');
}

View File

@ -1,113 +0,0 @@
@extends('layouts.default')
@section('content')
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<p class="lead">Use budgets to organize and limit your expenses.</p>
<p class="text-info">
Budgets are groups of expenses that reappear every [period]*. Examples could be "groceries", "bills" or
"drinks with friends". The table below lists all of the budgets you have, if any.
<a href="http://dictionary.reference.com/browse/budget">By definition</a>, budgets are an estimated amount
of money, ie. 400,-. Such an estimation can change over time but <em>should</em> always be set. Budgets
without an actual budget are fairly pointless.
</p>
<p class="text-info">
Use this page to create or change budgets and the estimated amount of money you think is wise. Pages further ahead
will explain what an "envelope" is in the context of budgeting.
</p>
<p class="text-info">
* <small>Every month, week, year, etc.</small>
</p>
<div class="btn-group">
<a class="btn btn-default" href ="{{route('budgets.create')}}?from=budget"><span class="glyphicon glyphicon-plus-sign"></span> Create a new budget</a>
<a class="btn btn-default" href ="{{route('budgets.limits.create')}}?from=budget"><span class="glyphicon glyphicon-plus-sign"></span> Create a new envelope</a>
</div>
</p>
</div>
</div><!-- TODO cleanup to match new theme & form -->
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<table class="table table-bordered table-striped">
<tr>
<th>Budget</th>
<th>Current envelope(s)</th>
<th>Update budget</th>
</tr>
@foreach($budgets as $budget)
<tr>
<td>
<a href="{{route('budgets.show',$budget->id)}}">{{{$budget->name}}}</a>
</td>
<td>
<div class="row">
<div class="col-sm-2">
<small>Envelope</small>
</div>
<div class="col-sm-2">
<small>Left</small>
</div>
</div>
@foreach($budget->limits as $limit)
@foreach($limit->limitrepetitions as $index => $rep)
<div class="row">
<div class="col-sm-2">
<span class="label label-primary">
<span class="glyphicon glyphicon-envelope"></span>
{{mf($rep->amount,false)}}</span>
</div>
<div class="col-sm-2">
@if($rep->leftInRepetition() < 0)
<span class="label label-danger">
<span class="glyphicon glyphicon-envelope"></span>
{{mf($rep->leftInRepetition(),false)}}</span>
@else
<span class="label label-success">
<span class="glyphicon glyphicon-envelope"></span>
{{mf($rep->leftInRepetition(),false)}}</span>
@endif
</div>
<div class="col-sm-3">
<small>
<a href="{{route('budgets.show',$budget->id,$rep->id)}}">
{{$rep->periodShow()}}
</a>
</small>
</div>
@if($limit->repeats == 1)
<div class="col-sm-2">
<span class="label label-warning">auto repeats</span>
</div>
@endif
<div class="col-sm-2 @if($limit->repeats == 0) col-sm-offset-2 @endif">
<div class="btn-group btn-group-xs">
<a href="{{route('budgets.limits.edit',$limit->id)}}?from=budget" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span></a>
@if($limit->repeats == 0 || ($limit->repeats == 1 && $index == 0))
<a href="{{route('budgets.limits.delete',$limit->id)}}?from=budget" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span></a>
@endif
</div>
</div>
</div>
@endforeach
@endforeach
<p style="margin-top:5px;">
<a href="{{route('budgets.limits.create',$budget->id)}}?from=budget" class="btn btn-default btn-xs"><span
class="glyphicon-plus-sign glyphicon"></span> Add another envelope</a>
</p>
</td>
<td>
<div class="btn-group btn-group-sm">
<a href="{{route('budgets.edit',$budget->id)}}?from=budget" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span></a>
<a href="{{route('budgets.delete',$budget->id)}}?from=budget" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span></a>
</div>
</td>
</tr>
@endforeach
</table>
</div>
</div>
@stop

View File

@ -1,87 +0,0 @@
@extends('layouts.default')
@section('content')
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<p class="lead">Use budgets to organize and limit your expenses.</p>
<p class="text-info">
Budgets are groups of expenses that reappear every [period]*. Examples could be "groceries", "bills" or
"drinks with friends". The table below lists all of the budgets you have, if any.
<a href="http://dictionary.reference.com/browse/budget">By definition</a>, budgets are an estimated amount
of money, ie. 400,-. Such an estimation can change over time but <em>should</em> always be set. Budgets
without an actual budget are fairly pointless.
</p>
<p class="text-info">
Use this page to create or change budgets and the estimated amount of money you think is wise. Pages further ahead
will explain what an "envelope" is in the context of budgeting.
</p>
<p class="text-info">
* <small>Every month, week, year, etc.</small>
</p>
<div class="btn-group">
<a class="btn btn-default" href ="{{route('budgets.create')}}?from=date"><span class="glyphicon glyphicon-plus-sign"></span> Create a new budget</a>
<a class="btn btn-default" href ="{{route('budgets.limits.create')}}?from=date"><span class="glyphicon glyphicon-plus-sign"></span> Create a new envelope</a>
</div>
</div>
</div><!-- TODO cleanup to match new theme & form -->
<!-- count = zero! -->
@foreach($budgets as $date => $entry)
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<h3><a href="{{route('transactions.index')}}?startdate={{$entry['start']->format('Y-m-d')}}&amp;enddate={{$entry['end']->format('Y-m-d')}}">{{$entry['date']}}</a>
<a class="btn btn-default btn-xs" href ="{{route('budgets.limits.create')}}?startdate={{$entry['start']->format('Y-m-d')}}"><span class="glyphicon glyphicon-plus-sign"></span> Create a new envelope for {{$entry['date']}}</a>
</h3>
<table class="table table-bordered table-striped">
<tr>
<th colspan="2" style="width:45%;">Budget</th>
<th style="width:15%;">Envelope</th>
<th style="width:15%;">Left</th>
<th>&nbsp;</th>
</tr>
@foreach($entry['limitrepetitions'] as $index => $repetition)
<tr>
<td>
<div class="btn-group">
<a title="Edit budget {{{$repetition->limit->budget->name}}}" href="{{route('budgets.edit',$repetition->limit->budget->id)}}?from=date" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil"></span></a>
<a title="Delete budget {{{$repetition->limit->budget->name}}}" href="{{route('budgets.delete',$repetition->limit->budget->id)}}?from=date" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span></a>
</div>
</td>
<td>
<a href="{{route('budgets.show',[$repetition->limit->budget->id,$repetition->id])}}">
{{{$repetition->limit->budget->name}}}
</a>
</td>
<td>
<span class="label label-primary">
<span class="glyphicon glyphicon-envelope"></span> {{mf($repetition->amount,false)}}</span>
</td>
<td>
@if($repetition->left < 0)
<span class="label label-danger">
<span class="glyphicon glyphicon-envelope"></span>
{{mf($repetition->left,false)}}</span>
@else
<span class="label label-success">
<span class="glyphicon glyphicon-envelope"></span>
{{mf($repetition->left,false)}}</span>
@endif
</td>
<td>
<div class="btn-group">
<a title="Edit envelope for {{{$repetition->limit->budget->name}}} in {{$entry['date']}}" href="{{route('budgets.limits.edit',$repetition->limit->id)}}?from=date" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil"></span></a>
<a title="Delete envelope for {{{$repetition->limit->budget->name}}} in {{$entry['date']}}" href="{{route('budgets.limits.delete',$repetition->limit->id)}}?from=date" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span></a>
</div>
@if($repetition->limit->repeats == 1)
<span class="label label-warning">auto repeats</span>
@endif
</td>
</tr>
@endforeach
</table>
</div>
</div>
@endforeach
@stop

View File

@ -1,30 +0,0 @@
@extends('layouts.default')
@section('content')
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
@if($view == 'session')
<!-- warning for session date -->
<p class="bg-primary" style="padding:15px;">
This view is filtered to only show transactions between {{Session::get('start')->format('d M Y')}}
and {{Session::get('end')->format('d M Y')}}.
</p>
@endif
</div><!-- TODO cleanup to match new theme & form -->
</div>
@if($transactions->count() > 0)
<div class="row">
<div class="col-lg-12">
@include('lists.transactions',['journals' => $transactions,'sum' => true])
</div>
</div>
@else
<div class="row">
<div class="col-lg-12">
<h4>{{$repetition['date']}}
</h4>
<p><em>No transactions</em></p>
</div>
</div>
@endif
@stop

View File

@ -1,119 +1,9 @@
@extends('layouts.default')
@section('content')
<div class="row"><!-- TODO cleanup to match new theme & form -->
<div class="col-lg-12 col-md-12 col-sm-12">
<p class="lead">Budgets can help you cut back on spending.</p>
@if($view == 1)
<!-- warning for selected limit -->
<p class="bg-primary" style="padding:15px;">
This view is filtered to show only the envelope from
{{{$repetitions[0]['limitrepetition']->periodShow()}}},
which contains {{mf($repetitions[0]['limit']->amount,false)}}.
</p>
@endif
@if($view == 2)
<!-- warning for non-caught only -->
<p class="bg-primary" style="padding:15px;">
This view is filtered to show transactions not in an envelope only.
</p>
@endif
@if($view == 3)
<!-- warning for session date -->
<p class="bg-primary" style="padding:15px;">
This view is filtered to only show transactions between {{Session::get('start')->format('d M Y')}}
and {{Session::get('end')->format('d M Y')}}.
</p>
@endif
@if($view != 4)
<p class="bg-info" style="padding:15px;">
<a class="btn btn-default btn-sm" href="{{route('budgets.show',$budget->id)}}">Reset the filter</a>
</p>
@endif
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<div id="chart"><img src="http://placehold.it/650x300" title="Placeholder" alt="" /></div>
@if($view == 1)
<div id="instr" data-type="envelope" data-envelope="{{$repetitions[0]['limitrepetition']->id}}"></div>
@endif
@if($view == 2)
<div id="instr" data-type="no_envelope" data-budget="{{$budget->id}}"></div>
@endif
@if($view == 3)
<div id="instr" data-type="session" data-budget="{{$budget->id}}"></div>
@endif
@if($view == 4)
<div id="instr" data-type="default" data-budget="{{$budget->id}}"></div>
@endif
</div>
</div>
@foreach($repetitions as $repetition)
@if(isset($repetition['journals']) && count($repetition['journals']) > 0)
<div class="row">
<div class="col-lg-12">
@if($repetition['paginated'] == true)
<h4>
<a href="{{route('budgets.show',$budget->id)}}?noenvelope=true">
{{$repetition['date']}}</a> <small>paginated</small></h4>
@else
<h4>
<a href="{{route('budgets.show',$budget->id,$repetition['limitrepetition']->id)}}">
{{$repetition['date']}}
</a>
</h4>
<small>{{mf($repetition['limit']->amount,false)}}
(left: {{mf($repetition['limitrepetition']->leftInRepetition(),false)}})</small>
@endif
</h4>
@if($repetition['paginated'] == true)
@include('paginated.transactions',['journals' => $repetition['journals'],'highlight' => $highlight])
@else
@include('lists.transactions',['journals' => $repetition['journals'],'sum' => true,'highlight' => $highlight])
@endif
</div>
</div>
@else
<div class="row">
<div class="col-lg-12">
<h4>{{$repetition['date']}}
</h4>
<p><em>No transactions</em></p>
</div>
</div>
@endif
@endforeach
@stop
@section('scripts')
@if($view == 1)
{{HTML::script('assets/javascript/firefly/budgets/limit.js')}}
@endif
@if($view == 2)
{{HTML::script('assets/javascript/firefly/budgets/nolimit.js')}}
@endif
@if($view == 3)
{{HTML::script('assets/javascript/firefly/budgets/session.js')}}
@endif
@if($view == 4)
{{HTML::script('assets/javascript/firefly/budgets/default.js')}}
@endif
@stop