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

{% block title %}
{% trans "Checkout" %} | {{ block.super }}
{% endblock %}

{% block header %}
{% endblock header %}

{% block checkout-nav %}
{% include 'checkout/nav.html' %}
{% endblock %}

{% block content %}

{% if error %}
	<div class="alert alert-error">
		{{ error }}
	</div>
{% endif %}

<div class="row-fluid shipping-payment">
    {% block shipping_address %}
    <div class="span6">
        <div class="sub-header">
			<h2>{% trans "Shipping" %}</h2>
        </div>
        <div class="well well-info">
			{% if shipping_address %}
                <h4>{% trans "Address" %}</h4>
                <p>
                    {% for field in shipping_address.active_address_fields %}
                    {{ field }}<br/>
                    {% endfor %}
                </p>
                {% if shipping_address.phone_number %}
                    <p>{% trans "Contact number" %}: {{ shipping_address.phone_number }}</p>
                {% endif %}

                {% if shipping_address.notes %}
                    <p>{% trans "Shipping notes" %}</p>
                    <p>{{ shipping_address.notes|linebreaks }}</p>
                {% endif %}

				<h4>{% trans "Shipping method" %}</h4>
				<p>{{ shipping_method.name }}
					{% if shipping_method.description %}
					- {{ shipping_method.description }}
					{% endif %}
				</p>
            </dl>

            {% block shipping_address_actions %}
            <div class="alert-actions">
				<a href="{% url checkout:shipping-address %}" class="btn">{% trans "Change shipping address" %}</a>
            </div>
            {% endblock %}

			{% else %}
                {% trans "No shipping is required for this order" %}
			{% endif %}
        </div>
    </div>
    {% endblock shipping_address %}

    {% block payment_method %}
   <div class="span6">
       <div class="sub-header">
		   <h2>{% trans "Payment" %}</h2>
        </div>
        <div class="well well-success">
			<p>{% trans "Payment details to go here" %}</p>
            <div class="alert-actions">
				<a href="{% url checkout:payment-details %}" class="btn">{% trans "Change payment details" %}</a>
            </div>
        </div>    
    </div>
     {% endblock payment_method %}
</div>

{% block order_contents %}
    <div class="sub-header">
		<h2>{% trans "Order contents" %}</h2>
    </div>
    <div class="basket-title">
        <div class="row-fluid">
			<h4 class="span9">{% trans "Items in basket" %}</h4>
			<h4 class="span1 align-center">{% trans "Quantity" %}</h4>
			<h4 class="span2 align-right">{% trans "Price" %}</h4>
        </div>
    </div>
    {% for line in basket.all_lines %}
    <div class="basket-items">
        <div class="row-fluid">
            <div class="span9">
                <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>
				<span class="availability {{ line.product.stockrecord.availability_code }}">{{ line.product.stockrecord.availability }}</span>
            </div>
            <div class="span1 align-center">
                {{ line.quantity }}
            </div>
            <div class="span2 align-right">
                <p class="price_color">{{ line.line_price_incl_tax|currency }}</p>
            </div>        
        </div>
    </div>
    {% endfor %}

    <div class="row-fluid">
        <div class="span6">&nbsp;</div>
        <div class="span6">
            {% include 'basket/partials/basket_totals.html' %}
        </div>
    </div>

    {% block order_contents_actions %}
    <div class="form-actions">
		<a href="{% url basket:summary %}" class="btn">{% trans "Edit order contents" %}</a>
    </div>
    {% endblock %}

{% endblock order_contents %}


{% block shipping_method %}
{% endblock shipping_method %}

{% block payment_details %}
{% endblock payment_details %}

{% block place_order %}
{% endblock place_order %}

{% endblock content %}
