{% extends 'EspaceEtudiant/base_etudiant.html' %}
{% load static %}
{% load custom_tag %}
{% load custom_tag_obj %}
{% block page_title %}{% endblock page_title %}
{% block content %}
{% load unicorn %}
{% unicorn_scripts %}

<section class="content">
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-12">
                <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">
                                <select class="form-control" name="libelle">
                                    {% for annee in annees %}
                                    <option value="{{annee.id}}">{{annee}}</option>
                                    {% endfor %}
                                </select>

                            </div>
                            <div class="col-md-2">
                                <button type="submit" name="AnneeFilter" class='btn btn-primary btn-sm'><i class="fa fa-filter"></i></button>
                            </div>

                        </div>
                        </form>
                    </div>
                </div>

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

<div class="card mb-3">
    <div class="card-header">
        <i class="fas fa-table"></i>
        MATI&Egrave;RES ETUDI&Eacute;ES
    </div>
    <div class="card-body">
        <div class="table-responsive">
            <table class="table table-bordered table-striped" id="dataTables" width="100%" cellspacing="0">
                {% for semestre in semestres %}
                <thead>
                <tr>
                    <th colspan="6" class="antd h4" style="background-color:#FBEEE6;text-transform:uppercase;text-align:center">
                         {{ semestre }} | {% if AnUniv %} {{AnUniv}}{% endif %}
                    </th>
                </tr>
                {% if etudiant.ufr.code != 'MPSI' and EtudAn|check_all_ue_delib:semestre == 0 %}
                <tr>
                    <td colspan="6" style="
                    {% if EtudAn|get_decision_annuelle_etudiant:semestre == 'ADMIS(E)' %}
                        background-color:green;
                    {% elif EtudAn|get_decision_annuelle_etudiant:semestre == 'AUTORISE(E)' %}
                        background-color:#9CFF33;
                    {% elif EtudAn|get_decision_annuelle_etudiant:semestre == 'REFUSE(E)' %}
                        background-color:#FF5733;
                    {% else %}
                    {% endif %}
                        text-align:center;color:#fff;font-size:20px;">
                        DECISION : {{ EtudAn|get_decision_annuelle_etudiant:semestre}}
                    </td>
                </tr>
                {% endif %}

                <tr>
                     <th>CODE</th>
                    <th>LIBELLE</th>
                    <th>COEFFICIENTS</th>
                    <th>MOYENNE</th>
                    <th>DECISION</th>
                    <th></th>
                </tr>
                </thead>
                <tbody>
                {% for item in UfrAn|get_ue_by_ufr_and_semestre_set:semestre.id %}
                    <tr>
                        <td><b>{{ item.code }}</b></td>
                        <td style="text-transform:uppercase;">{{ item.libelle }} </td>
                        <td style="text-transform:uppercase;text-align:center;">{{ item|get_credit_ue }}</td>
                        <td style="text-align:center;">
                        {% if item.id|check_deliberation_ue_an:AnUniv == 'Oui' %}
                            {{ EtudAn|get_etudiant_moyenne_ue3:item |stringformat:".2f" }}
                        {% else %}
                            <span class="badge badge-secondary"> en attente...</span>
                        {% endif %}
                        </td>
                        <td>
                        {% if item.id|check_deliberation_ue_an:AnUniv == 'Oui' %}
                            {% if EtudAn|get_etudiant_moyenne_ue3:item >= item|get_note_delib_ue:AnUniv and item|get_note_delib_ue:AnUniv > 0 %}
                            <span class="badge badge-success"> validée</span>
                            {% else %}
                            <span class="badge badge-danger"> ajournée</span>
                            {% endif %}
                        {% else %}
                            <span class="badge badge-secondary"> en attente...</span>
                        {% endif %}
                        </td>
                        <td width="80">

                               {%  if enseignant %}
                                    <a class="btn btn-primary mr-2 btn-sm" style="margin:1px;" href="{% url 'EspaceEnseignant:vpr_etudiant_detail_ue' item.id etudiant.id annee.id %}">Detail</a>
                                {% else %}
                                    <a class="btn btn-primary mr-2 btn-sm" style="margin:1px;" href="{% url 'EspaceEtudiant:detail_ue' item.id AnUniv.id %}">Detail</a>
                            {% endif %}

                           <!-- <button class="btn btn-warning mr-2 btn-sm" style="margin:1px;" data-toggle="modal" data-target="#syllabus_ue_{{item.id}}">Syllabus</button> -->
                                {% include 'EspaceEtudiant/modal_syllabus_ecue.html' %}
                        </td>
                    </tr>
                    {% endfor %}
                </tbody>
                {% endfor %}
            </table><br/>

        </div>
    </div>
</div>


{% endblock content %}

{% block custom_js %}
{% endblock custom_js %}