{% extends "kegadmin/base.html" %}
{% load kegweblib %}
{% load crispy_forms_tags %}

{% block title %}Kegbot Admin: Edit Keg | {{ block.super }}{% endblock %}
{% block pagetitle %}Kegbot Admin: Edit Keg {% endblock %}

{% block kegadmin-main %}

<h2>Keg #{{keg.id}}: {{keg.type.name}}
{% include 'kegadmin/includes/keg-status-label.html' %}
</h2>

<div class="well">
<div class="row-fluid">

<div class="span4">

  <img src="{{ keg.get_illustration }}">
  <center>
    <b>{{ keg.percent_full|floatformat:0 }}% full</b>
  </center>

</div>

<div class="span8">

  <table class="table">
  <tbody>
      {% if keg.is_on_tap or keg.is_finished %}
          <tr>
              <th>Started</th>
              <td>{{keg.start_time}}</td>
          </tr>
      {% endif %}
      {% if not keg.is_on_tap and keg.is_finished %}
          <tr>
              <th>End Time</th>
              <td>{{keg.end_time}}</td>
          </tr>
      {% endif %}
      <tr>
          <th>Size</th>
          <td>{{ keg.keg_type_description }}</td>
      </tr>
      <tr>
          <th>Initial Volume</th>
          <td>{% volume keg.full_volume_ml %}</td>
      </tr>
      <tr>
          <th>Served Volume</th>
          <td>{% volume keg.served_volume_ml %}</td>
      </tr>
      <tr>
          <th>Remaining Volume</th>
          <td>{% volume remaining %}</td>
      </tr>
      </tbody>
  </table>    

</div>

</div> <!-- /row-fluid -->
</div>


<form action="" method="post">{% csrf_token %}
  <div class="well">

{% if keg.is_finished %}

    <div class="row-fluid">

      <div class="span4">
          <button type="submit" class="btn btn-info btn-large btn-block" name="submit_reactivate">
            <i class="icon-refresh icon-white"></i> Reactivate</button>
          </button>
      </div>

      <div class="span8">
        This keg is marked as finished and cannot be tapped. Click <em>Reactivate</em> to
        return the keg to active status.
      </div>

    </div> <!-- /row-fluid -->

{% else %}

    <div class="row-fluid">

      <div class="span4">
          <button type="submit" class="btn btn-danger btn-large btn-block" name="submit_end">
            <i class="icon-stop icon-white"></i> End Keg</button>
          </button>
      </div>

      <div class="span8">
        Press <em>End Keg</em> to mark the keg as finished.
      </div>

    </div> <!-- /row-fluid -->


{% endif %}

  </div>
</form>


<h3>Edit Keg</h3>
{% crispy edit_form %}


<div id="cancelModal" class="modal hide fade" tabindex="-1"
    role="dialog" aria-labelledby="cancelDialogLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="cancelDialogLabel">Really Delete Keg {{ keg.id }}?</h3>
    </div>
    <div class="modal-body">
        <p>
            Are you sure you want to delete <b>Keg {{ keg.id }}</b>?
        </p>
        <p>
            Deleting the keg will <b>immediately and permanently delete all pour data associated with
            this keg</b>, including any recorded pictures and statistics.  This action cannot be undone.
        </p>
    </div>
    <div class="modal-footer">
         <form action="{% url "kegadmin-edit-keg" keg.id %}" method="POST">{% csrf_token %}
         <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
             <input type="submit" name="submit_delete_keg"
                class="btn btn-danger" value="Delete Keg"/>
         </form>
    </div>
</div>


{% endblock %}
