{% extends 'enseignant/base_profile.html' %}
{% load static %}
{% load widget_tweaks %}
{% load unicorn %}
{% load custom_tag %}
{% unicorn_scripts %}
{% block page_title %}{{page_title}}{% endblock page_title %}
{% block content %}
<section class="content">
    <div class="container-fluid">
        <!-- Small boxes (Stat box)-->
        {% include "enseignant/parts/stats_seance.html" %}
        <div class="container">

            <div class="card">
                <div class="card-header text-white" style="background: #21618C"><h3 class="card-title">MENU</h3></div>
                <div class="card-body">
                    <form action="#" method="post">
                         {% csrf_token %}
                    <div class="row">
                        <div class="col-md-2" hidden>
                            <label>Année</label>
                            <select class="form-control" name="annee">
                                {% for annee in annees %}
                                <option value="{{annee.id}}">{{annee}}</option>
                                {% endfor %}
                            </select>
                        </div>
                        <div class="col-md-2">
                            <label>Du (debut)</label>
                            {% render_field filter_form.debut class="form-control" type="date"  %}
                        </div>
                        <div class="col-md-2">
                            <label>Au (fin)</label>
                            {% render_field filter_form.fin class="form-control" type="date"  %}
                        </div>
                        <div class="col-md-2">
                            <label>Matière</label>
                            <select class="form-control" name="ecue">
                                <option value="tous">---- Tout ---</option>
                                {% for ecue in ecues %}
                                <option value="{{ecue.id}}">{{ecue.ue.ufr.code}} - {{ecue.libelle}} ({{ecue.code}})</option>
                                {% endfor %}
                            </select>
                        </div>
                        <div class="col-md-2">
                            <label>Status</label>
                            <select name="status" class="form-control">
                                <option value="tous">---- Tout ---</option>
                                <option value="validé">Validé</option>
                                <option value="en attente">En attente...</option>
                            </select>
                        </div>
                        <div class="col-md-2">
                            <button style="margin-top:30px;" type="submit" name="ecueFilter" class='btn btn-primary'><i class="fa fa-filter"></i> Trier</button>
                        </div>
                    </div>
                    </form>

                    <hr/>
                    {% if annee %}
                    <h4>
                        Ecue: <span style="font-weight:bold;color:red;">{% if ecue_obj %}{{ecue_obj.code}}{% else %}Tout{% endif %}</span> |
                        Status: <span style="font-weight:bold;color:red;">{% if status == 'tous' %}Tout{% else %}{{status}}{% endif %}</span> |
                        Du <span style="font-weight:bold;color:red;">{{debut|date:'d-m-Y'}}</span> Au <span style="font-weight:bold;color:red;">{{fin|date:'d-m-Y'}}</span>
                    </h4>
                        {% if UFR %}
                        <a href="{% url 'EspaceEnseignant:dr_ufr_seance_pdf' UFR.id enseignant.id ecue status debut fin %}" target="_blank" class="btn btn-success"><i class="fa fa-print"></i> Imprimer</a>
                        {% endif %}
                    {% endif %}

                </div>
            </div>
              <!-- DONUT CHART -->
              <!-- /.card -->
        </div>


    </div>
  </section> <br/>


<div class="card mb-3">
    <div class="card-header">
        <i class="fas fa-table"></i>
        SEANCES DE COURS EFFECTUEES
        <button style="float:right;" data-toggle="modal" data-target="#addseance" class="btn btn-primary btn-sm"><i class="fa fa-plus"></i> Ajouter</button>
        {% include 'enseignant/parts/modal_add_seance.html' %}
    </div>
    <div class="card-body">
        <div class="table-responsive">
            <table class="table table-bordered table-striped" id="dataTable" width="100%" cellspacing="0">
                <thead>
                <tr>
                    <th>TYPE</th>
                    <th>DATE</th>
                    <th>HORAIRE</th>
                    <th>DUREE</th>
                    <th>SALLE</th>
                    <th>MATIERE</th>
                    <th>DELEGUE</th>
                    <th>ADMIN</th>
                    <th>Action</th>
                </tr>
                </thead>
                <tfoot>
                <tr>
                    <th>TYPE</th>
                    <th>DATE</th>
                    <th>HORAIRE</th>
                    <th>DUREE</th>
                    <th>SALLE</th>
                    <th>MATIERE</th>
                    <th>DELEGUE</th>
                    <th>ADMIN</th>
                    <th>Action</th>
                </tr>
                </tfoot>
                <tbody>
                {% for seance in seances %}
                <tr>
                    <td>{{ seance.type_cours }}</td>
                    <td>{{ seance.date|date:'d-m-Y' }}</td>
                    <td>{{ seance.debut|time:'G:i' }} - {{ seance.fin|time:'G:i' }}</td>
                    <td>{{seance|get_duration_between}}</td>
                    <td>{{ seance.salle.libelle }}</td>
                    <td>{{ seance.ecue.code }} : {{ seance.ecue.libelle }}</td>
                    <td>
                        {% if seance.etudiant_valid %}
                        <span class="badge badge-info">validée</span>
                        {% else %}
                        <span class="badge badge-secondary">en attente</span>
                        {% endif %}
                    </td>
                    <td>
                        {% if seance.admin_valid %}
                        <span class="badge badge-info">validée</span>
                        {% else %}
                        <span class="badge badge-secondary">en attente</span>
                        {% endif %}
                    </td>
                    <td>
                        <a href="{% url 'EspaceEnseignant:edit_seance_cours' seance.id %}" class="btn btn-warning"><i class="fa fa-edit"></i></a>
                    </td>
                </tr>
              {% empty %}
                <tr>
                    <td colspan="9"><center>Aucun résultat</center></td>
                </tr>
              {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
</div>
{% endblock content %}

{% block custom_js %}

{% endblock custom_js %}