{% extends "shop/base.html" %}
{% load i18n %}

{% block extra-head %}
{% include "contact/_contact_info_form.html" %}
{% endblock %}

{% block navbar %}
   <li class="first"><a href="{{ shop_base }}/">{% trans "Home" %}</a></li>
   <li><a href="{% url satchmo_account_info %}">{% trans "Account" %}</a></li>
   <li>{% trans "Add Address" %}</li>
{% endblock %}


{% block content %}
{% if editing %}
    <h4>{% trans "Edit address book entry" %}</h4>
{% else %}
    <h4>{% trans "Add address to your address book" %}</h4>
{% endif %}
{% if form.non_field_errors %}
<h2>{% trans "Please correct the following error:" %}</h2>
{{ form.non_field_errors }}
{% endif %}

{% if editing %}
<form method="post" action="{% url satchmo_address_edit entry.id %}{% if next %}?next={{next}}{% endif%}">{% csrf_token %}
{% else %}
<form method="post" action="{% url satchmo_address_create %}{% if next %}?next={{next}}{% endif%}">{% csrf_token %}
{% endif %}
<table>
    <tr><td colspan="2"><p>{% trans "You&apos;ll need to fill out at least the fields with a *" %}</p></td></tr>

	<tr><td colspan="2"><h4>{% trans "Address Information" %}</h4></td></tr>
    <tr><td><label for="id_addressee">{% trans "Addressee Full Name" %}{% if form.addressee_name.field.required %}*{% endif %}</label></td><td> {{ form.addressee_name }}</td></tr>
   {% if form.addressee_name.errors %}<tr><td>&nbsp;</td><td>*** {{ form.addressee_name.errors|join:", " }}</td></tr>{% endif %}

    <tr><td><label for="id_description">{% trans "Address Description" %}{% if form.description.field.required %}*{% endif %}</label></td><td> {{ form.description }}</td></tr>
   {% if form.description.errors %}<tr><td>&nbsp;</td><td>*** {{ form.description.errors|join:", " }}</td></tr>{% endif %}

 <tr><td><label for="id_street1">{% trans "Street" %}{% if form.street1.field.required %}*{% endif %}</label></td><td> {{ form.street1 }}</td></tr>
    {% if form.street1.errors %}<tr><td class="error" colspan="2">*** {{ form.street1.errors|join:", " }}</td></tr>{% endif %}

    <tr><td><label for="id_street2">{% trans "Street" %}</label></td><td> {{ form.street2 }}</td></tr>
    {% if form.street2.errors %}<tr><td class="error" colspan="2">*** {{ form.street2.errors|join:", " }}</td></tr>{% endif %}

    <tr><td><label for="id_city">{% trans "City" %}{% if form.city.field.required %}*{% endif %}</label></td><td> {{ form.city }}</td></tr>
    {% if form.city.errors %}<tr><td class="error" colspan="2">*** {{ form.city.errors|join:", " }}</td></tr>{% endif %}

    {% if country %}
      {% if form.fields.state.choices %}
      <tr>
        <td><label for="id_state">{% if country.get_admin_area_display %}{{ country.get_admin_area_display }}{% else %}{% trans "State/Province" %}{% endif %} {% if form.state.field.required %}*{% endif %}</label></td>
        <td><p id="id_state_loading" style="display: none">Loading...</p> {{ form.state }}</td>
      </tr>
      {% endif %}
    {% else %}
      <tr>
        <td><label for="id_state">{% trans "State/Province" %} {% if form.state.field.required %}*{% endif %}</label></td>
        <td><p id="id_state_loading" style="display: none">Loading...</p> {{ form.state }}</td>
      </tr>
    {% endif %}
    {% if form.state.errors %}<tr><td class="error" colspan="2">*** {{ form.state.errors|join:", " }}</td></tr>{% endif %}

    <tr><td><label for="id_postal_code">{% trans "Zipcode/Postcode" %}{% if form.postal_code.field.required %}*{% endif %}</label></td><td> {{ form.postal_code }}</td></tr>
    {% if form.postal_code.errors %}<tr><td class="error" colspan="2">*** {{ form.postal_code.errors|join:", " }}</td></tr>{% endif %}

    {% if not country %}
    <tr><td><label for="id_country">{% trans "Country" %}</label></td><td> {{ form.country }}</td></tr>
    {% if form.country.errors %}<tr><td class="error" colspan="2">*** {{ form.country.errors|join:", " }}</td></tr>{% endif %}
    {% endif %}

{% if editing %}
    <tr><td></td><td><input type="submit" value="{% trans "Update" %}"/></td></tr>
{% else %}
    <tr><td></td><td><input type="submit" value="{% trans "Save" %}"/></td></tr>
{% endif %}
</table>
</form>
{% endblock %}
