More views and options for limits [skip ci]

This commit is contained in:
James Cole
2014-07-24 06:47:28 +02:00
parent 30553ed7a3
commit 36901359d0
13 changed files with 280 additions and 82 deletions

View File

@@ -1,9 +1,9 @@
<?php <?php
use Firefly\Helper\Preferences\PreferencesHelperInterface as PHI; use Firefly\Helper\Preferences\PreferencesHelperInterface as PHI;
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
use Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface as TJRI;
use Firefly\Helper\Toolkit\ToolkitInterface as Toolkit; use Firefly\Helper\Toolkit\ToolkitInterface as Toolkit;
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
use Firefly\Storage\Budget\BudgetRepositoryInterface as BRI; use Firefly\Storage\Budget\BudgetRepositoryInterface as BRI;
use Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface as TJRI;
/** /**
* Class HomeController * Class HomeController
@@ -17,8 +17,8 @@ class HomeController extends BaseController
protected $_tk; protected $_tk;
/** /**
* @param ARI $accounts * @param ARI $accounts
* @param PHI $preferences * @param PHI $preferences
* @param TJRI $journal * @param TJRI $journal
*/ */
public function __construct(ARI $accounts, PHI $preferences, TJRI $journal, Toolkit $toolkit, BRI $budgets) public function __construct(ARI $accounts, PHI $preferences, TJRI $journal, Toolkit $toolkit, BRI $budgets)
@@ -40,6 +40,7 @@ class HomeController extends BaseController
{ {
// count, maybe we need some introducing text to show: // count, maybe we need some introducing text to show:
$count = $this->_accounts->count(); $count = $this->_accounts->count();
list($start, $end) = $this->_tk->getDateRange();
// get the preference for the home accounts to show: // get the preference for the home accounts to show:
@@ -53,11 +54,11 @@ class HomeController extends BaseController
// get the budgets for this period: // get the budgets for this period:
$dates = $this->_tk->getDateRange(); $dates = $this->_tk->getDateRange();
$budgets = $this->_budgets->getWithRepetitionsInPeriod($dates[0],\Session::get('range')); $budgets = $this->_budgets->getWithRepetitionsInPeriod($dates[0], \Session::get('range'));
$transactions = []; $transactions = [];
foreach ($accounts as $account) { foreach ($accounts as $account) {
$transactions[] = [$this->_journal->getByAccount($account, 15), $account]; $transactions[] = [$this->_journal->getByAccountInDateRange($account, 15, $start, $end), $account];
} }
if (count($transactions) % 2 == 0) { if (count($transactions) % 2 == 0) {
@@ -68,6 +69,8 @@ class HomeController extends BaseController
$transactions = array_chunk($transactions, 3); $transactions = array_chunk($transactions, 3);
} }
// build the home screen: // build the home screen:
return View::make('index')->with('count', $count)->with('transactions', $transactions)->with('budgets',$budgets); return View::make('index')->with('count', $count)->with('transactions', $transactions)->with(
'budgets', $budgets
);
} }
} }

View File

