{% extends 'dg_ufr/base_ufr.html' %}
{% load static %}
{% load custom_tag %}
{% load custom_tag_obj %}
{% load widget_tweaks %}
{% block custom_css %}
{% endblock custom_css %}
{% block m-title %} {% endblock m-title %}
{% block content %}

<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">ETUDIANT</h3></div>
                    <div class="card-body">
                        <h5><strong style="color:red;">{{etudiant.nce}}</strong> | {{etudiant}}</h5>
                    </div>
                </div>

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

<div class="card mb-3">
    <div class="card-header">
        <i class="fas fa-table"></i>
        UEs ETUDIEES
    </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="7" class="antd h4" style="background-color:#FBEEE6;text-transform:uppercase;text-align:center">
                         {{ semestre.niveau }} | {{ semestre }} | {% if AnUniv %} {{AnUniv}}{% endif %}
                    </th>
                </tr>
                {% if etudiant.ufr.code != 'MPSI' and EtudAn|check_all_ue_delib:semestre == 0 %}
                <tr>
                    <td colspan="7" 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>CRED.</th>
                    <th>MOY.</th>
                    <th>DECISION</th>
                    <th width="50">+</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;">
                            {{ EtudAn|get_etudiant_moyenne_ue3:item |stringformat:".2f" }}
                        </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 style="color:red;">
                            {% if etudiant|create_list_2_obj:AnUniv|check_compensation:item %}
                            +{{etudiant|create_list_2_obj:AnUniv|get_compens_note:item}}
                            {% endif %}
                        </td>
                        <td width="140">
                            {% if etudiant|create_list_2_obj:AnUniv|check_compensation:item %}
                            <button class="btn btn-warning mr-2 btn-sm" data-target="#compEdit{{item.id}}" data-toggle="modal" style="margin:1px;" ><i class="fa fa-pen"></i> &nbsp;Modifier</button>
                            {% include 'dg_ufr/modal/modal_edit_compens_note_etudiant.html' %}
                            {% else %}
                            <button class="btn btn-primary mr-2 btn-sm" data-target="#comp{{item.id}}" data-toggle="modal" style="margin:1px;" ><i class="fa fa-hourglass"></i> &nbsp;Compenser</button>
                            {% include 'dg_ufr/modal/modal_add_compens_note_etudiant.html' %}
                            {% endif %}
                        </td>
                    </tr>
                    {% endfor %}
                </tbody>
                {% endfor %}
            </table>
        </div>
    </div>
</div>


{% endblock content %}

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