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

{% block title %}Person Timesheets{% endblock %}

{% block content %}

<h2>Person Timesheets ({{ time_sheets.count }} total)</h2>
<ul class='header-actions-left'>
{% if perms.timepiece.create_personrepeatperiod %}
    <li><a href='{% url create_person_time_sheet %}'>Add Person Time Sheet</a></li>
{% endif %}
</ul>

<table class='projects'>
    <tr>
        <th>Name</th>
        <th>Latest</th>
        <th>Current Hours</th>
        <th>Last Hours</th>
    </tr>
    {% for sheet in time_sheets %}
    <tr>
        <td><a href='{% url view_person_time_sheet sheet.user.pk,sheet.repeat_period.pk %}'>{{ sheet.user.first_name }} {{ sheet.user.last_name }}</a></td>
        <td>{{ sheet.repeat_period.billing_windows.latest }}</td>
        {% for aggs in sheet.list_total_hours %}
            {% if aggs.total %}
                <td>{{ aggs.total }}</td>
            {% else %}
                <td></td>            
            {% endif %}
            {% if sheet.list_total_hours|length < 2 %}
                <td></td>                
            {% endif %}
        {% empty %}
            <td></td>
        {% endfor %}
        <td><a href='{% url edit_person_time_sheet sheet.user.pk %}'>Change</a></td>
    </tr>
    {% empty %}
    <tr>
        <td colspan='3'>No time sheets found.</td>
    </tr>
    {% endfor %}
</table>

{% endblock %}
