firefly-iii/resources/views/transactions/create.twig
James Cole a0ea3882e1
Various code cleanup.
Signed-off-by: James Cole <thegrumpydictator@gmail.com>
2016-08-27 03:50:35 +02:00

147 lines
6.5 KiB
Twig

{% extends "./layout/default.twig" %}
{% block breadcrumbs %}
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, what) }}
{% endblock %}
{% block content %}
<form method="POST" action="{{ route('transactions.store',what) }}" accept-charset="UTF-8" class="form-horizontal" id="store" enctype="multipart/form-data">
<input name="_token" type="hidden" value="{{ csrf_token() }}">
<input type="hidden" name="what" value="{{ what }}"/>
<div class="row">
<div class="col-lg-6 col-md-12 col-sm-12">
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">{{ 'mandatoryFields'|_ }}</h3>
</div>
<div class="box-body">
<div class="form-group">
<label class="col-sm-4 control-label">Quickswitch</label>
<div class="col-sm-8">
<div class="btn-group btn-group-justified">
<a href="#" data-what="withdrawal" class="switch btn btn-default"> {{ 'withdrawal'|_ }}</a>
<a href="#" data-what="deposit" class="switch btn btn-default"> {{ 'deposit'|_ }}</a>
<a href="#" data-what="transfer" class="switch btn btn-default">{{ 'transfer'|_ }}</a>
</div>
</div>
</div>
<!-- DESCRIPTION ALWAYS AVAILABLE -->
{{ ExpandedForm.text('description') }}
<!-- SELECTABLE SOURCE ACCOUNT ONLY FOR WITHDRAWALS AND TRANSFERS -->
{{ ExpandedForm.select('source_account_id',assetAccounts, null, {label: trans('form.asset_source_account')}) }}
<!-- FREE FORMAT SOURCE ACCOUNT ONLY FOR DEPOSITS -->
{{ ExpandedForm.text('source_account_name',null, {label: trans('form.revenue_account')}) }}
<!-- FREE FORMAT DESTINATION ACCOUNT ONLY FOR EXPENSES -->
{{ ExpandedForm.text('destination_account_name',null, {label: trans('form.expense_account')}) }}
<!-- SELECTABLE DESTINATION ACCOUNT ONLY FOR TRANSFERS AND DEPOSITS -->
{{ ExpandedForm.select('destination_account_id',assetAccounts, null, {label: trans('form.asset_destination_account')} ) }}
<!-- ALWAYS SHOW AMOUNT -->
{{ ExpandedForm.amount('amount') }}
<!-- ALWAYS SHOW DATE -->
{{ ExpandedForm.date('date', phpdate('Y-m-d')) }}
</div>
</div>
</div>
<div class="col-lg-6 col-md-12 col-sm-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'optionalFields'|_ }}</h3>
</div>
<div class="box-body">
<!-- BUDGET ONLY WHEN CREATING A WITHDRAWAL -->
{% if budgets|length > 1 %}
{{ ExpandedForm.select('budget_id',budgets,0) }}
{% else %}
{{ ExpandedForm.select('budget_id',budgets,0, {helpText: trans('firefly.no_budget_pointer')}) }}
{% endif %}
<!-- CATEGORY ALWAYS -->
{{ ExpandedForm.text('category') }}
<!-- INTEREST DATE -->
{{ ExpandedForm.date('interest_date') }}
<!-- BOOK DATE -->
{{ ExpandedForm.date('book_date') }}
<!-- PROCESSING DATE -->
{{ ExpandedForm.date('process_date') }}
<!-- TAGS -->
{{ ExpandedForm.text('tags') }}
<!-- RELATE THIS TRANSFER TO A PIGGY BANK -->
{{ ExpandedForm.select('piggy_bank_id',piggies) }}
<!-- ATTACHMENTS -->
{{ ExpandedForm.file('attachments[]', {'multiple': 'multiple','helpText': trans('firefly.upload_max_file_size', {'size': uploadSize|filesize}) }) }}
</div>
</div>
<!-- panel for options -->
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'options'|_ }}</h3>
</div>
<div class="box-body">
{{ ExpandedForm.optionsList('create','transaction') }}
</div>
<div class="box-footer">
<button type="submit" id="transaction-btn" class="btn btn-success pull-right">
{{ trans('form.store_new_'~what) }}
</button>
</div>
</div>
</div>
</div>
</form>
{% endblock %}
{% block scripts %}
<script type="text/javascript">
var what = "{{ what }}";
var piggiesLength = {{ piggies|length }};
var doSwitch = true;
// some titles and names:
var txt = [];
var title = [];
var breadcrumbs = [];
var middleCrumbName = [];
var middleCrumbUrl = [];
var button = [];
{% for type in {0:'withdrawal',1:'deposit',2:'transfer'} %}
txt['{{ type }}'] = '{{ type|_ }}';
title['{{ type }}'] = '{{ trans('form.add_new_' ~ type) }}';
breadcrumbs['{{ type }}'] = '{{ trans('breadcrumbs.create_' ~ type) }}';
middleCrumbName['{{ type }}'] = '{{ trans('breadcrumbs.' ~ type ~ '_list') }}';
middleCrumbUrl['{{ type }}'] = '{{ route('transactions.index', type) }}';
button['{{ type }}'] = '{{ trans('form.store_new_' ~ type) }}';
{% endfor %}
</script>
<script type="text/javascript" src="js/lib/bootstrap3-typeahead.min.js"></script>
<script type="text/javascript" src="js/lib/bootstrap-tagsinput.min.js"></script>
<script type="text/javascript" src="js/ff/transactions/create-edit.js"></script>
<script type="text/javascript" src="js/ff/transactions/create.js"></script>
{% endblock %}
{% block styles %}
<link href="css/bootstrap-tagsinput.css" type="text/css" rel="stylesheet" media="all">
{% endblock %}