{% load i18n l10n fontawesome_5 %}
<div id="payments" class="card">
    <div class="card-header rlp-r">
        <div class="row">
            <div class="col-sm-6">
                <h5>
                    <span class="badge badge-light">{{obj.payments.count}}</span>
                    {% trans 'Payments' %}
                </h5>
            </div>
            <div class="col-sm-6">
                <div class="d-flex justify-content-end">
                    {% if is_default_member and is_entry_shared  %}
                    <button class="btn btn-outline-default btn-modal" data-form-url="{% url 'compensation:pay:new' obj.id %}" title="{% trans 'Add new payment' %}">
                        {% fa5_icon 'plus' %}
                        {% fa5_icon 'money-bill-wave' %}
                    </button>
                    {% endif %}
                </div>
            </div>
        </div>
    </div>
    <div class="card-body {% if tables_scrollable %}scroll-300{% endif %} p-2">
        <table class="table table-hover">
            <thead>
            <tr>
                <th scope="col">
                    {% trans 'Amount' context 'money' %}
                </th>
                <th scope="col">
                    {% trans 'Due on' %}
                </th>
                <th class="w-50" scope="col">
                    {% trans 'Comment' %}
                </th>
                {% if is_default_member and is_entry_shared %}
                    <th class="w-10" scope="col">
                        <span class="float-right">
                            {% trans 'Action' %}
                        </span>
                    </th>
                {% endif %}
            </tr>
            </thead>
            <tbody>
            {% for pay in obj.payments.all %}
            <tr>
                <td class="align-middle">
                    {% if is_entry_shared %}
                        {{ pay.amount|floatformat:2 }} €
                    {% else %}
                        ***
                    {% endif %}
                </td>
                <td class="align-middle">{{ pay.due_on|default_if_none:"---" }}</td>
                <td class="align-middle">
                    <div class="scroll-150">
                        {% if is_entry_shared %}
                            {{ pay.comment }}
                        {% else %}
                            {% trans 'This data is not shared with you' %}
                        {% endif %}
                    </div>
                </td>
                <td class="align-middle float-right">
                    {% if is_default_member and is_entry_shared  %}
                    <button data-form-url="{% url 'compensation:pay:edit' obj.id pay.id %}" class="btn btn-default btn-modal" title="{% trans 'Edit payment' %}">
                        {% fa5_icon 'edit' %}
                    </button>
                    <button data-form-url="{% url 'compensation:pay:remove' obj.id pay.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove payment' %}">
                        {% fa5_icon 'trash' %}
                    </button>
                    {% endif %}
                </td>
            </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
</div>
