{% extends 'corphandouts/base.html' %}
{% load aa_i18n %}
{% load i18n %}
{% load evelinks %}
{% load filters %}
{% load humanize %}
{% block handouts_block %}
    {% if not doctrines %}
    {% else %}
        <table class="table table-striped table-hover" id="reportTable">
            <thead>
                <tr>
                    <th>{% translate "Name" %}</th>
                    <th>
                        {% translate "Corporation<br>Division" %}
                    </th>
                    <th>{% translate "Ships to fix" %}</th>
                    <th>{% translate "Ships" %}</th>
                </tr>
            </thead>
            <tbody>
                {% for doctrine in doctrines %}
                    <tr>
                        <td>
                            <a class="text-decoration-none"
                               href="{% url "corphandouts:doctrine_report" doctrine.id %}">
                                <span class="d-block" style="min-width: 250px;">
                                    <span class="me-2" style="height: 64px; width: 64px;">
                                        <img src="{{ doctrine.first_ship_type_id|type_icon_url:64 }}"
                                             class="rounded"
                                             height="64"
                                             width="64"
                                             alt="">
                                    </span>
                                    <span>{{ doctrine.name }}</span>
                                </span>
                            </a>
                        </td>
                        <td>
                            {{ doctrine.corporation.corporation.corporation_name }}
                            <br>
                            {{ doctrine.corporation_hangar_division }}
                        </td>
                        <td>{{ doctrine.count_corrections }}</td>
                        <td>
                            {% for ship_type_id in doctrine.ship_types_ids %}
                                <img src="{{ ship_type_id|type_render_url:32 }}"
                                     class="rounded"
                                     data-bs-tooltip="aa-corphandouts">
                            {% endfor %}
                        </td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    {% endif %}
{% endblock %}
{% block extra_javascript %}
    {% include 'bundles/datatables-js-bs5.html' %}
    {% get_datatables_language_static LANGUAGE_CODE as DT_LANG_PATH %}
    <script>
        $(document).ready(() => {
            {% if doctrines %}
                $('#reportTable').DataTable({
                    language: {
                        url: '{{ DT_LANG_PATH }}'
                    },
                    order: [[ 0, "asc" ]],
                });
            {% endif %}

            $('[data-bs-tooltip="aa-corphandouts"]').tooltip();
        });
    </script>
{% endblock %}
