{% extends 'events/management/base.html' %}
{% from 'message_box.html' import message_box %}

{% block title %}
    {%- trans %}Registration{% endtrans -%}
{% endblock %}

{% block description %}
    {% trans -%}
        Registration forms allow people to register for the event.
    {%- endtrans %}
{% endblock %}

{% block content %}
    {% if not event.has_feature('payment') %}
        {% block payments_disabled_box %}
            <div id="payment-disabled-notice" class="action-box highlight">
                <div class="section">
                    <div class="icon icon-coins"></div>
                    <div class="text">
                        <div class="label">
                            {% trans %}Payments disabled{% endtrans %}
                        </div>
                        {% trans %}Payments are disabled for this event{% endtrans %}
                    </div>
                    {% if event.can_manage(session.user) %}
                        <div class="toolbar hide-if-locked">
                            <a href="#" class="js-enable-payments"
                               data-href="{{ url_for('event_features.switch', event, feature='payment') }}"
                               data-method="PUT"
                               data-title="{% trans %}Enable payments for the whole event?{% endtrans %}"
                               data-confirm="{% trans %}This will enable payments for all registration forms. If you need to disable it later on, you can do it from the Features menu entry.{% endtrans %}">
                                {% trans %}Enable payments{% endtrans %}
                            </a>
                        </div>
                    {% endif %}
                </div>
            </div>
        {% endblock %}
    {% endif %}

    {% block global_registration_actions_box %}
        <div class="action-box">
            <div class="section">
                <div class="icon icon-settings"></div>
                <div class="text">
                    <div class="label">{% trans %}Registration managers{% endtrans %}</div>
                    {% trans %}Add/remove users allowed to manage registrations{% endtrans %}
                </div>
                <div class="toolbar">
                    <div class="group">
                        <button class="i-button icon-settings"
                                data-title="{% trans %}Manage registration managers{% endtrans %}"
                                data-href="{{ url_for('.manage_registration_managers', event) }}"
                                data-ajax-dialog>
                            {%- trans %}Configure{% endtrans -%}
                        </button>
                    </div>
                </div>
            </div>
            <div class="section">
                <div class="icon icon-list"></div>
                <div class="text">
                    <div class="label">{% trans %}Participant list{% endtrans %}</div>
                    {% trans %}Define how the participant list will be shown on the event page{% endtrans %}
                </div>
                {% if event.type == 'conference' %}
                    <div class="toolbar">
                        <div class="group">
                            <a href="{{ url_for('.manage_participant_list_preview', event) }}" class="i-button icon-list">
                                {%- trans %}Preview as participant{% endtrans -%}
                            </a>
                        </div>
                    </div>
                {% endif %}
                <div class="toolbar">
                    <div class="group">
                        <a href="{{ url_for('.manage_regforms_display', event) }}" class="i-button icon-settings">
                            {%- trans %}Customize{% endtrans -%}
                        </a>
                    </div>
                </div>
            </div>
            {% block tags_section %}
                <div class="section">
                    <div class="icon icon-tag"></div>
                    <div class="text">
                        <div class="label">{% trans %}Registration tags{% endtrans %}</div>
                        {% trans %}Create tags to mark and filter registrations{% endtrans %}
                    </div>
                    <div class="toolbar">
                        <div class="group">
                            <a href="{{ url_for('.manage_registration_tags', event) }}" class="i-button icon-settings">
                                {%- trans %}Configure{% endtrans -%}
                            </a>
                        </div>
                    </div>
                </div>
            {% endblock %}
            {% if event.type == 'conference' and regforms|length > 1 %}
                {% block description_section %}
                    <div class="section">
                        <div class="icon icon-textarea"></div>
                        <div class="text">
                            <div class="label">{% trans %}Announcement for multiple registration forms{% endtrans %}</div>
                            {% trans %}Display a text on top of the registration form list{% endtrans %}
                        </div>
                        <div class="toolbar">
                            <div class="group">
                                <a href="#" id="ngo-quotas" class="i-button icon-settings"
                                   data-href="{{ url_for('.manage_registration_multi_forms_announcement', event) }}"
                                   data-title="{%- trans %}Edit announcement for multiple registration forms{% endtrans -%}"
                                   data-ajax-dialog>
                                    {%- trans %}Configure{% endtrans -%}
                                </a>
                            </div>
                        </div>
                    </div>
                {% endblock %}
            {% endif %}
        </div>
    {% endblock %}
    {{ template_hook('extra-registration-settings', event=event) }}
    <div class="regform-list">
        <h3>{% trans %}List of registration forms{% endtrans %}</h3>
        {% for regform in regforms %}
            <div class="action-box">
                <div class="section">
                    <div class="icon icon-quill"></div>
                    <div class="text">
                        <div class="label">{{ regform.title }}</div>
                    </div>
                    <div class="toolbar">
                        <div class="group">
                            {% set purged_title %}
                                {% trans %}Registration is disabled due to an expired retention period{% endtrans %}
                            {% endset %}
                            <a href="{{ url_for('.manage_reglist', regform) }}"
                               class="i-button icon-users {% if regform.is_purged %}disabled{% endif %}"
                               {% if regform.is_purged %}title="{{ purged_title }}"{% endif %}>
                                {%- trans %}Registrations{% endtrans -%}
                                {% block existing_count scoped %}
                                    <span class="badge">
                                        {{- regform.active_registration_count -}}
                                        {% if regform.registration_limit %}
                                            / {{ regform.registration_limit }}
                                        {%- endif -%}
                                    </span>
                                {% endblock %}
                            </a>
                        </div>
                        <div class="group">
                            <a href="{{ url_for('.manage_regform', regform) }}" class="i-button highlight icon-settings">
                                {% trans %}Manage{% endtrans %}
                            </a>
                        </div>
                        {% block delete_regform_button scoped %}
                            <div class="group hide-if-locked">
                                <button class="i-button icon-remove danger text-color"
                                        title="{% trans %}Delete this registration form{% endtrans %}"
                                        data-qtip-style="danger"
                                        data-href="{{ url_for('.delete_regform', regform) }}"
                                        data-method="POST"
                                        data-title="{% trans %}Delete registration form?{% endtrans %}"
                                        data-confirm="{% trans title=regform.title %}Do you really want to delete the registration form &quot;{{ title }}&quot;?{% endtrans %}"></button>
                            </div>
                        {% endblock %}
                    </div>
                </div>
            </div>
        {% else %}
            {%- call message_box('info', fixed_width=true) -%}
                {% trans %}There are no registration forms yet.{% endtrans %}
            {%- endcall %}
        {% endfor %}
    </div>

    <div class="toolbar f-j-end hide-if-locked">
        {% block create_form_button %}
            <a href="{{ url_for('.create_regform', event) }}" class="i-button icon-plus">
                {%- trans %}Create form{% endtrans -%}
            </a>
        {% endblock %}
    </div>

    <script>
        setupRegistrationFormListPage();
    </script>
{% endblock %}
