{% extends 'timepiece/time-sheet/base.html' %}
{% load timepiece_tags %}

{% block title %}Project Invoice Summary{% endblock %}

{% block content %}
<h2>Project Invoice Summary</h2>

{% date_filters "months_no_range" %}

<form method="get" action="" id="date-filter" accept-charset="utf-8">
    <ul id='ledger-date-fieldlist'>
        {{ form.as_ul }}
        <li>
            <input type='submit' name='submit' value='Update' id='id_date_form_submit_btn'/>
        </li>
        <li>
            <input type='button' name='clear' value='Clear' id='id_date_form_clear_btn'/>
        </li>
    </ul>
</form>

<div style='float: right;'>
{% for cal in cals %}
{{ cal|safe }}
{% endfor %}
</div>

{% if unverified %}
    <p><strong>Warning:</strong> The following users have <strong>unverified</strong> time during this period:</p>
    <ul>
        {% for pk, first, last in unverified %}
            <li><a href="{% url view_person_time_sheet pk %}">{{ first }} {{ last }}</a></li>
        {% endfor %}
    </ul>
{% endif %}

{% if unapproved %}
    <p><strong>Warning:</strong> The following users have <strong>unapproved</strong> time during this period:</p>
    <ul>
        {% for pk, first, last in unapproved %}
            <li><a href="{% url view_person_time_sheet pk %}">{{ first }} {{ last }}</a></li>
        {% endfor %}
    </ul>
{% endif %}

{% regroup project_totals by project__type__label as type_list %}
{% for type in type_list %}
    <h3>Summary of {{ type.grouper }} Entries</h3>
    <table>
        <tr>
            <th>Project name</th>
            <th>Status</th>
            <th>Uninvoiced Hours</th>
            <th></th>
        </tr>
        {% regroup type.list by project__name as project_list %}
        {% for project in project_list %}  
            <tr>
                <th>{{ project.grouper }}</th>
                <td>{{ project.list.0.project__status__label|title }}</td>
                {% build_invoice_row project.list to_date from_date %}
            </tr>
        {% endfor %}
    </table>
{% endfor %}
{% endblock %}

