{% extends 'detail.html.j2' %}

{% block additional-stylesheet %}
    {% load static %}
    <link rel="stylesheet" href="{% static 'ticketing.css' %}">
{% endblock additional-stylesheet %}

{% load json %}
{% load markdown %}


{% block tabs %}

<div id="details" class="content-tab">

    {% include 'content/section.html.j2' with tab=form.tabs.details %}

</div>

<div id="milestones" class="content-tab">

    {% include 'content/section.html.j2' with tab=form.tabs.milestones %}

    <input type="button" value="New Milestone" onclick="window.location='{% url 'Project Management:_project_milestone_add' project_id=project.id %}';">

    <table>
        <thead>
            <th>Name</th>
            <th>Completed</th>
            <th>Started</th>
            <th>Finished</th>
        </thead>
        {% if milestones %}
        {% for milestone in milestones %}
        <tr>
            <td>
                <a href="{% url 'Project Management:_project_milestone_view' project_id=project.id pk=milestone.id %}">
                {{ milestone.name }}
                </a>
            </td>
            <td>{{ milestone.percent_completed }}</td>
            <td>{{ milestone.start_date }}</td>
            <td>{{ milestone.finish_date }}</td>
        </tr>
        {% endfor %}
        {% else %}
        <tr><td colspan="4">Nothing Found</td></tr>
        {% endif %}
    </table>

</div>


<div id="tasks" class="content-tab">

    {% include 'content/section.html.j2' with tab=form.tabs.tasks %}

    <input type="button" value="New Task" onclick="window.location='{% url 'Project Management:_project_task_add' ticket_type='project_task' project_id=project.id %}';">

    <table>
    <tr>
        <th>id</th>
        <th>title</th>
        <th>status</th>
        <th>type</th>
        <th>created</th>
    </tr>
    {% for project_task in project_tasks %}
    <tr>
        <td>{{ project_task.id }}</td>
        <td>
            {% if project_task.get_ticket_type_display|lower == 'change' %}
            <a href="{% url 'ITIM:_ticket_change_view' ticket_type='change' pk=project_task.id %}">
            {% elif project_task.get_ticket_type_display|lower == 'incident' %}
            <a href="{% url 'ITIM:_ticket_incident_view' ticket_type='incident' pk=project_task.id %}">
            {% elif project_task.get_ticket_type_display|lower == 'problem' %}
            <a href="{% url 'ITIM:_ticket_problem_view' ticket_type='problem' pk=project_task.id %}">
            {% elif project_task.get_ticket_type_display|lower == 'request' %}
            <a href="{% url 'Assistance:_ticket_request_view' ticket_type='request' pk=project_task.id %}">
            {% elif project_task.get_ticket_type_display|lower == 'project task' %}
            <a href="{% url 'Project Management:_project_task_view' ticket_type='project_task' project_id=project.id pk=project_task.id %}">
            {% else %}
            <a href=""></a>
            {% endif %}
                {{ project_task.title }}
            </a>
        </td>
        <td>
        {% include 'core/ticket/badge_ticket_status.html.j2' with ticket_status_text=project_task.get_status_display ticket_status=project_task.get_status_display|ticket_status %}
        </td>
        <td>{{ project_task.get_ticket_type_display }}</td>
        <td>{{ project_task.created }}</td>
    </tr>
    {% endfor %}
    </table>


</div>

<div id="notes" class="content-tab">

    {% include 'content/section.html.j2' with tab=form.tabs.notes %}

        {{ notes_form }}
        <input type="submit" name="{{notes_form.prefix}}" value="Submit" />
        <div class="comments">
            {% if notes %}
            {% for note in notes%}
            {% include 'note.html.j2' %}
            {% endfor %}
            {% endif %}
        </div>


</div>

{% endblock %}
