{% extends 'babybuddy/page.html' %}
{% load bootstrap datetime duration i18n widget_tweaks %}

{% block title %}{% trans "Timers" %}{% endblock %}

{% block breadcrumbs %}
    <li class="breadcrumb-item active" aria-current="page">{% trans "Timers" %}</li>
{% endblock %}

{% block content %}
    <h1>
        {% trans "Timers" %}
        {% if perms.core.add_timer %}
            <a href="{% url 'core:timer-add' %}" class="btn btn-sm btn-success">
                <i class="icon-timer" aria-hidden="true"></i> {% trans "Start Timer" %}
            </a>
        {% endif %}
    </h1>
    {% include 'babybuddy/filter.html' %}
    <div class="table-responsive">
        <table class="table table-striped table-hover">
            <thead class="thead-inverse">
            <tr>
                <th>{% trans "Start" %}</th>
                <th>{% trans "Name" %}</th>
                {% if not unique_child %}
                    <th>{% trans "Child" %}</th>
                {% endif %}
                <th>{% trans "Duration" %}</th>
                <th>{% trans "End" %}</th>
                <th>{% trans "Active" %}</th>
                <th>{% trans "User" %}</th>
            </tr>
            </thead>
            <tbody>
            {% for timer in object_list %}
                <tr>
                    <th scope="row">{{ timer.start|datetime_short }}</th>
                    <td><a href="{% url 'core:timer-detail' timer.id %}">{{ timer }}</a></td>
                    {% if not unique_child %}
                        <td>
                            {% if timer.child %}
                                <a href="{% url 'core:child' timer.child.slug %}">{{ timer.child }}</a>
                            {% endif %}
                        </td>
                    {% endif %}
                    <td>{{ timer.duration|duration_string }}</td>
                    <td>
                        {% if timer.end %}
                            {{ timer.end|datetime_short }}
                        {% endif %}
                    </td>
                    <td>{{ timer.active|bool_icon }}</td>
                    <td>{{ timer.user_username }}</td>
                </tr>
            {% empty %}
                <tr>
                    <th colspan="7">{% trans "No timer entries found." %}</th>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
    {% include 'babybuddy/paginator.html' %}

    {% if perms.core.delete_timer %}
        <a href="{% url 'core:timer-delete-inactive' %}" class="btn btn-sm btn-danger">
            <i class="icon-delete" aria-hidden="true"></i> {% trans "Delete Inactive Timers" %}
        </a>
    {% endif %}

{% endblock %}