{% extends 'base.html' %}
{% load crispy_forms_tags %}
{% load l10n %}
{% block content %}
<div class="main-content">
    <section class="section">
        {% block entete %}
        <div class="col-12 col-md-12 col-lg-12">
        </div>
        {% endblock %}

        {% block board %}
        <div class="row">
            <div class="col-12">
                <div class="card">
                    <div class="card-header">
                        <h4>LISTE DES PLANIFICATIONS</h4>
                        <div class="card-header-action">
                            <div class="row justify-content-center text-center">
                                <button class="btn btn-primary btn-lg btn-block" data-toggle="modal" data-target="#addPlanification">Créer nouveau</button>
                            </div>
                        </div>
                    </div>
                    <div class="card-body">
                        <div class="table-responsive">
                            <table class="table table-striped table-hover" id="tableExport" style="width:100%;">
                                <thead>
                                <tr>
                                    <th>MOIS</th>
                                    <th>ZONE</th>
                                    <th>OBJECTIFS</th>
                                    <th>ATTEINT</th>
                                </tr>
                                </thead>
                                <tbody>
                                {% for planification in planifications %}
                                <tr>
                                    <td>{{ planification.mois}}</td>
                                    <td>{{ planification.zone }}</td>
                                    <td>{{ planification.objectif_reunions }}</td>
                                    <td>{% if planification.objectif_atteint %} OUI {% else %} NON {%endif%}</td>
                                </tr>
                                {% endfor %}
                                </tbody>
                            </table>

                            <!-- Pagination -->
                            <nav aria-label="Page navigation">
                                <ul class="pagination justify-content-end">
                                    {% if page_obj.has_previous %}
                                    <li class="page-item">
                                        <a class="page-link" href="?page={{ page_obj.previous_page_number }}">Prec</a>
                                    </li>
                                    {% endif %}
                                    {% for num in paginator.page_range %}
                                    {% if page_obj.number == num %}
                                    <li class="page-item active">
                                        <a class="page-link" href="#">{{ num }}</a>
                                    </li>
                                    {% elif num > page_obj.number|add:'-5' and num < page_obj.number|add:'5' %}
                                    <li class="page-item">
                                        <a class="page-link" href="?page={{ num }}">{{ num }}</a>
                                    </li>
                                    {% endif %}
                                    {% endfor %}
                                    {% if page_obj.has_next %}
                                    <li class="page-item">
                                        <a class="page-link" href="?page={{ page_obj.next_page_number }}">Suiv</a>
                                    </li>
                                    {% endif %}
                                </ul>
                            </nav>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        {% endblock %}
    </section>
</div>

{% include 'planification_form.html' %}


{% endblock %}
