{% extends "main.html" %}
{% load karaage_tags %}
{% load humanize %}
{% load filters %}


{% block title %}Project Usage{% endblock %}


{% block breadcrumbs %}
<div class="breadcrumbs">
    <a href='{% url "index" %}'>Home</a>&nbsp;›
    <a href="{% url 'kg_usage' %}">Usage</a>&nbsp;›
    <a href="{% url 'kg_usage_institute' project.institute.pk %}">{{ project.institute }}</a>&nbsp;›
    {{ project }}
</div>
{% endblock %}


{% block content %}
<div id="content-main">
    <h2>Usage {{ start|date }} - {{ end|date }}</h2>
    <h3><a href="{{ project.get_absolute_url }}">{{ project }}</a></h3>

    <p>{% date_filter start end %}</p>

    <p>Leader{{ project.leaders.all|pluralize }}:
    {% for leader in project.leaders.all %}<a href="{{ leader.get_absolute_url }}">{{ leader }}</a> {% endfor %}</p>

    <p><a href="{{ graph.data_url }}">data</a></p>

    <div class="module">
        <h2>Users</h2>
        <div class="table-container">
            <table>
                <thead>
                    <tr>
                        <th>User</th>
                        <th>CPU Time</th>
                        <th>No. Jobs</th>
                        <th>% of project</th>
                        <th>Colour</th>
                    </tr>
                </thead>
                {% if usage_list %}
                <tbody>
                    {% for u in usage_list %}
                    <tr>
                    <td><a href="{{ u.person.get_absolute_url }}">{{ u.person }}</a></td>
                    <td class="right">{{ u.usage|timeformat }}</td>
                    <td class="right">{{ u.jobs|intcomma }}</td>
                    <td class="right">{{ u.percent|floatformat:"2" }}%</td>
                    <td class="graph_key_{{ u.colour }}">{{ u.colour }}</td>
                    </tr>
                    {% endfor %}
                </tbody>
                <tfoot>
                    <tr>
                        <td>Total</td>
                        <td class="right">{{ total|timeformat }}</td>
                        <td class="right">{{ total_jobs|intcomma }}</td>
                    </tr>
                </tfoot>
                {% else %}
                <tbody>
                    <tr>
                        <td colspan="4">No usage for that time period</td>
                    </tr>
                </tbody>
                {% endif %}
            </table>
        </div>
    </div>
    <img src="{{ graph.graph_url }}"/>
</div>
{% endblock %}
