{% extends 'enseignant/base_profile.html' %}
{% load static %}
{% load custom_tag %}
{% block head %}{% endblock head %}
{% block page_title %}<!--({{ue.code}}) : {{ue.libelle}}--> {% endblock page_title %}
{% block content %}

<div class="row">
    <div class="col-md-12 not-lib" style="color:#179acf;font-size:26px;font-weight:bold;align:left;width:100%;margin-bottom:25px;margin-top:-35px;"
    >
        <!--<span style="margin-left:15px;">UE : {{ue.libelle}}</span><br/>-->
        <span style="margin-left:55px;">matière : ({{ecue.code}}) {{ecue.libelle}}</span>
    </div>
</div><br/>
<div style="text-align:center;">
    <h2>ANNEE: <span style="color:red">{{get_annee}}</span> | NIVEAU: <span style="color:red">{{get_niveau}}</span></h2>
</div>
<div class="card">
    <div class="card-header text-white" style="background: #21618C"><h3 class="card-title">MENU</h3></div>
    <div class="card-body">
        {% if id_ecue2|check_deliberation_ecue_2:'all' or not etudiantUes %}
        <button class="btn btn-primary mx-1 btn-sm" disabled><i class="fa  fa-lock"></i> Délibérer</button>
        {% else %}
        <button class="btn btn-primary mx-3 btn-sm" data-toggle="modal" data-target="#deliberation" id="delib"><i class="fa  fa-clock"></i> Délibération</button>
        {% endif %}

        {% if not etudiantUes %}
        <button class="btn btn-primary mx-1 btn-sm" disabled><i class="fa  fa-print"></i> Imprimer</button>
        {% else %}
       <!-- <a href="{% url 'EspaceEnseignant:resultat_ecue_pdf' ecue.id get_annee.id get_niveau.id get_ufr.id %}" target="_blank" class="btn btn-primary btn-sm" ><i class="fa fa-print"></i> Imprimer</a> -->
        {% endif %}

        {% include 'EspaceEnseignant/modal_deliberation.html' %}
        {% include 'EspaceEnseignant/modal.html' %}{% include 'EspaceEnseignant/modal_import_note.html' %}<br/><br/>

        <hr/>
        <form action="#" method="post">
            {% csrf_token %}
            <div class="row">
                <div class="col-md-2">
                    <select class="form-control" name="libelle" {% if not id_ecue2|check_deliberation_ecue_2:1 %} disabled {% endif %}>
                        {% for sess in Sessions %}
                        <option value="{{sess.id}}" {% if session_ini == sess %}selected{% endif %}>{{sess}}</option>
                        {% endfor %}
                    </select>
                </div>
                <div class="col-md-3">
                    <button type="submit" name="sessionFilter" class="btn btn-primary btn-sm" {% if not id_ecue2|check_deliberation_ecue_2:1 %} disabled {% endif %}><i class="fa fa-filter"></i> Trier</button>
                </div>
            </div>
        </form>
    </div>
</div>
<div class="card card-primary">
    <div class="card-header text-white" style="background: #21618C"><h3 class="card-title">VOIR LES NOTES</h3></div>
</div>
<div class="table p-2">
    <table class="table table-striped table-bordered">
        <tr>
            <th>NCE</th>
            <th>Nom et Prénoms</th>
            {% for evaluation in EvalEns %}
                <th>{{ evaluation.libelle }}</th>
            {% endfor %}
            {% if session_ini.id != 2  %}
            <th>Moy.</th>
            {% endif %}
            <th>D</th>
        </tr>
        {% for etudiantUe in etudiantUes %}
            <tr class="antr">
                <td class="antd" style="width:100px;">{{etudiantUe.nce}}</td>
                <td>{{etudiantUe}}</td>
                {% for evaluation in EvalAnZip %}
                     <td>
                         {% if etudiantUe.id|get_evalution_note2:evaluation %}
                         <span>{{ etudiantUe.id|get_evalution_note2:evaluation }}</span> <!--&nbsp;<i class="fa fa-pen">--></i>
                         {% else %}
                             {% if delib_ecue %}
                            ---
                            <!-- <button class="btn btn-primary" disabled><i class="fa fa-pen"></i></button> -->
                             {% else %}
                            <!-- <a href="add_note/{{etudiantUe.etudiant.id}}/{{ evaluation.id }}/{{ evaluation.id }}" class="btn btn-primary"><i class="fa fa-pen"></i></a> -->
                             <button class="btn btn-secondary btn-sm" disabled><i class="fa fa-pen"></i></button>
                             {% endif %}
                         {% endif %}
                        <!--<input type="number" name="{{etudiantUe.etudiant.id}}" size="4" style="width:60px;" />-->
                    </td>
                {% endfor %}
               <!-- <td>{{ etudiantUe.etudiant.id|get_moyenne_cc:id_ecue |stringformat:".2f" }}</td> -->
                {% if session_ini.id != 2  %}
                <td>{{ etudiantUe.id|get_moyenne_ue2:id_ecue2 |stringformat:".2f" }}</td>
                {% endif %}
                <td class="delib" style="text-transform:none;">

                    <span class="badge
                    {% if etudiantUe.id|get_moyenne_ue2:id_ecue2|get_decision == 'VALIDEE' %}
                    badge-success
                    {% else %}
                    badge-danger
                    {% endif%}
                    ">{{ etudiantUe.id|get_moyenne_ue2:id_ecue2|get_decision }}</span>

                </td>
            </tr>
        {% empty%}
            <tr>
                <td class="h4" colspan="4" style="text-align:center;">La liste est vide ....</td>
            </tr>
        {% endfor %}

    </table>
</div>


{% endblock content %}

{% block custom_js %}
<script src="{% static 'js/custom-js/save_note.js'%} "></script>
 <script src="{% static 'js/custom-js/note.js' %}"></script>
<script>
    var elements = rootElement.getElementsByClassName('delib')
    $('#sField').change(function(){
        $('#sForm1').submit()
    });
</script>
{% endblock custom_js %}