{% 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 sidebar %}

{% block col-1 %}
<div class="row">
  <div class="span8">
    <h2>Summary</h2>
    <table class="table table-condensed">
      {% if stats %}
       <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>
       {% endif %}
       {% endif %}

       <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 %}
       {% if last_drink %}
       <tr>
          <th>Last Drink</th>
          <td>
            {{ last_drink.time|date:"l, F j Y" }}<br>
            <i>({% timeago last_drink.time%})</i>
          </td>
       </tr>
       {% endif %}
       {% endwith %}

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

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

{% endblock col-1 %}

{% block col-2 %}
<div class="row">
    <h2>Drinker Stats</h2>
    {% if not stats.total_pours %}
    Looks like {{ drinker }} has never poured a drink. Boo!
    {% 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>
{% endblock col-2 %}
