Form for issue #6 is complete, final checks about to be written. Mebbe tomorrow. [skip ci]

This commit is contained in:
James Cole 2014-08-13 21:35:05 +02:00
parent aa55827bfc
commit 2b42cb8ef3
5 changed files with 34 additions and 3 deletions

View File

@ -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()

View File

@ -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.

View File

@ -1,6 +1,7 @@
<?php
namespace Firefly\Storage\Piggybank;
use Carbon\Carbon;
/**
@ -74,7 +75,19 @@ class EloquentPiggybankRepository implements PiggybankRepositoryInterface
$piggyBank = new \Piggybank($data);
$piggyBank->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();
}

View File

@ -75,7 +75,23 @@
<div class="col-sm-8">
<input type="date" name="targetdate" value="{{Input::old('targetdate') ?: ''}}"
class="form-control"/>
<span class="help-block">This field indicates when you want to have saved the indicated amount.</span>
<span class="help-block">If this piggy bank has a dead line, enter it here.</span>
</div>
</div>
<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="1" style="width:50px;display:inline;" max="100" name="reminder_skip" class="form-control" />
<select class="form-control" 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>
<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>
</div>
</div>

View File

@ -12,7 +12,7 @@
<p class="lead">Save money for large expenses</p>
<p class="text-info">
Saving money is <em>hard</em>. 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.
</p>
<p>