{% extends "ui/report_base.html" %}
{% load url from future %}
{% load icons %}
{% load formats %}
{% load bob %}

{% block contentarea %}

<form class="form form-inline daterange-form">
<div class="form-actions">
    {% for f in form %}
        <div style="display:inline-block; vertical-align:top" class="control-group {% if f.errors %}error{% endif %}" >
            {{ f }}
            {% if f.errors %}
                <span class="help-block">
                    {% for e in f.errors %}{{ e }}{% endfor %}
                </span>
            {% endif %}
        </div>
    {% endfor %}
    <button type="submit" class="btn">{% spaceless %}
        {% icon 'fugue-calendar-search-result' %}&nbsp;Update
        {% endspaceless %}</button>
    <button class="btn pull-right" name="export" value="csv">{% spaceless %}
        {% icon 'fugue-document-excel-csv' %}&nbsp;Export to CSV
    {% endspaceless %}</button>
</div>
</form>
</div>
<div class="row-fluid">
<div class="span12">
    <table class="table table-striped table-bordered table-condensed">
        <tr>
            <th>Venture</th>
            <th>Department</th>
            <th>Default margin</th>
            <th>Device count</th>
            <th>Core count</th>
            <th>Virtual core count</th>
            <th>Cloud use</th>
            <th>Total cost</th>
            {% if profile.is_staff %}
            <th>Actions</th>
            {% endif %}
        </tr>
        {% for venture in ventures %}
        <tr {% if not venture.parent %}class="table-highlight"{% endif %}>
            <td>
                {% if venture.parent %}&nbsp;&nbsp;&nbsp;&nbsp;{% endif %}
                <a href="/ui/ventures/{{ venture.symbol|slugify }}/venture/" >
                {{ venture|venture_icon }}
                {{ venture.name }}
                </a>
            </td>
            <td>{{ venture.department|default:'' }}</td>
            <td style="text-align:right">
                {{ venture.get_margin }}%
            </td>
            <td class="count">
                {{ venture.count|default:0 }}
            </td>
            <td class="count">
                {{ venture.core_count|default:0 }}
            </td>
            <td class="count">
                {{ venture.virtual_core_count|default:0 }}
            </td>
            <td style="text-align:right">
                {{ venture.cloud_use|default:0 }}%
            </td>
            <td class="currency">
                {{ venture.total|default:0|currency }}
            </td>
            {% if profile.is_staff %}
            <td>{% spaceless %}
            <a href="/admin/business/venture/{{ venture.id }}">
                {% icon 'fugue-toolbox--pencil' %}&nbsp;Edit
            </a>
            {% endspaceless %}</td>
            {% endif %}
        </tr>
        {% endfor %}
    </table>
</div>
{% endblock %}
