{% extends "ralph_pricing/base.html" %}
{% load url from future %}
{% load icons %}
{% load formats %}
{% load bob %}

{% block extra_headers %}
{{ block.super }}
{% if got_query and progress < 100 %}
<meta http-equiv="refresh" content="5">
{% endif %}
{% endblock %}

{% block contentarea %}
<div class="row-fluid main-body"><div class="span12">
    <div class="well well-small">
        {% if report_name %}<h4>{{ report_name }}</h4>{% endif %}
        {% block description %}
        {% endblock %}
    </div>
<form class="form form-inline daterange-form">
<div class="form-actions">
    {% for f in form %}
        <div style="display:inline-block; vertica-align:top" class="control-group {% if f.errors %}error{% endif %}" >
            {% if f.label %}
                <label>
                    <span style="vertical-align:middle; display:inline-block;">{{ f.label }}</span>&nbsp;{{ f }}
                </label>
            {% else %}
                {{ f }}
            {% endif %}
            {% if f.errors %}
                <span class="help-block">
                    {% for e in f.errors %}{{ e }}{% endfor %}
                </span>
            {% endif %}
        </div>
    {% endfor %}
    {% block form_buttons %}
    <button type="submit" class="btn btn-primary">{% spaceless %}
        {% icon 'fugue-calendar-search-result' %}&nbsp;Update
        {% endspaceless %}</button>
    <div class="btn-toolbar pull-right">
        <button type="submit" class="btn" name="clear">{% spaceless %}
            {% icon 'fugue-arrow-circle-double' %}&nbsp;Clear cache
            {% endspaceless %}</button>
        <button type="submit" class="btn" name="format" value="csv">{% spaceless %}
            {% icon 'fugue-document-excel-csv' %}&nbsp;Download CSV
            {% endspaceless %}</button>
    </div>
    {% endblock %}
</div>
</form>
</div>
<div class="clearfix"></div>
{% if got_query and progress < 100 %}
{% block progress_bar %}
<div class="well">
    <p>Calculating the report, please wait...</p>
    <div class="progress progress-striped active">
        <div class="bar" style="width: {{ progress }}%;"></div>
    </div>
</div>
{% endblock %}
{% endif %}
{% if progress > 0 %}
{%   if header %}
{%     block table %}
<table class="table table-striped table-bordered table-condensed">
    <tr>
        {% for column in header %}
        <th>{{ column }}</th>
        {% endfor %}
    </tr>
    {% for row in data %}
        <tr>
            {% for value in row %}
            <td
                {% if forloop.counter > 3 %}style="text-align:right"{% endif %}
            >{{ value }}</td>
            {% endfor %}
        </tr>
    {% endfor %}
</table>
{%     endblock %}
{%   else %}
{%     if got_query %}
<div class="alert alert-error">
    <p><strong>Error!</strong> We are extremely sorry, but unfortunately,
    the calculation of this report could not be completed due to an error
    in the code. The people responsible for that will be severely punished.</p>
    <p>Thank you and have a nice day.</p>
</div>
{%     endif %}
{%   endif %}
{% endif %}
</div></div>
{% endblock contentarea %}
