{% load combo %}

<h2>Contrats</h2>
<div class="cell--body">

{% if json.data and not json.err %}

{% with json.data as data %}

<h3>En cours</h3>

<div class="pk-table-wrapper">
<table class="pk-data-table pk-table-headers pk-table-borders pk-table-zebra" style="width:100%;">
  <tr>
    <th>N°</th>
    <th>Plateforme</th>
    <th>Opérateur</th>
    <th>Date de début</th>
    <th>Date de fin</th>
    <th>Durée</th>
    <th>Référent</th>
    <th>Décision</th>
    <th>Rétablissement</th>
  </tr>

  {% for contrat in data %}
  {% if contrat.clos == "Non" %}
  <tr>
    <td><a href="contrat/{{ contrat.id }}">{{ contrat.id }}</a></td>
    <td>{{ contrat.plateforme|default:"" }}</td>
    <td>{{ contrat.operateur|default:"" }}</td>
    <td>{{ contrat.date_deb|date:"d/m/Y"|default:"" }}</td>
    <td>{{ contrat.date_fin|date:"d/m/Y"|default:"" }}</td>
    <td>{% if contrat.duree %}{{ contrat.duree }}{% endif %}</td>
    <td>{{ contrat.referent|default:"" }}</td>
    <td>{{ contrat.decision|default:"" }}</td>
    <td>{{ contrat.retab|default:"" }}</td>
  </tr>
  {% endif %}
  {% endfor %}
</table>
</div>

<h3>Clos</h3>

<div class="pk-table-wrapper">
<table class="pk-data-table pk-table-headers pk-table-borders pk-table-zebra" style="width:100%;">
  <tr>
    <th>N°</th>
    <th>Plateforme</th>
    <th>Opérateur</th>
    <th>Date de début</th>
    <th>Date de fin</th>
    <th>Durée</th>
    <th>Référent</th>
    <th>Décision</th>
    <th>Rétablissement</th>
  </tr>

  {% for contrat in data %}
  {% if contrat.clos == "Oui" %}
  <tr>
    <td><a href="contrat/{{ contrat.id }}">{{ contrat.id }}</a></td>
    <td>{{ contrat.plateforme|default:"" }}</td>
    <td>{{ contrat.operateur|default:"" }}</td>
    <td>{{ contrat.date_deb|date:"d/m/Y"|default:"" }}</td>
    <td>{{ contrat.date_fin|date:"d/m/Y"|default:"" }}</td>
    <td>{% if contrat.duree %}{{ contrat.duree }}{% endif %}</td>
    <td>{{ contrat.referent|default:"" }}</td>
    <td>{{ contrat.decision|default:"" }}</td>
    <td>{{ contrat.retab|default:"" }}</td>
  </tr>
  {% endif %}
  {% endfor %}
</table>
</div>

{% endwith %}

{% else %}
<p>Aucune information.</p>
{% endif %}

</div>
