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

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

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

        <div class="row">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div class="box box-default">
                    <div class="box-header with-border">
                        <h3 class="box-title">{{ 'mass_bulk_journals'|_ }}</h3>
                    </div>

                    <div class="box-body">
                        <p>
                            {{ 'mass_bulk_journals_explain'|_ }}
                        </p>

                        <div class="row">
                            <div class="col-lg-8 col-md-12 col-sm-12 col-xs-12">
                                <table class="table table-striped table-condensed">
                                    <thead>
                                    <tr>
                                        <th>{{ trans('list.description') }}</th>
                                        <th>{{ trans('list.amount') }}</th>
                                        <th>{{ trans('list.date') }}</th>
                                        <th>{{ trans('list.category') }}</th>
                                        <th>{{ trans('list.budget') }}</th>
                                        <th>{{ trans('list.tags') }}</th>
                                        <th>&nbsp;</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {% for journal in journals %}
                                        <input type="hidden" name="journals[]" value="{{ journal.transaction_journal_id }}"/>
                                        <tr>
                                            <td>
                                                <a href="{{ route('transactions.show', [journal.transaction_group_id]) }}">
                                                    {{ 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>
                                                {% if journal.category_id != null %}
                                                    <a href="{{ route('categories.show', [journal.category_id]) }}" title="{{ journal.category_name }}">{{ journal.category_name }}</a>
                                                {% endif %}
                                            </td>
                                            <td>
                                                {% if journal.budget_id != null %}
                                                    <a href="{{ route('budgets.show', [journal.budget_id]) }}" title="{{ journal.budget_name }}">{{ journal.budget_name }}</a>
                                                {% endif %}
                                            </td>
                                            <td>
                                                {% for tag in journal.tags %}
                                                    {% if 0 != tag.id %}
                                                        <span style="display: inline;"><a class="label label-success" href="{{ route('tags.show', [tag.id]) }}">
                                                        <span class="fa fa-fw fa-tag"></span>
                                                        {{ tag.name }}</a>
                                                </span>
                                                    {% endif %}
                                                {% endfor %}
                                            </td>
                                            <td>
                                                {% if journal.journals_in_group > 1 %}
                                                    <span title="{{ 'part_of_split'|_ }}" class="text-danger fa fa-fw fa-exclamation-triangle"></span>
                                                {% endif %}
                                            </td>
                                        </tr>
                                    {% endfor %}
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <p>
                            {{ 'bulk_set_new_values'|_ }}
                        </p>
                        <div class="row">
                            <div class="col-lg-8 col-md-12 col-sm-12 col-xs-12">
                                <table class="table table-striped table-condensed">
                                    <tr>
                                        <th style="width:25%;">{{ trans('list.category') }}</th>
                                        <td>
                                            <input class="form-control" placeholder="" name="category" autocomplete="off" type="text" value="" spellcheck="false">
                                        </td>
                                        <td>
                                            <div class="checkbox">
                                                <label>
                                                    <input name="ignore_category" type="checkbox" value="1" checked>
                                                    {{ 'no_bulk_category'|_ }}
                                                </label>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>{{ trans('list.budget') }}</th>
                                        <td>
                                            <select class="form-control" name="budget_id">
                                                {% for id, budget in budgetList %}
                                                    <option value="{{ id }}" label="{{ budget }}">{{ budget }}</option>
                                                {% endfor %}
                                            </select>
                                        </td>
                                        <td>
                                            <div class="checkbox">
                                                <label>
                                                    <input name="ignore_budget" type="checkbox" value="1" checked>
                                                    {{ 'no_bulk_budget'|_ }}
                                                </label>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>{{ trans('list.tags') }}</th>
                                        <td>
                                            <input class="form-control" placeholder="" name="tags" autocomplete="off" type="text" value="" spellcheck="false">
                                        </td>
                                        <td>
                                            <div class="radio">
                                                <label>
                                                    <input type="radio" name="tags_action" id="tags_action_do_nothing" value="no_nothing" checked/>
                                                    {{ 'no_bulk_tags'|_ }}
                                                </label>
                                            </div>
                                            <div class="radio">
                                                <label>
                                                    <input type="radio" name="tags_action" id="tags_action_do_replace" value="do_replace"/>
                                                    {{ 'replace_with_these_tags'|_ }}
                                                </label>
                                            </div>
                                            <div class="radio">
                                                <label>
                                                    <input type="radio" name="tags_action" id="tags_action_do_append" value="do_append"/>
                                                    {{ 'append_these_tags'|_ }}
                                                </label>
                                            </div>
                                        </td>
                                    </tr>
                                </table>

                            </div>
                        </div>

                    </div>

                    <div class="box-footer">
                        <div class="row">
                            <div class="col-lg-8">
                                <input type="submit" name="submit" value="{{ trans('form.update_all_journals') }}" class="btn btn-success pull-right"/>
                                <a href="{{ route('index') }}" class="btn-default btn">{{ trans('form.cancel') }}</a>
                            </div>
                        </div>


                    </div>

                </div>

            </div>

        </div>

    </form>
{% endblock %}
{% block scripts %}
    <script type="text/javascript" nonce="{{ JS_NONCE }}">
        var what = "";
    </script>
    <script type="text/javascript" src="v1/js/lib/typeahead/typeahead.bundle.min.js?v={{ FF_BUILD_TIME }}" nonce="{{ JS_NONCE }}"></script>
    <script type="text/javascript" src="v1/js/ff/common/autocomplete.js?v={{ FF_BUILD_TIME }}" nonce="{{ JS_NONCE }}"></script>
    <script type="text/javascript" src="v1/js/lib/bootstrap-tagsinput.min.js?v={{ FF_BUILD_TIME }}" nonce="{{ JS_NONCE }}"></script>
    <script type="text/javascript" src="v1/js/ff/transactions/mass/edit-bulk.js?v={{ FF_BUILD_TIME }}" nonce="{{ JS_NONCE }}"></script>
{% endblock %}
{% block styles %}
    <link href="v1/css/bootstrap-tagsinput.css?v={{ FF_BUILD_TIME }}" type="text/css" rel="stylesheet" media="all" nonce="{{ JS_NONCE }}">
{% endblock %}
