From 2b42cb8ef30141966b9ae24ab309b6dc8d6f702b Mon Sep 17 00:00:00 2001 From: James Cole Date: Wed, 13 Aug 2014 21:35:05 +0200 Subject: [PATCH] Form for issue #6 is complete, final checks about to be written. Mebbe tomorrow. [skip ci] --- app/controllers/PiggybankController.php | 3 ++- ...14_07_05_100651_create_piggybanks_table.php | 1 + .../Piggybank/EloquentPiggybankRepository.php | 13 +++++++++++++ .../piggybanks/create-piggybank.blade.php | 18 +++++++++++++++++- app/views/piggybanks/index.blade.php | 2 +- 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/app/controllers/PiggybankController.php b/app/controllers/PiggybankController.php index b105dfd4a0..6e35f8fe2b 100644 --- a/app/controllers/PiggybankController.php +++ b/app/controllers/PiggybankController.php @@ -27,9 +27,10 @@ class PiggybankController extends BaseController */ public function createPiggybank() { + $periods = Config::get('firefly.piggybank_periods'); $accounts = $this->_accounts->getActiveDefaultAsSelectList(); - return View::make('piggybanks.create-piggybank')->with('accounts', $accounts); + return View::make('piggybanks.create-piggybank')->with('accounts', $accounts)->with('periods',$periods); } public function createRepeated() diff --git a/app/database/migrations/2014_07_05_100651_create_piggybanks_table.php b/app/database/migrations/2014_07_05_100651_create_piggybanks_table.php index 1f2b5d1828..c7b3da8e09 100644 --- a/app/database/migrations/2014_07_05_100651_create_piggybanks_table.php +++ b/app/database/migrations/2014_07_05_100651_create_piggybanks_table.php @@ -31,6 +31,7 @@ class CreatePiggybanksTable extends Migration $table->enum('rep_length', ['day', 'week', 'month', 'year'])->nullable(); $table->smallInteger('rep_times')->unsigned(); $table->enum('reminder', ['day', 'week', 'month', 'year'])->nullable(); + $table->smallInteger('reminder_skip')->unsigned(); $table->integer('order')->unsigned(); // connect account to piggybank. diff --git a/app/lib/Firefly/Storage/Piggybank/EloquentPiggybankRepository.php b/app/lib/Firefly/Storage/Piggybank/EloquentPiggybankRepository.php index 6e3b58ad93..ecb724221b 100644 --- a/app/lib/Firefly/Storage/Piggybank/EloquentPiggybankRepository.php +++ b/app/lib/Firefly/Storage/Piggybank/EloquentPiggybankRepository.php @@ -1,6 +1,7 @@ account()->associate($account); + $today = new Carbon; if ($piggyBank->validate()) { + echo 'Valid, but some more checking!'; + if($piggyBank->targetdate < $today) { + $piggyBank->errors()->add('targetdate','Target date cannot be in the past.'); + echo 'errrrrrr on target date'; + return $piggyBank; + } + + // first period for reminder is AFTER target date. + // just flash a warning + die('Here be a check. Sorry for the kill-switch. Will continue tomorrow.'); + $piggyBank->save(); } diff --git a/app/views/piggybanks/create-piggybank.blade.php b/app/views/piggybanks/create-piggybank.blade.php index 68147e1686..ae06586553 100644 --- a/app/views/piggybanks/create-piggybank.blade.php +++ b/app/views/piggybanks/create-piggybank.blade.php @@ -75,7 +75,23 @@
- This field indicates when you want to have saved the indicated amount. + If this piggy bank has a dead line, enter it here. +
+ + +
+ {{ Form::label('reminder', 'Remind you every', ['class' => 'col-sm-4 control-label'])}} +
+ + + + Enter a number and a period and Firefly will remind you to add money + to this piggy bank every now and then.
diff --git a/app/views/piggybanks/index.blade.php b/app/views/piggybanks/index.blade.php index 72fbc0d5b7..88cf559e11 100644 --- a/app/views/piggybanks/index.blade.php +++ b/app/views/piggybanks/index.blade.php @@ -12,7 +12,7 @@

Save money for large expenses

Saving money is hard. Firefly's piggy banks can help you to save money. Simply set the amount - of money you want to save, set an optional target and whether or not Firefly should remind you to add money + 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.