{% extends "timepiece/user/base.html" %}
{% load url from future %}
{% load bootstrap_toolkit %}

{% block title %}Users{% endblock title %}

{% block content %}
    <div class="row-fluid">
        <div class="span12">
            <h2>Users</h2>
            <ul class="nav nav-pills">
                {% if perms.auth.add_user %}
                    <li><a href='{% url 'create_user' %}'>Create User</a></li>
                {% endif %}
            </ul>
        </div>
    </div>

    <div class="row-fluid">
        <div class="span12">
            <form class='form-inline' accept-charset='UTF-8' method='get' action=''>
                {{ form|as_bootstrap:"inline" }}
                <button type='submit' name='submit' class="btn">Search</button>
            </form>
        </div>
    </div>

    <div class="row-fluid">
        <div class="span12">
            {% load pagination_tags %}
            {% autopaginate object_list %}

            {% paginate %}
            <table class='table table-bordered table-striped table-condensed'>
                <thead>
                    <tr>
                        <th>Username</th>
                        <th>First Name</th>
                        <th>Last Name</th>
                        <th>Email</th>
                        <th>Time Sheet</th>
                        <th>Active</th>
                    </tr>
                </thead>
                <tbody>
                    {% for user in object_list %}
                        <tr>
                            <td><a href='{% url 'view_user' user.pk %}'>{{ user.username }}</a></td>
                            <td>{{ user.first_name }}</td>
                            <td>{{ user.last_name }}</td>
                            <td>{{ user.email }}</td>

                            <td><a href="{% url 'view_user_timesheet' user.pk %}">View Time Sheet</a></td>
                            <td>
                                {% if user.is_active %}
                                    <span class="label label-success"><i class="icon-white icon-ok"></i></span>
                                {% else %}
                                    <span class="label label-important"><i class="icon-white icon-remove"></i></span>
                                {% endif %}
                            </td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
            {% paginate %}
        </div>
    </div>
{% endblock content %}
