{% extends "hosting/base_short.html" %}
{% load staticfiles bootstrap3 i18n humanize %}

{% block css_extra %}
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/paymentfont/1.1.2/css/paymentfont.min.css"/>
{% endblock css_extra %}

{% block content %}
<!-- Credit card form -->
<div class="dcl-order-container">
    <div class="payment-container">
        <div class="dcl-order-sec">
            <h3><strong>{%trans "Your Order" %}</strong></h3>
            <div class="row">
                <div class="col-xs-6 col-sm-12">
                    <div class="dcl-order-table-header">
                        <div class="row">
                            <div class="col-sm-2">
                                <div class="tbl-header">
                                    {%trans "Cores" %}
                                </div>
                            </div>
                            <div class="col-sm-4">
                                <div class="tbl-header tbl-header-center">
                                    {%trans "Memory" %}
                                </div>
                            </div>
                            <div class="col-sm-3">
                                <div class="tbl-header tbl-header-center">
                                    {%trans "Disk space" %}
                                </div>
                            </div>
                            <div class="col-sm-3">
                                <div class="tbl-header tbl-header-right">
                                    {%trans "Configuration" %}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-xs-6 col-sm-12">
                    <div class="dcl-order-table-content">
                        <div class="row">
                            <div class="col-sm-2">
                                <div class="tbl-content">
                                    {{request.session.specs.cpu|floatformat}}
                                </div>
                            </div>
                            <div class="col-sm-4">
                                <div class="tbl-content tbl-content-center">
                                    {{request.session.specs.memory|floatformat}} GB
                                </div>
                            </div>
                            <div class="col-sm-3">
                                <div class="tbl-content tbl-content-center">
                                    {{request.session.specs.disk_size|floatformat|intcomma}} GB
                                </div>
                            </div>
                            <div class="col-sm-3">
                                <div class="tbl-content tbl-content-right">
                                    {{request.session.template.name}}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="dcl-order-table-total">
                <div class="row">
                    <div class="col-xs-6">
                        <div class="tbl-tot">
                            {%trans "Total" %}&nbsp;
                            <span>{% if vm_pricing.vat_inclusive %}{%trans "including VAT" %}{% else %}{%trans "excluding VAT" %}{% endif %}</span>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <div class="tbl-total">
                            {{request.session.specs.price|intcomma}} CHF/{% trans "Month" %}
                        </div>
                    </div>
                </div>
                {% if vm_pricing.discount_amount %}
                <hr class="thin-hr">
                <div class="row">
                    <div class="col-xs-6">
                        <div class="tbl-tot">
                            {%trans "Discount" as discount_name %}
                            {{ vm_pricing.discount_name|default:discount_name }}&nbsp;&nbsp;<br>
                            <span>({% trans "Will be applied at checkout" %})</span>
                        </div>
                    </div>
                    <div class="col-xs-6 text-right">
                        <div class="tbl-total">
                            <div class="text-primary">- {{ vm_pricing.discount_amount }} CHF/{% trans "Month" %}</div>
                        </div>
                    </div>
                </div>
                {% endif %}
            </div>
        </div>
        <div class="dcl-billing-sec">
            <div class="row">
                <div class="col-sm-5 col-md-6">
                    <div class="billing dcl-billing">
                        <h3><b>{%trans "Billing Address"%}</b></h3>
                        <hr>
                        <form role="form" id="billing-form" method="post" action="" novalidate>
                            {% csrf_token %}
                            {% for field in form %}
                            {% bootstrap_field field show_label=False type='fields'%}
                            {% endfor %}
                        </form>
                    </div>
                </div>
                <div class="col-xs-12 col-sm-7 col-md-6 creditcard-box dcl-creditcard">
                    {% with card_list_len=cards_list|length %}
                    <h3><b>{%trans "Credit Card"%}</b></h3>
                    <hr>
                    <div>
                        <p>
                            {% if card_list_len > 0 %}
                            {% blocktrans %}Please select one of the cards that you used before or fill in your credit card information below. We are using <a href="https://stripe.com" target="_blank">Stripe</a> for payment and do not store your information in our database.{% endblocktrans %}
                            {% else %}
                            {% blocktrans %}Please fill in your credit card information below. We are using <a href="https://stripe.com" target="_blank">Stripe</a> for payment and do not store your information in our database.{% endblocktrans %}
                            {% endif %}
                        </p>
                        <div>
                            {% for card in cards_list %}
                                <div class="credit-card-info">
                                    <div class="col-xs-6 no-padding">
                                        <h5 class="billing-head">{% trans "Credit Card" %}</h5>
                                        <h5 class="membership-lead">{% trans "Last" %} 4: ***** {{card.last4}}</h5>
                                        <h5 class="membership-lead">{% trans "Type" %}: {{card.brand}}</h5>
                                    </div>
                                    <div class="col-xs-6 text-right align-bottom">
                                        <a class="btn choice-btn choice-btn-faded" href="#" data-id_card="{{card.id}}">{% trans "SELECT" %}</a>
                                    </div>
                                </div>
                            {% endfor %}
                            {% if card_list_len > 0 %}
                                <div class="new-card-head">
                                    <div class="row">
                                        <div class="col-xs-6">
                                            <h4>{% trans "Add a new credit card" %}</h4>
                                        </div>
                                        <div class="col-xs-6 text-right">
                                            <button data-toggle="collapse" data-target="#newcard" class="btn choice-btn">
                                                <span class="fa fa-plus"></span>&nbsp;&nbsp;{% trans "NEW CARD" %}
                                            </button>
                                        </div>
                                    </div>
                                </div>
                                <div id="newcard" class="collapse">
                                    <hr class="thick-hr">
                                    <div class="card-details-box">
                                        <h3>{%trans "New Credit Card" %}</h3>
                                        <hr>
                                        {% include "hosting/includes/_card_input.html" %}
                                    </div>
                                </div>
                            {% else%}
                                {% include "hosting/includes/_card_input.html" %}
                            {% endif %}
                        </div>
                    </div>
                    {% endwith %}
                </div>
            </div>
        </div>
    </div>
</div>

<!-- stripe key data -->
{% if stripe_key %}
{% get_current_language as LANGUAGE_CODE %}
<script type="text/javascript">
    window.processing_text = '{%trans "Processing" %}';
    window.enter_your_card_text = '{%trans "Enter your credit card number" %}';

    (function () {
        window.stripeKey = "{{stripe_key}}";
        window.current_lan = "{{LANGUAGE_CODE}}";
    })();
</script>
{%endif%}
{% comment "Looks as if no more used. To test..." %}
{% if credit_card_data.last4 and credit_card_data.cc_brand %}
<script type="text/javascript">
    (function () {
        window.hasCreditcard = true;
    })();
</script>
{%endif%}
{% endcomment %}
{%endblock%}
