{% extends 'oscar/dashboard/layout.html' %}
{% load currency_filters %}
{% load sorting_tags %}
{% load i18n %}

{% block title %}
    {{ description }} | {{ block.super }}
{% endblock %}

{% block breadcrumbs %}
    <nav aria-label="breadcrumb">
        <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="{% url 'dashboard:index' %}">{% trans "Dashboard" %}</a></li>
            <li class="breadcrumb-item active" aria-current="page">{{ description }}</li>
        </ol>
    </nav>
{% endblock %}

{% block header %}
<div class="page-header">
    <a href="{% url 'dashboard:voucher-set-create' %}" class="btn btn-primary float-right"><i class="fas fa-plus-circle"></i> {% trans "Create new voucher set" %}</a>
    <h1>{% trans "Voucher sets" %}</h1>
</div>
{% endblock header %}


{% block dashboard_content %}

<table class="table table-striped table-bordered table-hover">
    {% if description != "All voucher sets" %}
        <caption><i class="fas fa-money-bill"></i> {{ description }}</caption>
    {% endif %}
    {% if voucher_sets %}
    <tr>
        <th>{% trans "Name" %}</th>
        <th>{% trans "Num" %}</th>
        <th>{% trans "Status" %}</th>
        <th>{% trans "Num offers" %}</th>
        <th>{% anchor 'num_basket_additions' _("Num baskets") %}</th>
        <th>{% anchor 'num_orders' _("Num orders") %}</th>
        <th>{% anchor 'date_created' _("Date created") %}</th>
        <th></th>
    </tr>
        {% for voucher_set in voucher_sets %}
        <tr>
            <td><a href="{% url 'dashboard:voucher-set-detail' pk=voucher_set.pk %}">{{ voucher_set.name }}</a></td>
            <td>{{ voucher_set.count }}</td>
            <td>
                {% if voucher_set.is_active %}
                    <span class="badge badge-success">{% trans "Active" %}</span>
                {% else %}
                    <span class="badge badge-warning">{% trans "Inactive" %}</span>
                {% endif %}
            </td>
            <td>{{ voucher_set.vouchers.first.offers.count|default:0 }}</td>
            <td>{{ voucher_set.num_basket_additions }}</td>
            <td>{{ voucher_set.num_orders }}</td>
            <td>{{ voucher_set.date_created }}</td>
            <td>
                <div class="btn-toolbar">
                    <div class="dropdown">
                        <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            {% trans "Actions" %}
                        </button>
                        <div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
                            <a class="dropdown-item" href="{% url 'dashboard:voucher-set-detail' pk=voucher_set.pk %}">
                                {% trans "Detail" %}
                            </a>
                            <a class="dropdown-item" href="{% url 'dashboard:voucher-set-update' pk=voucher_set.pk %}">
                                {% trans "Edit" %}
                            </a>
                            <a class="dropdown-item" href="{% url 'dashboard:voucher-set-delete' pk=voucher_set.pk %}">
                                {% trans "Delete" %}
                            </a>
                        </div>
                    </div>
                </div>
            </td>
        </tr>
        {% endfor %}
    {% else %}
    <tr><td>{% trans "No voucher sets found." %}</td></tr>
    {% endif %}
</table>
{% include "oscar/partials/pagination.html" %}
{% endblock dashboard_content %}
