mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Also create routine for repeated expenses. [skip ci] issue #6
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
||||||
use Firefly\Storage\Piggybank\PiggybankRepositoryInterface as PRI;
|
use Firefly\Storage\Piggybank\PiggybankRepositoryInterface as PRI;
|
||||||
|
|
||||||
@@ -129,19 +130,23 @@ class PiggybankController extends BaseController
|
|||||||
/**
|
/**
|
||||||
* @return $this|\Illuminate\Http\RedirectResponse
|
* @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()) {
|
if ($piggyBank->validate()) {
|
||||||
Session::flash('success', 'New piggy bank "' . $piggyBank->name . '" created!');
|
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');
|
return Redirect::route('piggybanks.index');
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Session::flash('error', 'Could not save piggy bank: ' . $piggyBank->errors()->first());
|
Session::flash('error', 'Could not save piggy bank: ' . $piggyBank->errors()->first());
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
Saving account
|
Saving account
|
||||||
</label>
|
</label>
|
||||||
<div class="col-sm-8">
|
<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'))
|
@if($errors->has('account_id'))
|
||||||
<p class="text-danger">{{$errors->first('account_id')}}</p>
|
<p class="text-danger">{{$errors->first('account_id')}}</p>
|
||||||
@else
|
@else
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
Saving account
|
Saving account
|
||||||
</label>
|
</label>
|
||||||
<div class="col-sm-8">
|
<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'))
|
@if($errors->has('account_id'))
|
||||||
<p class="text-danger">{{$errors->first('account_id')}}</p>
|
<p class="text-danger">{{$errors->first('account_id')}}</p>
|
||||||
@else
|
@else
|
||||||
@@ -58,22 +58,67 @@
|
|||||||
</div>
|
</div>
|
||||||
</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>
|
||||||
<div class="col-lg-6 col-md-12 col-sm-6">
|
<div class="col-lg-6 col-md-12 col-sm-6">
|
||||||
|
|
||||||
<div class="no-repeat-piggy">
|
<h4>Optional fields</h4>
|
||||||
<h4>Optional fields for non-repeating piggy banks</h4>
|
|
||||||
Fields be here
|
<div class="form-group">
|
||||||
</div>
|
{{ Form::label('reminder', 'Remind you every', ['class' => 'col-sm-4 control-label'])}}
|
||||||
<div class="repeat-piggy">
|
<div class="col-sm-8">
|
||||||
<h4>Optional fields for repeating piggy banks</h4>
|
<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" />
|
||||||
Fields be here.
|
|
||||||
|
<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>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
{{ Form::label('targetdate', 'Target date', ['class' => 'col-sm-4 control-label'])}}
|
{{ Form::label('targetdate', 'Target date', ['class' => 'col-sm-4 control-label'])}}
|
||||||
|
|||||||
Reference in New Issue
Block a user