Piggy banks

This commit is contained in:
James Cole
2015-02-25 19:32:33 +01:00
parent f2eae2fc98
commit c0f96aa948
14 changed files with 542 additions and 160 deletions

View File

@@ -0,0 +1,33 @@
<table class="table table-bordered table-striped">
<tr>
@if(isset($showPiggyBank) && $showPiggyBank === true)
<th>Piggy bank</th>
@endif
<th>Date</th>
<th>Amount</th>
</tr>
@foreach($events as $event)
<tr>
@if(isset($showPiggyBank) && $showPiggyBank === true)
<td>
<a href="{{route('piggyBanks.show',$event->piggyBank_id)}}">{{{$event->piggyBank->name}}}</a>
</td>
@endif
<td>
@if(!is_null($event->transaction_journal_id))
<a href="{{route('transactions.show',$event->transaction_journal_id)}}" title="{{{$event->transactionJournal->description}}}">{{$event->date->format('j F Y')}}</a>
@else
{{$event->date->format('j F Y')}}
@endif
</td>
<td>
@if($event->amount < 0)
<span class="text-danger">Removed {{Amount::format($event->amount*-1,false)}}</span>
@else
<span class="text-success">Added {{Amount::format($event->amount,false)}}</span>
@endif
</td>
</tr>
@endforeach
</table>

View File

@@ -1,5 +1,5 @@
<form style="display: inline;" id="add" action="{{route('piggy-banks.add',$piggyBank->id)}}" method="POST">
{{Form::token()}}
{!! Form::token() !!}
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@@ -8,7 +8,7 @@
</div>
<div class="modal-body">
<p>
The maximum amount you can add is {{Amount::format($maxAmount)}}
The maximum amount you can add is {!! Amount::format($maxAmount) !!}
</p>
<div class="input-group">
<div class="input-group-addon"></div>

View File

@@ -1,7 +1,9 @@
@extends('layouts.default')
@section('content')
{{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName()) }}
{{Form::open(['class' => 'form-horizontal','id' => 'store','url' => route('piggy-banks.store')])}}
{!! Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName()) !!}
{!! Form::open(['class' => 'form-horizontal','id' => 'store','url' => route('piggy-banks.store')]) !!}
<input type="hidden" name="repeats" value="0" />
<div class="row">
<div class="col-lg-6 col-md-12 col-sm-6">
@@ -10,9 +12,10 @@
<i class="fa fa-fw fa-exclamation"></i> Mandatory fields
</div>
<div class="panel-body">
{{Form::ffText('name')}}
{{Form::ffSelect('account_id',$accounts,null,['label' => 'Save on account'])}}
{{Form::ffAmount('targetamount')}}
{!! ExpandedForm::text('name') !!}
{!! ExpandedForm::select('account_id',$accounts,null,['label' => 'Save on account']) !!}
{!! ExpandedForm::amount('targetamount') !!}
</div>
</div>
@@ -29,9 +32,9 @@
<i class="fa fa-smile-o"></i> Optional fields
</div>
<div class="panel-body">
{{Form::ffDate('targetdate')}}
{{Form::ffCheckbox('remind_me','1',false,['label' => 'Remind me'])}}
{{Form::ffSelect('reminder',$periods,'month',['label' => 'Remind every'])}}
{!! ExpandedForm::date('targetdate') !!}
{!! ExpandedForm::checkbox('remind_me','1',false,['label' => 'Remind me']) !!}
{!! ExpandedForm::select('reminder',$periods,'month',['label' => 'Remind every']) !!}
</div>
</div>
@@ -41,54 +44,12 @@
<i class="fa fa-bolt"></i> Options
</div>
<div class="panel-body">
{{Form::ffOptionsList('create','piggy bank')}}
{!! ExpandedForm::optionsList('create','piggy bank') !!}
</div>
</div>
</div>
</div>
{{--
<h4>Mandatory fields</h4>
<h4>Optional fields</h4>
<div class="form-group">
{{ Form::label('reminder', 'Remind you every', ['class' => 'col-sm-4 control-label'])}}
<div class="col-sm-8">
<input type="number" step="1" min="1" value="{{Input::old('reminder_skip') ?: 1}}" style="width:50px;display:inline;" max="100" name="reminder_skip" class="form-control" />
<select class="form-control" name="reminder" style="width:150px;display: inline">
<option value="none" label="do not remind me">do not remind me</option>
@foreach($periods as $period)
<option value="{{$period}}" label="{{$period}}">{{$period}}</option>
@endforeach
</select>
@if($errors->has('reminder'))
<p class="text-danger">{{$errors->first('reminder')}}</p>
@else
<span class="help-block">Enter a number and a period and Firefly will remind you to add money
to this piggy bank every now and then.</span>
@endif
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-12 col-sm-6">
<div class="form-group">
<div class="col-sm-offset-4 col-sm-8">
<button type="submit" class="btn btn-default btn-success">Create the piggy bank</button>
</div>
</div>
</div>
</div>
--}}
{{Form::close()}}
{!! Form::close() !!}
@stop

View File

