{% extends "agenda/base.html" %}

{% block body-class %}{{ block.super }} no-left-column{% endblock %}

{% block appbar %}
<h2>Activité du {{ service_name }} - {{ date|date:"DATE_FORMAT"|title }}</h2>
<a href="..">Retourner à l'agenda</a>
<button id='print-button'>Imprimer</button>
{% endblock %}

{% block agenda-content %}


<table class="main" id="activity">
  <thead>
      <tr><th class="no-border" colspan=5 style="border: 0;">
          <h2 class="print-only">Activité du {{ service_name }} - {{ date|date:"DATE_FORMAT"|title }}</h2>
      </th></tr>
      <tr> <th>Heure</th> <th>Libellé</th> <th>Absence</th> <th>Type d'acte</th> <th>Intervenants</th> </tr>
  </thead>
  <tbody>
    {% for row_appointments in appointments_times %}
    <tr class="hour-change">
      <td class="hour" rowspan="{{ row_appointments.1.row }}">{{ row_appointments.0 }}</td>
      {% for appointment in row_appointments.1.appointments %}
      {% if forloop.counter != 1 %}
      <tr>
        {% endif %}
        <td {% if appointment.type == 2 %}colspan="2"{% endif %} class="avoid-page-break-before" style="page-break-before: avoid;">{{ appointment.label }}{% if appointment.paper_id %} - {{ appointment.paper_id }} {% endif %}{% if appointment.workers_absent %} <span title="Au moins un intervenant est absent" class="icon-warning-sign absent"></span>{% endif %}</td>
        <td>{% if appointment.absent %}{{ appointment.state }}{% endif %}</td>
        {% if appointment.type != 2 %}<td>{{ appointment.act }}</td>{% endif %}
        <td>
        {% if appointment.len_participants > 10 %}
            {% if appointment.workers_absent %}<span class="absent" title="Absents : {% for participant in appointment.workers_absent %}{{ participant.last_name }} {{ participant.first_name }} {% endfor %}">{% endif %}
            {{ appointment.len_participants }} intervenants
            {% if appointment.workers_absent %}</span>{% endif %}
        {% else %}
        {% for participant in appointment.participants %}
            {% if participant in appointment.workers_absent %}<span class="absent" title="Absent">{% endif %}
            <span class="lastname">{{ participant.last_name }}</span> {{ participant.first_name }}<br/>
            {% if participant in appointment.workers_absent %}</span>{% endif %}
        {% endfor %}
        {% endif %}
        </td>
      </tr>
      {% endfor %}
    </tr>
    {% endfor %}
  </tbody>
</table>
{% endblock %}
