{% 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 'Shipping Address' %}</a></li>
        <li><a href="#2" data-toggle="tab">{% trans 'Shipping Method' %}</a></li>
        <li><a href="#3" data-toggle="tab">{% trans 'Order Contents' %}</a></li>
    </ul>

    <div class="tab-content">

        <div class="tab-pane active" id="1">
            <div class="sub-header">
                <h3>{% trans 'Profile' %}</h3>
            </div>
            <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 class="tab-pane" id="2">
            <div class="sub-header">
                <h3>{% trans 'Shipping method' %}</h3>
            </div>
            <p>{{ order.shipping_method }}</p>
        </div>

        <div class="tab-pane" id="3">
            <div class="sub-header">
                <h3>{% trans 'Order contents' %}</h3>
            </div>

            {% csrf_token %}
            <table class="table table-striped table-bordered">
                <tr>
                    <th>{% trans 'Product' %}</th>
                    <th>{% trans 'Availability' %}</th>
                    <th>{% trans 'Quantity' %}</th>
                    <th>{% trans 'Line price excl tax' %}</th>
                    <th>{% trans 'Line price incl tax' %}</th>
                    <th></th>
                </tr>
                {% for line in order.lines.all %}
                <tr>
                    <td><a href="{{ line.product.get_absolute_url }}">{{ line.description }}</a></td>
                    <td>{{ line.product.stockrecord.availability }}</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 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>
            </table>
        </div>
    </div>
</div>
{% endblock content %}

