{% load combo %}

<h2>Fonds d'aide</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">
  <tr>
    <th>Nom</th>
    <th>Code</th>
    <th>Montant demande</th>
    <th>Date demande</th>
    <th>Pôle d'insertion</th>
    <th>Service des Aides Individuelles</th>
  </tr>

  {% for fa in data %}
  {% if fa.clos == "Non" %}
  <tr>
    <td><a href="fond-d-aide/{{ fa.id }}">{{ fa.lib_tfi|default:"" }}</a></td>
    <td>{{ fa.code_tfi|default:"" }}</td>
    <td>{% if fa.demande.montant %}{{ fa.demande.montant }} €{% endif %}</td>
    <td>{{ fa.demande.date|date:"d/m/Y"|default:"" }}</td>
    <td>
      <p>Montant : <strong>{% if fa.avis_pi.montant %}{{ fa.avis_pi.montant }} €{% endif %}</strong></p>
      <p>Date : <strong>{{ fa.avis_pi.date|date:"d/m/Y"|default:"" }}</strong></p>
      <p>Avis : <strong>{{ fa.avis_pi.avis|default:"" }}</strong></p>
    </td>
    <td>
      <p>Montant : <strong>{% if fa.decision_sai.montant %}{{ fa.decision_sai.montant }} €{% endif %}</strong></p>
      <p>Date : <strong>{{ fa.decision_sai.date|date:"d/m/Y"|default:"" }}</strong></p>
      <p>Avis : <strong>{{ fa.decision_sai.decision|default:"" }}</strong></p>
    </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">
  <tr>
    <th>Nom</th>
    <th>Code</th>
    <th>Montant demande</th>
    <th>Date demande</th>
    <th>Pôle d'insertion</th>
    <th>Service des Aides Individuelles</th>
  </tr>

  {% for fa in data %}
  {% if fa.clos == "Oui" %}
  <tr>
    <td><a href="fond-d-aide/{{ fa.id }}">{{ fa.lib_tfi|default:"" }}</a></td>
    <td>{{ fa.code_tfi|default:"" }}</td>
    <td>{% if fa.demande.montant %}{{ fa.demande.montant }} €{% endif %}</td>
    <td>{{ fa.demande.date|date:"d/m/Y"|default:"" }}</td>
    <td>
      <p>Montant : <strong>{% if fa.avis_pi.montant %}{{ fa.avis_pi.montant }} €{% endif %}</strong></p>
      <p>Date : <strong>{{ fa.avis_pi.date|date:"d/m/Y"|default:"" }}</strong></p>
      <p>Avis : <strong>{{ fa.avis_pi.avis|default:"" }}</strong></p>
    </td>
    <td>
      <p>Montant : <strong>{% if fa.decision_sai.montant %}{{ fa.decision_sai.montant }} €{% endif %}</strong></p>
      <p>Date : <strong>{{ fa.decision_sai.date|date:"d/m/Y"|default:"" }}</strong></p>
      <p>Avis : <strong>{{ fa.decision_sai.decision|default:"" }}</strong></p>
    </td>
  </tr>
  {% endif %}
  {% endfor %}
</table>
</div>

{% endwith %}

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

</div>
