{% extends "helpdesk/inner.html" %}
{% load i18n %}
{% load url from future %}

{% block helpdesk_title %}{% trans "View a Ticket" %}{% endblock %}

{% block helpdesk_widgets %}
    <div class="dk-widget">
        <h3>{{ ticket.ticket }} {{ ticket.title }}</h3>
        <hr />
        <table width='100%'>
            <tr>
                <th>{% blocktrans %}Queue:{% endblocktrans %}</th>
                <td>{{ ticket.queue }}</td>
            </tr>
            <tr>
                <th>{% blocktrans %}Status:{% endblocktrans %}</th>
                <td>{{ ticket.get_status }}</td>
            </tr>
            <tr>
                <th>{% trans "Submitted On" %}</th>
                <td>{{ ticket.created|date:"r" }} ({{ ticket.created|timesince }} ago)</td>
            </tr>
            <tr>
                <th>{% trans "Submitter E-Mail" %}</th>
                <td>{{ ticket.submitter_email }}</td>
            </tr>
            <tr>
                <th>{% trans "Priority" %}</th>
                <td>{{ ticket.get_priority_display }}</td>
            </tr>
            
            {% for customfield in ticket.ticketcustomfieldvalue_set.all %}
                <tr>
                    <th>{{ customfield.field.label }}</th>
                    <td>{{ customfield.value }}</td>
                </tr>
            {% endfor %}
            
            {% if tags_enabled %}
                <tr>
                    <th>{% trans "Tags" %}</th>
                    <td>{{ ticket.tags }}</td>
                </tr>
            {% endif %}
            
            <tr>
                <th colspan='2'>{% trans "Description" %}</th>
            </tr>
            <tr>
                <td colspan='2'>{{ ticket.description|force_escape|urlizetrunc:50|linebreaksbr }}</td>
            </tr>
            
            {% if ticket.resolution %}
                <tr>
                    <th colspan='2'>{% trans "Resolution" %}{% ifequal ticket.get_status_display "Resolved" %} <a href='{{ ticket.ticket_url }}&close'><img src='{{ STATIC_URL }}/helpdesk/buttons/accept.png' alt='{% trans "Accept" %}' title='{% trans "Accept and Close" %}' width='60' height='15' /></a>{% endifequal %}</th>
                </tr>
                <tr>
                    <td colspan='2'>{{ ticket.resolution|urlizetrunc:50|linebreaksbr }}</td>
                </tr>
            {% endif %}
            
        </table>
    </div>
    
    {% if ticket.followup_set.public_followups %}
        <div class="dk-widget">
            <h3>{% trans "Follow-Ups" %}</h3>
            <hr />
            {% load ticket_to_link %}
            {% for followup in ticket.followup_set.public_followups %}
            <div class='followup'>
                <div class='title'>{{ followup.title }} <span class='byline'>{% if followup.user %}by {{ followup.user }}{% endif %} <span title='{{ followup.date|date:"r" }}'>{{ followup.date|timesince }} ago</span></span></div>
                {{ followup.comment|force_escape|urlizetrunc:50|num_to_link|linebreaksbr }}
                {% if followup.ticketchange_set.all %}<div class='changes'><ul>
                {% for change in followup.ticketchange_set.all %}
                <li>{% blocktrans with change.field as field and change.old_value as old_value and change.new_value as new_value %}Changed {{ field }} from {{ old_value }} to {{ new_value }}.{% endblocktrans %}</li>
                {% endfor %}
                {% for attachment in followup.attachment_set.all %}{% if forloop.first %}<div class='attachments'><ul>{% endif %}
                <li><a href='{{ attachment.file.url }}'>{{ attachment.filename }}</a> ({{ attachment.mime_type }}, {{ attachment.size|filesizeformat }})</li>
                {% if forloop.last %}</ul></div>{% endif %}
                {% endfor %}
                </ul></div>{% endif %}
            </div>
            {% endfor %}
        </div>
    {% endif %}

{% endblock %}
