{% load combo gnm l10n assets %}
{% with event=json.features.0 is_place_page=page|is_place_page place_page=cell|place_page %}
  {% get_tile_picture_size page as size %}
  <div class="tile evenement-routier {% if is_place_page %}is-place{% endif %}" data-place-type="evenement-routier" data-tile-cache="300">
  {% if is_place_page %}
  {% placeholder "infos-pratiques" name="Infos pratiques" render=False %}
  <div class="tile-picture" style="background-image: url({% asset_url place_page.picture "picture:banner:evenement-routier" size=size crop="center" %})"></div>
  {% else %}
  <div class="tile-picture" style="background-image: url({% asset_url place_page.picture "picture:evenement-routier" size=size crop="center" %})"></div>
  {% endif %}
      <div class="tile-head">
        <div class="tile-title">
          <h2>{{event.properties.townname}}</h2>
          <span class="producer" style="background-image: url({% asset_url "logo:grandlyon" %})">Grand Lyon</span>
        </div>
      </div>
      {% include "combo/dashboard_cell_icons.html" %}

      {% if is_place_page %}

        <div class="tile-content">

        <div class="place-info">

            {% if event.properties.probability != '' %}Probabilité : {{event.properties.probability}}{% endif %}
            {% if event.properties.starttime != '' %}<br />Du : {{event.properties.starttime}} {% endif %}
            {% if event.properties.endtime != '' %}au : {{event.properties.endtime}}{% endif %}
            {% if event.properties.publiccomment != '' %}<br />Détail : {{event.properties.publiccomment}}{% endif %}

            <br />Confidentialité : {{event.properties.confidentiality}}
            <br />Info status : {{event.properties.informationstatus}}
            <br />Type : {{event.properties.type}}
            <br />Status : {{event.properties.status}}
            <br />Nb voie restraintes : {{event.properties.numberoflanesrestricted}}
            <br />Direction : {{event.properties.direction}}
            <br />disturbance activity type : {{event.properties.disturbanceacivitytype}}
            <br />effect on road layout : {{event.properties.effectonroadlayout}}
            <br />network management type : {{event.properties.networkmanagementtype}}
            <br />public event type : {{event.properties.publiceventtype}}
            <br />road maintennace type : {{event.properties.roadmaintenancetype}}
            <br />mobility : {{event.properties.mobility}}
            <br />Abnomal traffic type : {{event.properties.abnormaltraffictype}}
            <br />Future : {{event.properties.future}}

            {% include "combo/json/includes/share.html" with place=event url=cell|place_page_url %}
            {% placeholder "infos-pratiques" %}
         </div>

        <div class="place-data">

        <div class="adresse">
            {% localize off %}
            <a class="action-goto" data-lat="{{event.geometry.coordinates.1}}" data-lng="{{event.geometry.coordinates.0}}" href="/m-y-rendre/?to={{cell.id}}">M’y rendre</a>
            {% endlocalize %}
        </div> <!-- adresse -->

        </div> <!-- place-data -->

        {% gnm_place_map event.geometry.coordinates.1 event.geometry.coordinates.0 %}

        </div> <!-- tile-content -->

     {% else %}
        <div class="tile-content">
          <p>
            {# formatage de la date car celle recue de data.grandlyon.com est difficilement lisible #}
            {% for comparedate in event.properties.starttime|slice:":-3"|split %}
              {% if forloop.first %}

                {% if comparedate not in event.properties.endtime %}
                  {# si starttime et endtime ne sont pas le meme jour on affiche du xxx au xxx #}
                  <b>Du
                  {% for dateitem in event.properties.starttime|slice:":-3"|split %}
                    {# date #}
                    {% if forloop.first %}
                      {% for dateelt in dateitem|split:"-" reversed %}{{dateelt}}{% if not forloop.last %}/{% endif %}{% endfor %}
                    {% endif %}
                    {# heure #}
                    {% if forloop.last %}
                       {% for line in dateitem|split:":" %}
                        {% if forloop.first and line != "00"  %}{{line}}{% endif %}{% if forloop.first%}h{% endif %}
                      {% endfor %}
                    {% endif %}
                  {% endfor %}
                  </b>
                  <b>au
                  {% for dateitem in event.properties.endtime|slice:":-3"|split %}
                    {# date #}
                    {% if forloop.first %}
                      {% for dateelt in dateitem|split:"-" reversed %}{{dateelt}}{% if not forloop.last %}/{% endif %}{% endfor %}
                    {% endif %}
                    {# heure #}
                    {% if forloop.last %}
                       {% for line in dateitem|split:":" %}
                        {% if forloop.first and line != "00"  %}{{line}}{% endif %}{% if forloop.first%}h{% endif %}
                      {% endfor %}
                    {% endif %}
                  {% endfor %}
                  </b>

                {% else %}
                  {# sinon on affiche le xxx de xxh à xxh #}
                  <b>Le
                  {% for dateitem in event.properties.starttime|slice:":-3"|split %}
                    {# date #}
                    {% if forloop.first %}
                      {% for dateelt in dateitem|split:"-" reversed %}{{dateelt}}{% if not forloop.last %}/{% endif %}{% endfor %}
                    {% endif %}
                    {# heure #}
                    {% if forloop.last %}
                      de
                      {% for line in dateitem|split:":" %}
                        {% if forloop.first and line != "00"  %}{{line}}{% endif %}{% if forloop.first%}h{% endif %} 
                      {% endfor %}
                      à
                      {% for dateitem in event.properties.endtime|slice:":-3"|split %}
                        {% if forloop.last %}
                           {% for line in dateitem|split:":" %}
                            {% if forloop.first and line != "00"  %}{{line}}{% endif %}{% if forloop.first%}h{% endif %}
                          {% endfor %}
                        {% endif %}
                      {% endfor %}  
                    {% endif %}
                  {% endfor %}
                  </b>
                {% endif %}
              {% endif %}
            {% endfor %}
          </p>

          {# Affichage du commentaire public #}
          {% if event.properties.publiccomment != '' %}
          <p>
          {% for line in event.properties.publiccomment|split:"|" %}
            {{line}}.<br />
          {% endfor %}
          </p>
          {% endif %}
        </div>
        <div class="tile-actions">
        </div>
      {% endif %}
    </div>
{% endwith %}
