{% load url from future %}
{% load timepiece_tags %}
<table class="table table-striped table-bordered table-condensed">
    <thead>
        <tr>
            <th>Date</th>
            <th>Project</th>
            <th class="desktop">Activity</th>
            <th class="desktop">Clock In</th>
            <th class="{% if not active %}desktop{% endif %}">Clock Out</th>
            <th class="desktop">Breaks</th>
            <th>Hours</th>
            <th class="desktop">Location</th>
            <th>Actions</th>
        </tr>
    </thead>
    <tbody>
        {% for entry in entries %}
        <tr{% if entry.comments %} title='{{ entry.comments }}'{% endif %} class='{% if entry.is_paused %}paused{% endif %}{% if not entry.end_time %} active{% endif %} '>
            <td>{{ entry.start_time|date:"m/d | D" }}</td>
            <td>
                {% if perms.timepiece.view_project %}
                    <a href='{% url 'view_project' project_id=entry.project.id %}'>{{ entry.project }}</a>
                {% else %}
                    {{ entry.project }}
                {% endif %}
            </td>
            <td class="desktop">{{ entry.activity }}</td>
            <td class="desktop">{{ entry.start_time|date:"P" }}</td>
            <td class="{% if not active %}desktop{% endif %}">
                {% if active or not entry.end_time %}
                    <a href="{% url 'timepiece-clock-out' entry.id %}">Clock Out</a>
                {% else %}
                    {{ entry.end_time|date:"P" }}
                {% endif %}
            </td>
            <td class="hours desktop">
                {{ entry.seconds_paused|seconds_to_hours|floatformat:2 }}
                {% if active or not entry.end_time %}
                    {% if entry.is_paused %}
                        <a href="{% url 'timepiece-toggle-paused' entry.id %}">(Resume)</a>
                    {% else %}
                        <a href="{% url 'timepiece-toggle-paused' entry.id %}">(Pause)</a>
                    {% endif %}
                {% endif %}
            </td>
            <td class="hours">{{ entry.get_active_seconds|seconds_to_hours }}</td>
            <td class="desktop">{{ entry.location }}</td>
            <td>
                <ul class='actions'>
                    {% ifequal entry.status 'unverified' %}
                    <li><a href="{% url 'timepiece-update' entry.id %}">Change</a></li>
                    <li><a href="{% url 'timepiece-delete' entry.id %}">Remove</a></li>
                    {% endifequal %}
                </ul>
            </td>
        </tr>
        {% empty %}
            <tr><td colspan='9'>You have no time logged for this period.</td></tr>
        {% endfor %}
    </tbody>
</table>
