{% load static %}
{% load custom_tag %}
{% load custom_tag_obj %}
<!DOCTYPE>
<html>
    <head>
        <title>PV FINAL - {{UFR}} - {{get_niveau}} | {{get_annee}}</title>
        <style type="text/css">
         
            .usp-info img{
                width:100%;

            }
            .table{
                border:1px solid #000000;
                text-align:left;
                font-size:11px;
            }
            .table-2{
                border:1px solid #000000;
                width:80%;
                text-align:left;
                font-size:12px;
            }
            .table tr{
                padding:1px;
            }
            .table td {
              border: 1px solid;
            }
            .table th{
                text-align:left;
                padding:1px;
            }
            .nce{
                width:148px;
            }
            .nom{
                width:160px;
            }
            .ue-content{
                min-width:45px;
            }
            .title{
                font-size:20px;
                text-align: center;
                border:1px solid #000000;
                padding:15px;
            }
            .stat-ue{
                font-size:16px;
                font-weight:bold;
                width:113px;
                padding:3px 2px 1px 2px;
            }
            .stat-ue-2{
                font-size:16px;
                font-weight:bold;
                width:200px;
                padding:3px 2px 1px 2px;
            }
            .bg-orange{
                background-color:#fdc000;
            }
            @page{
                size: a2 landscape;
                margin: 25px;
            }

        </style>
    </head>
    <body>
      <div class="pdf-content">
          <div class="usp-info">
               <center> <img src="static/ac-img/usp-info.png"></center>
          </div>
          <br/><br/>
          <div class="title">
              <span style="font-weight:bold;">UFR: {{UFR}}</span><br/>
              <span style="text-transform: uppercase;">ANNEE UNIVERSITAIRE: {{get_annee}}</span><br/>
              <span style="text-transform: uppercase;">NIVEAU: {{get_niveau}}</span><br/>
              <span style="text-transform:uppercase;">
                    {{semestre.0}} & {{semestre.1}}
              </span><br/>
              <span style="font-weight:bold;">PROCES-VERBAL DE DELIBERATIONS</span><br/>
          </div><br/><br/>
          <br/><br/>
          <center>
          <table class="table">
              <thead>
              <tr>
                  <th colspan="{{header_cols}}" style="font-size:20px;padding-top:4px;">
                      <center>{{semestre.0}}</center>
                  </th>
                  <th style="background-color:#000000;"></th>
                  <th colspan="{{header_colsS2}}" style="font-size:20px;padding-top:4px;">
                      <center>{{semestre.1}}</center>
                  </th>
                  <th style="background-color:#000000;"></th>
                  <th
                          {% if UFR.code == 'MPSI'  %}
                                colspan="2"
                            {% else %}
                                colspan="4"
                          {% endif %}

                          style="font-size:20px;padding-top:4px;"
                  >
                      <center>ANNUEL</center>
                  </th>
              </tr>
              <tr>
                    <th style="width:35px;float:left;"></th>
                    <th style="width:100px;float:left;">ID Permanent</th>
                    <th style="width:150px;">ID ETUDIANT</th>
                    {% for ue in ues_S1 %}
                    <th class="ue-content"><center>{{ue.code}}<br/>{{ue|get_credit_ue}}</center></th>
                    {% endfor %}
                    <th style="width:40px;">
                        <center>Moy.<br/>S1</center>
                    </th>
                  {% if UFR.code == 'MPSI'  %}
                    {% else %}
                    <th style="width:60px;"><center>TTC S1<br/> {{total_credit_S1}}</center></th>
                    <th style="width:35px;">Déc.</th>
                  {% endif %}
                    <th style="width:10px;background-color:#000000;"></th>
                    {% for ue in ues_S2 %}
                    <th class="ue-content"><center>{{ue.code}}<br/>{{ue|get_credit_ue}}</center></th>
                    {% endfor %}
                    <th style="width:40px;">
                        <center>Moy.<br/>S2</center>
                    </th>
                  {% if UFR.code == 'MPSI'  %}
                    {% else %}
                    <th style="width:60px;"><center>TTC S2<br/> {{total_credit_S2}}</center></th>
                    <th style="width:35px;">Déc.</th>
                  {% endif %}
                    <th style="width:10px;background-color:#000000;"></th>
                  {% if UFR.code == 'MPSI'  %}
                    {% else %}
                    <th style="width:50px;">
                        <center>TTC An.<br/>/{{tota_ue_an}}</center>
                    </th>
                  {% endif %}
                    <th style="width:35px;"><center>Moy<br/>An.</center></th>
                  {% if UFR.code == 'MPSI'  %}
                    {% else %}
                    <th style="width:75px;">Déc. An.</th>
                  {% endif %}
                  <th style="width:55px;"><center></center></th>
                </tr>
              </thead>
              <tbody>
              {% for item in datas_etudiant %}
                    <tr>
                        <td style="text-align:center;">{{ forloop.counter }}</td>
                        <td style="text-align:center;">{{ item.0.nce }}</td>
                        <td style="padding-top:3px;">
                            <b>{{ item.0 }}</b><br/>
                            Né(e) le {{ item.0.datenaiss |date:'d/m/Y' }} à {{ item.0.lieunaiss }}<br/>
                            SEXE: {{ item.0.sexe }}<br/>
                        </td>
                        {% for ue in EuAnDataZipS1 %}
                            <td style="
                            background-color:
                            {% if item.0|check_session2_ue:ue > 0  %}
                                {{item.0|get_etudiant_session_2_moy_ue:ue|stringformat:'.2f'|is_validate}}
                            {% else %}
                                    {{item.0|get_etudiant_moyenne_ue_session_1:ue|stringformat:'.2f'|is_validate}}
                            {% endif %}
                            ">
                                <center>
                                    {% if item.0|check_session2_ue:ue > 0 and item.0|get_etudiant_session_2_moy_ue_plus_bonus:ue > item.0|get_etudiant_moyenne_ue_session_1:ue %}
                                    {{item.0|get_etudiant_session_2_moy_ue_plus_bonus:ue|stringformat:".2f"}}
                                    {% else %}
                                    {{item.0|get_etudiant_moyenne_ue_session_1:ue|stringformat:".2f" }}
                                    {% endif %}
                                   <!-- {% if item.0|check_session2_ue:ue > 0  %}
                                        <br/>
                                        S2: {{item.0|get_etudiant_session_2_moy_ue_plus_bonus:ue|stringformat:".2f"}}
                                    {% endif %} -->
                                </center>
                            </td>
                        {% endfor %}
                        <td style="width:40px;background-color:
                        {% if UFR.code == 'MPSI'  %}
                            {{item.1|is_validate_semestre_mpsi}}
                        {% else %}
                            {{item.3|is_validate_semestre}}
                        {% endif %}
                        ;
                        "><center>{{ item.1|stringformat:".2f" }}</center></td>
                        {% if UFR.code == 'MPSI'  %}
                        {% else %}
                        <td style="width:50px;"><center>{{ item.2 }}</center></td>
                        <td style="width:35px;background-color:{{item.3|is_validate_semestre}}">
                            <center>{{ item.3 }}</center>
                        </td>
                        {% endif %}
                        <td style="background-color:#000000;"></td>
                        {% for ue in EuAnDataZipS2 %}
                            <td style="
                            background-color:
                            {% if item.0|check_session2_ue:ue > 0  %}
                                {{item.0|get_etudiant_session_2_moy_ue:ue|stringformat:'.2f'|is_validate}}
                            {% else %}
                                    {{item.0|get_etudiant_moyenne_ue_session_1:ue|stringformat:'.2f'|is_validate}}
                            {% endif %}
                            ">
                                <center>
                                    {% if item.0|check_session2_ue:ue > 0 and item.0|get_etudiant_session_2_moy_ue_plus_bonus:ue > item.0|get_etudiant_moyenne_ue_session_1:ue %}
                                    {{item.0|get_etudiant_session_2_moy_ue_plus_bonus:ue|stringformat:".2f"}}
                                    {% else %}
                                    {{item.0|get_etudiant_moyenne_ue_session_1:ue|stringformat:".2f" }}
                                    {% endif %}
                                    <!--{% if item.0|check_session2_ue:ue > 0  %}
                                        <br/>
                                        S2: {{item.0|get_etudiant_session_2_moy_ue_plus_bonus:ue|stringformat:".2f"}}
                                    {% endif %} -->
                                </center>
                            </td>
                        {% endfor %}

                        <td style="width:40px;background-color:
                        {% if UFR.code == 'MPSI'  %}
                            {{item.4|is_validate_semestre_mpsi}}
                        {% else %}
                            {{item.3|is_validate_semestre}}
                        {% endif %}
                        ;
                        "><center>{{ item.4|stringformat:".2f" }}</center></td>
                        {% if UFR.code != 'MPSI'  %}
                        <td style="width:50px;"><center>{{ item.5 }}</center></td>
                        <td style="width:35px;background-color:{{item.6|is_validate_semestre}};">
                            <center>{{ item.6 }}</center>
                        </td>
                        {% endif %}

                        <td style="background-color:#000000;"></td>
                        {% if UFR.code != 'MPSI'  %}
                           <!-- <td style="width:50px;"><center>{{item.0|create_list_2_obj:get_annee|get_credit_valide_annuel }}</center></td> -->
                            <td style="width:50px;"><center>{{item.10 }}</center></td>
                        {% endif %}
                        <td style="width:35px;background-color:
                        {% if UFR.code == 'MPSI'  %}
                            {{item.8|is_validate_semestre_mpsi}}
                        {% else %}
                            {{item.7|is_validate_semestre}}
                        {% endif %};
                        "><center>{{ item.8 }}</center></td>
                        {% if UFR.code != 'MPSI'  %}
                        <td style="width:75px;background-color:{{item.7|is_validate_semestre}};">
                            <center>{{ item.7 }}</center>
                        </td>
                        {% endif %}
                        <td style="width:55px;"></td>
                    </tr>
              {% endfor %}
              </tbody>
          </table>
            </center>
      </div>
    </body>
</html>