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

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

{% block content %}
    <div class="row">
        <div class="col-lg-12 col-sm-12 col-md-12">
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">{{ 'currencies'|_ }}</h3>
                    <a class="btn btn-success pull-right" href="{{ route('currencies.create') }}">{{ 'create_currency'|_ }}</a>
                </div>
                <div class="box-body">
                    <p>
                        {{ 'currencies_intro'|_ }}
                        {{ 'currencies_default_disabled'|_ }}
                        {{ 'currencies_switch_default'|_ }}
                    </p>
                    {% if currencies|length > 0 %}
                        <div class="m-1">
                            {{ currencies.links('pagination.bootstrap-4')|raw }}
                        </div>
                        <table class="table table-hover">
                            <thead>
                            <tr>
                                <th>&nbsp;</th>
                                <th>{{ 'currency'|_ }}</th>
                                <th>{{ 'number_of_decimals'|_ }}</th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for currency in currencies %}
                                <tr>
                                        <td>
                                            <div class="btn-group btn-group-xs">
                                                {% if isOwner %}
                                                <a class="btn btn-default" href="{{ route('currencies.edit',currency.id) }}"><span
                                                        class="fa fa-fw fa-pencil"></span></a>
                                                <a class="btn btn-danger" href="{{ route('currencies.delete',currency.id) }}"><span
                                                        class="fa fa-fw fa-trash"></span></a>
                                                {% endif %}
                                                {# Disable the currency. #}
                                                {% if currency.userGroupEnabled %}
                                                    <a class="btn btn-default disable-currency" data-code="{{ currency.code }}"
                                                       href="#">
                                                        <span class="fa fa-fw fa-square-o"></span>
                                                        {{ 'disable_currency'|_ }}</a>
                                                {% endif %}

                                                {# Enable the currency. #}
                                                {% if not currency.userGroupEnabled %}
                                                    <a class="btn btn-default enable-currency" data-code="{{ currency.code }}"
                                                       href="#">
                                                        <span class="fa fa-fw fa-check-square-o"></span>
                                                        {{ 'enable_currency'|_ }}</a>
                                                {% endif %}
                                            </div>
                                        </td>
                                    <td>
                                        {% if currency.userGroupEnabled == false %}
                                        <span class="text-muted">
                                        {% endif %}
                                            {{ currency.name }} ({{ currency.code }}) ({{ currency.symbol|raw }})
                                        {% if currency.id == primaryCurrency.id %}
                                            <span class="label label-success" id="default-currency">{{ 'primary_currency_button'|_ }}</span>
                                        {% endif %}
                                        {% if currency.userGroupEnabled == false %}

                                            <span class="label label-default">{{ 'currency_is_disabled'|_ }}</span>
                                            {% endif %}

                                        {% if currency.userGroupEnabled == false %}
                                        </span>
                                        {% endif %}
                                    </td>

                                    <td>{{ currency.decimal_places }}</td>
                                </tr>
                            {% endfor %}
                            </tbody>
                        </table>
                        <div class="m-1">
                            {{ currencies.links('pagination.bootstrap-4')|raw }}
                        </div>
                    {% endif %}
                </div>
                <div class="box-footer">
                    <a class="btn btn-success pull-right" href="{{ route('currencies.create') }}">{{ 'create_currency'|_ }}</a>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
{% block scripts %}
    <script type="text/javascript" nonce="{{ JS_NONCE }}">
        var redirectUrl = "{{ route('currencies.index') }}";
        var updateCurrencyUrl = "{{ route('api.v1.currencies.update', ['']) }}";
    </script>
    <script type="text/javascript" src="v1/js/ff/currencies/index.js?v={{ FF_BUILD_TIME }}" nonce="{{ JS_NONCE }}"></script>
{% endblock %}
