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

{% block content %}

{% if deprecated %}
    <div class="alert alert-block">
        Device is deprecated, so the cost is equal to 0
    </div>
{% endif %}


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

<table class="table table-striped table-bordered details-costs">
    <tbody><tr>
        <td width="16">{% icon 'fugue-store' %}</td>
        <th>Venture</th>
        <td>{{ device.venture.name }}</td>
    </tr><tr>
        <td>{% icon 'fugue-mask' %}</td>
        <th>Role</th>
        <td>{{ device.venture_role.name }}</td>
    </tr><tr>
        <td width="16">{% icon 'fugue-receipt-text' %}</td>
        <th>Monthly Cost</th>
        <td class="currency">{{ device.cached_cost|currency }}</td>
    </tr></tbody>
</table>
<table class="table table-striped table-bordered details-costs-owners">
    <thead><tr>
        <th width="16"></th>
        <th>Owner</th>
    </tr></thead>
    <tbody>
         {% for o in device.venture.all_ownerships %}
             <tr>
                 <td>{{ o|owner_icon }}</td>
                 <td>{{ o.owner }}</td>
             </tr>
        {% endfor %}
    </tbody>
</table>
</div>
<div class="span6">
<table class="table table-striped table-bordered details-costs-hostory">
    <thead><tr>
        <th>Start</th>
        <th>End</th>
        <th>Days</th>
        <th>Venture</th>
        <th>Cores</th>
        <th>Daily Cost</th>
    </tr></thead>
    <tbody>
        {% for h in history_page.object_list %}
        <tr>
            <td>
                {% if h.start > ALWAYS_DATE %}
                    {{ h.start|date:'Y-m-d' }}
                {% endif %}
            </td>
            <td>
                {% if h.end < FOREVER_DATE %}
                    {{ h.end|date:'Y-m-d' }}
                {% endif %}
            </td>
            <td>{{ h.span }}</td>
            <td>{{ h.venture.name }}</td>
            <td class="count">{{ h.cores }}</td>
            <td class="currency">{{ h.daily_cost|currency:2 }}</td>
        </tr>
        {% endfor %}
    </tbody>
</table>
{% pagination history_page fugue_icons=1 url_query=url_query query_variable_name=query_variable_name %}

{% if splunk_size %}
<table class="table table-striped table-bordered details-costs-hostory">
    <thead><tr>
        <th>Splunk Usage (MiBs)</th>
        <th>Monthly Cost</th>
        <th>Daily Cost</th>
    </tr></thead>
    <tbody>
        <tr>
            <td>{{ splunk_size }}</td>
            <td>{{ splunk_monthly_cost|currency:2 }}</td>
            <td>{{ splunk_daily_cost|currency:2 }}</td>
            <td class="currency">{{ h.daily_cost|currency:2 }}</td>
        </tr>
    </tbody>
</table>
{% endif %}
</div>
{% endblock content %}
