{% extends "layout.html" %}
{% load i18n display_tags currency_filters static thumbnail %}

{% block extrahead %}
<meta name="robots" content="noindex">
{{ block.super }}
{% endblock %}

{% block title %}
    {% trans 'Try again' %} | {{ block.super }}
{% endblock %}

{% block headertext %}
<div class="container">
        {% trans "Payment canceled" %}
    <div class="lead">
        {% trans "Payment has been canceled, would you like to try again?" %}
    </div>
</div>
{% endblock %}

{% block extrastyles %}
{{ block.super }}
<link href="{% static 'css/checkout/try_again.css' %}" type="text/css" rel="stylesheet">
<link href="{% static 'css/checkout/onestep.css' %}" type="text/css" rel="stylesheet">
{% endblock %}

{% block content %}
<section class="onestep col-lg-12 mx-auto">
    <div class="container">
        <div class="row">
            {% block info %}
                <div class="col-lg-7 col-12 checkout-left">
                    <div class="panel">
                        {% if order.shipping_address %}
                            <label class="control-label">
                                <h3>{% trans "Shipping address" %}</h3>
                            </label>
                            <div class="panel-body">
                                {% for field in order.shipping_address.ordered_active_address_fields %}
                                    {{ field }}<br/>
                                {% endfor %}

                                {% if order.shipping_address.phone_number %}
                                    <h4>{% trans "Contact" %}</h4>
                                    <p>
                                        {% trans "Phone" %}: {{ order.shipping_address.phone_number }}
                                        {% if order.guest_email %}
                                            <br/>{% trans "Email" %}: {{ order.guest_email }}
                                        {% endif %}
                                    </p>
                                {% endif %}

                                {% if order.shipping_address.notes %}
                                    <h4>{% trans "Instructions" %}</h4>
                                    <p>{{ order.shipping_address.notes|linebreaks }}</p>
                                {% endif %}
                            </div>
                        {% else %}
                            <label class="control-label">
                                <h3>{% trans "No shipping address required." %}</h3>
                            </label>
                        {% endif %}
                    </div>
                    {% if order.billing_address %}
                    <div class="panel">
                        <label class="control-label">
                            <h3>{% trans "Billing address" %}</h3>
                        </label>
                        <div class="panel-body">
                            <address>
                                {% for field in order.billing_address.active_address_fields %}
                                    {{ field }}<br/>
                                {% endfor %}
                            </address>
                        </div>
                    </div>
                    {% endif %}
                    <div class="panel">
                        <label class="control-label"><h3>{% trans "Shipping method" %}</h3></label>
                        <div class="panel-body">
                             <ul id="shipping-method-list" class="shipping-methods">
                                <li>
                                    <div class="shipping-label">
                                        <span>{{ order.shipping_method }}</span>
                                    </div>
                                    <span class="shipping-price">
                                        <span class="first-session-price price_color price_incl_tax">{{ order.shipping_incl_tax|currency:order.currency }}</span>
                                        <span class="second-session-price price_excl_tax">
                                        {% with order.shipping_excl_tax|currency:order.currency as price_excl_tax %}
        {% blocktrans %}Excl. tax {{ price_excl_tax }}{% endblocktrans %}
                                        {% endwith %}
                                        </span>
                                    </span>
                                </li>
                            </ul>
                        </div>
                    </div>
                    <form method="POST">
                    {% csrf_token %}
                        {% block payment_method_form %}
                            <div class="panel">
                                <div class="panel-body">
                                    {% include "checkout/partials/payment_method_block.html" with form=payment_method_form title=title nolabel=True id="payment_method_form" %}
                                </div>
                            </div>
                        {% endblock %}
                        <button class="btn btn-lg btn-primary" type="submit" name="_try-again" value="try-again">{% trans "Place order" %}</button>
                    </form>
                    <form class="mt-2" method="POST">
                        {% csrf_token %}
                        <button class="btn btn-lg btn-outline-danger" type="submit" name="_cancel" value="cancel">{% trans "Cancel" %}</button>
                    </form>
                </div>
            {% endblock %}
            <div class="col-lg-5 col-12 checkout-right">
                {% block order_contents %}
                {% if messages %}
                    {% for msg in messages %}
                        {% if msg.extra_tags == "extra_checkout_warning" %}
                            <div class="alert alert-warning"><i class="fa fa-exclamation-triangle"></i> 
                                {{ msg }}
                            </div>
                        {% endif %}
                    {% endfor %}
                {% endif %}
                {% include "checkout/partials/try_again_lines.html" %}
                <div class="basket-totals-outer">
                    <div class="basket-totals-wrapper">
                        {% trans "Your order" as title %}
                        {% include "checkout/partials/try_again_totals_block.html" with title=title nohide=True id="checkouttotal" %}
                    </div>
                </div>
                {% endblock order_contents %}
            </div>
        </div>
    </div>
</section>
{% endblock content %}
