{% load i18n leprikon_tags qr_code %}

<div class="row">
    <label class="col-sm-4">{% trans 'Price' %}:</label>
    <div class="col-sm-8">
        {{ reg.price | currency }}
        {% if reg.subject.course.school_year_division.period_name %} / {{ reg.subject.course.school_year_division.period_name }}{% endif %}
        {% if reg.subject_variant %}({{ reg.subject_variant.name }}){% endif %}
    </div>
</div>
{% if reg.subject.subject_type.subject_type == 'event' and reg.all_discounts %}{# events #}
<div class="row">
    <label class="col-sm-4">{% trans 'Discount' %}:</label>
    <div class="col-sm-8">
        <strong class="clickable" data-toggle="collapse" id="discount-{{ reg.id }}" data-target="#explanation-{{ reg.id }}">
            {{ reg.discount | currency }}
        </strong>
        <div class="collapse out" id="explanation-{{ reg.id }}">
            {% for discount in reg.all_discounts %}
            {{ discount.explanation | linebreaks }}
            {% endfor %}
        </div>
    </div>
</div>
{% endif %}
<div class="row">
    <label class="col-sm-4">{% trans 'Payments' %}:</label>
    <div class="col-sm-8">
        {% if reg.payment_status %}{# events #}
        <strong style="color: {{ reg.payment_status.color }}" title="{{ reg.payment_status.title }}">
            {{ reg.payment_status.paid | currency }}
        </strong>
        {% else %}{# courses #}
        <strong class="clickable" data-toggle="collapse" id="payments-{{ reg.id }}" data-target="#period-payments-{{ reg.id }}"
            style="color: {{ reg.payment_statuses.partial.color }}" title="{{ reg.payment_statuses.total.title }}">
            {{ reg.payment_statuses.total.paid | currency }}
        </strong>
        <div class="collapse out" id="period-payments-{{ reg.id }}">
            {% for ps in reg.get_period_payment_statuses %}
            {{ ps.period.name }}:
            <strong style="color: {{ ps.status.color }}" title="{{ ps.status.title }}">
                {{ ps.status.paid | currency }}
            </strong>
            {% if ps.status.discount %}({% trans 'discount' %}: {{ ps.status.discount | currency }}{% if ps.status.explanation %} - {{ ps.status.explanation }}{% endif %}){% endif %}
            <br />
            {% endfor %}
        </div>
        {% endif %}
        {% if reg.payment_requested and reg.current_receivable %}
            {% 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 site.bank_account %}
                <h4>{% trans 'Bank transfer' %}</h4>
                <p>
                    {% trans 'Please, use following information for bank transfer' %}:<br/>
                    {% trans 'Bank account' %}: {{ site.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/>
                    {% qr_from_text reg.spayd border=1 %}
                </p>
            {% endif %}
            {% if not site.bank_account and not site.payment_gateway %}
                <p>{% trans 'Currently we only accept payments in cash.' %}</p>
            {% endif %}
        {% endif %}
    </div>
</div>
<div class="row">
    <label class="col-sm-4">{% trans 'Presence' %}:</label>
    <div class="col-sm-8">
    {% if reg.subject.course %}
        {% for history in reg.course_history.all %}
        {% for entry in history.journal_entries.all %}
        <strong title="{{ entry.date }}{% if history.course_id != reg.subject_id %} ({{ history.course.display_name }}){% endif %}" style="color: #{% if reg.id in entry.all_registrations_idset %}0a0{% else %}e00{% endif %}">
        {% if reg.id in entry.all_registrations_idset %}&#x2713;{% else %}&#x2717;{% endif %}
        </strong>
        {% endfor %}
        {% endfor %}
    {% elif reg.subject.event %}
        {% for entry in reg.subject.journal_entries.all %}
        <strong title="{{ entry.date }}" style="color: #{% if reg.id in entry.all_registrations_idset %}0a0{% else %}e00{% endif %}">
        {% if reg.id in entry.all_registrations_idset %}&#x2713;{% else %}&#x2717;{% endif %}
        </strong>
        {% endfor %}
    {% endif %}
    </div>
</div>
