Quick & dirty fixes for the piggy bank controller.

This commit is contained in:
James Cole 2014-09-28 09:01:57 +02:00
parent 7d2627515f
commit 1b3d345fbd
2 changed files with 24 additions and 24 deletions

View File

@ -94,7 +94,7 @@ class PiggybankController extends BaseController
View::share('subTitle', 'Delete "' . $piggyBank->name . '"');
if ($piggyBank->repeats == 1) {
View::share('title', 'Repeated expenses');
View::share('mainTitleIcon', 'fa-rotate-right')
View::share('mainTitleIcon', 'fa-rotate-right');
} else {
View::share('title', 'Piggy banks');
View::share('mainTitleIcon', 'fa-sort-amount-asc');
@ -196,8 +196,13 @@ class PiggybankController extends BaseController
}
break;
}
if($piggyBank->repeats == 1) {
$route = 'piggybanks.index.repeated';
return Redirect::route('piggybanks.index');
} else {
$route = 'piggybanks.index.piggybanks';
}
return Redirect::route($route);
}
/**
@ -219,7 +224,8 @@ class PiggybankController extends BaseController
$account = $piggybank->account;
$id = $account->id;
if (!isset($accounts[$id])) {
$accounts[$id] = ['account' => $account, 'left' => $this->_repository->leftOnAccount($account)];
$account->leftOnAccount = $this->_repository->leftOnAccount($account);
$accounts[$id] = ['account' => $account, 'left' => $this->_repository->leftOnAccount($account)];
}
}
@ -268,7 +274,8 @@ class PiggybankController extends BaseController
$account = $piggybank->account;
$id = $account->id;
if (!isset($accounts[$id])) {
$accounts[$id] = ['account' => $account, 'left' => $this->_repository->leftOnAccount($account)];
$account->leftOnAccount = $this->_repository->leftOnAccount($account);
$accounts[$id] = ['account' => $account, 'left' => $this->_repository->leftOnAccount($account)];
}
}
@ -373,10 +380,19 @@ class PiggybankController extends BaseController
{
$piggyBank = $this->_repository->update($piggyBank, Input::all());
if ($piggyBank->validate()) {
Session::flash('success', 'Piggy bank "' . $piggyBank->name . '" updated.');
if ($piggyBank->repeats == 1) {
$route = 'piggybanks.index.repeated';
$message = 'Repeated expense';
} else {
$route = 'piggybanks.index.piggybanks';
$message = 'Piggy bank';
}
Session::flash('success', $message . ' "' . $piggyBank->name . '" updated.');
Event::fire('piggybanks.update', [$piggyBank]);
return Redirect::route('piggybanks.index');
return Redirect::route($route);
} else {
Session::flash('error', 'Could not update piggy bank: ' . $piggyBank->errors()->first());

View File

@ -1,28 +1,12 @@
@extends('layouts.default')
@section('content')
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-12">
<p class="lead">Save money for large expenses</p>
<p class="text-info">
Saving money is <em>hard</em>. Firefly's piggy banks can help you to save money. Simply set the amount
of money you want to save, set an optional target date and whether or not
Firefly should remind you to add money
to the piggy bank.
</p>
<p>
<a href="{{route('piggybanks.create.piggybank')}}" class="btn btn-success">Create new piggy bank</a>
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-12">
<p class="lead">Save money for repeated expenses</p>
<p class="text-info">
Taxes are due every year. Or maybe you want to save up for your yearly fireworks-binge. Buy a new smart
phone every three years. Firefly can help you organize these repeated expenses.
</p>
<p>
<a href="{{route('piggybanks.create.repeated')}}" class="btn btn-success">Create new repeated expense</a>
</p>
@ -59,7 +43,7 @@
</td>
<td style="width:40%;">
<div class="btn-group-xs btn-group">
@if($piggyBank->leftInAccount > 0)
@if($accounts[$piggyBank->account_id]['account']->leftOnAccount > 0)
<a data-toggle="modal" href="{{route('piggybanks.amount.add',$piggyBank->id)}}" data-target="#modal" class="btn btn-default"><span class="glyphicon glyphicon-plus-sign"></span> Add money</a>
@endif
@if($piggyBank->currentRelevantRep()->currentamount > 0)
@ -122,7 +106,7 @@
</td>
<td style="width:40%;">
<div class="btn-group-xs btn-group">
@if($repeated->leftInAccount > 0)
@if($accounts[$repeated->account_id]['account']->leftOnAccount > 0)
<a data-toggle="modal" href="{{route('piggybanks.amount.add',$repeated->id)}}" data-target="#modal" class="btn btn-default"><span class="glyphicon glyphicon-plus-sign"></span> Add money</a>
@endif
@if($repeated->currentRelevantRep()->currentamount > 0)