{% extends "base.html" %}
{% load crm_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 business_id=project.business.id,project_id=project.id %}'>Edit project</a></li>
{% endif %}
{% if perms.crm.view_businesses %}
    <li><a href='{% url view_business business_id=project.business.id %}'>Return to {{ project.business.name }}</a></li>
{% endif %}
{# {% if perms.ledger.add_exchange %} #}
{#  <li><a href='{% url create_exchange exchange_type_slug="invoice",business_id=project.business.id,project_id=project.id %}?next={% url view_project business_id=project.business.id,project_id=project.id %}'>Invoice</a></li> #}
{#  <li><a href='{% url create_exchange exchange_type_slug="receipt",business_id=project.business.id,project_id=project.id %}?next={% url view_project business_id=project.business.id,project_id=project.id %}'>Receipt</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.contacts.count 0 %}
    {% for contact in project.contacts.select_related.all %}
        <li>
            {% if perms.crm.view_contact %}
                <a href='{% url view_person person_id=contact.id %}'>{{ contact.get_full_name }}</a>
            {% else %}
                {{ contact.get_full_name }}
            {% endif %}
            {% if perms.timepiece.change_projectrelationship %}
                <a title="Edit {{ contact.get_full_name }}'s relationship to {{ project }}" href='{% url edit_project_relationship business_id=project.business.id,project_id=project.id,user_id=contact.id %}?next={% url view_project business_id=project.business.id,project_id=project.id %}'><img alt="Edit {{ contact.get_full_name }}'s relationship to {{ project }}" src='{{ FAMFAMFAM_URL }}pencil.png' /></a>
            {% endif %}
            {% if perms.timepiece.delete_projectrelationship %}
                <a title='Remove {{ contact.get_full_name }}' href='{% url associate_contact business_id=project.business.id,project_id=project.id,user_id=contact.id,action="remove" %}?next={% url view_project business_id=project.business.id,project_id=project.id %}'><img alt='Remove {{ contact.get_full_name }}' src='{{ FAMFAMFAM_URL }}/delete.png' /></a>
            {% endif %}
        </li>
    {% endfor %}
    {% endifnotequal %}
    </ul>
    {% if perms.timepiece.add_projectrelationship %}
    <form id="add-contact" action='{% url associate_contact business_id=project.business.id,project_id=project.id,action="add" %}?next={% url view_project business_id=project.business.id,project_id=project.id %}' method="post" accept-charset="utf-8">
        <div class="field-wrapper">
            {{ add_contact_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>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>

{# {% if exchanges and perms.ledger.view_exchange %} #}
{# <h3>Exchanges</h3> #}
{# {% if exchange_type %} #}
{#  {% load pagination_tags %} #}
{#  {% autopaginate exchanges %} #}
{# {% endif %} #}
{#  #}
{# {% paginate %} #}
{# {% regroup exchanges by type as type_list %} #}
{# {% include 'crm/business/_exchange_list.html' %} #}
{# {% endif %} #}

{% endblock %}
