{% load combo gnm assets %}
{% with synthese=syntheses.values|dictsort:"date_bulletin"|last is_place_page=page|is_place_page %}
{% with validity_date=synthese.date_fin_validite|parse_datetime|date:"Y-m-d" %}
{% now "Y-m-d" as date_now %}
{% now "Y-m-d H:M" as datetime_now %}
{% if validity_date >= date_now or is_place_page %}
<div class="tile pollen {% if is_place_page %}is-place{% endif %}">
  {% if is_place_page %}
  <div class="tile-picture" style="background-image: url({% asset_url "picture:banner:pollen" %})"></div>
  {% else %}
  <div class="tile-picture" style="background-image: url({% asset_url "picture:pollen" %})"></div>
  {% endif %}
  <div class="tile-head">
    <div class="tile-title">
      <h2><a href="{{cell|place_page_url}}">Pollen</a>
      {% if is_place_page %}<br><span class="subtitle">Autour de moi</span>{% endif %}
      </h2>
      <span class="producer" style="background-image: url({% asset_url "logo:rnsa" %})">RNSA</span>
    </div>
  </div>
{% include "combo/dashboard_cell_icons.html" %}
<div class="tile-content">
<div>
{% if validity_date < date_now %}
<p>Il n’y a pas de bulletin d’information pollen disponible.</p>
{% else %}
    {% if validity_date >= date_now %}
    {% if not is_place_page %}
    <a class="location" href="{{cell|place_page_url}}">Autour de moi</a>
    {% endif %}

  <span class="pollen valeur raep-{{synthese.raep|last}}">{{ synthese.raep|last }}</span>
  <span class="qualif">
   {% if synthese.raep|last == "0" %}Pas de pollen
   {% elif synthese.raep|last == "1" %}Très faible
   {% elif synthese.raep|last == "2" %}Faible
   {% elif synthese.raep|last == "3" %}Moyen
   {% elif synthese.raep|last == "4" %}Élevé
   {% elif synthese.raep|last == "5" %}Très élevé
   {% endif %}
  </span>

    {% if is_place_page %}

<p class="commentaire">{{synthese.commentaire}}</p>

<table>
 <thead><tr><th>Nom du pollen</th><th>Risque allergique d’exposition</th><tr></thead>
 <tbody>
{% for entry in json.values|dictsort:"type"|dictsort:"designation" %}
{% if entry.type != 'Synthese' and entry.date_bulletin < datetime_now and entry.date_fin_validite > date_now %}
<tr><td>{{entry.designation}} (<i>{{entry.nom_latin}}</i>)</td> <td>{{entry.raep}}</td></tr>
{% endif %}
{% endfor %}
</tbody>
</table>

<p class="validity-date">Bulletin valable jusqu’au {{validity_date|strptime:"%Y-%m-%d"|date:"DATE_FORMAT"}}.</p>


    {% endif %} {# is_place_page #}
  {% endif %} {# validity_date >= date_now #}
{% endif %} {# validity_date < date_now #}


</div>
</div>
       {% if not is_place_page %}
      <div class="tile-actions">
        <a class="action-more-info" href="{{pollen_details_path}}">d’infos</a>
      </div>
      {% endif %}

</div>
{% endif %} {# validity_date >= date_now or is_place_page #}
{% endwith %}
{% endwith %}
