{% extends "layout.html" %}
{% load currency_filters %}
{% load i18n %}

{% block title %}
{% trans 'Order' %} {{ order.number }} | {{ block.super }}
{% endblock %}

{% block breadcrumbs %}
<ul class="breadcrumb">
    <li>
        <a href="{% url promotions:home %}">{% trans 'Home' %}</a>
        <span class="divider">/</span>
    </li>
    <li>
        <a href="{% url customer:summary %}">{% trans 'Account' %}</a>
        <span class="divider">/</span>
    </li>
    <li>
        <a href="{% url customer:order-list %}">{% trans 'Order history' %}</a>
        <span class="divider">/</span>
    </li>
    <li class="active"><a href=".">{% blocktrans with number=order.number %}Order #{{ number }}{% endblocktrans %}</a></li>
</ul>
{% endblock %}

{% block header %}
<div class="page-header">
    <h1>{% blocktrans with number=order.number %}Order #{{ number }}{% endblocktrans %}</h1>
</div>
{% endblock header %}

{% block content %}

<div class="tabbable dashboard">
    <ul class="nav nav-tabs">
        <li class="active"><a href="#1" data-toggle="tab">{% trans 'Order contents' %}</a></li>
        <li><a href="#2" data-toggle="tab">{% trans 'Shipping Method' %}</a></li>
        <li><a href="#3" data-toggle="tab">{% trans 'Shipping Address' %}</a></li>
    </ul>

    <div class="tab-content">
        <div class="tab-pane active" id="1">
            <table class="table table-striped table-bordered">
				<thead>
					<tr>
						<th>{% trans 'Product' %}</th>
						<th>{% trans 'Dispatch date' %}</th>
						<th>{% trans 'Quantity' %}</th>
						<th>{% trans 'Line price excl tax' %}</th>
						<th>{% trans 'Line price incl tax' %}</th>
						<th></th>
					</tr>
				</thead>
				<tbody>
					{% for line in order.lines.all %}
					<tr>
						<td><a href="{{ line.product.get_absolute_url }}">{{ line.description }}</a></td>
						<td>{{ line.est_dispatch_date|default:"-" }}</td>
						<td>{{ line.quantity }}</td>
						<td>{{ line.line_price_before_discounts_excl_tax|currency }}</td>
						<td>{{ line.line_price_before_discounts_incl_tax|currency }}</td>
						<td>
							<form id="line_form_{{ line.id }}" action="{% url customer:order-line order.number line.id %}" method="POST">
								{% csrf_token %}
								<input type="hidden" name="action" value="reorder" />
								<button class="btn btn-success" type="submit">{% trans 'Re-order' %}</button>
								<a class="btn btn-info" href="{% url catalogue:reviews-add line.product.slug line.product.id %}">{% trans 'Write a review' %}</a>
							</form>
						</td>
					</tr>
					{% endfor %}
					{% for discount in order.discounts.all %}
					<tr>
						<td colspan="4">{{ discount.description }}</td>
						<td>-{{ discount.amount|currency }}</td>
					</tr>
					{% endfor %}
					<tr>
						<th colspan="4">{% trans 'Basket total (inc. tax)' %}</th>
						<td colspan="2">{{ order.basket_total_incl_tax|currency }}</td>
					</tr>
					<tr>
						<th colspan="4">{% trans 'Shipping charge (inc. tax)' %}</th>
						<td colspan="2">{{ order.shipping_incl_tax|currency }}</td>
					</tr>
					<tr>
						<th colspan="4">{% trans 'Order total' %}</th>
						<td colspan="2">{{ order.total_incl_tax|currency }}</td>
					</tr>
				</tbody>
            </table>
        </div>

        <div class="tab-pane" id="2">
            <p>{{ order.shipping_method }}</p>
        </div>

        <div class="tab-pane" id="3">
			<div class="row-fluid">
                <div class="span4">
                    <div class="well well-info">
                        <h4>{% trans 'Address:' %}</h4>
                        <p>{% for field in order.shipping_address.active_address_fields %}
                        {{ field }}<br/>
                        {% endfor %}</p>
                    </div>
                </div>
                <div class="span4">
                    <div class="well well-info">
                        <h4>{% trans 'Contact Number:' %}</h4>
                        <p>{{ shipping_address.phone_number }}</p>
                    </div>
                </div>
                <div class="span4">
                    <div class="well well-info">
                        <h4>{% trans 'Shipping Notes:' %}</h4>
                        <p>{{ shipping_address.notes }}</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock content %}

