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

{% block title %}
{% blocktrans with name=voucher.name %}Voucher '{{ name }}'{% endblocktrans %} | Vouchers | {{ block.super }}
{% endblock %}

{% block breadcrumbs %}
<ul class="breadcrumb">	  	
    <li>	  	
        <a href="{% url dashboard:index %}">{% trans "Dashboard" %}</a>	  	
        <span class="divider">/</span>	  	
    </li>	  	
    <li>	  	
        <a href="{% url dashboard:voucher-list %}">{% trans "Vouchers" %}</a>	  	
        <span class="divider">/</span>	  	
    </li>	  	
    <li class="active">{% blocktrans with name=voucher.name %}Voucher '{{ name }}'{% endblocktrans %}</li>	  	
</ul>
{% endblock %}

{% block headertext %}
{% blocktrans with name=voucher.name %}Voucher '{{ name }}'{% endblocktrans %}
{% endblock %}

{% block dashboard_content %}

<div class="table-header">
  <h2>Voucher details</h2>  
</div>
<table class="table table-striped table-bordered table-hover">
	<tbody>
		<tr><th>{% trans "Name" %}</th><td>{{ voucher.name }}</td></tr>
		<tr><th>{% trans "Code" %}</th><td>{{ voucher.code }}</td></tr>
		<tr><th>{% trans "Start date" %}</th><td>{{ voucher.start_date }}</td></tr>
		<tr><th>{% trans "End date" %}</th><td>{{ voucher.end_date }}</td></tr>
		<tr><th>{% trans "Usage" %}</th><td>{{ voucher.usage }}</td></tr>
		<tr><th>{% trans "Discount" %}</th><td>{{ voucher.benefit.description }}</td></tr>
	</tbody>
</table>

<div class="table-header">
  <h2>{% trans "Voucher performance" %}</h2>
</div>
<table class="table table-striped table-bordered table-hover">
	<tbody>
		<tr><th>{% trans "Number of basket additions" %}</th><td>{{ voucher.num_basket_additions }}</td></tr>
		<tr><th>{% trans "Number of orders" %}</th><td>{{ voucher.num_orders }}</td></tr>
		<tr><th>{% trans "Total discount" %}</th><td>{{ voucher.total_discount|currency }}</td></tr>
	</tbody>
</table>

<div class="table-header">
  <h2>{% trans "Recent orders" %}</h2>
</div>

<table class="table table-striped table-bordered table-hover">
    {% if not discounts %}
	<tr><td>{% trans "No orders have been placed that use this voucher." %}</td></tr>
	{% else %}
	<thead>
		<th>{% trans "Order number" %}</th>
		<th>{% trans "Order total" %}</th>
		<th>{% trans "Discount" %}</th>
		<th>{% trans "Date placed" %}</th>
		<th></th>
	</thead>
	<tbody>
		{% for discount in discounts %}
		{% with order=discount.order %}
			<tr>
				<td>{{ order.number }}</td>
				<td>{{ order.total_incl_tax|currency }}</td>
				<td>{{ discount.amount|currency }}</td>
				<td>{{ order.date_placed }}</td>
				<td><a href="{% url dashboard:order-detail order.number %}" class="btn btn-info">{% trans "View" %}</a></td>
			</tr>
		{% endwith %}
		{% endfor %}
	</tbody>
	{% endif %}
</table>


<div class="form-actions">
	<a class="btn btn-primary" href="{% url dashboard:voucher-update voucher.id %}">{% trans "Edit" %}</a> {% trans "or" %}
	<a class="btn btn-danger" href="{% url dashboard:voucher-delete voucher.id %}">{% trans "Delete" %}</a> {% trans "or" %}
	<a href="{% url dashboard:voucher-list %}">{% trans "cancel" %}</a>
</div>


{% endblock dashboard_content %}
