{% load i18n l10n fontawesome_5 humanize %}
<div id="eco-account-deductions" class="card">
    <div class="card-header rlp-r">
        <div class="row">
            <div class="col-sm-6">
                <h5>
                    <span class="badge badge-light">{{deductions.count}}</span>
                    {% trans 'Eco Account Deductions' %}
                </h5>
            </div>
            <div class="col-sm-6">
                <div class="d-flex justify-content-end">
                    {% if is_default_member and obj.recorded %}
                    <button class="btn btn-outline-default btn-modal" data-form-url="{% url 'compensation:acc:new-deduction' obj.id %}" title="{% trans 'Add new deduction' %}">
                        {% fa5_icon 'plus' %}
                        {% fa5_icon 'tree' %}
                    </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 'Intervention Identifier' %}
                </th>
                <th scope="col">
                    {% trans 'Recorded' %}
                </th>
                <th scope="col">
                    {% trans 'Amount' %}
                </th>
                <th scope="col">
                    {% trans 'Created' %}
                </th>
                <th class="w-10" scope="col">
                    <span class="float-right">
                        {% trans 'Action' %}
                    </span>
                </th>
            </tr>
            </thead>
            <tbody>
            {% for deduction in deductions %}
            <tr>
                <td class="align-middle">
                    <a href="{% url 'intervention:detail' deduction.intervention.id %}">
                        {{ deduction.intervention.identifier }}
                    </a>
                </td>
                <td class="align-middle">
                    {% if deduction.intervention.recorded %}
                        <em title="{% trans 'Recorded on' %} {{deduction.intervention.recorded.timestamp}} {% trans 'by' %} {{deduction.intervention.recorded.user}}" class='fas fa-bookmark registered-bookmark'></em>
                    {% else %}
                        <em title="{% trans 'Not recorded yet' %}" class='far fa-bookmark'></em>
                    {% endif %}
                </td>
                <td class="align-middle">{{ deduction.surface|floatformat:2|intcomma }} m²</td>
                <td class="align-middle">{{ deduction.created.timestamp|default_if_none:""|naturalday}}</td>
                <td class="align-middle float-right">
                    {% if is_default_member and is_entry_shared or is_default_member and user in deduction.intervention.shared_users  %}
                    <button data-form-url="{% url 'compensation:acc:edit-deduction' deduction.account.id deduction.id %}" class="btn btn-default btn-modal" title="{% trans 'Edit Deduction' %}">
                        {% fa5_icon 'edit' %}
                    </button>
                    <button data-form-url="{% url 'compensation:acc:remove-deduction' deduction.account.id deduction.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove Deduction' %}">
                        {% fa5_icon 'trash' %}
                    </button>
                    {% endif %}
                </td>
            </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
</div>