{% load molly_utils %}
{% load i18n %}

{% if entity.metadata.real_time_information %}
<!--googleoff: all-->
<div id="rti-{{ entity.identifier_scheme }}-{{ entity.identifier_value }}">
    {% if entity.metadata.real_time_information.pip_info %}
    <ul class="content-list">
        <li>{% for info in entity.metadata.real_time_information.pip_info %}
    {{ info|sanitize_html }}{% if not forloop.last %}<br/>{% endif %}
        {% endfor %}</li>
    </ul>
    {% else %}
    <ul class="content-list">
        {% if not entity.metadata.real_time_information.services %}
            <li>{% trans "Sorry, there is currently no real time information for this stop." %}</li>
        {% endif %}
    </ul>
    {% endif %}
  {% if entity.metadata.real_time_information.services %}
 <div class="section-content">
  <div class="pad-5">
   <table class="real-time-information">
    <thead class="invisible">
        <tr>
            <th>{% trans "Service" %}</th>
            <th>{% trans "Destination" %}</th>
            <th>{% trans "Expected" %}</th>
        </tr>
    </thead>
    <tbody id="bus_times">
    {% for service in entity.metadata.real_time_information.services %}
        <tr>
            <td rowspan="2" class="service-id" >
                {% if service.route %}<a href="{{ entity.get_absolute_url }}service?route={{ service.service|urlencode }}">{% endif %}
                {% if service.journey %}<a href="{{ entity.get_absolute_url }}service?journey={{ service.journey.pk }}">{% endif %}
                    {{ service.service }}
                {% if service.journey %}</a>{% endif %}
                {% if service.route %}</a>{% endif %}
            </td>
            <td>{{ service.destination }}</td>
            <td>{{ service.next }}</td>
        </tr>
        <tr class="notopborder">
            {# Translators: Next as in next service #}
            <td colspan="2"><small>
                {% trans "Next" %}: {% if service.following %}{{ service.following|join:", " }}{% else %}<em>{% trans "No further info" %}</em>{% endif %}
            </small></td>
        </tr>
    {% endfor %}
    </tbody>
   </table>
  </div>
 </div>
  {% endif %}
</div>
<!--googleon: all-->
{% endif %}
