Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Also create routine for repeated expenses. [skip ci] issue #6
James Cole12e5f80d80f4
diff --git a/app/controllers/PiggybankController.php b/app/controllers/PiggybankController.phpindex 2c3d7940b4..add254c912 100644--- a/app/controllers/PiggybankController.php+++ b/app/controllers/PiggybankController.php@@ -1,5 +1,6 @@<?php+use Carbon\Carbon;use Firefly\Storage\Account\AccountRepositoryInterface as ARI;use Firefly\Storage\Piggybank\PiggybankRepositoryInterface as PRI;@@ -129,19 +130,23 @@ class PiggybankController extends BaseController/*** @return $this|\Illuminate\Http\RedirectResponse*/- public function store()+ public function storeRepeated(){- $piggyBank = $this->_repository->store(Input::all());++ $data = Input::all();+ unset($data['_token']);++ // extend the data array with the settings needed to create a repeated:+ $data['repeats'] = 1;+ $data['startdate'] = new Carbon;+ $data['order'] = 0;++ $piggyBank = $this->_repository->store($data);if ($piggyBank->validate()) {Session::flash('success', 'New piggy bank "' . $piggyBank->name . '" created!');- if (Input::get('create') == '1') {- return Redirect::route('piggybanks.create')->withInput();- }-return Redirect::route('piggybanks.index');-} else {Session::flash('error', 'Could not save piggy bank: ' . $piggyBank->errors()->first());diff --git a/app/views/piggybanks/create-piggybank.blade.php b/app/views/piggybanks/create-piggybank.blade.phpindex 3342e1135d..ce61153649 100644--- a/app/views/piggybanks/create-piggybank.blade.php+++ b/app/views/piggybanks/create-piggybank.blade.php@@ -32,7 +32,7 @@Saving account</label><div class="col-sm-8">- {{Form::select('account_id',$accounts,Input::old('account_id') ?: Input::get('account'),['class' => 'form-control'])}}+ {{Form::select('account_id',$accounts,Input::old('account_id') ?: Input::get('account_id'),['class' => 'form-control'])}}@if($errors->has('account_id'))<p class="text-danger">{{$errors->first('account_id')}}</p>@elsediff --git a/app/views/piggybanks/create-repeated.blade.php b/app/views/piggybanks/create-repeated.blade.phpindex 51547d0ff1..8d68ccef23 100644--- a/app/views/piggybanks/create-repeated.blade.php+++ b/app/views/piggybanks/create-repeated.blade.php@@ -33,7 +33,7 @@Saving account</label><div class="col-sm-8">- {{Form::select('account_id',$accounts,Input::old('account_id') ?: Input::get('account'),['class' => 'form-control'])}}+ {{Form::select('account_id',$accounts,Input::old('account_id') ?: Input::get('account_id'),['class' => 'form-control'])}}@if($errors->has('account_id'))<p class="text-danger">{{$errors->first('account_id')}}</p>@else@@ -58,22 +58,67 @@</div></div>+ <div class="form-group">+ {{ Form::label('targetdate', 'Target date', ['class' => 'col-sm-4 control-label'])}}+ <div class="col-sm-8">+ <input type="date" name="targetdate" value="{{Input::old('targetdate') ?: ''}}"+ class="form-control"/>+ @if($errors->has('targetdate'))+ <p class="text-danger">{{$errors->first('targetdate')}}</p>+ @else+ <span class="help-block">A dead line is needed to properly repeat this repeated expesnse.</span>+ @endif+ </div>+ </div>---+ <div class="form-group">+ {{ Form::label('rep_times', 'Repeat every', ['class' => 'col-sm-4 control-label'])}}+ <div class="col-sm-8">+ <input type="number" step="1" min="1" value="{{Input::old('rep_times') ?: 1}}" style="width:50px;display:inline;" max="100" name="rep_times" class="form-control" />++ <select class="form-control" name="rep_length" style="width:150px;display: inline">+ @foreach($periods as $period)+ @if($period == 'month' || Input::old('reminder') == $period)+ <option value="{{$period}}" label="{{$period}}" selected="selected">{{$period}}</option>+ @else+ <option value="{{$period}}" label="{{$period}}">{{$period}}</option>+ @endif+ @endforeach+ </select>+ @if($errors->has('rep_length'))+ <p class="text-danger">{{$errors->first('rep_length')}}</p>+ @else+ <span class="help-block">Something about every X years bla bla bla.</span>+ @endif+ </div>+ </div></div><div class="col-lg-6 col-md-12 col-sm-6">- <div class="no-repeat-piggy">- <h4>Optional fields for non-repeating piggy banks</h4>- Fields be here- </div>- <div class="repeat-piggy">- <h4>Optional fields for repeating piggy banks</h4>- Fields be here.+ <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 save money+ for this repeated expense every now and then.</span>+ @endif+ </div></div>++<!--<div class="form-group">{{ Form::label('targetdate', 'Target date', ['class' => 'col-sm-4 control-label'])}}