{% extends "pretixcontrol/item/base.html" %}
{% load i18n %}
{% load bootstrap3 %}
{% load formset_tags %}
{% block inside %}
    <form action="" method="post" class="form-horizontal" enctype="multipart/form-data">
        {% csrf_token %}
        <div class="row">
            <div class="col-xs-12 col-lg-10">
                <div class="tabbed-form">
                    <fieldset>
                        <legend>{% trans "General" %}</legend>
                        {% bootstrap_field form.active layout="control" %}
                        {% bootstrap_field form.name layout="control" %}
                        <div class="internal-name-wrapper">
                            {% bootstrap_field form.internal_name layout="control" %}
                        </div>
                        {% bootstrap_field form.category layout="control" %}

                        <div class="form-group">
                            <label class="col-md-3 control-label">{% trans "Product type" %}</label>
                            <div class="col-md-9">
                                {% for e in form.errors.admission %}
                                    <div class="alert alert-danger has-error">
                                        {{ e }}
                                    </div>
                                {% endfor %}
                                <div class="big-radio radio">
                                    <label>
                                        <input type="radio" value="on" name="{{ form.admission.html_name }}" {% if form.admission.value %}checked{% endif %}>
                                        <span class="fa fa-fw fa-user"></span>
                                        <strong>{% trans "Admission product" %}</strong><br>
                                        <div class="help-block">
                                            {% blocktrans trimmed %}
                                                Every purchase of this product represents one person who is allowed to enter your event.
                                                By default, pretix will only ask for attendee information and offer ticket downloads for these products.
                                            {% endblocktrans %}
                                        </div>
                                        <div class="help-block">
                                            {% blocktrans trimmed %}
                                                This option should be set for most things that you would call a "ticket". For product add-ons or bundles, this should
                                                be set on the main ticket, except if the add-on products or bundled products represent additional people (e.g. group bundles).
                                            {% endblocktrans %}
                                        </div>
                                    </label>
                                </div>
                                <div class="big-radio radio">
                                    <label>
                                        <input type="radio" value="" name="{{ form.admission.html_name }}" {% if not form.admission.value %}checked{% endif %}>
                                        <span class="fa fa-fw fa-cube"></span>
                                        <strong>{% trans "Non-admission product" %}</strong>
                                        <div class="help-block">
                                            {% blocktrans trimmed %}
                                                A product that does not represent a person. By default, pretix will not ask for attendee information or offer
                                                ticket downloads.
                                            {% endblocktrans %}
                                        </div>
                                        <div class="help-block">
                                            {% blocktrans trimmed %}
                                                Examples: Merchandise, donations, gift cards, add-ons to a main ticket.
                                            {% endblocktrans %}
                                        </div>
                                    </label>
                                </div>
                            </div>
                        </div>

                        {% bootstrap_field form.description layout="control" %}
                        {% bootstrap_field form.picture layout="control" %}
                        {% bootstrap_field form.require_approval layout="control" %}

                        {% if meta_forms %}
                            <div class="form-group metadata-group">
                                <label class="col-md-3 control-label">{% trans "Meta data" %}</label>
                                <div class="col-md-9">
                                    {% for form in meta_forms %}
                                        <div class="row">
                                            <div class="col-md-4">
                                                <label for="{{ form.value.id_for_label }}">
                                                    {{ form.property.name }}
                                                </label>
                                            </div>
                                            <div class="col-md-8">
                                                {% bootstrap_form form layout="inline" %}
                                            </div>
                                        </div>
                                    {% endfor %}
                                </div>
                            </div>
                        {% endif %}
                    </fieldset>
                    <fieldset>
                        <legend>{% trans "Price" %}</legend>
                        {% bootstrap_field form.default_price addon_after=request.event.currency layout="control" %}
                        {% bootstrap_field form.tax_rule layout="control" %}
                        {% bootstrap_field form.free_price layout="control" %}
                        {% bootstrap_field form.original_price addon_after=request.event.currency layout="control" %}
                    </fieldset>
                    <fieldset>
                        <legend>{% trans "Availability" %}</legend>
                        {% bootstrap_field form.sales_channels layout="control" %}
                        {% bootstrap_field form.available_from layout="control" %}
                        {% bootstrap_field form.available_until layout="control" %}
                        {% bootstrap_field form.max_per_order layout="control" %}
                        {% bootstrap_field form.min_per_order layout="control" %}
                        {% bootstrap_field form.require_voucher layout="control" %}
                        {% bootstrap_field form.hide_without_voucher layout="control" %}
                        {% bootstrap_field form.require_bundling layout="control" %}
                        {% if form.require_membership %}
                            {% bootstrap_field form.require_membership layout="control" %}
                            <div data-display-dependency="#{{ form.require_membership.id_for_label }}">
                                {% bootstrap_field form.require_membership_types layout="control" %}
                                {% bootstrap_field form.require_membership_hidden layout="control" %}
                            </div>
                        {% endif %}
                        {% bootstrap_field form.allow_cancel layout="control" %}
                        {% bootstrap_field form.allow_waitinglist layout="control" %}
                        {% bootstrap_field form.hidden_if_available layout="control" %}
                    </fieldset>
                    {% for v in formsets.values %}
                        <fieldset>
                            <legend>{{ v.title }}</legend>
                            {% include v.template with formset=v %}
                        </fieldset>
                    {% endfor %}
                    <fieldset>
                        <legend>{% trans "Tickets & check-in" %}</legend>
                        {% bootstrap_field form.generate_tickets layout="control" %}
                        {% bootstrap_field form.checkin_attention layout="control" %}
                    </fieldset>
                    <fieldset>
                        <legend>{% trans "Additional settings" %}</legend>
                        {% bootstrap_field form.issue_giftcard layout="control" %}
                        {% bootstrap_field form.show_quota_left layout="control" %}
                        {% if form.grant_membership_type %}
                            {% bootstrap_field form.grant_membership_type layout="control" %}
                            <div data-display-dependency="#id_grant_membership_type">
                                {% bootstrap_field form.grant_membership_duration_like_event layout="control" %}
                                <div data-display-dependency="#id_grant_membership_duration_like_event" data-inverse class="form-group">
                                    {% blocktrans asvar days %}days{% endblocktrans %}
                                    {% blocktrans asvar months %}months{% endblocktrans %}
                                    <label class="col-md-3 col-xs-12 control-label">
                                        {% trans "Membership duration after purchase" %}
                                    </label>
                                    <div class="col-md-4 col-xs-5">
                                        {% bootstrap_field form.grant_membership_duration_months layout="" addon_after=months label_class="sr-only" form_group_class="" %}
                                    </div>
                                    <label class="col-md-1 col-xs-2 control-label text-center">
                                        +
                                    </label>
                                    <div class="col-md-4 col-xs-5">
                                        {% bootstrap_field form.grant_membership_duration_days layout="" addon_after=days label_class="sr-only" form_group_class="" %}
                                    </div>
                                </div>
                            </div>
                        {% endif %}
                        {% for f in plugin_forms %}
                            {% bootstrap_form f layout="control" %}
                        {% endfor %}
                    </fieldset>
                </div>
                <div class="form-group submit-group">
                    <button type="submit" class="btn btn-primary btn-save">
                        {% trans "Save" %}
                    </button>
                </div>
            </div>
            <div class="col-xs-12 col-lg-2">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">
                            {% trans "Product history" %}
                        </h3>
                    </div>
                    {% include "pretixcontrol/includes/logs.html" with obj=item %}
                </div>
            </div>
        </div>
    </form>
{% endblock %}
