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

{% block title %}
{% blocktrans with name=offer.name %}
'{{ name }}' | Offer management
{% endblocktrans %} | {{ 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:offer-list %}">{% trans "Offers" %}</a>
        <span class="divider">/</span>
    </li>
    <li class="active">'{{ offer.name }}'</li>
</ul>
{% endblock %}

{% block dashboard_content %}
	{% include 'dashboard/offers/partials/offer.html' %}

	<h2>{% trans "Recent orders" %}</h2>
	{% if not order_discounts %}
	<p>{% trans "No orders have been placed that use this offer." %}</p>
	{% else %}
	<p>{% trans "We show a maximum of 20 orders sorted by recency." %}</p>
	<table class="table">
		<thead>
			<th>{% trans "Order number" %}</th>
			<th>{% trans "Order total" %}</th>
			<th>{% trans "Discount" %}</th>
			<th></th>
		</thead>
		<tbody>
			{% for discount in order_discounts %}
			{% with order=discount.order %}
				<tr>
					<td>{{ order.number }}</td>
					<td>{{ order.total_incl_tax|currency }}</td>
					<td>{{ discount.amount|currency }}</td>
					<td><a href="{% url dashboard:order-detail order.number %}" class="btn btn-info">{% trans "View" %}</a></td>
				</tr>
			{% endwith %}
			{% endfor %}
		</tbody>
	</table>
	{% endif %}

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

{% endblock dashboard_content %}
