firefly-iii/resources/views/split/journals/edit.twig
James Cole 6c5cd705c0
Some code for new optional fields, see #301
Signed-off-by: James Cole <thegrumpydictator@gmail.com>
2016-09-04 16:21:51 +02:00

245 lines
12 KiB
Twig

{% extends "./layout/default.twig" %}
{% block breadcrumbs %}
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, journal) }}
{% endblock %}
{% block content %}
<form method="POST" action="{{ route('split.journal.update',journal.id) }}" accept-charset="UTF-8" class="form-horizontal" id="update"
enctype="multipart/form-data">
<input name="_token" type="hidden" value="{{ csrf_token() }}">
<input type="hidden" name="id" value="{{ journal.id }}"/>
<input type="hidden" name="what" value="{{ preFilled.what }}"/>
{% if errors.all()|length > 0 %}
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="box box-danger">
<div class="box-header with-border">
<h3 class="box-title">{{ 'errors'|_ }}</h3>
</div>
<div class="box-body">
<ul>
{% for key, err in errors.all() %}
<li class="text-danger">{{ err }}</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
{% endif %}
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'transaction_data'|_ }}</h3>
</div>
<div class="box-body">
{{ ExpandedForm.text('journal_description', journal.description) }}
{{ ExpandedForm.select('journal_currency_id', currencies, preFilled.transaction_currency_id) }}
{{ ExpandedForm.staticText('journal_amount', preFilled.journal_amount|formatAmount ) }}
<input type="hidden" name="journal_amount" value="{{ preFilled.journal_amount }}"/>
<!-- show source if withdrawal or transfer -->
{% if preFilled.what == 'withdrawal' or preFilled.what == 'transfer' %}
{{ ExpandedForm.select('journal_source_account_id', assetAccounts, preFilled.journal_source_account_id) }}
{% endif %}
<!-- show destination account id, if deposit (is asset): -->
{% if preFilled.what == 'deposit' %}
{{ ExpandedForm.select('journal_destination_account_id', assetAccounts, preFilled.journal_destination_account_id) }}
{% endif %}
<!-- show static destination if transfer -->
{% if preFilled.what == 'transfer' %}
{{ ExpandedForm.select('journal_destination_account_id', assetAccounts, preFilled.journal_destination_account_id) }}
{% endif %}
</div>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'transaction_meta_data'|_ }}</h3>
</div>
<div class="box-body">
{{ ExpandedForm.date('date', journal.date) }}
{% if optionalFields.interest_date or journal.interest_date %}
<!-- INTEREST DATE -->
{{ ExpandedForm.date('interest_date', journal.interest_date) }}
{% endif %}
{% if optionalFields.book_date or journal.book_date %}
<!-- BOOK DATE -->
{{ ExpandedForm.date('book_date', journal.book_date) }}
{% endif %}
{% if optionalFields.process_date or journal.process_date %}
<!-- PROCESSING DATE -->
{{ ExpandedForm.date('process_date', journal.process_date) }}
{% endif %}
{% if optionalFields.due_date or journal.due_date %}
<!-- DUE DATE -->
{{ ExpandedForm.date('due_date', journal.due_date) }}
{% endif %}
{% if optionalFields.payment_date or journal.payment_date %}
<!-- PAYMENT DATE -->
{{ ExpandedForm.date('payment_date', journal.payment_date) }}
{% endif %}
{% if optionalFields.internal_reference or journal.internal_reference %}
<!-- REFERENCE -->
{{ ExpandedForm.text('internal_reference', journal.internal_reference) }}
{% endif %}
{% if optionalFields.notes or journal.notes %}
<!-- NOTES -->
{{ ExpandedForm.textarea('notes', journal.notes) }}
{% endif %}
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'splits'|_ }}</h3>
</div>
<div class="box-body">
<table class="table table-bordered table-condensed table-striped split-table">
<thead>
<tr>
<th>{{ trans('list.split_number') }}</th>
<th>{{ trans('list.description') }}</th>
<!-- withdrawal and deposit have a destination. -->
{% if preFilled.what == 'withdrawal' %}
<th>{{ trans('list.destination') }}</th>
{% endif %}
{% if preFilled.what == 'deposit' %}
<th>{{ trans('list.source') }}</th>
{% endif %}
<th>{{ trans('list.amount') }}</th>
<!-- only withdrawal has budget -->
{% if preFilled.what == 'withdrawal' %}
<th>{{ trans('list.budget') }}</th>
{% endif %}
<th>{{ trans('list.category') }}</th>
</tr>
</thead>
<tbody>
{% for index, descr in preFilled.description %}
<tr class="{% if loop.index == 1 %}initial-row{% else %}not-initial-row{% endif %}">
<td class="count">#{{ loop.index }}</td>
<td>
<input type="text" name="description[]" value="{{ descr }}" class="form-control"/>
</td>
<!-- withdrawal has several destination names. -->
{% if preFilled.what == 'withdrawal' %}
<td>
<input type="text" name="destination_account_name[]" value="{{ preFilled.destination_account_name[index] }}"
class="form-control"/>
</td>
{% endif %}
<!-- deposit has several source names -->
{% if preFilled.what == 'deposit' %}
<td>
<input type="text" name="source_account_name[]" value="{{ preFilled.source_account_name[index] }}"
class="form-control"/>
</td>
{% endif %}
<td style="width:10%;">
<input type="number" name="amount[]" value="{{ preFilled.amount[index] }}"
class="form-control" autocomplete="off" step="any" min="0.01">
</td>
{% if preFilled.what == 'withdrawal' %}
<td>
<select class="form-control" name="budget_id[]">
{% for key, budget in budgets %}
<option label="{{ budget }}" value="{{ key }}"
{% if preFilled.budget_id[index] == key %}
selected="selected"
{% endif %}
>{{ budget }}</option>
{% endfor %}
</select>
</td>
{% endif %}
<td>
<input type="text" name="category[]" value="{{ preFilled.category[index] }}" class="form-control"/>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<p>
<br/>
<a href="#" class="btn btn-default btn-do-split"><i class="fa fa-plus-circle"></i> {{ 'add_another_split'|_ }}</a>
</p>
<!--<p class="pull-right">
<button type="submit" id="transaction-btn" class="btn btn-success pull-right">
{{ ('update_splitted_'~preFilled.what)|_ }}
</button>
</p>
-->
</div>
</div>
</div>
</div>
<div class="row">
{% if optionalFields.attachments %}
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'optionalFields'|_ }}</h3>
</div>
<div class="box-body">
<!-- ATTACHMENTS -->
{{ ExpandedForm.file('attachments[]', {'multiple': 'multiple','helpText': trans('firefly.upload_max_file_size', {'size': uploadSize|filesize}) }) }}
</div>
</div>
</div>
{% endif %}
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
<!-- 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('update','split-transaction') }}
</div>
<div class="box-footer">
<button type="submit" class="pull-right btn btn-success">{{ ('update_' ~ preFilled.what)|_ }}</button>
</div>
</div>
</div>
</div>
</form>
{% endblock %}
{% block scripts %}
<script type="text/javascript">
var originalSum = {{ preFilled.journal_amount }};
var what = "{{ preFilled.what }}";
</script>
<script type="text/javascript" src="js/lib/bootstrap3-typeahead.min.js"></script>
<script type="text/javascript" src="js/ff/transactions/create-edit.js"></script>
<script type="text/javascript" src="js/ff/split/journal/from-store.js"></script>
{% endblock %}
{% block styles %}
{% endblock %}