{% extends "pretixpresale/event/checkout_base.html" %}
{% load i18n %}
{% load money %}
{% load bootstrap3 %}
{% load rich_text %}
{% block inner %}
    <p>{% trans "Please select how you want to pay." %}</p>
    {% if event.settings.payment_explanation %}
        {{ event.settings.payment_explanation|rich_text }}
    {% endif %}
    <form method="post">
        {% csrf_token %}
        <div class="panel-group" id="payment_accordion">
            {% for p in providers %}
                <div class="panel panel-default" data-total="{{ p.total|floatformat:2 }}">
                    <label class="accordion-radio">
                        <div class="panel-heading">
                            <h4 class="panel-title">
                                {% if show_fees %}
                                    <strong class="pull-right flip">{% if p.fee < 0 %}-{% else %}+{% endif %} {{ p.fee|money:event.currency|cut:"-" }}</strong>
                                {% endif %}
                                <input type="radio" name="payment" value="{{ p.provider.identifier }}"
                                       title="{{ p.provider.public_name }}"
                                       data-parent="#payment_accordion"
                                       {% if selected == p.provider.identifier %}checked="checked"{% endif %}
                                       data-toggle="radiocollapse" data-target="#payment_{{ p.provider.identifier }}"/>
                                <strong>{{ p.provider.public_name }}</strong>
                            </h4>
                        </div>
                    </label>
                    <div id="payment_{{ p.provider.identifier }}"
                         class="panel-collapse collapsed {% if selected == p.provider.identifier %}in{% endif %}">
                        <div class="panel-body form-horizontal">
                            {% if request.event.testmode %}
                                {% if p.provider.test_mode_message %}
                                    <div class="alert alert-info">
                                        {{ p.provider.test_mode_message }}
                                    </div>
                                    {% if not request.sales_channel.testmode_supported %}
                                        <div class="alert alert-danger">
                                            {% trans "This sales channel does not provide support for test mode." %}
                                            <strong>
                                                {% trans "If you continue, you might pay an actual order with non-existing money!" %}
                                            </strong>
                                        </div>
                                    {% endif %}
                                {% else %}
                                    <div class="alert alert-warning">
                                        {% trans "This payment provider does not provide support for test mode." %}
                                        <strong>
                                            {% trans "If you continue, actual money might be transferred." %}
                                        </strong>
                                    </div>
                                {% endif %}
                            {% endif %}
                            {{ p.form }}
                        </div>
                    </div>
                </div>
            {% endfor %}
            {% if not providers %}
                <p><em>{% trans "There are no payment providers enabled." %}</em></p>
                {% if not event.live %}
                    <p>{% trans "Please go to the payment settings and activate one or more payment providers." %}</p>
                {% endif %}
            {% endif %}
        </div>
        <div class="row checkout-button-row">
            <div class="col-md-4 col-sm-6">
                <a class="btn btn-block btn-default btn-lg"
                        href="{{ prev_url }}">
                    {% trans "Go back" %}
                </a>
            </div>
            <div class="col-md-4 col-md-offset-4 col-sm-6">
                <button class="btn btn-block btn-primary btn-lg" type="submit">
                    {% trans "Continue" %}
                </button>
            </div>
            <div class="clearfix"></div>
        </div>
    </form>
{% endblock %}
