{% extends "checkout/checkout.html" %}
{% load i18n %}

{% block title %}
{% trans "Shipping address" %} | {{ block.super }}
{% endblock %}

{% block checkout-nav %}
{% include 'checkout/nav.html' with step=1 %}
{% endblock %}

{% block order_contents %}{% endblock %}

{% block shipping_address %}
    <div class="sub-header">
		<h2>{% trans "Where should we ship to?" %}</h2>
    </div>
    {% if request.user.is_authenticated %}
        {% if addresses %}
            
		<h3>An address from your addressbook?</h3>
      
            <div class="choose-block">
                <ul class="row-fluid">
                    {% for address in addresses %}
					<li class="span3">
						<div class="well well-info {% if address.is_default_for_shipping %}default-address{% endif %}">
							<address>{% for field in address.active_address_fields %}
							{{ field }}<br/>
							{% endfor %}</address>
							<form action="{% url checkout:shipping-address %}" method="post">
								{% csrf_token %}
								<input type="hidden" name="action" value="ship_to" />
								<input type="hidden" name="address_id" value="{{ address.id }}" />
								<button type="submit" class="btn btn-primary  ship-address">{% trans "Ship to this address" %}</button>
								<a class="btn btn-small btn-info" href="{% url checkout:user-address-update address.id %}">{% trans "Edit" %}</a>
								<a href="{% url checkout:user-address-delete address.id %}" class="btn btn-small btn-danger">{% trans "Delete" %}</a>
							</form>
						</div>
					</li>
                    {% if forloop.counter|divisibleby:4 %}
						</ul>
						{% if not forloop.last %}<ul class="row-fluid">{% endif %}
                    {% endif %}
                    {% endfor %}
                </ul>
            </div>
            <div class="sub-header">
				<h3>{% trans "Or a new address?" %}</h3>
    		</div>
        {% endif %}
	</div>
    {% endif %}

    <div class="well well-info">
    	<form action="{% url checkout:shipping-address %}" method="post" class="form-horizontal">
            {% csrf_token %}
            {% include "partials/form_fields.html" with form=form %}
			<div class="form-actions"><button type="submit" class="btn btn-large btn-primary">{% trans "Continue" %}</button>
				{% trans "or" %} <a href="{% url basket:summary %}">{% trans "return to basket" %}</a></div>
        </form>
    </div>
{% endblock shipping_address %}

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