{% extends "checkout/layout.html" %}
{% load currency_filters %}
{% load thumbnail %}
{% load i18n %}

{% block title %}
{% trans "Confirmation of order" %} {{ order.number }} | {{ block.super }}
{% endblock title %}

{% block checkout-nav %}{% endblock %}


{% block content %}
<div class="sub-header">
	<h1>{% blocktrans with order_num=order.number %}
		Confirmation for order #{{ order_num }}
		{% endblocktrans %}</h1>
</div>
<p>{% trans "Your order has been placed and a confirmation email has ben sent - your order number is" %}
<span class="label label-success">{{ order.number }}</span></p>
<p>{% trans "Please make a note of this reference or print this page and quote it in any communication with us regarding your order." %}</p>

<div class="row-fluid shipping-payment">
    <div class="span6">
		{% block shipping_info %}
        <div class="well well-info">
			<h3>{% trans "Shipping" %}</h3>
			{% if order.shipping_address %}
				<dl>
					<dt>{% trans "Address" %}</dt>
					<dd>
						{% for field in order.shipping_address.active_address_fields %}
						{{ field }}<br/>
						{% endfor %}
					</dd>
					{% if order.shipping_address.phone_number %}
					<dt>{% trans "Contact number" %}</dt>
					<dd>{{ order.shipping_address.phone_number }}</dd>
					{% endif %}
					{% if order.shipping_address.notes %}
					<dt>{% trans "Shipping notes" %}</dt>
					<dd>{{ order.shipping_address.notes }}</dd>
					{% endif %}
					<dt>{% trans "Shipping method" %}</dt>
					<dd>{{ order.shipping_method }}</dd>
				</dl>
			{% else %}
				{% trans "No shipping is required for this order." %}
			{% endif %}
        </div>
		{% endblock %}
    </div>
    <div class="span6">
		{% block payment_info %}
        <div class="well well-success">
			<h3>{% trans "Payment" %}</h3>
            {% for source in order.sources.all %}
            {{ source }}
			{% empty %}
			{% trans "No payment was required for this order." %}
            {% endfor %}
        </div>
		{% endblock %}
    </div>
</div>
<div class="sub-header">
	<h3>{% trans "Order details" %}</h3>
</div>

<div class="basket-title">
    <div class="row-fluid">
		<h4 class="span6">{% trans "Items purchased" %}</h4>
		<h4 class="span3 align-center">{% trans "Estimated dispatch date" %}</h4>
		<h4 class="span1 align-center">{% trans "Quantity" %}</h4>
		<h4 class="span2 align-right">{% trans "Cost" %}</h4>
    </div>
</div>

{% for line in order.lines.all %}
<div class="basket-items">
    <div class="row-fluid">
        <div class="span6">
            <div class="image_container">
				{% with image=line.product.primary_image %}
				{% thumbnail image.original "200x200" upscale=False as thumb %}
				<a href="{{ form.instance.product.get_absolute_url }}"><img class="thumbnail" src="{{ thumb.url }}" alt="{{ product.get_title }}"></a>
				{% endthumbnail %}
				{% endwith %}
		    </div>
            <h4><a href="{{ line.product.get_absolute_url }}">{{ line.description }}</a></h4>
        </div>
        <div class="span3 align-center">
            {{ line.est_dispatch_date|default:"-" }}
        </div>
        <div class="span1 align-center">
            {{ line.quantity }}
        </div>
        <div class="span2 align-right">
            <p class="price_color">{{ line.line_price_before_discounts_incl_tax|currency }}</p>
        </div>        
    </div>
</div>
{% endfor %}

{% for discount in order.discounts.all %}
<div class="basket-items">
    <div class="row-fluid align-right">
        <h4 class="span10">{{ discount.offer }}</h4>
        <h5 class="span2">- {{ discount.amount|currency }}</h5>
    </div>
</div>
{% endfor %}

<div class="basket-items">
    <div class="row-fluid align-right">
		<h4 class="span10">{% trans "Basket total" %}</h4>
        <h5 class="span2">{{ order.basket_total_incl_tax|currency }}</h5>
    </div>
</div>
<div class="basket-items">
    <div class="row-fluid align-right">
		<h4 class="span10">{% trans "Shipping" %}</h4>
        <h5 class="span2">{{ order.shipping_incl_tax|currency }}</h5>
    </div>
</div>
<div class="basket-items total">
    <div class="row-fluid align-right">
		<h3 class="span10">{% trans "Order total" %}</h3>
        <h3 class="span2 price_color">{{ order.total_incl_tax|currency }}</h3>
    </div>
</div>
 
{% if not order.user %}
    <div class="sub-header">
		<h4>{% trans "Tracking your order" %}</h4>
    </div>
	<p>{% trans "You can" %}
		<a href="{% url customer:anon-order order.number order.verification_hash %}">{% trans "track the status of your order" %}</a>.</p>
	</p>
{% endif %}

<div class="form-actions">
	<a onclick="window.print()" href="#" class="btn btn-primary btn-large">{% trans "Print this page" %}</a>
	<a href="/" class="btn btn-primary btn-large pull-right">{% trans "Continue shopping" %}</a>
</div>
{% endblock content %}

{% block extratracking %}
    _gaq.push(['_addTrans',
        '{{ order.number|escapejs }}',
		'{{ shop_name|escapejs }}',
        '{{ order.total_incl_tax|escapejs }}',
        '{{ order.total_tax|escapejs }}',
        '{{ order.shipping_incl_tax|escapejs }}',
        '{{ order.shipping_address.line4|escapejs }}',
        '{{ order.shipping_address.state|escapejs }}',
        '{{ order.shipping_address.country.name|escapejs }}'
    ]);
    {% for line in order.lines.all %}
        _gaq.push(['_addItem',
            '{{ order.number }}',
            '{{ line.partner_sku|escapejs }}',
            '{{ line.title|escapejs }}',
            '{{ line.category|escapejs }}',
            '{{ line.unit_price_incl_tax }}',
            '{{ line.quantity }}']);
    {% endfor %}
    _gaq.push(['_trackTrans']);
{% endblock %}
