{% extends "page-twocol.html" %}
{% load kegweblib %}

{% block title %}Drinker Details: {{ drinker.username }}{% endblock %}
{% block pagetitle %}Drinker Details: {{ drinker.username }}{% endblock %}

{% block sidebar %}
  <div class="well">
    {% mugshot_box drinker %}
  </div>
{% endblock %}

{% block col-1 %}
<div class="row">
  <div class="span9">
    <h2>Summary</h2>
    <table class="condensed-table">
       <tr>
          <th>Total Volume</th>
          <td> {% volume stats.total_volume_ml %}</td>
       </tr>

       <tr>
          <th>Total Pours</th>
          <td>{{ stats.total_pours }}</td>
       </tr>

       <tr>
         <th>Total Sessions</td>
         <td>{{ stats.sessions_count }}</td>
       </tr>

       {% if stats.total_pours %}
       <tr>
          <th>Average Pour</th>
          <td>{% volume stats.average_volume_ml %}</td>
       </tr>

       <tr>
          <th>Largest Pour</th>
          <td>{% volume stats.greatest_volume_ml %}</td>
       </tr>

       <tr>
          <th>Member Since</th>
          <td>
            {{ drinker.date_joined|date:"l, F j Y" }}<br>
            <i>({% timeago drinker.date_joined %})</i>
          </td>
       </tr>

       {% with drinker.drinks.latest as last_drink %}
       <tr>
          <th>Last Drink</th>
          <td>
            {{ last_drink.starttime|date:"l, F j Y" }}<br>
            <i>({% timeago last_drink.starttime%})</i>
          </td>
       </tr>
       {% endwith %}
       {% endif %}

    </table>
  </div> <!-- span9 -->
</div> <!-- row -->

{% if chunks %}
<div class="row">
  <div class="span9">
  <h2>Recent Sessions</h2>
    {% for chunk in chunks %}
      {% with chunk.session as session %}
        {% include "kegweb/keg-session.html" %}
      {% endwith %}
    {% endfor %}
  </div>
</div>
{% endif %}

{% endblock %}

{% block col-2 %}
<div class="row">
  <div class="span5">
    <h2>Drinker Stats</h2>
    {% if not stats.total_pours %}
    No sessions recorded for {{ drinker }}, nothing to display!
    {% else %}
    <div class="kb-contentbox">
      <p>
        <b>total pints, by day of week</b><br>
        {% chart sessions_weekday drinker 350 100 %}
      </p>

      <p>
        <b>all sessions, by pints per session</b><br>
        {% chart sessions_volume chunks 350 100 %}
      </p>
      {% endif %}
    </div>
  </div> <!-- span5 -->
</div>
{% endblock %}
