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

{% load i18n %}
{% load rules %}

{% block extra_title %}{{ page_obj.paginator.count }} {% blocktranslate trimmed count count=page_obj.paginator.count %}submitter{% plural %}submitters{% endblocktranslate %} :: {% endblock extra_title %}

{% block content %}
    <h2>
        {{ page_obj.paginator.count }}
        {% blocktranslate trimmed count count=page_obj.paginator.count %}
            submitter
        {% plural %}
            submitters
        {% endblocktranslate %}
    </h2>

    {% include "common/includes/search_form.html" %}

    {% if filter_form.is_valid and filter_form.cleaned_data.question %}
        <p class="text-muted ml-2">
            <span class="fa fa-filter"></span>
            {% blocktranslate trimmed with question=filter_form.cleaned_data.question.question %}
                List filtered by answers to question “{{ question }}”.
            {% endblocktranslate %}
            <a href="{% querystring question="" answer="" answer__options="" %}" class="text-muted">
                <span class="fa fa-times"></span>
                {% translate "Remove filter" %}
            </a>
        </p>
    {% endif %}

    {% has_perm "orga.mark_speakers_arrived" request.user request.event as can_mark_speaker %}
    {% has_perm "orga.see_speakers_arrival" request.user request.event as can_see_speaker_status %}
    <div class="table-responsive-md">
        <table class="table table-sm table-hover table-flip table-sticky">
            <thead>
                <tr>
                    <th>{% translate "Name" %}</th>
                    <th class="numeric">{% translate "Accepted Proposals" %}</th>
                    <th class="numeric">{% translate "Proposals" %}</th>
                    {% if can_mark_speaker or can_see_speaker_status %}<th></th>{% endif %}
                </tr>
            </thead>
            <tbody>
                {% for profile in speakers %}
                    <tr>
                        <td>
                            <a href="{{ profile.orga_urls.base }}">
                                {% include "orga/includes/user_name.html" with user=profile.user %}
                            </a>
                        </td>
                        <td class="numeric">{{ profile.accepted_submission_count }}</td>
                        <td class="numeric">{{ profile.submission_count }}</td>
                        {% if can_mark_speaker or can_see_speaker_status %}
                            <td class="text-right">
                                {% if profile.accepted_submission_count %}
                                    {% if can_mark_speaker %}
                                        <a class="btn btn-sm btn-{{ profile.has_arrived|yesno:"success,info" }}" href="{{ profile.orga_urls.toggle_arrived }}?from=list">
                                            {% if profile.has_arrived %}
                                                {% translate "Mark speaker as not arrived" %}
                                            {% else %}
                                                {% translate "Mark speaker as arrived" %}
                                            {% endif %}
                                        </a>
                                    {% else %}
                                        {% if profile.has_arrived %}
                                            <a><i class="fa fa-check"></i> {% translate "Arrived" %}</a>
                                        {% else %}
                                            <a><i class="fa fa-times"></i> {% translate "Not arrived" %}</a>
                                        {% endif %}
                                    {% endif %}
                                {% endif %}
                            </td>
                        {% endif %}
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>

    {% include "orga/includes/pagination.html" %}

{% endblock content %}
