{% load i18n l10n fontawesome_5 %}
<div id="documents" class="card">
    <div class="card-header rlp-r">
        <div class="row">
            <div class="col-sm-6">
                <h5>
                    <span class="badge badge-light">{{obj.documents.count}}</span>
                    {% trans 'Documents' %}
                </h5>
            </div>
            <div class="col-sm-6">
                <div class="d-flex justify-content-end">
                    {% if is_default_member and has_access  %}
                    <button class="btn btn-outline-default btn-modal" data-form-url="{% url 'intervention:new-doc' obj.id %}" title="{% trans 'Add new document' %}">
                        {% fa5_icon 'plus' %}
                        {% fa5_icon 'file' %}
                    </button>
                    {% endif %}
                </div>
            </div>
        </div>
    </div>
    {% if has_payment_without_document %}
    <div class="alert alert-danger mb-0">
        {% trans 'You entered a payment. Please upload the legal document which defines the payment`s amount.' %}
    </div>
    {% endif %}
    <div class="card-body {% if tables_scrollable %}scroll-300{% endif %} p-2">
        <table class="table table-hover">
            <thead>
            <tr>
                <th scope="col">
                    {% trans 'Title' %}
                </th>
                <th scope="col">
                    {% trans 'Created on' %}
                </th>
                <th scope="col">
                    {% trans 'Comment' %}
                </th>
                {% if is_default_member and has_access %}
                    <th class="w-10" scope="col">
                        <span class="float-right">
                            {% trans 'Action' %}
                        </span>
                    </th>
                {% endif %}
            </tr>
            </thead>
            <tbody>
            {% for doc in obj.documents.all %}
            <tr>
                <td>
                    <a href="{% url 'intervention:get-doc' obj.id doc.id %}">
                        {{ doc.title }}
                    </a>
                </td>
                <td>
                    <div class="scroll-150">
                        {{ doc.date_of_creation }}
                    </div>
                </td>
                <td>
                    <div class="scroll-150">
                        {{ doc.comment }}
                    </div>
                </td>
                <td class="align-middle float-right">
                    {% if is_default_member and has_access  %}
                    <button data-form-url="{% url 'intervention:edit-doc' obj.id doc.id %}" class="btn btn-default btn-modal" title="{% trans 'Edit document' %}">
                        {% fa5_icon 'edit' %}
                    </button>
                    <button data-form-url="{% url 'intervention:remove-doc' obj.id doc.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove document' %}">
                        {% fa5_icon 'trash' %}
                    </button>
                    {% endif %}
                </td>
            </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
</div>