@@ -1,7 +1,10 @@
@extends('layouts.default')
@section('content')
{{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $piggyBank) }}
{{Form::model($piggyBank, ['class' => 'form-horizontal','id' => 'update','url' => route('piggy-banks.update',$piggyBank->id)])}}
{!! Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $piggyBank) !!}
{!! Form::model($piggyBank, ['class' => 'form-horizontal','id' => 'update','url' => route('piggy-banks.update',$piggyBank->id)]) !!}
<input type="hidden" name="repeats" value="0" />
<input type="hidden" name="id" value="{{$piggyBank->id}}" />
<div class="row">
<div class="col-lg-6 col-md-12 col-sm-6">
@@ -10,9 +13,13 @@
<i class="fa fa-fw fa-exclamation"></i> Mandatory fields
</div>
<div class="panel-body">
{{Form::ffText('name')}}
{{Form::ffSelect('account_id',$accounts,null,['label' => 'Save on account'])}}
{{Form::ffAmount('targetamount')}}
@foreach($errors->all() as $err)
{{$err}}
@endforeach
{!! ExpandedForm::text('name') !!}
{!! ExpandedForm::select('account_id',$accounts,null,['label' => 'Save on account']) !!}
{!! ExpandedForm::amount('targetamount') !!}
</div>
</div>
@@ -29,9 +36,9 @@
<i class="fa fa-smile-o"></i> Optional fields
</div>
<div class="panel-body">
{{Form::ffDate('targetdate')}}
{{Form::ffCheckbox('remind_me','1',$preFilled['remind_me'],['label' => 'Remind me'])}}
{{Form::ffSelect('reminder',$periods,$preFilled['reminder'],['label' => 'Remind every'])}}
{!! ExpandedForm::date('targetdate') !!}
{!! ExpandedForm::checkbox('remind_me','1',$preFilled['remind_me'],['label' => 'Remind me']) !!}
{!! ExpandedForm::select('reminder',$periods,$preFilled['reminder'],['label' => 'Remind every']) !!}
</div>
</div>
@@ -41,54 +48,12 @@
<i class="fa fa-bolt"></i> Options
</div>
<div class="panel-body">
{{Form::ffOptionsList('update','piggy bank')}}
{!! ExpandedForm::optionsList('update','piggy bank') !!}
</div>
</div>
</div>
</div>
{{--
<h4>Mandatory fields</h4>
<h4>Optional fields</h4>
<div class="form-group">
{{ Form::label('reminder', 'Remind you every', ['class' => 'col-sm-4 control-label'])}}
<div class="col-sm-8">
<input type="number" step="1" min="1" value="{{Input::old('reminder_skip') ?: 1}}" style="width:50px;display:inline;" max="100" name="reminder_skip" class="form-control" />
<select class="form-control" name="reminder" style="width:150px;display: inline">
<option value="none" label="do not remind me">do not remind me</option>
@foreach($periods as $period)
<option value="{{$period}}" label="{{$period}}">{{$period}}</option>
@endforeach
</select>
@if($errors->has('reminder'))
<p class="text-danger">{{$errors->first('reminder')}}</p>
@else
<span class="help-block">Enter a number and a period and Firefly will remind you to add money
to this piggy bank every now and then.</span>
@endif
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-12 col-sm-6">
<div class="form-group">
<div class="col-sm-offset-4 col-sm-8">
<button type="submit" class="btn btn-default btn-success">Create the piggy bank</button>
</div>
</div>
</div>
</div>
--}}
{{Form::close()}}
{!! Form::close() !!}
@stop

View File

@@ -1,5 +1,5 @@
<form style="display: inline;" id="remove" action="{{route('piggy-banks.remove',$piggyBank->id)}}" method="POST">
{{Form::token()}}
{!! Form::token() !!}
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@@ -8,7 +8,7 @@
</div>
<div class="modal-body">
<p>
The maximum amount you can remove is {{Amount::format($piggyBank->currentRelevantRep()->currentamount)}}
The maximum amount you can remove is {!! Amount::format($piggyBank->currentRelevantRep()->currentamount) !!}
</p>
<div class="input-group">
<div class="input-group-addon"></div>

View File

@@ -1,6 +1,6 @@
@extends('layouts.default')
@section('content')
{{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $piggyBank) }}
{!! Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $piggyBank) !!}
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-6">
<div class="panel panel-default">
@@ -40,15 +40,15 @@
</tr>
<tr>
<td>Target amount</td>
<td>{{Amount::format($piggyBank->targetamount)}}</td>
<td>{!! Amount::format($piggyBank->targetamount) !!}</td>
</tr>
<tr>
<td>Saved so far</td>
<td>{{Amount::format($piggyBank->currentRelevantRep()->currentamount)}}</td>
<td>{!! Amount::format($piggyBank->currentRelevantRep()->currentamount) !!}</td>
</tr>
<tr>
<td>Left to save</td>
<td>{{Amount::format($piggyBank->targetamount-$piggyBank->currentRelevantRep()->currentamount)}}</td>
<td>{!! Amount::format($piggyBank->targetamount-$piggyBank->currentRelevantRep()->currentamount) !!}</td>
</tr>
<tr>
<td>Start date</td>
@@ -114,12 +114,13 @@
@section('scripts')
<script type="text/javascript">
var piggyBankID = {{{$piggyBank->id}}};
var currencyCode = '{{Amount::getCurrencyCode()}}';
var piggyBankID = {{{$piggyBank->id}}};
</script>
<!-- load the libraries and scripts necessary for Google Charts: -->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
{{HTML::script('assets/javascript/firefly/gcharts.options.js')}}
{{HTML::script('assets/javascript/firefly/gcharts.js')}}
{{HTML::script('assets/javascript/firefly/piggy-banks.js')}}
<script type="text/javascript" src="js/gcharts.options.js"></script>
<script type="text/javascript" src="js/gcharts.js"></script>
<script type="text/javascript" src="js/piggy-banks.js"></script>
@stop