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

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

{% block extrascripts %}
    {{ block.super }}
    <script src="{% static 'js/checkout/tryagain.js' %}" type="text/javascript"></script>
{% endblock %}

{% block content %}
<section class="container">
    <div class="row">
        {% block info %}
            <div class="col-lg-4">
                <div class="card card-default mb-3">
                    <div class="card-header">
                        <h4 class="m-0">{% trans "Shipping method" %}</h4>
                    </div>
                    <div class="card-body">
                        <table class="table table-smaller table-borderless mt-0 mb-0">
                            <tr>
                                <td class="total">
                                    {{ order.shipping_method }}
                                </td>
                                <td class="total text-right">
                                    {% if not show_tax_separately %}
                                        {{ order.shipping_incl_tax|currency:order.currency }}
                                    {% else %}
                                        {{ order.shipping_excl_tax|currency:order.currency }}
                                    {% endif %}
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
                {% if order.shipping_address %}
                <div class="card card-default mb-3">
                    <div class="card-header">
                        <h4 class="m-0">{% trans "Shipping address" %}</h4>
                    </div>
                    <div class="card-body">
                        <address>
                            {% for field in order.shipping_address.active_address_fields %}
                                {{ field }}<br/>
                            {% endfor %}
                        </address>

                        {% 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 %}
                    {% else %}
                        <p>{% trans "No shipping address required." %}</p>
                    {% endif %}
                    </div>
                </div>
                {% if order.billing_address %}
                <div class="card card-default mb-3">
                    <div class="card-header">
                        <h4 class="m-0">{% trans "Billing address" %}</h4>
                    </div>
                    <div class="card-body">
                        <address>
                            {% for field in order.billing_address.active_address_fields %}
                                {{ field }}<br/>
                            {% endfor %}
                        </address>
                    </div>
                </div>
                {% endif %}
            </div>
        {% endblock %}
        {% block order_contents %}
            <div class="col-lg-4">
                {% trans "Your order" as title %}
                {% include "checkout/partials/try_again_totals_block.html" with title=title nohide=True id="checkouttotal" %}
            </div>
        {% endblock order_contents %}
        {% block payment_method_form %}
        <div class="col-lg-4 try-again-form">
            <form class="mb-2" method="POST">
                {% csrf_token %}
                {% trans "Payment method" as title %}
                {% include "checkout/partials/payment_method_block.html" with form=payment_method_form title=title nolabel=True id="payment_method_form" %}
                <button class="btn btn-primary float-right" type="submit" name="_try-again" value="try-again">{% trans "Pay" %}</button>
            </form>
            <form class="mb-3" method="POST">
                {% csrf_token %}
                <button class="btn btn-warning mr-2 float-right" type="submit" name="_cancel" value="cancel">{% trans "Cancel" %}</button>
            </form>
        </div>
        {% endblock %}
    </div>
</section>
{% endblock content %}
