{% 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>{% trans "Checkout" %}</li>
{% endblock %}

{% block content %}
<h3>{% trans "Checkout" %}</h3>
<div id="checkoutprogress">
<ul>
    <li class="first active">{% trans "Ship/Bill" %}</li>
    <li>{% trans "Payment" %}</li>
    <li>{% trans "Confirmation" %}</li>
</ul>
</div>
<h4>{% trans "Please complete the following information in order to submit your order." %}</h4>
{% if form.non_field_errors %}
<h2>{% trans "Please correct the following error:" %}</h2>
{{ form.non_field_errors }}
{% endif %}
{% if user.is_anonymous %}
<form method="post" action="{% if is_secure %}{% url auth_secure_login %}{% else %}{{ login_url }}{% endif %}">
<input type="hidden" name="next" value="{% url satchmo_checkout-step1 %}" />
<table>
		<tr>
			<td colspan="2">
				{% trans "If you already have an account, you can login now to fill in most of the information below." %}
				{% trans "This is just a convenience, no account is required!" %}
			</td>
		</tr>
		<tr><td><label for="id_username">{% trans "Username or email" %}:</label></td><td><input type="text" id="id_username" class="vTextField required" name="username" size="15" value="" maxlength="75" /></td></tr>
        <tr><td><label for="id_password">{% trans "Password" %}:</label></td><td><input type="password" id="id_password" class="vPasswordField required" name="password" size="15" value="" maxlength="30" /></td></tr>
		<tr><td>&nbsp;</td><td><input type="submit" value="{% trans "Login" %}" /></td></tr>
</table>
</form>
{% endif %}

<form method="post" action="{% url satchmo_checkout-step1 %}">
<table>
    <tr><td colspan="2"><p>{% trans "You'll need to fill out at least the fields with a *" %}</p></td></tr>

	{% ifequal paymentmethod_ct 1 %}
	    {# If we only have one payment method, then the form renders it as a hidden field #}{{ form.paymentmethod }}
    {% else %}
	<tr><td colspan="2"><h4>{% trans "How do you want to pay?" %}</h4></td></tr>
	<tr><td><label for="id_paymentmethod">{% trans "Payment method" %}*</label></td> <td><div id="payment">{{ form.paymentmethod }}</div></td></tr>
    {% if form.paymentmethod.errors %}<tr><td class="error" colspan="2">*** {{ form.paymentmethod.errors|join:", " }}</td></tr>{% endif %}
    {% endifequal %}

	<tr><td colspan="2"><h4>{% trans "Basic Information" %}</h4></td></tr>
    <tr><td><label for="id_email">{% trans "Email address" %}*</label></td> <td>{{ form.email }}</td></tr>
    {% if form.email.errors %}<tr><td class="error" colspan="2">*** {{ form.email.errors|join:", " }}</td></tr>{% endif %}

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

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

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

    {% block billing-info %}{% include "contact/_contact_info_form_billing.html" %}{% endblock %}

{% if cart.is_shippable %}
    {% block shipping-info %}{% include "contact/_contact_info_form_shipping.html" %}{% endblock %}
{% endif %}

{% if form.discount.is_hidden %}
    {{ form.discount }}
{% else %}
    <tr><td colspan="2"><h4>{% trans "Discounts" %}</h4></td></tr>
    <tr><td><label for="id_discount">{% trans "Discount code" %}</label></td><td>{{ form.discount }}</td></tr>
    {% if form.discount.errors %}<tr><td class="error" colspan="2">*** {{ form.discount.errors|join:", " }}</td></tr>{% endif %}
{% endif %}
{% if sale %}{% include "product/sale_details.html" %}{% endif %}

	<tr><td></td><td><input type="submit" value="{% trans "Continue Checkout" %}"/></td></tr>
</table>
</form>
{% endblock %}
