{% extends "pretixcontrol/items/base.html" %}
{% load i18n %}
{% block title %}{% trans "Product categories" %}{% endblock %}
{% block inside %}
    <h1>{% trans "Product categories" %}</h1>
    <p>
        {% blocktrans trimmed %}
            You can use categories to group multiple products together in an organized way.
        {% endblocktrans %}
    </p>
    {% if categories|length == 0 %}
        <div class="empty-collection">
            <p>
                {% blocktrans trimmed %}
                    You haven't created any categories yet.
                {% endblocktrans %}
            </p>

            <a href="{% url "control:event.items.categories.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 category" %}</a>
        </div>
    {% else %}
        <p>
            <a href="{% url "control:event.items.categories.add" organizer=request.event.organizer.slug event=request.event.slug %}" class="btn btn-default"><i class="fa fa-plus"></i> {% trans "Create a new category" %}
            </a>
        </p>
        <form method="post">
            {% csrf_token %}
        <div class="table-responsive">
            <table class="table table-hover">
                <thead>
                <tr>
                    <th>{% trans "Product categories" %}</th>
                    <th class="action-col-2"></th>
                    <th class="action-col-2"></th>
                </tr>
                </thead>
                <tbody data-dnd-url="{% url "control:event.items.categories.reorder" organizer=request.event.organizer.slug event=request.event.slug %}">
                {% for c in categories %}
                    <tr data-dnd-id="{{ c.id }}">
                        <td>
                            <strong><a href="{% url "control:event.items.categories.edit" organizer=request.event.organizer.slug event=request.event.slug category=c.id %}">{{ c.internal_name|default:c.name }}</a></strong>
                        </td>
                        <td>
                            <button formaction="{% url "control:event.items.categories.up" organizer=request.event.organizer.slug event=request.event.slug category=c.id %}" class="btn btn-default btn-sm sortable-up"{% if forloop.counter0 == 0 and not page_obj.has_previous %} disabled{% endif %}><i class="fa fa-arrow-up"></i></button>
                            <button formaction="{% url "control:event.items.categories.down" organizer=request.event.organizer.slug event=request.event.slug category=c.id %}" class="btn btn-default btn-sm sortable-down"{% if forloop.revcounter0 == 0 and not page_obj.has_next %} disabled{% endif %}><i class="fa fa-arrow-down"></i></button>
                            <span class="dnd-container"></span>
                        </td>
                        <td class="text-right flip">
                            <a href="{% url "control:event.items.categories.edit" organizer=request.event.organizer.slug event=request.event.slug category=c.id %}" class="btn btn-default btn-sm"><i class="fa fa-edit"></i></a>
                            <a href="{% url "control:event.items.categories.add" organizer=request.event.organizer.slug event=request.event.slug %}?copy_from={{ c.id }}"
                               class="btn btn-sm btn-default" title="{% trans "Clone" %}" data-toggle="tooltip">
                                <span class="fa fa-copy"></span>
                            </a>
                            <a href="{% url "control:event.items.categories.delete" organizer=request.event.organizer.slug event=request.event.slug category=c.id %}" class="btn btn-danger btn-sm"><i class="fa fa-trash"></i></a>
                        </td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>
        </form>
        {% include "pretixcontrol/pagination.html" %}
    {% endif %}
{% endblock %}