@@ -35,6 +35,51 @@ class LimitController extends BaseController
); );
} }
public function edit($limitId = null)
{
$limit = $this->_limits->find($limitId);
$budgets = $this->_budgets->getAsSelectList();
$periods = [
'weekly' => 'A week',
'monthly' => 'A month',
'quarterly' => 'A quarter',
'half-year' => 'Six months',
'yearly' => 'A year',
];
if ($limit) {
return View::make('limits.edit')->with('limit', $limit)->with('budgets', $budgets)->
with('periods',$periods);
}
}
public function update($limitId = null)
{
/** @var \Limit $limit */
$limit = $this->_limits->find($limitId);
if($limit) {
$limit->startdate = new \Carbon\Carbon(Input::get('date'));
$limit->repeat_freq = Input::get('period');
$limit->repeats = !is_null(Input::get('repeats')) && Input::get('repeats') == '1' ? 1 : 0;
$limit->amount = floatval(Input::get('amount'));
if(!$limit->save()) {
Session::flash('error','Could not save new limit: ' . $limit->errors()->first());
return Redirect::route('budgets.limits.edit',$limit->id)->withInput();
} else {
Session::flash('success','Limit saved!');
foreach($limit->limitrepetitions()->get() as $rep) {
$rep->delete();
}
return Redirect::route('budgets.index');
}
}
return View::make('error')->with('message','No limit!');
}
public function store() public function store()
{ {
// find a limit with these properties, as we might already have one: // find a limit with these properties, as we might already have one:

View File

@@ -20,7 +20,6 @@ class Toolkit implements ToolkitInterface
*/ */
public function getDateRange() public function getDateRange()
{ {
\Log::debug('Should be mocked!');
$preferences = \App::make('Firefly\Helper\Preferences\PreferencesHelperInterface'); $preferences = \App::make('Firefly\Helper\Preferences\PreferencesHelperInterface');
$viewRange = $preferences->get('viewRange', '1M'); $viewRange = $preferences->get('viewRange', '1M');

View File

@@ -34,13 +34,31 @@ class EloquentBudgetRepository implements BudgetRepositoryInterface
// $q->where('startdate',$date->format('Y-m-d')); // $q->where('startdate',$date->format('Y-m-d'));
}, 'limits.limitrepetitions' => function ($q) use ($date) { }, 'limits.limitrepetitions' => function ($q) use ($date) {
$q->orderBy('limit_repetitions.startdate', 'ASC'); $q->orderBy('limit_repetitions.startdate', 'ASC');
$q->where('startdate',$date->format('Y-m-d')); $q->where('startdate', $date->format('Y-m-d'));
}] }]
)->orderBy('name', 'ASC')->get(); )->orderBy('name', 'ASC')->get();
foreach ($set as $budget) { foreach ($set as $budget) {
$budget->count = 0; $budget->count = 0;
foreach($budget->limits as $limit) { foreach ($budget->limits as $limit) {
/** @var $rep \LimitRepetition */
foreach ($limit->limitrepetitions as $rep) {
$rep->left = $rep->left();
// overspent:
if ($rep->left < 0) {
$rep->spent = ($rep->left * -1) + $rep->amount;
$rep->overspent = $rep->left * -1;
$total = $rep->spent + $rep->overspent;
$rep->spent_pct = round(($rep->spent / $total) * 100);
$rep->overspent_pct = 100 - $rep->spent_pct;
} else {
$rep->spent = $rep->amount - $rep->left;
$rep->spent_pct = round(($rep->spent / $rep->amount) * 100);
$rep->left_pct = 100 - $rep->spent_pct;
}
}
$budget->count += count($limit->limitrepetitions); $budget->count += count($limit->limitrepetitions);
} }
} }

View File

@@ -14,7 +14,9 @@ class EloquentLimitRepository implements LimitRepositoryInterface
public function find($limitId) public function find($limitId)
{ {
return \Limit::with('limitrepetitions')->where('limits.id', $limitId)->leftJoin('components', 'components.id', '=', 'limits.component_id') return \Limit::with('limitrepetitions')->where('limits.id', $limitId)->leftJoin(
'components', 'components.id', '=', 'limits.component_id'
)
->where('components.user_id', \Auth::user()->id)->first(['limits.*']); ->where('components.user_id', \Auth::user()->id)->first(['limits.*']);
} }

View File

