From 12e5f80d80f45ac5e54869645a325e88ff68c85a Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 14 Aug 2014 18:17:02 +0200 Subject: [PATCH] Also create routine for repeated expenses. [skip ci] issue #6 --- app/controllers/PiggybankController.php | 19 ++++-- .../piggybanks/create-piggybank.blade.php | 2 +- .../piggybanks/create-repeated.blade.php | 65 ++++++++++++++++--- 3 files changed, 68 insertions(+), 18 deletions(-) diff --git a/app/controllers/PiggybankController.php b/app/controllers/PiggybankController.php index 2c3d7940b4..add254c912 100644 --- a/app/controllers/PiggybankController.php +++ b/app/controllers/PiggybankController.php @@ -1,5 +1,6 @@ _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.php index 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
- {{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'))

{{$errors->first('account_id')}}

@else diff --git a/app/views/piggybanks/create-repeated.blade.php b/app/views/piggybanks/create-repeated.blade.php index 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
- {{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'))

{{$errors->first('account_id')}}

@else @@ -58,22 +58,67 @@
+
+ {{ Form::label('targetdate', 'Target date', ['class' => 'col-sm-4 control-label'])}} +
+ + @if($errors->has('targetdate')) +

{{$errors->first('targetdate')}}

+ @else + A dead line is needed to properly repeat this repeated expesnse. + @endif +
+
+
+ {{ Form::label('rep_times', 'Repeat every', ['class' => 'col-sm-4 control-label'])}} +
+ - - + + @if($errors->has('rep_length')) +

{{$errors->first('rep_length')}}

+ @else + Something about every X years bla bla bla. + @endif +
+
-
-

Optional fields for non-repeating piggy banks

- Fields be here -
-
-

Optional fields for repeating piggy banks

- Fields be here. +

Optional fields

+ +
+ {{ Form::label('reminder', 'Remind you every', ['class' => 'col-sm-4 control-label'])}} +
+ + + + @if($errors->has('reminder')) +

{{$errors->first('reminder')}}

+ @else + Enter a number and a period and Firefly will remind you to save money + for this repeated expense every now and then. + @endif +
+ +