{% extends 'timepiece/invoice/base.html' %}
{% load timepiece_tags bootstrap_toolkit %}

{% block title %}Invoices{% endblock title %}

{% block content %}
    <div class="row-fluid">
        <div class="span12">
            <h2>All Invoices</h2>
            <ul class="nav nav-pills">
                <li>
                    <a href="{% url 'list_outstanding_invoices' %}">Outstanding Hours</a>
                </li>
                <li>
                    <span>Previous Invoices</span>
                </li>
            </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">Search</button>
            </form>
        </div>
    </div>

    <div class="row-fluid">
        <div class="span12">
            {% if object_list %}
                {% include "timepiece/pagination.html" %}
                <table class="table table-bordered table-striped table-condensed">
                    <thead>
                        <tr>
                            <th>Invoice</th>
                            <th>Reference</th>
                            <th>Project</th>
                            <th>Status</th>
                            <th>Invoiced by</th>
                            <th>Created on</th>
                            <th>Starting on</th>
                            <th>Ending on</th>
                            <th>Comments</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for invoice in object_list %}
                            <tr>
                                <td><a href="{% url 'view_invoice' invoice.pk %}">{{ invoice.pk }}</a></td>
                                <td>{{ invoice.number|default:'' }}</td>
                                <td>{{ invoice.project }}</td>
                                <td>{{ invoice.status|capfirst }}</td>
                                <td>{{ invoice.user.get_name_or_username }}</td>
                                <td>{{ invoice.created|date:'M j, Y P' }}</td>
                                <td>{{ invoice.start|date:'M j, Y'}}</td>
                                <td>{{ invoice.end|date:'M j, Y'}}</td>
                                <td title="{{ invoice.comments }} ">{{ invoice.comments|truncatewords:12 }}</td>
                            </tr>
                        {% endfor %}
                    </tbody>
                </table>
            {% else %}
                <p>There are no invoices.</p>
            {% endif %}
        </div>
    </div>
{% endblock content %}
