{% extends "base.html" %}
{% load myTemplateTag %}

{% block content %}
<h1>Inscriptions 2024/2025</h1>
<br>
<div>

<br>
<br>
</div>

<section class="heading-section">
    <!-- Search bar -->
    <div class="input-group max-80">
        <div class="input-wrapper max">
            <span class="icon-ctn">
                <i class="icon user-search"></i>
            </span>
            <input type="text" id="username" placeholder="Rechercher">
        </div>
    </div>
    <a class="btn primary" href="nouvelEleve">
         Ajouter <i class="icon profile-add"></i>
    </a>
</section>
<section class="heading-section">
   <div class="alphabet-filter">
        {% for letter in "*ABCDEFGHIJKLMNOPQRSTUVWXYZ" %}
            <a class="item" href="?letter={{ letter }}">{{ letter }}</a>
        {% endfor %}
    </div>
</section>

    <table class="table">
        <thead>
            <tr>
                <th>Nom</th>
                <th>Prenom</th>
                <th>Mail</th>
                <th>Téléphone</th>
                <th>MàJ Le</th>
                <th>Statut</th>
                <th>Fichiers</th>
                <th>Action</th>
            </tr>
        </thead>
        <tbody>

            {% for registerForm in ficheInscriptions_list %}
            {% with eleve=registerForm.eleve %}
            {% with responsable=eleve.getMainGuardian %}
            {% with fichiers=registerForm|recupereFichiersDossierInscription %}
            <tr>
                <td>{{ eleve.nom }}</td>
                <td>{{ eleve.prenom }}</td>
                <td>{{ responsable.mail }}</td>
                <td>{{ responsable.telephone }}</td>
                <td>{{ registerForm.dateMAJ }}</td>
                <td>
                    {% if registerForm.etat == 0 %}
                        <span class="tag blue"> Créé</span>
                    {% elif registerForm.etat == 1 %}
                        <span class="tag orange"> Envoyé</span>
                    {% elif registerForm.etat == 2 %}
                        <span class="tag purple"> En Validation</span>
                    {% else %}
                        <span class="tag green"> Validé</span>
                    {% endif %}
                </td>
                <td>
                    {% for fichier in fichiers %}
                        <a href="{{ fichier.url }}">{{ fichier.nom }}</a>
                    {% endfor %}
                </td>
                <td class="actions">
                    <button  class="icon-btn" onclick="location.href='{% url 'Subscriptions:send' eleve.id %}'"  type="submit"> <i class="icon directbox-send"></i></button>
                    <button  class="icon-btn"> <i class="icon edit"></i></button>
                    <button  class="icon-btn red"> <i class="icon user-minus"></i></button>
                </td>
            </tr>
            {% endwith %}
            {% endwith %}
            {% endwith %}
        {% endfor %}
        </tbody>
        <tfoot>
            <tr>
                <td></td>
                <td colspan="6">
                    <div class="pagination">
                        {% if ficheInscriptions_list.has_previous %}
                            {% if ficheInscriptions_list.previous_page_number == 1 %}
                                <a class="item" href="?page={{ ficheInscriptions_list.previous_page_number }}">&lt;</a>
                                <a class="item" href="?page=1">1</a>
                            {% else %}
                                <a class="item" href="?page={{ ficheInscriptions_list.previous_page_number }}">&lt;</a>
                                <a class="item" href="?page=1">1</a>
                                <a class="item" >...</a>
                            {% endif %}
                        {% endif %}

                        {% if ficheInscriptions_list %}
                            <a class="item active">{{ ficheInscriptions_list.number }}</a>
                        {% else %}
                            <a class="item">{{ ficheInscriptions_list.number }}</a>
                        {% endif %}

                        {% if ficheInscriptions_list.has_next %}
                            {% if ficheInscriptions_list.next_page_number == ficheInscriptions_list.paginator.num_pages %}
                                <a class="item" href="?page={{ ficheInscriptions_list.next_page_number }}">{{ ficheInscriptions_list.next_page_number }}</a>
                                <a class="item" href="?page={{ ficheInscriptions_list.next_page_number }}">&gt;</a>
                            {% else %}
                                <a class="item" >...</a>
                                <a class="item" href="?page={{ ficheInscriptions_list.paginator.num_pages }}">{{ ficheInscriptions_list.paginator.num_pages }}</a>
                                <a class="item" href="?page={{ ficheInscriptions_list.next_page_number }}">&gt;</a>
                            {% endif %}
                        {% endif %}
                    </div>
                </td>
                <td></td>
            </tr>
        </tfoot>
    </table>

{% endblock %}