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

{% block title %}Projects{% endblock %}

{% block content %}
    <div class="row-fluid">
        <div class="span12">
            <h2>Projects</h2>
            <ul class="nav nav-pills">
            {% if perms.timepiece.add_project %}
                <li><a href='{% url 'create_project' %}'>Create Project</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' class="btn" name='submit'>Search</button>
            </form>
        </div>
    </div>

    {% load pagination_tags %}

    <div class="row-fluid">
        <div class="span12">
            {% autopaginate projects %}
            {% paginate %}
            <table class='table table-striped table-bordered table-condensed'>
                <thead>
                    <tr>
                        <th>Name</th>
                        <th>Business</th>
                        <th>Description</th>
                        <th>Timesheet</th>
                    </tr>
                </thead>
                <tbody>
                    {% for project in projects %}
                        <tr>
                            <td><a href="{% url 'view_project' project_id=project.id %}">{{ project.name }}</a></td>
                            <td>{{ project.business }}</td>
                            <td>{{ project.description|truncatewords:8 }}</td>
                            <td><a href="{% url 'project_time_sheet' project.id %}">Timesheet</a></td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
            {% paginate %}
        </div>
    </div>
{% endblock %}
