{% extends 'ledger/base.html' %}
{% load i18n %}

{% block page_template_title %}
    {{ title }}
{% endblock page_template_title %}

{% block page_topic %}
    <h1 class="page-header text-center">
        {{ title }}
    </h1>
{% endblock page_topic %}

{% block ledger_block %}
    <div class="card-body bg-primary rounded-top d-flex align-items-center">
        <h3 class="me-3">{% translate "Alliance Ledger" %}</h3>
        {% if years %}
            <div class="dropdown px-2">
                <button id="yearDropDownButton" class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
                    {% trans "Year" %}
                </button>
                <ul class="dropdown-menu" id="yearDropdown">
                    {% for year in years %}
                        <li>
                            <a class="dropdown-item {% if view.date.year|default:'null' == year %}active{% endif %}" href="{% url 'ledger:alliance_ledger' alliance_id=alliance_id year=year %}{% if view.type == 'single' %}?single=True{% endif %}">{{ year }}</a>
                        </li>
                    {% endfor %}
                </ul>
            </div>
            <div class="dropdown px-2">
                <button id="monthDropDownButton" class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
                    {% trans "Month" %}
                </button>
                <ul class="dropdown-menu" id="monthDropdown">
                    {% for m in 12|range_filter %}
                        <li>
                            <a class="dropdown-item {% if view.date.month|default:'null' == m %}active{% endif %}" href="{% url 'ledger:alliance_ledger' alliance_id=alliance_id year=view.date.year|default:view.date.current.year month=m %}{% if view.type == 'single' %}?single=True{% endif %}">
                                {{ m|month_name }}
                            </a>
                        </li>
                    {% endfor %}
                </ul>
            </div>
            <div class="dropdown px-2">
                <button id="dayDropDownButton" class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
                    {% trans "Day" %}
                </button>
                <ul class="dropdown-menu" id="dayDropdown">
                    {% month_days view.date as month_days %}
                    {% for day in month_days %}
                        <li>
                            <a class="dropdown-item {% if view.date.day|default:'null' == day %}active{% endif %}" href="{% url 'ledger:alliance_ledger' alliance_id=alliance_id year=view.date.year|default:view.date.current.year month=view.date.month|default:view.date.current.month day=day %}{% if view.type == 'single' %}?single=True{% endif %}">
                                {{ day }}
                            </a>
                        </li>
                    {% endfor %}
                </ul>
            </div>
        {% endif %}
        <div class="ms-auto">
            <a class="btn btn-secondary me-2 administration {% if disabled %}disabled{% endif %}" href="{% url 'ledger:alliance_administration' alliance_id=alliance_id %}">{% translate 'Administration' %}</a>
            <a href="{% url 'ledger:alliance_overview' %}"><button class="btn btn-secondary overview">{% translate 'Alliance Overview' %}</button></a>
        </div>
    </div>
    <div id="ledger-index" class="card-body rounded-bottom fade">
        <div class="card-body bg-secondary table-responsive">
            {% include 'ledger/partials/table/corp-ledger.html' with characters=characters totals=totals %}
        </div>

        {% include 'ledger/partials/thirdparty/billboard.html' %}
    </div>
    {% include 'ledger/partials/modal/modal.html' with name="ViewCharacter" %}
{% endblock %}

{% block extra_css %}
    {% include 'ledger/bundles/table-css.html' %}
{% endblock %}

{% block extra_javascript %}
    {% include 'bundles/datatables-js-bs5.html' %}
    {% include 'ledger/bundles/ledger-bundles.html' %}
    {% include 'ledger/bundles/corporation-ledger-bundles.html' %}
{% endblock extra_javascript %}

{% block extra_script %}
{% endblock extra_script %}
