{% extends "corpstat/base.html" %}

{% load i18n %}
{% load evelinks %}

{% block member_data %}
    <div class="aa-corpstats-search">
        <div class="card card-default">
            <div class="card-header">
                <div class="card-title mb-0">{% trans "Search Results" %}</div>
            </div>

            <div class="card-body">
                <table class="table table-striped table-hover w-100" id="table-search">
                    <thead>
                        <tr>
                            <th></th>
                            <th>{% trans "Character" %}</th>
                            <th>{% trans "Corporation" %}</th>
                            <th>{% trans "zKillboard" %}</th>
                            <th>{% trans "Main Character" %}</th>
                            <th>{% trans "Main Corporation" %}</th>
                            <th>{% trans "Main Alliance" %}</th>
                        </tr>
                    </thead>

                    <tbody>
                        {% for result in results %}
                            <tr{% if not result.1.registered %} class="table-warning"{% endif %}>
                                <td>
                                    <img
                                        class="img-circle"
                                        src="{{ result.1.character_id|character_portrait_url:32 }}"
                                        alt="{{ result.1.character_name }}"
                                    >
                                </td>
                                <td>{{ result.1.character_name }}</td>
                                <td>{{ result.0.corp.corporation_name }}</td>

                                <td class="text-center" style="width: 5%;">
                                    <a
                                        class="badge bg-danger"
                                        href="{{ result.1.character_id|zkillboard_character_url }}"
                                        target="_blank"
                                    >
                                        {% trans "Killboard" %}
                                    </a>
                                </td>

                                <td>{{ result.1.main_character.character_name }}</td>
                                <td>{{ result.1.main_character.corporation_name }}</td>
                                <td>{{ result.1.main_character.alliance_name }}</td>
                            </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
{% endblock %}

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

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

    <script>
        $(document).ready(() => {
            $('#table-search').DataTable();
        });
    </script>
{% endblock %}
