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

{% block title %}{{ project }}{% endblock %}

{% block crumbs %}
    {{ block.super }}
    <li><span class="divider">/</span> <a href="{% url 'view_project' project.pk %}">Project Detail</a></li>
{% endblock crumbs %}

{% block content %}
    <div class="row-fluid">
        <div class="span12">
            <h2>{{ project }}</h2>
            <ul class="nav nav-pills">
                {% if perms.timepiece.change_project %}
                    <li><a href="{% url 'edit_project' project_id=project.id %}">Edit Project</a></li>
                    <li><a href="{% url 'delete_project' project.id %}">Delete Project</a></li>
                {% endif %}
                {% if perms.timepiece.view_businesses %}
                    <li><a href="{% url 'view_business' business=project.business.id %}">Return to {{ project.business.name }}</a></li>
                {% endif %}
                {% if perms.timepiece.view_project_time_sheet %}
                    <li><a href="{% url 'project_time_sheet' project.id %}">View Project Time Sheet</a></li>
                {% endif %}
            </ul>
        </div>
    </div>

    <div class="row-fluid">
        <div class="span6">
            <table class="table table-bordered table-striped">
                <tr><th>Type</th><td>{{ project.type }}</td></tr>
                <tr><th>Status</th><td>{{ project.status }}</td></tr>
                <tr><th>Billable</th><td>{{ project.billable }}</td></tr>
                <tr><th>Point Person</th><td>{{ project.point_person }}</td></tr>
                <tr><th>Description</th><td>{{ project.description|linebreaks }}</td></tr>
                {% if project.tracker_url %}
                    <tr><th>Tracker URL</th><td>{{ project.tracker_url }}</td></tr>
                {% endif %}
            </table>
        </div>

        <div class="span4 offset1">
            <h3>Contacts</h3>
            <ul class="people">
            {% ifnotequal project.users.count 0 %}
            {% for user in project.users.select_related.all %}
                <li>
                    {{ user.get_full_name }}
                    {% if perms.timepiece.change_projectrelationship %}
                        {% with caption="Edit "|add:user.get_full_name|add:"'s relationship to "|add:project.name %}
                            <a title="{{ caption }}" href="{% url 'edit_project_relationship' project_id=project.id user_id=user.id %}?next={% url 'view_project' project_id=project.id %}"><i alt="{{ caption }}" class="icon-pencil"></i></a>
                        {% endwith %}
                    {% endif %}
                    {% if perms.timepiece.delete_projectrelationship %}
                        {% with caption="Remove "|add:user.get_full_name|add:" from "|add:project.name %}
                            <a title="{{ caption }}" href="{% url 'remove_project_relationship' project_id=project.id user_id=user.id %}?next={% url 'view_project' project_id=project.id %}"><i alt="{{ caption }}" class="icon-remove"></i></a>
                        {% endwith %}
                    {% endif %}
                </li>
            {% endfor %}
            {% endifnotequal %}
            </ul>
            {% if perms.timepiece.add_projectrelationship %}
            <form class="form-inline" action="{% url 'add_user_to_project' project_id=project.id %}?next={% url 'view_project' project_id=project.id %}" method="post" accept-charset="utf-8">
                {% csrf_token %}
                {{ add_user_form|as_bootstrap:"inline" }}
                <input class="btn" type="submit" name="submit" id="submit" value="Add" />
            </form>
            {% endif %}
        </div>
    </div>

{% endblock %}
