{% extends "base.html" %}
{% load static my_tags %}

{% block content %}
    <ul class="nav nav-tabs nav-prestations">
        <li class="nav-item">
            <a class="nav-link" href="{% url 'prestation-menu' %}">Prestations par famille</a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="{% url 'prestation-generale' %}">Prestations générales</a>
        </li>
       <li class="nav-item">
            <a class="nav-link active" href="{% url 'prestation-personnelle' %}">Mes prestations</a>
        </li>
    </ul>
   <div class="row mt-3">
      <div class="col">
         <p class="lead">
            {% if prev_month %}
               <a class="btn btn-sm" href="?date={{ prev_month|date:'mY' }}"><button>&lt;</button></a>
            {% endif %}
            {{ current_date.month|month_name }} {{ current_date.year }}
            {% if next_month %}
               <a class="btn btn-sm" href="?date={{ next_month|date:'mY' }}"><button>&gt;</button></a>
            {% endif %}
         </p>
      </div>
   </div>
   <div class="row mt-2">
      <div class="col">
         <table class="table table-sm">
            <thead class="table-light">
               <tr>
                  <th width="7%">Date</th>
                  <th width="5%">Durée</th>
                  <th width="10">Famille</th>
                  <th width="10%">Intervenant-e-s</th>
                  <th>Contenu</th>
                  <th width="5%">Auteur</th>
                  <th width="10%">Prestation</th>
                  <th width="5%" align="center">Actions</th>
               </tr>
            </thead>
            <tbody>
               {% for prest in object_list %}
                  <tr>
                     <td>{{ prest.date_prestation|date:"d.m.Y" }}</td>
                     <td>{{ prest.duree|strip_seconds }}</td>
                     <td>{{ prest.famille.nom }}</td>
                     <td>{{ prest|sigles_intervenants }}</td>
                     <td>{{ prest.texte|truncate_html_with_more:20 }}</td>
                     <td>{{ prest.auteur|sigle_personne }}</td>
                     <td>{{ prest.lib_prestation.nom }}</td>
                     <td align="center">
                     {% if prest|can_edit:user %}
                        <a href="{{ prest.edit_url }}">
                           <img src="{% static 'admin/img/icon-changelink.svg' %}">
                        </a>
                     {% endif %}
                     </td>
                  </tr>
               {% empty %}
                  <tr><td colspan="5" align="center">Aucune prestation saisie</td></tr>
               {% endfor %}
            </tbody>
         </table>
      </div>
   </div>
   <div class="row">
      <div class="col-3">
         <div class="card border border-success mb-2">
            <div class="card-header bg-success-3">
               RÉCAPITULATIF pour {{ current_date.month|month_name }} {{ current_date.year }}
            </div>
            <div class="card-body">
               <table class="table table-sm table-borderless">
                  {% for code, total in totaux %}
                     <tr>
                        <th>Total prestations {{ code }}</th>
                        <td align="right">{{ total|strip_seconds|default:'00:00' }}</td>
                     </tr>
                  {% endfor %}
                  <tr class="border-top">
                     <th>Total</th>
                     <th class="text-end">{{ total_final|strip_seconds|default:'00:00' }}</th>
                   </tr>
               </table>
            </div>
         </div>
      </div>
   </div>
{% endblock %}
