{% extends "base.html" %}
{% block title %}Expedition {{expedition.name}}{% endblock %}
{% block related %}
{% endblock %}

{% block content %}
<!-- templates/expedition.html - this text visible because this template has been included -->

<h2>{{expedition.name}}</h2>

<p><b>Other years:</b>
{% for otherexpedition in expeditions %}
  {% if otherexpedition == expedition %}
  | <b>{{otherexpedition.year}}</b>
  {% else %}
  | <a href="{{otherexpedition.get_absolute_url}}">{{ otherexpedition.year }}</a>
  {% endif %}
{% endfor %}
</p>
<p>See also the
<ul>
<li> <a href="/years/{{expedition.year}}/">documentation index</a> for this Expo 
<li> <a href="/wallets/year/{{expedition.year}}">wallet completion status</a> for this Expo 
<li> <a href="/years/{{expedition.year}}/{{expedition.logbookfile}}">full logbook</a> for this Expo
{% if logged_in %}
<p>Reparse and reload this year's logbook by clicking here: <a href="/expedition/{{expedition.year}}?reload">RELOAD</a>
{% endif %}

<p><b>At a single glance:</b> The table shows all expo cavers and their recorded trips.  
The columns are the date in the month (July or August), with a 
"<b>T</b>" for a logbook entry, and 
an "<b>S</b>" for a survey trip.  The colours are the same for people on the same trip. </p>
<!-- Colours are set in trog3.css and there can be 3 trips a day of each type-->

<table class="expeditionpersonlist">
<tr>
<th>Caver</th>
{% for expeditionday in expedition.expeditionday_set.all %} 
<th>
  {{expeditionday.date.day}}
</th>
{% endfor %}
</tr>
{% for personexpeditionday in personexpeditiondays %}
  <tr>
  <td><a href="{{ personexpeditionday.personexpedition.get_absolute_url }}">{{personexpeditionday.personexpedition.person|safe}}</a></td>
  {% for persondayactivities in personexpeditionday.personrow %}

  {% if persondayactivities.persontrips or persondayactivities.survexblocks %}
  <td class="persondayactivity">
    {% for persontrip in persondayactivities.persontrips %}
      <a href="{{persontrip.logbook_entry.get_absolute_url}}" class="dayindexlog-{{persontrip.logbook_entry.DayIndex}}">T</a>
    {% endfor %}
   <br/>
    {% for survexblock in persondayactivities.survexblocks %}
      <a href="{% url "svx" survexblock.survexfile.path %}" class="dayindexsurvex-{{survexblock.DayIndex}}">S</a>
    {% endfor %}
  </td>
  {% else %}
  <td class="persondayactivity-nothing">
  </td>
  {% endif %}

  {% endfor %}
  </tr>
{% endfor %}
</table>

<h3 id="trips"> {{expedition.name}} - Records per day</h3>

<table class="expeditionlogbooks">
<tr><th>Date</th><th>Logged trips and diary entries</th><th>Surveys</th><th>Wallets</th></tr>
{% regroup dateditems|dictsort:"date" by date as dates %}
{% for date in dates %}
<tr>
<td>{{date.grouper|date:"D d M Y"}}</td>
<td>{% for item in date.list %}
        {% if item.isLogbookEntry %}<a href="{{ item.get_absolute_url }}">{{item.title|safe}}</a><br/>{% endif %}
    {% endfor %}</td>
<td>{% for item in date.list %}
        {% if item.isSurvexBlock %}<a href="{% url "svx" item.survexfile.path %}">{{item.name}}</a><br/>{% endif %}
    {% endfor %}</td>
<td>{% for item in date.list %}
        {% if item.isSurvexBlock %}
            <a href="{{item.scanswallet.get_absolute_url}}">{{item.scanswallet.walletname}}</a><br/> 
        {% endif %}
    {% endfor %}</td></tr>  
{% endfor %}
</table>
<h3> {{expedition.name}} </h3>
{% endblock %}