{% extends "checkout/onestep.html" %}

{% load i18n static display_tags ocyanjson ocyan_main %}

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

{% block extrascripts %}
{{ block.super }}
<script src="{% static 'js/checkout/onestep.js' %}" type="text/javascript" charset="utf-8"></script>
{% endblock %}

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


{% block content %}
{% ocyanjson "oscar_checkout" "show_voucher_block" True as show_voucher_block %}
<section class="onestep">
    <div class="container">
        <form method="POST" action="." novalidate="novalidate" id="onstepcheckout">
            {% csrf_token %}
            {% block checkout_hidden_inputs %}{% endblock %}
            <div class="row">
                {% if basket.is_empty %}
                <h1>{% trans "Your shopping basket appears to be empty" %}</h1>
                <a class="btn btn-primary" href="{% url 'catalogue:index' %}">{% trans "Continue shopping" %}</a>
                {% else %}
                <div class="col-lg-7 col-12 checkout-left">
                    {% if request.user.is_anonymous %}
                    {% trans "Registration" as title %}
                    {% include "checkout/partials/gateway_block.html" with form=gateway_form title=title id="gateway" %}
                    {% endif %}

                    {% block vat_check %}{{block.super}}{% endblock %}

                    {% block shipping_address %}
                    {% trans "Shipping address" as title %}
                    {% include "checkout/partials/shipping_address_block.html" with form=shipping_address_form address_form=shipping_address_chooser_form show_address_chooser=show_shipping_address_chooser title=title id="shipping-address-form-block" %}
                    {% endblock %}

                    {% block billing_address %}
                    {% trans "Billing address" as title %}
                    {% include "checkout/partials/address_block.html" with form=billing_address_form address_form=billing_address_chooser_form show_address_chooser=show_billing_address_chooser title=title id="billing-address-form-block" %}
                    {% endblock %}
                    <fieldset id="shipping-method-form-block">
                        {% block delivery_date_wrapper %}{{ block.super }}{% endblock %}


                        {% block shipping_method_wrapper %}
                        {% trans "Shipping method" as title %}
                        {% include "checkout/partials/shipping_method_block.html" with form=shipping_method_form title=title id="shipping_method_form" %}
                        {% endblock %}

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

                    {% block notes %}
                        {% trans "Notes" as title %}
                        {% include "checkout/partials/shipping_address_notes_block.html" with form=shipping_address_form title=title nolabel=True %}
                    {% endblock notes %}
                </div>
                <div class="col-lg-5 col-12 checkout-right">
                    {% include "checkout/partials/basket_lines.html" %}
                    <div class="basket-totals-outer">
                        <div class="basket-totals-wrapper">
                            {% trans "Your order" as title %}
                            {% include "checkout/partials/totals_block.html" with title=title nohide=True id="checkouttotal" %}
                            
                            {% if show_voucher_block %}
                                <div class="voucher_form" id="voucher_form">
                                    <div class="input-group">
                                        {% include "oscar/partials/form_fields.html" with form=voucher_form nolabel=True placeholder=promo_code form_clean=True %}
                                        <button type="submit" formaction="{% url 'basket:vouchers-add' %}" class="btn btn-primary" data-loading-text="{% trans 'Adding...' %}" accesskey="v">{% trans "Add voucher" %}</button>
                                    </div>
                                </div>
                            {% endif %}
                            
                            <div class="checkbox terms_block">
                                {% block vat_regulation_text %}
                                {{block.super}}
                                {% endblock %}
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" name="accepttermsofservice" id="termsofservice">
                                    <label for="termsofservice" class="form-check-label control-label required">{% include "checkout/partials/terms_of_service.html" %}</label>
                                </div>  
                            </div>

                            {% iffeature "newsletter" %}
                            <div class="checkbox newsletter_block">
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" name="subscribetonewsletter" id="newsletter"{% if request.POST.subscribetonewsletter %} checked {% endif %}>
                                    <label for="newsletter" class="form-check-label control-label">{% trans 'Subscribe to our newsletter.' %}</label>
                                </div>
                            </div>
                            {% endiffeature %}

                            <div class="form-group clearfix checkout_button">
                                <button class="btn btn-lg btn-primary" type="submit" accesskey="o">{% trans "Place order" %}</button>
                            </div>
                            <div class="clearfix"></div>
                        </div>
                    </div>
                </div>
                {% endif %}
            </div>
        </form>
    </div>
</section>
{% endblock %}