{% extends 'afat/base.html' %}

{% load static %}
{% load i18n %}

{% block page_title %}{% translate 'Fleet Activity' %}{% endblock %}

{% block afat_header %}
    <br>
    {% include "afat/partials/menu.html" %}

    <h2>{% translate "All FAT Links" %}</h2>
{% endblock %}

{% block afat_body %}
    <h4>
        <a class="btn btn-primary btn-sm" href="{% url 'afat:links' year_prev %}" title='{% translate "Previous Month" %}'><i class="fas fa-backward"></i></a>

        <span class="afat-label-statistics">{{ year }}</span>

        {% if year_next <= year_current %}
            <a class="btn btn-primary btn-sm" href="{% url 'afat:links' year_next %}" title='{% translate "Next Month" %}'><i class="fas fa-forward"></i></a>
            <a class="btn btn-primary btn-sm" href="{% url 'afat:links' year_current %}" title='{% translate "Current Month" %}'><i class="fas fa-fast-forward"></i></a>
        {% endif %}
    </h4>

    {% if msg %}
        <div class="alert alert-{{ msg.0 }} alert-dismissible" role="alert">
            <button type="button" class="close" data-dismiss="alert" aria-label="close">
                <span aria-hidden="true">&times</span>
            </button>

            <h4>
                {% if msg.0 == 'danger' %}
                    {% translate "Oh No!" %}
                {% elif msg.0 == 'success' %}
                    {% translate "Success!" %}
                {% endif %}
            </h4>

            <p>{{ msg.1 }}</p>
        </div>
    {% endif %}

    <div class="panel panel-default">
        <div class="panel-body">
            <table class="table table-striped table-hover" id="link-list" style="width: 100%;">
                <thead>
                    <tr>
                        <th>{% translate "Fleet Name" %}</th>
                        <th>{% translate "Fleet Type" %}</th>
                        <th>{% translate "Creator" %}</th>
                        <th>{% translate "EVE Time" %}</th>
                        <th>{% translate "# of FATs" %}</th>
                        <th><!-- {% translate "Actions" %} --></th>
                    </tr>
                </thead>

                <tbody></tbody>

                <tfoot>
                    <tr>
                        <td colspan="{% if perms.afat.manage_afat %}6{% else %}5{% endif %}">
                            {% include "afat/partials/fatlinks/fatlink_list_legend.html" %}
                        </td>
                    </tr>
                </tfoot>
            </table>
        </div>
    </div>

    {% translate "Delete FAT Link" as translated_title %}
    {% include "afat/modals/general.html" with modal_name='deleteFatLink' modal_title=translated_title confirm_button_class='btn-danger' %}
{% endblock %}

{% block extra_css %}
    {% include 'bundles/datatables-css.html' %}

    <link rel="stylesheet" type="text/css" href="{% static 'afat/css/aa-bootstrap-fix.min.css' %}">
    <link rel="stylesheet" type="text/css" href="{% static 'afat/css/allianceauth-afat.min.css' %}">
{% endblock %}

{% block extra_javascript %}
    {% include 'bundles/datatables-js.html' %}
    {% include 'bundles/moment-js.html' with locale=True %}

    <script type="application/javascript" src="{% static 'afat/libs/datatables/plugins/dataTables.rowGroup.min.js' %}"></script>
    <script type="application/javascript" src="{% static 'afat/libs/datatables/plugins/datetime.min.js' %}"></script>
    <script type="application/javascript" src="{% static 'js/filterDropDown/filterDropDown.min.js' %}"></script>
    <script type="application/javascript" src="{% static 'afat/javascript/allianceauth-afat.min.js' %}"></script>

    <script type="application/javascript">
        let afatSettings = {
            url: {
                linkList: '{% url 'afat:fatlinks_ajax_get_fatlinks_by_year' year %}'
            },
            permissions: {
                addFatLink: {% if perms.afat.add_fatlink %}true{% else %}false{% endif %},
                manageAfat: {% if perms.afat.manage_afat %}true{% else %}false{% endif %}
            },
            translation: {
                dataTable: {
                    filter: {
                        viaEsi: '{% translate 'via ESI' %}'
                    }
                },
            },
            modal: {
                deleteModal: {
                    element: '#deleteFatLinkModal'
                }
            }
        }
    </script>
    <script type="application/javascript" src="{% static 'afat/javascript/afat-fatlist.min.js' %}"></script>
{% endblock %}
