{% extends "pretixcontrol/items/base.html" %}
{% load i18n %}
{% block title %}{% trans "Products" %}{% endblock %}
{% block inside %}
    <h1>{% trans "Products" %}</h1>
    <p>
        {% blocktrans trimmed %}
            Below, you find a list of all available products. You can click on a product name to inspect and change
            product details. You can also use the buttons on the right to change the order of products within a
            give category.
        {% endblocktrans %}
    </p>
    {% if items|length == 0 %}
        <div class="empty-collection">
            <p>
                {% blocktrans trimmed %}
                    You haven't created any products yet.
                {% endblocktrans %}
            </p>

            <a href="{% url "control:event.items.add" organizer=request.event.organizer.slug event=request.event.slug %}"
                    class="btn btn-primary btn-lg"><i class="fa fa-plus"></i> {% trans "Create a new product" %}</a>
        </div>
    {% else %}
        <p>
            <a href="{% url "control:event.items.add" organizer=request.event.organizer.slug event=request.event.slug %}"
                    class="btn btn-default"><i class="fa fa-plus"></i> {% trans "Create a new product" %}</a>
        </p>
        <div class="table-responsive">
            <table class="table table-condensed table-hover">
                <thead>
                <tr>
                    <th>{% trans "Product name" %}</th>
                    <th>{% trans "Category" %}</th>
                    <th class="action-col-2"></th>
                    <th class="action-col-2"></th>
                </tr>
                </thead>
                <tbody>
                {% regroup items by category as cat_list %}
                {% for c in cat_list %}
                    {% for i in c.list %}
                        <tr>
                            <td><strong>
                                {% if not i.active %}<strike>{% endif %}
                                <a href="
                        {% url "control:event.item" organizer=request.event.organizer.slug event=request.event.slug item=i.id %}">{{ i.name }}</a>
                                {% if not i.active %}</strike>{% endif %}
                            </strong></td>
                            <td>{% if i.category %}{{ i.category.name }}{% endif %}</td>
                            <td>
                                <a href="{% url "control:event.items.up" organizer=request.event.organizer.slug event=request.event.slug item=i.id %}" class="btn btn-default btn-sm {% if forloop.counter0 == 0 %}disabled{% endif %}"><i class="fa fa-arrow-up"></i></a>
                                <a href="{% url "control:event.items.down" organizer=request.event.organizer.slug event=request.event.slug item=i.id %}" class="btn btn-default btn-sm {% if forloop.revcounter0 == 0 %}disabled{% endif %}"><i class="fa fa-arrow-down"></i></a>
                            </td>
                            <td class="text-right">
                                <a href="{% url "control:event.item" organizer=request.event.organizer.slug event=request.event.slug item=i.id %}" class="btn btn-default btn-sm"><i class="fa fa-edit"></i></a>
                                <a href="{% url "control:event.items.delete" organizer=request.event.organizer.slug event=request.event.slug item=i.id %}" class="btn btn-danger btn-sm"><i class="fa fa-trash"></i></a>
                            </td>
                        </tr>
                    {% endfor %}
                {% endfor %}
                </tbody>
            </table>
        </div>
        {% include "pretixcontrol/pagination.html" %}
    {% endif %}
{% endblock %}
