{% extends 'ledger/base.html' %}
{% load i18n %}
{% load humanize %}

{% block page_title %}
    {{ title }} ⋗ {% translate "Ledger" %}
{% endblock %}

{% block page_topic %}
    <h1 class="page-header text-center">
        {{ title }}
    </h1>
{% endblock page_topic %}

{% block header_nav_collapse_left %}

{% include 'ledger/partials/menu/events/navigation.html' %}

{% endblock header_nav_collapse_left %}

{% block header_nav_collapse_right %}

{% include 'ledger/partials/menu/events/administration.html' %}

{% endblock header_nav_collapse_right %}

{% block ledger_block %}
    <div class="card-body card-primary">
        <div class="card-header bg-primary">
             <h3><div class="card-title">{% trans "Manage Events" %}</div></h3>
        </div>
        <div class="card-body bg-secondary">
            <table class="table table-dark table-striped table-hover w-100" id="event-table">
                <thead>
                    <tr>
                        <th>{% trans "ID" %}</th>
                        <th>{% trans "Title" %}</th>
                        <th>{% trans "Start Date" %}</th>
                        <th>{% trans "End Date" %}</th>
                        <th>{% trans "Location" %}</th>
                        <th>{% trans "Description" %}</th>
                        <th>{% trans "Char Ledger Exclude" %}</th>
                        <th>{% trans "Actions" %}</th>
                    </tr>
                </thead>
                <tbody>
                    {% for event in events %}
                    <tr>
                        <td>{{ event.id }}</td>
                        <td>{{ event.title }}</td>
                        <td>{{ event.date_start }}</td>
                        <td>{{ event.date_end }}</td>
                        <td>{{ event.location }}</td>
                        <td>{{ event.description }}</td>
                        <td>{{ event.char_ledger }}</td>
                        <td>
                            <div class="d-flex justify-content-end">
                                <a href="{% url 'ledger:edit_event' event.id %}" class="btn btn-warning btn-sm btn-square me-2">
                                    <span class="fas fa-pencil"></span>
                                </a>
                                <a href="{% url 'ledger:delete_event' event.id %}" class="btn btn-danger btn-sm btn-square me-2">
                                    <span class="fas fa-trash"></span>
                                </a>
                            </div>
                        </td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
{% endblock %}

{% block extra_javascript %}
{% include 'bundles/datatables-js-bs5.html' %}
<script>
document.addEventListener('DOMContentLoaded', function () {
    $(document).ready(function() {
        $('#event-table').DataTable({
            "pageLength": 10
        });
    });
});
</script>
{% endblock %}

{% block extra_css %}
    {% include "ledger/bundles/ledger-css.html" %}
{% endblock %}

{% block extra_script %}
{% endblock %}
