{% extends './layout/default' %}

{% block breadcrumbs %}
    {{ Breadcrumbs.render(Route.getCurrentRoute.getName, journals) }}
{% endblock %}

{% block content %}
    <form method="POST" action="{{ route('transactions.mass.destroy') }}" accept-charset="UTF-8" class="form-horizontal" id="destroy">
        <input name="_token" type="hidden" value="{{ csrf_token() }}">

        <div class="row">
            <div class="col-lg-8 col-lg-offset-2 col-md-8 coll-offset-md-2 col-sm-12">
                <div class="box box-danger">
                    <div class="box-header with-border">
                        <h3 class="box-title">{{ 'mass_delete_journals'|_ }}</h3>
                    </div>
                    <div class="box-body">
                        <p class="text-danger">
                            {{ trans('form.permDeleteWarning') }}
                            {{ 'perm-delete-many'|_ }}
                        </p>
                        <p>
                            {{ trans('form.mass_journal_are_you_sure') }}
                            {{ trans('form.mass_make_selection') }}
                        </p>

                        <table class="table table-striped table-condensed">
                            <tr>
                                <th>&nbsp;</th>
                                <th>{{ trans('list.transaction_type') }}</th>
                                <th>{{ trans('list.description') }}</th>
                                <th>{{ trans('list.amount') }}</th>
                                <th class="hidden-sm hidden-xs">{{ trans('list.date') }}</th>
                                <th class="hidden-xs">{{ trans('list.from') }}</th>
                                <th class="hidden-xs">{{ trans('list.to') }}</th>
                            </tr>
                            {% for journal in journals %}
                                <tr>
                                    <td>
                                        <input type="checkbox" name="confirm_mass_delete[]" value="{{ journal.transaction_journal_id }}" checked/>
                                    </td>
                                    <td>
                                        {% if journal.transaction_type_type == 'Withdrawal' %}
                                            <span class="fa fa-long-arrow-left fa-fw" title="{{ trans('firefly.Withdrawal') }}"></span>
                                        {% endif %}

                                        {% if journal.transaction_type_type == 'Deposit' %}
                                            <span class="fa fa-long-arrow-right fa-fw" title="{{ trans('firefly.Deposit') }}"></span>
                                        {% endif %}

                                        {% if journal.transaction_type_type == 'Transfer' %}
                                            <span class="fa fa-exchange fa-fw" title="{{ trans('firefly.Deposit') }}"></span>
                                        {% endif %}

                                        {% if journal.transaction_type_type == 'Reconciliation' %}
                                            <span class="fa-fw fa fa-calculator" title="{{ trans('firefly.reconciliation_transaction') }}"></span>
                                        {% endif %}
                                        {% if journal.transaction_type_type == 'Opening balance' %}
                                            <span class="fa-fw fa fa-star-o" title="{{ trans('firefly.Opening balance') }}"></span>
                                        {% endif %}
                                    </td>
                                    <td>
                                        <a href="{{ route('transactions.show',journal.transaction_group_id) }}"
                                           title="{{ journal.description }}">{{ journal.description }}</a>
                                    </td>
                                    <td>
                                        {% if journal.transaction_type_type == 'Deposit' %}
                                            {{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_decimal_places) }}
                                            {% if null != journal.foreign_amount %}
                                                ({{ formatAmountBySymbol(journal.foreign_amount*-1, journal.foreign_currency_symbol, journal.foreign_currency_decimal_places) }})
                                            {% endif %}
                                        {% elseif journal.transaction_type_type == 'Transfer' %}
                                            <span class="text-info money-transfer">{{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_decimal_places, false) }}
                                                {% if null != journal.foreign_amount %}
                                                    ({{ formatAmountBySymbol(journal.foreign_amount*-1, journal.foreign_currency_symbol, journal.foreign_currency_decimal_places, false) }})
                                                {% endif %}
                                            </span>
                                        {% else %}
                                            {{ formatAmountBySymbol(journal.amount, journal.currency_symbol, journal.currency_decimal_places) }}
                                            {% if null != journal.foreign_amount %}
                                                ({{ formatAmountBySymbol(journal.foreign_amount, journal.foreign_currency_symbol, journal.foreign_currency_decimal_places) }})
                                            {% endif %}
                                        {% endif %}
                                    </td>
                                    <td>
                                        {{ journal.date.isoFormat(monthAndDayFormat) }}
                                    </td>
                                    <td>
                                        <a href="{{ route('accounts.show', [journal.source_account_id]) }}"
                                           title="{{ journal.source_account_iban|default(journal.source_account_name) }}">{{ journal.source_account_name }}</a>
                                    </td>
                                    <td>
                                        <a href="{{ route('accounts.show', [journal.destination_account_id]) }}"
                                           title="{{ journal.destination_account_iban|default(journal.destination_account_name) }}">{{ journal.destination_account_name }}</a>
                                    </td>
                                </tr>
                            {% endfor %}
                        </table>

                    </div>
                    <div class="box-footer">
                        <input type="submit" name="submit" value="{{ trans('form.delete_all_permanently') }}" class="btn btn-danger pull-right"/>
                        <a href="{{ route('index') }}" class="btn-default btn">{{ trans('form.cancel') }}</a>
                    </div>
                </div>
            </div>
        </div>
    </form>
{% endblock %}
