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

{% block appbar %}
<h2>Dossiers</h2>
<a href=".">Retourner aux dossiers</a>
<button id='print-button' class='icon-print'>Imprimer</button>
{% endblock %}

{% block content %}
<div id="sidebar">
  <div>
    <form>
      <h3>Rechercher les dossiers</h3>
      <div>
        <label>
          <input name="without_quotations" type="checkbox"
                 {% if request.GET.without_quotations == 'on' %}checked="checked"{% endif %}/> Sans quotation MISES</label>
      </div>
      <div>
        <label>
          <input name="without_anap_quotations" type="checkbox"
                 {% if request.GET.without_anap_quotations == 'on' %}checked="checked"{% endif %}/> Sans quotation ANAP</label>
      </div>
      <h5>Avec au moins un acte (optionnel)</h5>
      Après le (jj/mm/aaaa)
      <label><input name="date_actes_start" type="text" value="{{ request.GET.date_actes_start }}"></label>
      Avant le (jj/mm/aaaa)
      <label><input name="date_actes_end" type="text" value="{{ request.GET.date_actes_end }}"></label>
      <p><br/></p>
      {% if request.GET %}
      <div class="search-reset">
        <button id="search">Rechercher</button>
        <button id="reset" class="icon-remove-sign" title="Réinitialiser"></button>
      </div>
      {% else %}
      <button id="search">Rechercher</button>
      {% endif %}
      <p id="search-results" style="display: none; "></p>
  </div>
  <div id="filtre">
    <h4>Filtres sur l'état</h4>
    {{ search_form.states }}
    <button id="btn_all_state">Tous</button>
    <button id="btn_none_state">Aucun</button>
  </form>
  </div>
</div>
<div class="content">
  <table id="dossiers" class="main screen-only">
    <thead>
      <tr>
        <th colspan="2">N° dossier
        </th><th rowspan="2">Nom</th>
        <th rowspan="2">Prénom</th>
        <th rowspan="2">Date de naissance</th>
        <th rowspan="2">État du dossier</th>
        <th rowspan="2">Date du prochain rendez-vou</th>
        <th rowspan="2">Date du dernier rendez-vous</th>
        <th rowspan="2">Mises</th>
        <th rowspan="2">ANAP</th>
      </tr>
      <tr>
        <th>papier</th>
        <th>inform.</th>
      </tr>
    </thead>
    <tbody>

      {% for patient_record in patient_records %}
      <tr style="display: table-row;" class="pr-line {{ patient_record.state_class }}" data-link="{{ patient_record.object.id }}/view">
        <td>{{ patient_record.object.paper_id|default_if_none:"" }}</td>
        <td>{{ patient_record.object.id }}</td>
        <td><span class="lastname">{{ patient_record.object.last_name }}</span></td>
        <td>{{ patient_record.object.first_name }}</td>
        <td>{{ patient_record.object.birthdate|date:"d-m-Y" }}</td>
        <td class="{{ patient_record.state_class }}">{{ patient_record.state }}</td>
        <td>{% if patient_record.next_rdv_date %}
          {{ patient_record.next_rdv_date|date:"d-m-Y, H:i" }}
          {% endif %}
        </td>
        <td>{% if patient_record.last_rdv_date %}
          {{ patient_record.last_rdv_date|date:"d-m-Y, H:i" }}
          {% endif %}</td>
        <td>{% if patient_record.mises %}<span class="icon-ok"></span>{% endif %}</td>
        <td>{% if patient_record.anap %}<span class="icon-ok"></span>{% endif %}</td>
      </tr>
      {% endfor %}

    </tbody>
  </table>

  {% if request.GET %}
  <div class="pagination screen-only">
    <span class="step-links">
      {% if paginate_patient_records.has_previous %}
      <a href="?{{ query }}&page={{ paginate_patient_records.previous_page_number }}">««</a>
      {% endif %}

      <span class="current">
        page {{ paginate_patient_records.number }} de {{ paginate_patient_records.paginator.num_pages }}
      </span>

      {% if paginate_patient_records.has_next %}
      <a href="?{{ query }}&page={{ paginate_patient_records.next_page_number }}">»»</a>
      {% endif %}
    </span>
  </div>
  {% endif %}



  {% if not request.GET %}
  <div class="big-msg-info">
    Utilisez le formulaire de recherche sur la gauche de l'écran pour afficher
    les dossiers correspondants.
  </div>
  {% elif not patient_records %}
  <div>Pas de résultat pour votre recherche</div>
  {% endif %}

</div>
{% endblock %}
