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

{% block appbar %}
    <h2>Agenda</h2>
    <a href="../..">Retourner à l'accueil</a>
    <div class="new">
      <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>
    </div>
{% 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 %}
     <a href="rendez-vous-periodiques">Rendez-vous périodiques</a>
     |
     <a href="agendas-therapeutes">Tous les agendas des intervenants</a>
    </div>

    <div id="users">
    <div id="filtre" class="search">
     <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="worker-{{worker.id}}" class="item in_service intervenant worker" 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="icon-toggle"></span></li>
       {% elif worker|is_worker_in_service:service_name %}
       <li id="worker-{{worker.id}}" class="item in_service worker" 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="icon-toggle"></span></li>
       {% elif worker|is_intervenant %}
       <li id="worker-{{worker.id}}" class="item intervenant worker" 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="icon-toggle"></span></li>
       {% else %}
       <li id="worker-{{worker.id}}" class="item worker" 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="icon-toggle"></span></li>
       {% endif %}
       {% endfor %}
     </ul></dd>
     {% endfor %}
     {% for ressources_type in ressources_types %}
     <dt>{{ ressources_type.type }}</dt>
     <dd><ul>
       {% for ressource in ressources_type.ressources %}
       <li id="ressource-{{ressource.id}}" class="item ressource" data-target=".ressource-{{ressource.id}}.agenda" data-type="ressource">{{ ressource.name }} <span class="icon-toggle"></span></li>
       {% endfor %}
     </ul></dd>
     {% endfor %}
   </dl>

 </div>
{% endblock %}

{% block agenda-content %}
   <table>
    <tbody>
    <tr>
     <td id="dispos">
       <ul id="availability">
         <li id='time'>
           <ul>
             <li class="initials">&nbsp;</li>
             {% for start_time in disponibility_start_times %}
             <li class="hour-mark {% if start_time == 12 %}noon-start{% elif start_time == 13%}noon-end{% endif %}">
               {{ start_time|stringformat:"02d" }}
             </li>
             {% endfor %}
           </ul>
         </li>
       </ul>
     </td>

     <td id="agendas">
       <div id="tabs" class="agenda">
         <div id="close-all-agendas" style="display: none" title="Fermer tous les agendas"></div>
         <ul>
           {% for worker in workers %}
           <li style="display: none" class="worker-{{ worker.id }} agenda">
             <a id="worker-{{ worker.id }}" href="{% url "ajax-worker-tab" service date worker.id %}" class="tab">
               {{ worker.first_name }}
               <p class="lastname">{{ worker.last_name }}</p>
             </a>
             <a href="#" style="padding: 3px;cursor: auto;" class="close-tab" data-target="worker-{{ worker.id }}"><span class="ui-icon ui-icon-circle-close"></span></a>
           </li>
           {% endfor %}

           {% for ressource in ressources_types.0.ressources %}
           <li style="display: none" class="ressource-{{ ressource.id }} agenda">
             <a id="ressource-{{ ressource.id }}" href="{% url "ajax-ressource-tab" service date ressource.id %}" class="tab">
               {{ ressource }}
             </a>
             <a href="#" style="padding: 3px;cursor: auto;" class="close-tab" data-target="ressource-{{ ressource.id }}"><span class="ui-icon ui-icon-circle-close"></span></a>
           </li>
           {% endfor %}
         </ul>
       </div>
</td>
</tr>
</tbody>
</table>

{% endblock %}

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