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

{% block title %}
  keg {{ keg.seqn }} detail
{% endblock %}

{% block pagetitle %}
  keg {{ keg.seqn }} detail
{% endblock %}

{% block sidebar %}
  <div class="well">
  {% include "kegweb/keg-image.html" %}

  {% with keg.next as next %} {% with keg.previous as previous %}
  {% if next or previous %}
  <div style="font-size: 0.8em; text-align:center; margin-bottom:16px;">
    {% if previous %}
      <a href="{% url kb-keg kbsite.url previous.seqn %}">&laquo; previous keg</a>
    {% endif %}
    {% if next and previous %}
    &mdash;
    {% endif %}
    {% if next %}
      <a href="{% url kb-keg kbsite.url next.seqn %}">next keg &raquo;</a>
    {% endif %}
  </div>
  {% endif %}
  {% endwith %} {% endwith %}
  </div>
{% endblock %}


{% block col-1 %}

<div class="row">
  <div class="span9">
    <h2>{{keg.type.name}}</h2>
    <span class="label">{{keg.type.brewer}}</span>
  </div>
</div>

<div class="row">
  &nbsp;
</div>

{% if keg.description %}
<div class="row">
  <div class="span9">
    <blockquote>
      <p>{{ keg.description}}</p>
    </blockquote>
  </div>
</div>
{% endif %}

<div class="row">
  <div class="span9">
    <table class="condensed-table">
      <tbody>
        <tr>
          <th>Status</th>
          <td>
            {% ifequal keg.status "online" %}
            this keg is <b>online</b>, and is {{ keg.keg_age.days }}
            day{{keg.keg_age.days|pluralize}} old.
            <br/>
            it is
            {% if keg.is_empty %}
              <i>empty</i>.
            {% else %}
              <i>{{ keg.percent_full|floatformat:2 }}% full</i>.
            {% endif %}
            {% else %}
            this keg is <b>offline</b>; it lasted {{ keg.keg_age.days }}
            day{{keg.keg_age.days|pluralize}}.
            {% endifequal %}
          </td>
        </tr>

        {% include "kegweb/basic-stats.html" %}

        <tr>
          <th>Total Poured</th>
          <td>
            {% volume keg.served_volume %}
            {% if not keg.is_empty %}
              ({% volume keg.remaining_volume %} remain)
            {% endif %}<br/>
            {% chart keg_volume keg 340 60 %}
          </td>
        </tr>

        {% with keg.current_tap as tap %}
        {% if tap and tap.temperature_sensor %}
        <tr>
          <th>Temperature</th>
          <td>
            {{ tap.Temperature.TempC|floatformat:1}}&deg;C / 
            {{ tap.Temperature.TempF|floatformat:1}}&deg;F<br/>
            {% chart sensor tap.temperature_sensor 340 60 %}
          </td>
        </tr>
        {% endif %}
        {% endwith %}

        {% if keg.spilled_volume > 0 %}
        <tr>
          <th>Total Spilled/Lost</th>
          <td>{% volume keg.spilled_volume %}</td>
        </tr>
        {% endif %}

      </tbody>
    </table>
  </div>
</div>

{% if sessions %}
<div class="row">
  <div class="span9">
    <h2>All Sessions</h2>
    {% for session in sessions %}
      {% include "kegweb/keg-session.html" %}
    {% endfor %}
  </div>
</div>
{% endif %}

{% endblock col-1 %}

{% block col-2 %}
<div class="row">
  <div class="span5">
    <h2>Top Drinkers</h2>
    {% chart users_by_volume stats 280 220 %}<br/>
    {% with keg.TopDrinkers as ranked_drinkers %}
      {% include "kegweb/drinker-rank.html" %}
    {% endwith %}
  </div>
</div>

{% endblock col-2 %}