@@ -167,7 +167,7 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
} }
public function getByAccount(\Account $account, $count = 25) public function getByAccountInDateRange(\Account $account, $count = 25,\Carbon\Carbon $start, \Carbon\Carbon $end)
{ {
$accountID = $account->id; $accountID = $account->id;
$query = \Auth::user()->transactionjournals()->with( $query = \Auth::user()->transactionjournals()->with(
@@ -180,6 +180,8 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id') ->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->where('accounts.id', $accountID) ->where('accounts.id', $accountID)
->where('date','>=',$start->format('Y-m-d'))
->where('date','<=',$end->format('Y-m-d'))
->orderBy('transaction_journals.date', 'DESC') ->orderBy('transaction_journals.date', 'DESC')
->orderBy('transaction_journals.id', 'DESC') ->orderBy('transaction_journals.id', 'DESC')
->take($count) ->take($count)

View File

@@ -11,7 +11,7 @@ interface TransactionJournalRepositoryInterface
public function find($journalId); public function find($journalId);
public function getByAccount(\Account $account, $count = 25); public function getByAccountInDateRange(\Account $account, $count = 25,\Carbon\Carbon $start, \Carbon\Carbon $end);
public function getByAccountAndDate(\Account $account, \Carbon\Carbon $date); public function getByAccountAndDate(\Account $account, \Carbon\Carbon $date);

View File

@@ -25,23 +25,11 @@ class EloquentLimitTrigger
// get todays date. // get todays date.
foreach ($budgets as $budget) { foreach ($budgets as $budget) {
\Log::debug(
'Now checking the ' . count($budget->limits) . ' limits in ' . $budget->name . ' (#' . $budget->id
. ').'
);
// loop limits: // loop limits:
foreach ($budget->limits as $limit) { foreach ($budget->limits as $limit) {
\Log::debug(
'Now at limit #' . $limit->id . ', which has ' . count($limit->limitrepetitions) . ' reps already'
);
\Log::debug(
'More: Amount: ' . $limit->amount . ', repeat: ' . $limit->repeats . ', freq: '
. $limit->repeat_freq
);
// should have a repetition, at the very least // should have a repetition, at the very least
// for the period it starts (startdate and onwards). // for the period it starts (startdate and onwards).
if (count($limit->limitrepetitions) == 0) { if (count($limit->limitrepetitions) == 0) {
\Log::debug('No reps, create one.');
// create such a repetition: // create such a repetition:
$repetition = new \LimitRepetition(); $repetition = new \LimitRepetition();
$start = clone $limit->startdate; $start = clone $limit->startdate;
@@ -73,7 +61,6 @@ class EloquentLimitTrigger
$repetition->enddate = $end; $repetition->enddate = $end;
$repetition->amount = $limit->amount; $repetition->amount = $limit->amount;
$repetition->limit()->associate($limit); $repetition->limit()->associate($limit);
\Log::debug('Created single rep for non-repeating limit, from ' . $start . ' until ' . $end);
try { try {
$repetition->save(); $repetition->save();
@@ -163,7 +150,6 @@ class EloquentLimitTrigger
} }
} }
} }
\Log::debug('Done checking the budget!');
} }
} }

View File

@@ -34,6 +34,7 @@ Route::group(['before' => 'auth'], function () {
// limit controller: // limit controller:
Route::get('/budgets/limits/create/{id?}',['uses' => 'LimitController@create','as' => 'budgets.limits.create']); Route::get('/budgets/limits/create/{id?}',['uses' => 'LimitController@create','as' => 'budgets.limits.create']);
Route::get('/budgets/limits/delete/{id?}',['uses' => 'LimitController@delete','as' => 'budgets.limits.delete']); Route::get('/budgets/limits/delete/{id?}',['uses' => 'LimitController@delete','as' => 'budgets.limits.delete']);
Route::get('/budgets/limits/edit/{id?}',['uses' => 'LimitController@edit','as' => 'budgets.limits.edit']);
// JSON controller: // JSON controller:
Route::get('/json/beneficiaries', ['uses' => 'JsonController@beneficiaries', 'as' => 'json.beneficiaries']); Route::get('/json/beneficiaries', ['uses' => 'JsonController@beneficiaries', 'as' => 'json.beneficiaries']);
@@ -41,7 +42,7 @@ Route::group(['before' => 'auth'], function () {
// transaction controller: // transaction controller:
Route::get('/transactions/create/{what}', ['uses' => 'TransactionController@create', 'as' => 'transactions.create'])->where(['what' => 'withdrawal|deposit|transfer']); Route::get('/transactions/create/{what}', ['uses' => 'TransactionController@create', 'as' => 'transactions.create'])->where(['what' => 'withdrawal|deposit|transfer']);
Route::get('/transaction/show/{id}',['uses' => 'TransactionController@show','as' => 'transactions.show']); Route::get('/transaction/show/{id}',['uses' => 'TransactionController@show','as' => 'transactions.show']);
Route::get('/transaction/edit/{id}',['uses' => 'TransactionController@edit','as' => 'transactions.edit']); Route::get('/transaction/edit/{id}',['uses' => 'TransactionController@edit','as' => 'transactions.edit']);
Route::get('/transaction/delete/{id}',['uses' => 'TransactionController@delete','as' => 'transactions.delete']); Route::get('/transaction/delete/{id}',['uses' => 'TransactionController@delete','as' => 'transactions.delete']);
@@ -69,8 +70,9 @@ Route::group(['before' => 'csrf|auth'], function () {
Route::get('/accounts/store', ['uses' => 'AccountController@store', 'as' => 'accounts.store']); Route::get('/accounts/store', ['uses' => 'AccountController@store', 'as' => 'accounts.store']);
// limit controller: // limit controller:
Route::post('/limits/store', ['uses' => 'LimitController@store', 'as' => 'budgets.limits.store']); Route::post('/budgets/limits/store', ['uses' => 'LimitController@store', 'as' => 'budgets.limits.store']);
Route::post('/budgets/limits/destroy/{id?}',['uses' => 'LimitController@destroy','as' => 'budgets.limits.destroy']); Route::post('/budgets/limits/destroy/{id?}',['uses' => 'LimitController@destroy','as' => 'budgets.limits.destroy']);
Route::post('/budgets/limits/update/{id?}',['uses' => 'LimitController@update','as' => 'budgets.limits.update']);
// transaction controller: // transaction controller:
Route::post('/transactions/store/{what}', ['uses' => 'TransactionController@store', 'as' => 'transactions.store']) Route::post('/transactions/store/{what}', ['uses' => 'TransactionController@store', 'as' => 'transactions.store'])

View File

@@ -13,6 +13,7 @@
<tr> <tr>
<td> <td>
<a href="{{route('budgets.show',$rep->limit->budget->id)}}">{{{$rep->limit->budget->name}}}</a> <a href="{{route('budgets.show',$rep->limit->budget->id)}}">{{{$rep->limit->budget->name}}}</a>
</td> </td>
<td> <td>
<span class="label label-primary"> <span class="label label-primary">
@@ -30,10 +31,15 @@
@endif @endif
</td> </td>
<td> <td>
<a href="{{route('budgets.limits.delete',$rep->limit->id)}}" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span></a> <div class="btn-group">
<a href="{{route('budgets.limits.edit',$rep->limit->id)}}" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil"></span></a>
<a href="{{route('budgets.limits.delete',$rep->limit->id)}}" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span></a>
</div>
@if($rep->limit->repeats == 1) @if($rep->limit->repeats == 1)
<span class="label label-warning">auto repeats</span> <span class="label label-warning">auto repeats</span>
@endif @endif
<a href="{{route('budgets.limits.create',$rep->limit->budget->id)}}" class="btn btn-default btn-xs"><span
class="glyphicon-plus-sign glyphicon"></span> Add another limit</a>
</td> </td>
</tr> </tr>
@endforeach @endforeach

View File

@@ -9,20 +9,34 @@
</h1> </h1>
@if($count > 0) @if($count > 0)
<form role="form" class="form-horizontal"> <form role="form" class="form-horizontal">
<div class="input-group"> <div class="input-group">
<?php $r = Session::get('range','1M');?> <?php $r = Session::get('range', '1M'); ?>
<span class="input-group-btn input-group-btn"> <span class="input-group-btn input-group-btn">
<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="1D" class="btn btn-default @if($r=='1D') btn-info @endif btn-sm"
<button name="range" value="1W" class="btn btn-default @if($r=='1W') btn-info @endif btn-sm" type="submit">1W</button> type="submit">1D
<button name="range" value="1M" class="btn btn-default @if($r=='1M') btn-info @endif btn-sm" type="submit">1M</button> </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="1W" class="btn btn-default @if($r=='1W') btn-info @endif btn-sm"
<button name="range" value="6M" class="btn btn-default @if($r=='6M') btn-info @endif btn-sm" type="submit">6M</button> 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>
</span> </span>
<input value="{{Session::get('start')->format('Y-m-d')}}" name="start" type="date" style="width:15%;border-right:0;" class="form-control input-sm"> <input value="{{Session::get('start')->format('Y-m-d')}}" name="start" type="date"
<input value="{{Session::get('end')->format('Y-m-d')}}" name="end" type="date" style="width:15%;border-right:0;" class="form-control input-sm"> style="width:15%;border-right:0;" class="form-control input-sm">
<button class="btn btn-default btn-sm @if($r=='custom') btn-info @endif" type="submit" name="range" value="custom">Custom</button> <input value="{{Session::get('end')->format('Y-m-d')}}" name="end" type="date"
</div> style="width:15%;border-right:0;" class="form-control input-sm">
<button class="btn btn-default btn-sm @if($r=='custom') btn-info @endif" type="submit" name="range"
value="custom">Custom
</button>
</div>
</form> </form>
@endif @endif
@@ -32,6 +46,7 @@
<div class="row"> <div class="row">
<div class="col-lg-12 col-md-12 col-sm-12"> <div class="col-lg-12 col-md-12 col-sm-12">
<p class="lead">Welcome to Firefly III.</p> <p class="lead">Welcome to Firefly III.</p>
<p> <p>
To get get started, choose below: To get get started, choose below:
</p> </p>
@@ -41,18 +56,19 @@
<div class="row"> <div class="row">
<div class="col-lg-6 col-md-6 col-sm-12"> <div class="col-lg-6 col-md-6 col-sm-12">
<h2><a href="{{route('migrate')}}">Migrate from Firefly II</a></h2> <h2><a href="{{route('migrate')}}">Migrate from Firefly II</a></h2>
<p> <p>
Use this option if you have a JSON file from your current Firefly II installation. Use this option if you have a JSON file from your current Firefly II installation.
</p> </p>
</div> </div>
<div class="col-lg-6 col-md-6 col-sm-12"> <div class="col-lg-6 col-md-6 col-sm-12">
<h2><a href="#">Start from scratch</a></h2> <h2><a href="#">Start from scratch</a></h2>
<p> <p>
Use this option if you are new to Firefly (III). Use this option if you are new to Firefly (III).
</p> </p>
</div> </div>
@else @else
<!-- ACCOUNTS --> <!-- ACCOUNTS -->
@@ -78,35 +94,44 @@
@endif @endif
<div class="row"> <div class="row">
<div class="col-lg-12 col-md-12 col-sm-12"> <div class="col-lg-12 col-md-12 col-sm-12">
<h4>Budgets</h4> <h4>Budgets</h4>
<table class="table table-bordered">
@foreach($budgets as $budget) @foreach($budgets as $budget)
<tr> <h5><a href="{{route('budgets.show',$budget->id)}}">{{{$budget->name}}}</a></h5>
<td> @if($budget->count == 0)
<a href="{{route('budgets.show',$budget->id)}}">{{{$budget->name}}}</a> <p>
</td> <small><em>No budget set for this period.</em></small>
@if($budget->count == 0) </p>
<td colspan="2"> @else
<em>No budget set for this period.</em> @foreach($budget->limits as $limit)
</td> @foreach($limit->limitrepetitions as $rep)
@else @if($rep->left() < 0)
@foreach($budget->limits as $limit) <!-- bar to display when over budget -->
@foreach($limit->limitrepetitions as $rep) <div class="progress progress-striped">
<td> <div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="{{$rep->spent_pct}}" aria-valuemin="0"
{{mf($rep->amount)}} aria-valuemax="100" style="width: {{$rep->spent_pct}}%;min-width:30px;">{{mf($rep->amount,false)}}</div>
</td> <div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="{{$rep->overspent_pct}}" aria-valuemin="0"
<td> aria-valuemax="100" style="width: {{$rep->overspent_pct}}%;min-width:30px;">{{mf($rep->overspent,false)}}
{{mf($rep->left())}} </div>
</td> </div>
@endforeach @else
@endforeach <!-- bar to display when UNDER budget -->
@endif <div class="progress progress-striped">
</tr> <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="{{$rep->spent_pct}}" aria-valuemin="0"
aria-valuemax="100" style="width: {{$rep->spent_pct}}%;min-width:80px;">{{mf($rep->spent,false)}}
</div>
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="{{$rep->left_pct}}" aria-valuemin="0"
aria-valuemax="100" style="width: {{$rep->left_pct}}%;min-width:30px;">{{mf($rep->left,false)}}
</div>
</div>
@endif
@endforeach
@endforeach
@endif
@endforeach @endforeach
</table>
</div> </div>
</div> </div>
@@ -117,17 +142,16 @@
</div> </div>
@endif
@endif @stop
@section('scripts')
@stop
@section('scripts')
<script src="assets/javascript/highcharts.js"></script> <script src="assets/javascript/highcharts.js"></script>
<script src="assets/javascript/highcharts-more.js"></script> <script src="assets/javascript/highcharts-more.js"></script>
<script src="assets/javascript/highslide-full.min.js"></script> <script src="assets/javascript/highslide-full.min.js"></script>
<script src="assets/javascript/highslide.config.js"></script> <script src="assets/javascript/highslide.config.js"></script>
<script src="assets/javascript/index.js"></script> <script src="assets/javascript/index.js"></script>
@stop @stop
@section('styles') @section('styles')
<link href="assets/css/highslide.css" rel="stylesheet"> <link href="assets/css/highslide.css" rel="stylesheet">
@stop @stop

View File

@@ -0,0 +1,110 @@
@extends('layouts.default')
@section('content')
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<h1>Firefly
<small>Edit limit of {{mf($limit->amount,false)}}
for budget {{{$limit->budget->name}}}
@if($limit->repeats == 0)
in {{$limit->limitrepetitions[0]->startdate->format('M Y')}} ({{$limit->repeat_freq}})
@endif
</small>
</h1>
<p class="text-info">
Firefly uses an "<a href="http://en.wikipedia.org/wiki/Envelope_System" class="text-success">envelope
system</a>" for your budgets, which means that for each period of time (for example a month) a virtual
"envelope" can be created containing a certain amount of money. Money spent within a budget is removed from
the envelope.
</p>
<p class="text-info">
Firefly gives you the opportunity to create such an envelope when you create a budget. However, you can
always add more of them.
</p>
</div>
</div>
{{Form::open(['class' => 'form-horizontal','url' => route('budgets.limits.update',$limit->id)])}}
<div class="row">
<div class="col-lg-6 col-md-12 col-sm-6">
<h4>Mandatory fields</h4>
<div class="form-group">
{{ Form::label('budget_id', 'Budget', ['class' => 'col-sm-3 control-label'])}}
<div class="col-sm-9">
{{Form::select('budget_id',$budgets,Input::old('budget_id') ?: $limit->component_id, ['class' =>
'form-control'])}}
@if($errors->has('budget_id'))
<p class="text-danger">{{$errors->first('name')}}</p>
@else
<span class="help-block">Select one of your existing budgets.</span>
@endif
</div>
</div>
<div class="form-group">
{{ Form::label('startdate', 'Start date', ['class' => 'col-sm-3 control-label'])}}
<div class="col-sm-9">
<input type="date" name="startdate" value="{{Input::old('startdate') ?: $limit->startdate->format('Y-m-d')}}"
class="form-control"/>
<span class="help-block">This date indicates when the envelope "starts". The date you select
here will correct itself to the nearest [period] you select below.</span>
</div>
</div>
<div class="form-group">
<label for="period" class="col-sm-3 control-label">Spending period</label>
<div class="col-sm-9">
{{Form::select('period',$periods,Input::old('period') ?: $limit->repeat_freq,['class' => 'form-control'])}}
<span class="help-block">How long will the envelope last? A week, a month, or even longer?</span>
</div>
</div>
<div class="form-group">
<label for="period" class="col-sm-3 control-label">Repeat</label>
<div class="col-sm-9">
<div class="checkbox">
<label>
<input type="checkbox" value="1" name="repeats" @if(intval(Input::old('repeats')) == 1 || intval($limit->repeats) == 1) checked @endif>
Repeat
</label>
</div>
<span class="help-block">If you want, Firefly can automatically recreate the "envelope" and fill it again
when the timespan above has expired. Be careful with this option though. It makes it easier
to <a href="http://en.wikipedia.org/wiki/Personal_budget#Concepts">fall back to old habits</a>.
Instead, you should recreate the envelope yourself each [period].</span>
</div>
</div>
<div class="form-group">
{{ Form::label('amount', 'Amount', ['class' => 'col-sm-3 control-label'])}}
<div class="col-sm-9">
<input type="number" value="{{Input::old('amount') ?: $limit->amount}}" name="amount" min="0.01" step="any" class="form-control"/>
<span class="help-block">Of course, there needs to be money in the envelope.</span>
</div>
</div>
<div class="form-group">
{{ Form::label('submit', '&nbsp;', ['class' => 'col-sm-3 control-label'])}}
<div class="col-sm-9">
<input type="submit" name="submit" value="Save new limit" class="btn btn-default"/>
</div>
</div>
</div>
</div>
{{Form::open()}}
@stop
@section('scripts')
<script type="text/javascript" src="assets/javascript/moment.min.js"></script>
<script type="text/javascript" src="assets/javascript/limits.js"></script>
@stop

View File

@@ -1,9 +1,9 @@
<table class="table table-bordered table-striped table-condensed"> <table class="table table-bordered table-striped table-condensed">
<tr> <tr>
<th>&nbsp;</th> <th><small>&nbsp;</small></th>
<th>Description</th> <th><small>Description</small></th>
<th>Date</th> <th style="min-width:100px;"><small>Date</small></th>
<th>Amount</th> <th style="min-width:80px;"><small>Amount</small></th>
</tr> </tr>
@foreach($transactions as $journal) @foreach($transactions as $journal)
<tr> <tr>
@@ -20,14 +20,15 @@
@endif @endif
</td> </td>
<td><a href="{{route('transactions.show',$journal->id)}}">{{{$journal->description}}}</a></td> <td><small><a href="{{route('transactions.show',$journal->id)}}">{{{$journal->description}}}</a></small></td>
<td>{{$journal->date->format('jS M Y')}}</td> <td><small>{{$journal->date->format('jS M Y')}}</small></td>
<td> <td><small>
@foreach($journal->transactions as $t) @foreach($journal->transactions as $t)
@if($t->account_id == $account->id) @if($t->account_id == $account->id)
{{mf($t->amount)}} {{mf($t->amount)}}
@endif @endif
@endforeach @endforeach
</small>
</td> </td>
</tr> </tr>
@endforeach @endforeach