{% extends "agenda/base.html" %}
{% load url from future %}
{% load apptags %}

{% block appbar %}
    <h2>Agenda</h2>
    <a href="../..">Retourner à l'accueil</a>
    <button class="newevent" data-hour="" data-url="{% url 'new-event' service=service date=date %}">Nouvel événement</button>
    <button class="newrdv" data-hour="" data-url="{% url 'nouveau-rdv' service=service date=date %}">Nouveau rendez-vous patient</button>
{% endblock %}

{% block beforecontent %}
    <div id="extra-top-links">
     <a href="activite-du-service">Activité du service</a>
     —
     {% if 'validator' in role %}<a href="validation-des-actes">Validation des actes</a>
     —{% endif %}
{% comment %}
     <a href="rendez-vous-periodiques">Rendez-vous périodiques</a>
     —
{% endcomment %}
     <a href="agendas-therapeutes">Tous les agendas des intervenants</a>
    </div>


    <div id="users">
    <div id="filtre">
     <input type="text" class="focus"/>
    </div>
    <p id="filtre-workers">
     <input type="checkbox" id="show-everybody"><label for="show-everybody">Tout le monde</label></input>
    </p>
    <dl>
     {% for workers_type in workers_types %}
     <dt>{{ workers_type.type }}</dt>
     <dd><ul>
       {% for worker in workers_type.workers %}
       {% if worker|is_worker_in_service:service_name and worker|is_intervenant %}
       <li id="selector-worker-{{worker.id}}" class="person-item in_service intervenant" data-worker-id="{{worker.id}}" data-target=".worker-{{worker.id}}.agenda">{{ worker.first_name }} <span class="lastname">{{ worker.last_name }}</span>{% if not worker.services.all %} (Ext){% endif %} <span class="toggle" title="cliquer pour déselectionner">(-)</span></li>
       {% elif worker|is_worker_in_service:service_name %}
       <li id="selector-worker-{{worker.id}}" class="person-item in_service" data-worker-id="{{worker.id}}" data-target=".worker-{{worker.id}}.agenda">{{ worker.first_name }} <span class="lastname">{{ worker.last_name }}</span>{% if not worker.services.all %} (Ext){% endif %} <span class="toggle" title="cliquer pour déselectionner">(-)</span></li>
       {% elif worker|is_intervenant %}
       <li id="selector-worker-{{worker.id}}" class="person-item intervenant" data-worker-id="{{worker.id}}" data-target=".worker-{{worker.id}}.agenda">{{ worker.first_name }} <span class="lastname">{{ worker.last_name }}</span>{% if not worker.services.all %} (Ext){% endif %} <span class="toggle" title="cliquer pour déselectionner">(-)</span></li>
       {% else %}
       <li id="selector-worker-{{worker.id}}" class="person-item" data-worker-id="{{worker.id}}" data-target=".worker-{{worker.id}}.agenda">{{ worker.first_name }} <span class="lastname">{{ worker.last_name }}</span>{% if not worker.services.all %} (Ext){% endif %} <span class="toggle" title="cliquer pour déselectionner">(-)</span></li>
       {% endif %}
       {% endfor %}
     </ul></dd>
     {% endfor %}
   </dl>
   <a href="ressources">Agenda des salles</a>
 </div>
{% endblock %}

{% block agenda-content %}
   <table>
    <tbody>
    <tr>
     <td id="dispos">
      Disponibilités
      <table>
        <tr class="initials"><td></td></tr>
        {% for start_time in disponibility_start_times %}
          <tr class="hour-mark">
              <td rowspan="4">{{ start_time }}:00</td>
          </tr>
          <tr></tr>
          <tr></tr>
          <tr></tr>
        {% endfor %}
      </table>
     </td>

     <td id="agendas">
       <div id="tabs">
       <ul>
        {% for worker in workers %}
        <li style="display: none" class="worker-{{ worker.id }} agenda">
        <a id="link-tab-worker-{{ worker.id }}" href="#tabs-worker-{{ worker.id }}" class="tab" data-id="{{ worker.id }}">{{ worker.first_name }} <span class="lastname">{{ worker.last_name }}</span></a>
        <a href="#" style="padding: 3px;cursor: auto;" class="close-tab" data-target="selector-worker-{{ worker.id }}"><span class="ui-icon ui-icon-circle-close"></span></a>
        </li>
        {% endfor %}
       </ul>
       {% for worker in workers %}
       <div id="tabs-worker-{{ worker.id }}" class="tabs agenda worker-{{ worker.id }}" style="display: none;">
         <div class="worker-tab-content-placeholder">
           <!-- placeholder -->
         </div>
       </div>
       {% endfor %}

       </div>

       </div>
     </td>
    </tr>
    </tbody>
   </table>

{% endblock %}

{% block dialogs %}
  <div id="rdv" style="display: none;">
 </div>
 <div id="ajax-dlg" style="display: none;"></div>
{% endblock %}
