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

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

{% block breadcrumbs %}
<ul class="breadcrumb">
    <li>
        <a href="{% url 'dashboard:index' %}">{% trans "Dashboard" %}</a>
        <span class="divider">/</span>
    </li>
    <li class="active">{{ description }}</li>
</ul>
{% endblock %}

{% block header %}
<div class="page-header">
    <a href="{% url 'dashboard:voucher-create' %}" class="btn btn-primary btn-large pull-right"><i class="icon-plus"></i> {% trans "Create new voucher" %}</a>
    <h1>{% trans "Voucher management" %}</h1>
</div>
{% endblock header %}


{% block dashboard_content %}
<div class="table-header">
    <h3><i class="icon-search icon-large"></i>{% trans "Search" %}</h3>
</div>
<div class="well">
    <form action="." method="get" class="form-inline">
		{% include 'partials/form_fields_inline.html' with form=form %}
		<button type="submit" class="btn btn-primary">{% trans "Search" %}</button>
		<a href="{% url 'dashboard:voucher-list' %}" class="btn">{% trans "Reset" %}</a>
    </form>
</div>

<table class="table table-striped table-bordered table-hover">
    {% if description != "All vouchers" %}
        <caption><i class="icon-money icon-large"></i>{{ description }}</caption>
    {% endif %}
    {% if vouchers %}
    <tr>
        <th>{% trans "Name" %}</th>
        <th>{% trans "Code" %}</th>
        <th>{% trans "Is active?" %}</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 in vouchers %}
        <tr>
            <td><a href="{% url 'dashboard:voucher-stats' voucher.id %}">{{ voucher.name }}</a></td>
            <td>{{ voucher.code }}</td>
        <td>{{ voucher.is_active|yesno:_("True,False") }}</td>
            <td>{{ voucher.num_basket_additions }}</td>
            <td>{{ voucher.num_orders }}</td>
            <td>{{ voucher.date_created }}</td>
            <td>
                <div class="btn-toolbar">
                    <div class="btn-group">
                      <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
                        {% trans "Actions" %}
                        <span class="caret"></span>
                      </a>
                      <ul class="dropdown-menu pull-right">
                          <li><a href="{% url 'dashboard:voucher-stats' pk=voucher.id %}">{% trans "Stats" %}</a></li>
                            <li><a href="{% url 'dashboard:voucher-update' pk=voucher.id %}">{% trans "Edit" %}</a></li>
                            <li><a href="{% url 'dashboard:voucher-delete' pk=voucher.id %}">{% trans "Delete" %}</a></li>
                      </ul>
                    </div>
                </div>
            </td>
        </tr>
        {% endfor %}
    {% else %}
    <tr><td>{% trans "No vouchers found." %}</td></tr>
    {% endif %}
</table>
{% include "partials/pagination.html" %}
{% endblock dashboard_content %}
