{% extends "layout/landing_page.html" %}

{% load i18n %}
{% load event_tags %}

{% block extra_head %}
    <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
    <link rel="stylesheet" href="https://cdn.datatables.net/2.2.2/css/dataTables.dataTables.css" />
    <script src="https://cdn.datatables.net/2.2.2/js/dataTables.js"></script>
    <script src="https://cdn.datatables.net/plug-ins/2.2.2/i18n/cs.js"></script>
{% endblock %}


{% block landing_content %}
    <div class="w3-padding w3-padding-top-64">
    <table class="w3-table w3-striped w3-bordered w3-border w3-hoverable w3-white">
        <thead>
        <tr>
            <th>Krestni jmeno</th>
            <th>Prijmeni</th>
            <th>Email</th>
            <th>Kategorie</th>
            <th>Variabilni symbol</th>
            <th>Startovni cislo</th>
            <th>Kod cipu</th>
            <th>Prezentovane</th>
            <th></th>
        </tr>
        </thead>
        <tbody>
        {% for registration in registrations %}
            <tr>
                <td>{{ registration.first_name }}</td>
                <td>{{ registration.last_name }}</td>
                <td>{{ registration.email }}</td>
                <td>{{ registration.category }}</td>
                <td>{{ registration.variable_symbol }}</td>
                <td>{{ registration.start_number }}</td>
                <td>{{ registration.chip_id }}</td>
                 <td>{{ registration.is_presented }}</td>
                <td>
                    <a href="{% url 'admin:events_registration_change' registration.id %}" class="w3-button w3-green w3-small" target="_blank">Upravit</a>
                    {% if not registration.is_presented %}
                        <a href="{% url 'registration_present' registration.id %}" class="w3-button w3-blue-gray w3-small">Prezentovat</a>
                    {% endif %}
                </td>
            </tr>
        {% empty %}
            <tr>
                <td colspan="2">Nemáš žádné registrace na tomto závodu.</td>
            </tr>
        {% endfor %}
        </tbody>
    </table>


 </div>
    {% include 'layout/landing_footer.html' %}
{% endblock %}

{% block js %}
    <script>
        $(document).ready(function () {
            $('.w3-table').DataTable(
                {
                    "language": {
                        url: 'https://cdn.datatables.net/plug-ins/2.2.2/i18n/cs.json'
                    }
                }
            );
        });
    </script>
{% endblock %}
