{% extends "orga/cfp/base.html" %}
{% load bootstrap4 %}
{% load i18n %}
{% load rules %}
{% load url_replace %}

{% block content %}

{% has_perm 'orga.create_submission' request.user request.event as can_create_submission %}

    <legend>
        {{ page_obj.paginator.count }}
        {% blocktrans trimmed count count=page_obj.paginator.count %}
        submission
        {% plural %}
        submissions
        {% endblocktrans %}
    </legend>

    <p>
        {% if can_create_submission %}
        <a href="{{ request.event.orga_urls.new_submission }}" class="btn btn-primary">
            <span class="fa fa-plus"></span> {% trans "Add new submission" %}
        </a>
        {% endif %}
        <a href="{{ request.event.orga_urls.submission_cards }}" class="btn btn-default">
            <span class="fa fa-print"></span> {% trans "Print cards" %}
        </a>
    </p>

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

    <table class="table table-condensed table-responsive-md">
        <thead>
            <tr>
                <th>
                    {% trans "Title" %}
                    <a href="?{% url_replace request 'sort' '-title' %}"><i class="fa fa-caret-down"></i></a>
                    <a href="?{% url_replace request 'sort' 'title' %}"><i class="fa fa-caret-up"></i></a>
                </th>
                <th>{% trans "Speakers" %}</th>
                <th>
                    {% trans "Type" %}
                    <a href="?{% url_replace request 'sort' '-submission_type' %}"><i class="fa fa-caret-down"></i></a>
                    <a href="?{% url_replace request 'sort' 'submission_type' %}"><i class="fa fa-caret-up"></i></a>
                </th>
                <th>
                    {% trans "State" %}
                    <a href="?{% url_replace request 'sort' '-state' %}"><i class="fa fa-caret-down"></i></a>
                    <a href="?{% url_replace request 'sort' 'state' %}"><i class="fa fa-caret-up"></i></a>
                </th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            {% for submission in submissions %}
                <tr>
                    <td>
                        <a href="{{ submission.orga_urls.base }}">
                            {{ submission.title }}
                        </a>
                    </td>
                    <td>
                        {% for speaker in submission.speakers.all %}
                            <a href="{% url "orga:speakers.view" event=request.event.slug pk=speaker.id %}">
                                {{ speaker.get_display_name }}
                            </a><br>
                        {% endfor %}
                    </td>
                    <td>
                        {{ submission.submission_type.name }}
                    </td>
                    <td>
                        {% include "cfp/event/fragment_state.html" with state=submission.state %}
                    </td>
                    <td class="text-right">
                        <a href="{{ submission.orga_urls.edit }}"
                            title="{% trans "edit" %}"
                            class="btn btn-sm btn-secondary">
                            <span class="fa fa-pencil"></span>
                        </a>
                        <a href="{{ submission.orga_urls.delete }}?from=list"
                            title="{% trans "delete" %}"
                            class="btn btn-sm btn-secondary">
                            <span class="fa fa-trash"></span>
                        </a>
                    </td>
                </tr>
            {% endfor %}
        </tbody>
    </table>

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


{% endblock %}
