mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Also validate edits.
This commit is contained in:
parent
ec601efa6e
commit
980d9ce885
@ -342,8 +342,8 @@ class TransactionController extends BaseController
|
|||||||
Session::flash('success', 'Transaction updated!');
|
Session::flash('success', 'Transaction updated!');
|
||||||
Event::fire('journals.update', [$journal]);
|
Event::fire('journals.update', [$journal]);
|
||||||
|
|
||||||
if (Input::get('post_submit_action') == 'create_another') {
|
if (Input::get('post_submit_action') == 'return_to_edit') {
|
||||||
return Redirect::route('transactions.create', $what)->withInput();
|
return Redirect::route('transactions.edit', $journal->id);
|
||||||
} else {
|
} else {
|
||||||
return Redirect::route('transactions.index.' . $what);
|
return Redirect::route('transactions.index.' . $what);
|
||||||
}
|
}
|
||||||
@ -355,6 +355,16 @@ class TransactionController extends BaseController
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 'validate_only':
|
||||||
|
$data = Input::all();
|
||||||
|
$data['what'] = strtolower($journal->transactionType->type);
|
||||||
|
$messageBags = $this->_helper->validate($data);
|
||||||
|
|
||||||
|
Session::flash('warnings', $messageBags['warnings']);
|
||||||
|
Session::flash('successes', $messageBags['successes']);
|
||||||
|
Session::flash('errors', $messageBags['errors']);
|
||||||
|
return Redirect::route('transactions.edit', $journal->id)->withInput();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new FireflyException('Method ' . Input::get('post_submit_action') . ' not implemented yet.');
|
throw new FireflyException('Method ' . Input::get('post_submit_action') . ' not implemented yet.');
|
||||||
|
@ -16,7 +16,7 @@ class Form
|
|||||||
* @return string
|
* @return string
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public static function ffAmount($name, $value = null, array $options = [])
|
public static function ffNumber($name, $value = null, array $options = [])
|
||||||
{
|
{
|
||||||
$options['step'] = 'any';
|
$options['step'] = 'any';
|
||||||
$options['min'] = '0.01';
|
$options['min'] = '0.01';
|
||||||
|
@ -78,8 +78,8 @@ App::down(
|
|||||||
\Form::macro('ffSelect', function ($name, array $list = [], $selected = null, array $options = []) {
|
\Form::macro('ffSelect', function ($name, array $list = [], $selected = null, array $options = []) {
|
||||||
return \Firefly\Form\Form::ffSelect($name, $list, $selected, $options);
|
return \Firefly\Form\Form::ffSelect($name, $list, $selected, $options);
|
||||||
});
|
});
|
||||||
\Form::macro('ffAmount', function ($name, $value = null, array $options = []) {
|
\Form::macro('ffNumber', function ($name, $value = null, array $options = []) {
|
||||||
return \Firefly\Form\Form::ffAmount($name, $value, $options);
|
return \Firefly\Form\Form::ffNumber($name, $value, $options);
|
||||||
});
|
});
|
||||||
\Form::macro('ffDate', function ($name, $value = null, array $options = []) {
|
\Form::macro('ffDate', function ($name, $value = null, array $options = []) {
|
||||||
return \Firefly\Form\Form::ffDate($name, $value, $options);
|
return \Firefly\Form\Form::ffDate($name, $value, $options);
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<!-- ALWAYS SHOW AMOUNT -->
|
<!-- ALWAYS SHOW AMOUNT -->
|
||||||
{{Form::ffAmount('amount')}}
|
{{Form::ffNumber('amount')}}
|
||||||
|
|
||||||
<!-- ALWAYS SHOW DATE -->
|
<!-- ALWAYS SHOW DATE -->
|
||||||
{{Form::ffDate('date', date('Y-m-d'))}}
|
{{Form::ffDate('date', date('Y-m-d'))}}
|
||||||
|
@ -12,103 +12,33 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<!-- ALWAYS AVAILABLE -->
|
<!-- ALWAYS AVAILABLE -->
|
||||||
<div class="form-group">
|
{{Form::ffText('description',$journal->description)}}
|
||||||
<label for="description" class="col-sm-4 control-label">Description</label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<input type="text"
|
|
||||||
name="description" value="{{{Input::old('description') ?: $journal->description}}}"
|
|
||||||
autocomplete="off" class="form-control" placeholder="Description" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- SHOW ACCOUNT (FROM) ONLY FOR WITHDRAWALS AND DEPOSITS -->
|
<!-- SHOW ACCOUNT (FROM) ONLY FOR WITHDRAWALS AND DEPOSITS -->
|
||||||
@if($what == 'deposit' || $what == 'withdrawal')
|
@if($what == 'deposit' || $what == 'withdrawal')
|
||||||
<div class="form-group">
|
{{Form::ffSelect('account_id',$accounts,$data['account_id'])}}
|
||||||
<label for="account_id" class="col-sm-4 control-label">
|
|
||||||
@if($what == 'deposit')
|
|
||||||
Received into account
|
|
||||||
@endif
|
|
||||||
@if($what == 'withdrawal')
|
|
||||||
Paid from account
|
|
||||||
@endif
|
|
||||||
</label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
{{Form::select('account_id',$accounts,Input::old('account_id') ?: $data['account_id'],['class' => 'form-control'])}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
<!-- SHOW EXPENSE ACCOUNT ONLY FOR WITHDRAWALS -->
|
<!-- SHOW EXPENSE ACCOUNT ONLY FOR WITHDRAWALS -->
|
||||||
@if($what == 'withdrawal')
|
@if($what == 'withdrawal')
|
||||||
<div class="form-group">
|
{{Form::ffText('expense_account',$data['expense_account'])}}
|
||||||
<label for="expense_account" class="col-sm-4 control-label">
|
|
||||||
Expense account
|
|
||||||
</label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<input type="text"
|
|
||||||
name="expense_account"
|
|
||||||
value="{{{Input::old('expense_account') ?: $data['expense_account']}}}"
|
|
||||||
autocomplete="off" class="form-control" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@endif
|
@endif
|
||||||
<!-- SHOW REVENUE ACCOUNT ONLY FOR DEPOSITS -->
|
<!-- SHOW REVENUE ACCOUNT ONLY FOR DEPOSITS -->
|
||||||
@if($what == 'deposit')
|
@if($what == 'deposit')
|
||||||
<div class="form-group">
|
{{Form::ffText('revenue_account',$data['revenue_account'])}}
|
||||||
<label for="revenue_account" class="col-sm-4 control-label">
|
|
||||||
Revenue account
|
|
||||||
</label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<input type="text"
|
|
||||||
name="revenue_account"
|
|
||||||
value="{{{Input::old('revenue_account') ?: $data['revenue_account']}}}"
|
|
||||||
autocomplete="off" class="form-control" placeholder="Beneficiary" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
<!-- ONLY SHOW FROM/TO ACCOUNT WHEN CREATING TRANSFER -->
|
<!-- ONLY SHOW FROM/TO ACCOUNT WHEN CREATING TRANSFER -->
|
||||||
@if($what == 'transfer')
|
@if($what == 'transfer')
|
||||||
<div class="form-group">
|
{{Form::ffSelect('account_from_id',$accounts,$data['account_from_id'])}}
|
||||||
<label for="account_from_id" class="col-sm-4 control-label">Account from</label>
|
{{Form::ffSelect('account_to_id',$accounts,$data['account_to_id'])}}
|
||||||
<div class="col-sm-8">
|
|
||||||
{{Form::select('account_to_id',$accounts,Input::old('account_from_id') ?: $data['account_from_id'],['class' => 'form-control'])}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="account_to_id" class="col-sm-4 control-label">Account to</label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
{{Form::select('account_from_id',$accounts,Input::old('account_to_id') ?: $data['account_to_id'],['class' => 'form-control'])}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
<!-- ALWAYS SHOW AMOUNT -->
|
<!-- ALWAYS SHOW AMOUNT -->
|
||||||
<div class="form-group">
|
{{Form::ffNumber('amount',$data['amount'])}}
|
||||||
<label for="amount" class="col-sm-4 control-label">
|
|
||||||
@if($what == 'withdrawal')
|
|
||||||
Amount spent
|
|
||||||
@endif
|
|
||||||
@if($what == 'deposit')
|
|
||||||
Amount received
|
|
||||||
@endif
|
|
||||||
@if($what == 'transfer')
|
|
||||||
Amount transferred
|
|
||||||
@endif
|
|
||||||
</label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<input type="number" name="amount" min="0.01" value="{{Input::old('amount') ?: $data['amount']}}" step="any" class="form-control" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- ALWAYS SHOW DATE -->
|
<!-- ALWAYS SHOW DATE -->
|
||||||
<div class="form-group">
|
{{Form::ffDate('date',$data['date'])}}
|
||||||
<label for="date" class="col-sm-4 control-label">Date</label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<input type="date" name="date" value="{{Input::old('date') ?: $data['date']}}" class="form-control" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div> <!-- close panel -->
|
</div> <!-- close panel -->
|
||||||
|
|
||||||
@ -128,44 +58,16 @@
|
|||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<!-- BUDGET ONLY WHEN CREATING A WITHDRAWAL -->
|
<!-- BUDGET ONLY WHEN CREATING A WITHDRAWAL -->
|
||||||
@if($what == 'withdrawal')
|
@if($what == 'withdrawal')
|
||||||
<div class="form-group">
|
{{Form::ffSelect('budget_id',$budgets,$data['budget_id'])}}
|
||||||
<label for="budget_id" class="col-sm-4 control-label">Budget</label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
{{Form::select('budget_id',$budgets,Input::old('budget_id') ?: $data['budget_id'],['class' => 'form-control'])}}
|
|
||||||
<span class="help-block">Select one of your budgets to make this transaction a part of it.</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@endif
|
@endif
|
||||||
<!-- CATEGORY ALWAYS -->
|
<!-- CATEGORY ALWAYS -->
|
||||||
<div class="form-group">
|
{{Form::ffText('category',$data['category'])}}
|
||||||
<label for="category" class="col-sm-4 control-label">Category</label>
|
|
||||||
<div class="col-sm-8">
|
<!-- TAGS -->
|
||||||
<input type="text" name="category" value="{{Input::old('category') ?: $data['category']}}" autocomplete="off" class="form-control" placeholder="Category" />
|
|
||||||
<span class="help-block">Add more fine-grained information to this transaction by entering a category.
|
|
||||||
Like the beneficiary-field, this field will auto-complete existing categories but can also be used
|
|
||||||
to create new ones.
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- RELATE THIS TRANSFER TO A PIGGY BANK -->
|
<!-- RELATE THIS TRANSFER TO A PIGGY BANK -->
|
||||||
@if($what == 'transfer' && count($piggies) > 0)
|
@if($what == 'transfer' && count($piggies) > 0)
|
||||||
<div class="form-group">
|
{{Form::ffSelect('piggybank_id',$piggies,$data['piggybank_id'])}}
|
||||||
<label for="piggybank_id" class="col-sm-4 control-label">
|
|
||||||
Piggy bank
|
|
||||||
</label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
{{Form::select('piggybank_id',$piggies,Input::old('piggybank_id') ?: $data['piggybank_id'],['class' => 'form-control'])}}
|
|
||||||
@if($errors->has('piggybank_id'))
|
|
||||||
<p class="text-danger">{{$errors->first('piggybank_id')}}</p>
|
|
||||||
@else
|
|
||||||
<span class="help-block">
|
|
||||||
You can directly add the amount you're transferring
|
|
||||||
to one of your piggy banks, provided they are related to the account your
|
|
||||||
transferring <em>to</em>.
|
|
||||||
</span>
|
|
||||||
@endif
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div><!-- end of panel for options-->
|
</div><!-- end of panel for options-->
|
||||||
|
Loading…
Reference in New Issue
Block a user