{% extends 'dashboard/layout.html' %}
{% load currency_filters %}
{% 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"><a href=".">{{ description }}</a></li>
</ul>
{% endblock %}

{% block header %}
<div class="page-header">
	<h1>{% trans "Vouchers" %}</h1>
</div>
{% endblock header %}

{% block dashboard_content %}
<div class="well well-info">
    <div class="sub-header">
		<h3>{% trans "Search" %}</h3>
    </div>
    <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>

<p><a href="{% url dashboard:voucher-create %} " class="btn-large btn-primary">{% trans "Create new voucher" %}</a></p>

	<div class="sub-header">
		<h2>{{ description }}</h2>
	</div>
	{% if vouchers.count %}
		<table class="table table-striped table-bordered">
			<tr>
				<th>{% trans "Name" %}</th>
				<th>{% trans "Code" %}</th>
				<th>{% trans "Is active?" %}</th>
				<th>{% trans "Num baskets" %}</th>
				<th>{% trans "Num orders" %}</th>
				<th>{% trans "Date created" %}</th>
				<th></th>
			</tr>
			{% for voucher in vouchers %}
			<tr>
				<td>{{ voucher.name }}</td>
				<td>{{ voucher.code }}</td>
				<td>{{ voucher.is_active }}</td>
				<td>{{ voucher.num_basket_additions }}</td>
				<td>{{ voucher.num_orders }}</td>
				<td>{{ voucher.date_created }}</td>
				<td>
					<a class="btn btn-info" href="{% url dashboard:voucher-stats voucher.id %}">{% trans "Stats" %}</a>
					<a class="btn btn-primary" href="{% url dashboard:voucher-update voucher.id %}">{% trans "Edit" %}</a>
					<a class="btn btn-danger" href="{% url dashboard:voucher-delete voucher.id %}">{% trans "Delete" %}</a>
				</td>
			</tr>
			{% endfor %}
		</table>
		{% if page_obj %}
			{% include "catalogue/partials/pagination.html" %}
		{% endif %}
	{% else %}
	<p>{% trans "No vouchers found." %}</p>
	{% endif %}
{% endblock dashboard_content %}