{% extends "base.html" %}
{% load timepiece_tags markup %}

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

{% block content %}
<h2>{{ project }}</h2>
<ul class='header-actions-left'>
{% if perms.timepiece.change_project %}
	<li><a href='{% url edit_project project_id=project.id %}'>Edit 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 repeat_period and perms.timepiece.view_project_time_sheet %}
    <li><a href='{% url project_time_sheet project.id %}'>Project Time Sheet</a></li>
{% endif %}
</ul>

<div id='sidebar'>
    <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 %}
                <a title="Edit {{ user.get_full_name }}'s relationship to {{ project }}" href='{% url edit_project_relationship project_id=project.id,user_id=user.id %}?next={% url view_project project_id=project.id %}'><img alt="Edit {{ user.get_full_name }}'s relationship to {{ project }}" src='{{ FAMFAMFAM_URL }}pencil.png' /></a>
            {% endif %}
            {% if perms.timepiece.delete_projectrelationship %}
                <a title='Remove {{ user.get_full_name }}' href='{% url remove_user_from_project project_id=project.id,user_id=user.id %}?next={% url view_project project_id=project.id %}'><img alt='Remove {{ user.get_full_name }}' src='{{ FAMFAMFAM_URL }}/delete.png' /></a>
            {% endif %}
        </li>
    {% endfor %}
    {% endifnotequal %}
    </ul>
    {% if perms.timepiece.add_projectrelationship %}
    <form id="add-user" 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 %}
        <div class="field-wrapper">
            {{ add_user_form }}
            <input type="submit" name="submit" value="Add" id="submit" />
        </div>
    </form>
    {% endif %}
</div>

<table class='vertical'>
    <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>
    {% if project.billing_period %}
        <tr>
            <th>Billing Period:</th>
            <td>{{ project.billing_period }} - Latest billing window: {{ project.billing_period.billing_windows.latest }}</td>
        </tr>
    {% endif %}
    <tr>
        <th>Description:</th>
        <td>{{ project.description|textile }}</td>
    </tr>
</table>

{% endblock %}
