{% import "includes/macros" as macros %}
{% import "includes/forms/log" as log %}
{% extends "base" %}
{% block content %}
    <link rel="stylesheet" href="/public/table.css" />
    <div class="w-full">
        <h1 class="h1">Abzeichen für {{ rowingbadge_year }}</h1>
        <div class="text-black dark:text-white">
            <table id="basic">
                <thead>
                    <tr>
                        <th>Name</th>
                        <th>Erster Log</th>
                        <th>Letzter Log</th>
                        <th>Gesamt-KM</th>
                        <th>Äquatorpreis (ÄP)</th>
                        <th>
                            ÄP diese
                            <br>
                            Saison bekommen
                        </th>
                        <th>
                            Fahrtenabzeichen (FA)
                            <br>
                            geschafft
                        </th>
                        <th>FA - KM</th>
                        <th>FA - fehlende KM</th>
                        <th>Eintagesausfahrten</th>
                        <th>Mehrtagesausfahrten</th>
                    </tr>
                </thead>
                <tbody>
                    {% for person in people %}
                        {% set user = person.0 %}
                        {% set achievement = person.1 %}
                        <tr>
                            <td>{{ user.name }}</td>
                            <td>
                                {% if achievement.year_first_mentioned %}{{ achievement.year_first_mentioned }}{% endif %}
                            </td>
                            <td>
                                {% if achievement.year_last_mentioned %}{{ achievement.year_last_mentioned }}{% endif %}
                            </td>
                            <td>{{ achievement.all_time_km }}</td>
                            <td>{{ achievement.curr_equatorprice_name }}</td>
                            <td>
                                {% if achievement.new_equatorprice_this_season %}
                                    🎉
                                {% else %}
                                    -
                                {% endif %}
                            </td>
                            {% if achievement.rowingbadge %}
                                {% set badge = achievement.rowingbadge %}
                                <td>
                                    {% if badge.achieved %}
                                        ja
                                    {% else %}
                                        nein
                                    {% endif %}
                                </td>
                                <td>{{ badge.rowed_km }} / {{ badge.required_km }}</td>
                                <td>{{ badge.missing_km }}</td>
                                <td>
                                    <details>
                                        <summary>
                                            > {{ badge.single_day_trips_required_distance }} km: {{ badge.single_day_trips_over_required_distance | length }} / 2
                                        </summary>
                                        {% for log in badge.single_day_trips_over_required_distance %}
                                            {{ log::show_old(log=log, state="completed", only_ones=false, index=loop.index, hide_type=true) }}
                                        {% endfor %}
                                    </details>
                                </td>
                                <td>
                                    <details>
                                        <summary>
                                            > {{ badge.multi_day_trips_required_distance }} km: {{ badge.multi_day_trips_over_required_distance | length }} / 1
                                        </summary>
                                        {% for log in badge.multi_day_trips_over_required_distance %}
                                            {{ log::show_old(log=log, state="completed", only_ones=false, index=loop.index, hide_type=true) }}
                                        {% endfor %}
                                    </details>
                                </td>
                            {% else %}
                                <td>Geb.datum fehlt 👻</td>
                                <td>Geb.datum fehlt 👻</td>
                                <td>Geb.datum fehlt 👻</td>
                                <td>Geb.datum fehlt 👻</td>
                                <td>Geb.datum fehlt 👻</td>
                            {% endif %}
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
    <script src="/public/jstable.min.js"></script>
    <script src="/public/table.js"></script>
{% endblock content %}