{% extends 'base.html' %}
{% load i18n %}

{% block title %}{% trans 'Debts' %}{% endblock %}

{% block breadcrumb %}
    <ol class="breadcrumb">
        <li><span class="glyphicon glyphicon-home"></span></li>
        <li><a href="{% url 'abonapp:group_list' %}">{% trans 'User groups' %}</a></li>
        <li><a href="{% url 'abonapp:people_list' group.pk %}">{{ group.title }}</a></li>
        <li class="active">{% trans 'Debts' %}</li>
    </ol>
{% endblock %}

{% block page-header %}
    {% trans 'Debtor' %} {{ abon.fio }}
{% endblock %}

{% block main %}
    <div class="table-responsive">
        <table class="table table-striped table-bordered">
            <thead>
            <tr>
                <th>{% trans 'Pay status' %}</th>
                <th>{% trans 'Month' %}</th>
                <th>{% trans 'Sum' %}</th>
                <th>{% trans 'Comment' %}</th>
                <th>{% trans 'Date of make' %}</th>
                <th>{% trans 'Date of payment' %}</th>
                <th>{% trans 'Author of payment' %}</th>
            </tr>
            </thead>
            <tbody>
            {% for inv in invoices %}
                <tr>
                    <td class="col-xs-1 text-center">{% if inv.status %}
                        <span class="glyphicon glyphicon-ok"></span>
                    {% else %}
                        <span class="glyphicon glyphicon-time"></span>
                    {% endif %}</td>
                    <td class="col-xs-1">{{ inv.date_create|date:"F" }}</td>
                    <td class="col-xs-1">{{ inv.amount }}</td>
                    <td class="col-xs-3">{{ inv.comment }}</td>
                    <td class="col-xs-2">{{ inv.date_create|date:"D d E Y H:i:s" }}</td>
                    <td class="col-xs-2">
                        {% if inv.date_pay %}
                            {{ inv.date_pay|date:"D d M Y H:i:s" }}
                        {% else %}
                            {{ inv.status|yesno:_('Created paid,Not yet paid') }}
                        {% endif %}
                    </td>
                    <td class="col-xs-2">
                        <a href="{% url 'acc_app:other_profile' inv.author.id %}">{{ inv.author.username }}</a>
                    </td>
                </tr>
            {% empty %}
                <tr>
                    <td colspan="7">{% trans 'Receipts not found' %}</td>
                </tr>
            {% endfor %}
            </tbody>
            {% if perms.abonapp.add_invoiceforpayment %}
                <tfoot>
                <tr>
                    <th colspan="7">
                        <div class="btn-group btn-group-sm">
                            <a href="{% url 'abonapp:add_invoice' group.id abon.username %}" class="btn btn-success">
                                <span class="glyphicon glyphicon-plus"></span> {% trans 'Add debt' %}
                            </a>
                            <a href="{% url 'abonapp:abon_home' group.id abon.username %}" class="btn btn-default">
                                <span class="glyphicon glyphicon-backward"></span> {% trans 'Back to home' %}
                            </a>
                        </div>
                    </th>
                </tr>
                </tfoot>
            {% endif %}
        </table>
    </div>
{% endblock %}
