{% load i18n leprikon_tags qr_code %}

<div class="row">
    <label class="col-sm-4">{% trans 'Price' %}:</label>
    <div class="col-sm-8">
        {{ reg.price_text }}
        {% if reg.subject_variant.name %}({{ reg.subject_variant.name }}){% endif %}
    </div>
</div>
<div class="row">
    <label class="col-sm-4">{% trans 'Payments status' %}:</label>
    <div class="col-sm-8">
        {% if reg.payment_status.amount_due %}
        <a class="btn btn-primary btn-xs right" href="{{ reg.get_payment_request_url }}">
            <span class="glyphicon glyphicon-download" aria-hidden="true"></span>
            {% trans 'payment request' %}
        </a>
        {% endif %}
        <div class="clickable" data-toggle="collapse" id="payments-{{ reg.id }}" data-target="#payments-{{ reg.id }}-details">
            <strong style="color: {{ reg.payment_status.color }}">{{ reg.payment_status.title }}</strong>
        </div>
        <div class="collapse out" id="payments-{{ reg.id }}-details">
            {% if reg.period_payment_statuses %}
                {% for pps in reg.period_payment_statuses %}
                {{ pps.period.name }}:
                <strong style="color: {{ pps.status.color }}" title="{{ pps.status.title }}">
                    {% blocktrans with received=pps.status.received|currency %}paid {{ received }}{% endblocktrans %}{% if pps.status.returned %},
                    {% blocktrans with returned=pps.status.returned|currency %}refunded {{ returned }}{% endblocktrans %}{% endif %}
                </strong>
                {% if pps.status.discount %}({% trans 'discount' %}: {{ pps.status.discount | currency }}{% if pps.status.explanation %} - {{ pps.status.explanation }}{% endif %}){% endif %}
                {% if not forloop.last %}<br />{% endif %}
                {% endfor %}
            {% else %}
                <strong style="color: {{ reg.payment_status.color }}" title="{{ reg.payment_status.title }}">
                    {% blocktrans with received=reg.payment_status.received|currency %}paid {{ received }}{% endblocktrans %}{% if reg.payment_status.returned %},
                    {% blocktrans with returned=reg.payment_status.returned|currency %}refunded {{ returned }}{% endblocktrans %}{% endif %}
                </strong>
                {% if reg.payment_status.discount %}({% trans 'discount' %}: {{ reg.payment_status.discount | currency }}{% if reg.payment_status.explanation %} - {{ reg.payment_status.explanation }}{% endif %}){% endif %}
            {% endif %}
            {% if reg.payment_status.amount_due %}
                {% if site.payment_gateway %}
                    <h4>{% trans 'Online payment' %}</h4>
                    <p><a class="btn btn-primary" href="{{ reg.payment_url }}">{% trans 'pay online' %}</a></p>
                {% endif %}
                {% if reg.organization.bank_account %}
                    <h4>{% trans 'Bank transfer' %}</h4>
                    <p>
                        {% trans 'Please, use following information for bank transfer' %}:<br/>
                        {% trans 'Bank account' %}: {{ reg.organization.bank_account }}<br/>
                        {% trans 'Variable symbol' %}: {{ reg.variable_symbol }}<br/>
                    </p>
                    <p>
                        {% trans 'Or You may use following QR code to scan the payment details to your mobile banking application' %}:<br/>
                        <span class="qrcode">{% qr_from_text reg.spayd border=1 %}</span>
                    </p>
                {% endif %}
                {% if not reg.organization.bank_account and not site.payment_gateway %}
                    <p>{% trans 'Currently we only accept payments in cash.' %}</p>
                {% endif %}
            {% endif %}
        </div>
    </div>
</div>
