{% extends "menu.html" %}

{% block title %}{{ section.title }}{% endblock %}

{% block content %}
<h1>Tickets</h1>

{% if ticket_list %}
    <table>
        <tr>
            <th><a href="/ts/index?order={{order}}&sort_by=id">#</a></th>
            <th><a href="/ts/index?order={{order}}&sort_by=title">Title</a></th>
            <th>Requestor</th>
            <th><a href="/ts/index?order={{order}}&sort_by=owner">Responsible</a></th>
            <th><a href="/ts/index?order={{order}}&sort_by=e_date">Deadline</a></th>
            <th><a href="/ts/index?order={{order}}&sort_by=status">Status</a></th>
            <th><a href="/ts/index?order={{order}}&sort_by=queue">Queue</a></th>
            <th><a href="/ts/index?order={{order}}&sort_by=urg">Urgen.</a></th>
            <th><a href="/ts/index?order={{order}}&sort_by=done">Done</a></th>
        </tr>
    {% for ticket in ticket_list %}
        <tr class="listing{% cycle '_odd' '_even'%}">
            <td><a href="/ts/detail/{{ticket.id}}">{{ticket.id}}</a></td>
            <td class="left"><a href="/ts/detail/{{ticket.id}}">{{ticket.s_desc}}</a></td>
            <td>{{ticket.creator.username}}</a></td>
            <td>{{ticket.resp}}</td>
            <td>{{ticket.e_date}}</td>
            <td>{{ticket.get_status}}</td>
            <td><a href="/ts/filter?queue={{ticket.queue.name}}">{{ticket.queue.name}}</a></td>
            <td>{{ ticket.get_urgency }}</td>
        {% if ticket.done %}
            <td class="center"><a style="color:green" href="/ts/status/{{ticket.id}}/open">&#8730;</a></td>
        {% else %}
            <td class="center"><a style="color:red" href="/ts/status/{{ticket.id}}/resolved">x</a></td>
        {% endif %}
        </tr>
    {% endfor %}
    </table>
{% else %}
  {% if not message %}
    <p>No tickets are available. YAY</p>
  {% endif %}
{% endif %}

{% if message %} <div class="error">{{ message }}</div> {% endif %}
{% endblock %}

