{% extends 'profil/profil_base.html' %}
{% load static %}
{% load custom_tag %}

{% block title %} Liste des commandes{% endblock title %}

{% block profil_content %}
<div class="row">
    <div class="col-lg-12"><br/>
        <h3><i class="bi bi-calendar-date-fill"></i> Résultats disponibles</h3><hr/>
    </div>
</div>
<div class="row col-lg-11">
    <div>
    <form method="post" action="#">
        {% csrf_token %}
        <div class="row">
            <div class="col-md-4">
                <select class="form-control" name="type_concours">
                    {% for conc in TypeConcs %}
                    <option value="{{conc.id}}">{{conc.code}}</option>
                    {% endfor %}
                </select>
            </div>
            <div class="col-md-2">
                <button style="margin:1px;" type="submit" class="btn btn-primary"><i class="bi bi-filter-fill"></i> Trier</button>
            </div>
            <div class="col-md-1">
                <input type="text" value="1" name="annee" hidden />
            </div>
          </div>
    </form>
        <br/>
        </div>

    {% if candidature.type_concours.id|check_proclamation_provisoire:annee.id %}
        <!-- moy ecrit >= delib_prov & delib_prov > 0 & proclam_def = Non -->
        {% if candidature.id|get_moyenne_ecrit:annee.id >= candidature.type_concours.id|get_deliberation_provisoire:annee.id and candidature.type_concours.id|get_deliberation_provisoire:annee.id > 0 and candidature.decision_finale == 'en attente'  %}
            <div class="alert bg-success" style="margin-left:10px;color:#fff;text-align:center;font-size:16px;">Félicitations! vous êtes qualifié(e) pour les auditions</div>
        <!-- moy ecrit < delib_prov & delib_prov > 0 & proclam_def = Non -->
        {% elif candidature.id|get_moyenne_ecrit:annee.id < candidature.type_concours.id|get_deliberation_provisoire:annee.id and candidature.type_concours.id|get_deliberation_provisoire:annee.id > 0 and candidature.decision_finale == 'en attente' %}
            <div class="alert bg-danger" style="margin-left:10px;color:#fff;text-align:center;font-size:16px;">Désolé! vous n'êtes pas qualifié(e) pour les auditions</div>
        <!-- moy ecrit >= delib_prov & delib_prov > 0 & proclam_def = Oui & decision_finale = 'admis' -->
        {% elif candidature.id|get_moyenne_ecrit:annee.id >= candidature.type_concours.id|get_deliberation_provisoire:annee.id and candidature.type_concours.id|get_deliberation_provisoire:annee.id > 0 and candidature.type_concours.id|check_proclamation_definitive:annee.id and candidature.decision_finale == 'admis'  %}
            <div class="alert bg-success" style="margin-left:10px;color:#fff;text-align:center;font-size:16px;">Félicitations! vous êtes admis(e) au concours</div>
        <!-- moy ecrit >= delib_prov & delib_prov > 0 & proclam_def = Oui & decision_finale != 'admis' -->
        {% elif candidature.id|get_moyenne_ecrit:annee.id >= candidature.type_concours.id|get_deliberation_provisoire:annee.id and candidature.type_concours.id|get_deliberation_provisoire:annee.id > 0 and candidature.type_concours.id|check_proclamation_definitive:annee.id and candidature.decision_finale != 'admis'  %}
            <div class="alert bg-danger" style="margin-left:10px;color:#fff;text-align:center;font-size:16px;">Désolé! vous n'êtes admis(e) au concours</div>
        {% else %}
        {% endif %}
        <table class="table profil-cmd">
            <thead>
                <tr>
                    <th></th>
                    <th>EPREUVES ECRITES</th>
                    <th>COEF.</th>
                    <th>NOTE (/20)</th>
                    <th>COEF. X NOTE</th>
                </tr>
            </thead>
            <tbody>
            {% for evaluation in evaluations %}
                <tr>
                    <td></td>
                    <td style="text-align:right;font-weight:bold;">{{evaluation.epreuve.libelle}}</td>
                    <td style="width:70px;text-align:center;">{{evaluation|get_coefficient }}</td>
                    <td style="width:50px;">{{evaluation.id|get_evaluation_note:args}}</td>
                    <td style="width:70px;">{{evaluation.id|total_pondere:args}}</td>
                </tr>
            {% endfor %}
                <tr>
                    <td style="text-align:right;" colspan="5">MOYENNE DES EPREUVES ECRITES: <span style="color:red;font-weight:bold;">{{candidature.id|get_moyenne_ecrit:annee.id|stringformat:".2f"}}/20</span></td>
                </tr>
                <tr>
                    <td style="text-align:right;" colspan="5">MOYENNE REQUISE: <span style="color:red;font-weight:bold;">{{candidature.type_concours.id|get_deliberation_provisoire:annee.id|stringformat:".2f"}}/20</span></td>
                </tr>
            </tbody>
        </table>
    {% endif %}

    {% if candidature.type_concours.id|check_proclamation_definitive:annee.id and candidature.id|get_moyenne_ecrit:annee.id >= candidature.type_concours.id|get_deliberation_provisoire:annee.id and candidature.type_concours.id|get_deliberation_provisoire:annee.id > 0 and candidature.decision_finale != 'en attente' %}
    <div>
        <br/>
    <table class="table profil-cmd">
        <thead>
            <tr>
                <th style="text-align:center;">NOTE OBTENUE A L'AUDITION</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td style="text-align:right;">AUDITION: <span style="color:red;font-weight:bold;">{{candidature.id|get_note_orale:annee.id|stringformat:".2f"}}/20</span></td>
            </tr>
        </tbody>
    </table>
    </div>
    {% endif %}
        <br/><br/>
</div>
{% endblock profil_content %}