{% load django_ledger %}
{% load i18n %}

<div class="box">
    <div class="table-container">
        <table class="table is-fullwidth is-striped is-hoverable is-narrow django-ledger-table-bottom-margin-75">
            <thead>
            <tr>
                <th>{% trans 'Closing Entry Date' %}</th>
                <th class="has-text-centered">{% trans 'Posted' %}</th>
                <th class="has-text-centered">{% trans 'Txs' %}</th>
                <th>{% trans 'Created' %}</th>
                <th class="has-text-centered">{% trans 'Actions' %}</th>
            </tr>
            </thead>
            <tbody>
            {% for closing_entry_model in closing_entry_list %}
                <tr id="{{ closing_entry_model.get_html_id }}">
                    <td><span class="has-text-weight-bold">{{ closing_entry_model.closing_date | date }}</span></td>
                    <td class="has-text-centered">
                        {% if closing_entry_model.is_posted %}
                            <span class="icon has-text-success" title="{% trans 'Posted' %}">
                                {% icon 'ant-design:check-circle-filled' 20 %}
                            </span>
                        {% else %}
                            <span class="icon has-text-grey-lighter" title="{% trans 'Not Posted' %}">
                                {% icon 'ant-design:check-circle-filled' 20 %}
                            </span>
                        {% endif %}
                    </td>
                    <td class="has-text-centered">
                        <span class="tag is-rounded is-light">{{ closing_entry_model.ce_txs_count }}</span>
                    </td>
                    <td>{{ closing_entry_model.created | date }}</td>
                    <td class="has-text-centered">
                        <div class="dropdown is-right is-hoverable" id="closing-entry-action-{{ closing_entry_model.uuid }}">
                            <div class="dropdown-trigger">
                                <button class="button is-small is-rounded is-white"
                                        aria-haspopup="true"
                                        aria-controls="dropdown-menu">
                                    <span class="icon is-small">{% icon 'bi:three-dots-vertical' 20 %}</span>
                                </button>
                            </div>
                            <div class="dropdown-menu" id="dropdown-menu-{{ closing_entry_model.uuid }}" role="menu">
                                <div class="dropdown-content">
                                    <a href="{% url 'django_ledger:closing-entry-detail' entity_slug=entity_slug closing_entry_pk=closing_entry_model.uuid %}"
                                       class="dropdown-item">
                                        <span class="icon is-small mr-2">{% icon 'bi:eye' 16 %}</span>
                                        {% trans 'Details' %}
                                    </a>
                                    {% if closing_entry_model.can_delete %}
                                        <hr class="dropdown-divider">
                                        <a href="{% url 'django_ledger:closing-entry-delete' entity_slug=entity_slug closing_entry_pk=closing_entry_model.uuid %}"
                                           class="dropdown-item has-text-danger">
                                            <span class="icon is-small mr-2">{% icon 'bi:trash-fill' 16 %}</span>
                                            {% trans 'Delete' %}
                                        </a>
                                    {% endif %}
                                </div>
                            </div>
                        </div>
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
</div>
