{% extends 'timepiece/base.html' %}
{% load timepiece_tags %}
{% load bootstrap_toolkit %}

{% block title %}General Ledger{% endblock %}

{% block crumbs %}
    {{ block.super }}
    <li><span class="divider">/</span> <a href="{% url timepiece-summary %}">General Ledger</a></li>
{% endblock crumbs %}

{% block content %}
    <div class="row">
        <div class="span12">
            <h2>Reports</h2>
            <ul class="nav nav-pills">
                <li>
                    {% if perms.timepiece.view_entry_summary %}
                        <a href="{% url hourly_report %}">Hourly</a>
                    {% endif %}
                </li>
                <li class="active">
                    <a href="#">General Ledger</a>
                </li>
                <li>
                    {% if perms.timepiece.view_payroll_summary %}
                        <a href="{% url payroll_summary %}">Payroll Report</a>
                    {% endif %}
                </li>
            </ul>
        </div>
    </div>

    <div class="row">
        <div class="span12">
            <form class="form-inline" method="get" action="" id="date-filter" accept-charset="utf-8">
                {{ form|as_bootstrap:"inline" }}
                <input class="btn" type="submit" name="submit" value="Update" id="id_date_form_submit_btn"/>
                <input class="btn" type="button" name="clear" value="Clear" id="id_date_form_clear_btn"/>
            </form>
        </div>
    </div>

    <div class="row">
        <div class="span6">
            <h3>Hours by Project</h3>
            <table class="table table-bordered table-striped table-condensed">
                <tbody>
                    {% for entry in project_totals %}
                        <tr>
                            <td><a href="{% url view_project entry.project__id %}">{{ entry.project__name }}</a></td>
                            <td class="hours">{{ entry.total_hours|floatformat:2 }}</td>
                        </tr>
                    {% endfor %}
                    <tr>
                        <th colspan="2">&nbsp;</th>
                    </tr>
                    <tr>
                        <th>Total:</th>
                        <td class="hours">{{ total_hours|floatformat:2 }}</td>
                    </tr>
                </tbody>
            </table>
        </div>

        <div class="span5 offset1">
            <h3>Hours by People</h3>
            <table class="table table-striped table-bordered table-condensed">
                <tbody>
                    {% for entry in people_totals %}
                        <tr>
                            <td>{{ entry.user__first_name}} {{ entry.user__last_name }}</td>
                            <td class="hours">{{ entry.total_hours|floatformat:2 }}</td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
{% endblock %}
