{% extends "pretixpresale/event/base.html" %}
{% load i18n %}
{% load bootstrap3 %}
{% block title %}{% trans "Modify order" %}{% endblock %}
{% block content %}
    <h2>
        {% blocktrans trimmed with code=order.code %}
            Modify order: {{ code }}
        {% endblocktrans %}
    </h2>
    <form class="form-horizontal" method="post" enctype="multipart/form-data">
        {% csrf_token %}
        <div class="panel-group" id="questions_accordion">
            {% if event.settings.invoice_address_asked %}
                <div class="alert alert-info">
                    {% blocktrans trimmed %}
                        Modifying your invoice address will not automatically generate a new invoice.
                        Please contact us if you need a new invoice.
                    {% endblocktrans %}
                </div>
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h4 class="panel-title">
                            <a data-toggle="collapse" href="#invoice" data-parent="#questions_accordion">
                                <strong>{% trans "Invoice information" %}{% if not event.settings.invoice_address_required %}
                                    {% trans "(optional)" %}
                                {% endif %}</strong>
                                <i class="fa fa-angle-down collapse-indicator"></i>
                            </a>
                        </h4>
                    </div>
                    <div id="invoice" class="panel-collapse collapsed in">
                        <div class="panel-body">
                            {% bootstrap_form invoice_form layout="horizontal" %}
                        </div>
                    </div>
                </div>
            {% endif %}
            {% for pos, forms in formgroups %}
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h4 class="panel-title">
                            <a data-toggle="collapse" href="#cp{{ pos.id }}">
                                <strong>{{ pos.item.name }}{% if pos.variation %}
                                    – {{ pos.variation }}
                                {% endif %}</strong>
                                <i class="fa fa-angle-down collapse-indicator"></i>
                            </a>
                        </h4>
                    </div>
                    <div id="cp{{ pos.id }}"
                            class="panel-collapse collapsed in">
                        <div class="panel-body">
                            {% for form in forms %}
                                {% if form.pos.item != pos.item %}
                                    {# Add-Ons #}
                                    <legend>+ {{ form.pos.item }}</legend>
                                {% endif %}
                                {% bootstrap_form form layout="horizontal" %}
                            {% endfor %}
                        </div>
                    </div>
                </div>
            {% endfor %}
        </div>
        <div class="row checkout-button-row">
            <div class="col-md-4">
                <a class="btn btn-block btn-default btn-lg"
                        href="{{ view.get_index_url }}">
                    {% trans "Revert changes" %}
                </a>
            </div>
            <div class="col-md-4 col-md-offset-4">
                <button class="btn btn-block btn-primary btn-lg" type="submit">
                    {% trans "Save changes" %}
                </button>
            </div>
            <div class="clearfix"></div>
        </div>
    </form>
{% endblock %}
