{% extends "base.html" %} {% block title %}{{ ticket.ticket_number }}{% endblock %} {% block page_title %}{{ ticket.ticket_number }}{% endblock %} {% block content %}

{{ ticket.title }}

{{ ticket.priority.upper() }} {{ ticket.status.replace('_',' ').upper() }}
{{ ticket.ticket_number }} {{ ticket.creator.full_name }} {{ ticket.category.replace('_',' ').title() }} {{ ticket.created_at.strftime('%b %d, %Y %H:%M') }} {% if ticket.location %}{{ ticket.location }}{% endif %} {% if ticket.asset_tag %}{{ ticket.asset_tag }}{% endif %} {% if ticket.ai_generated %}AI-generated{% endif %}
Description
{{ ticket.description }}
{% set ticket_atts = ticket.attachments.filter_by(comment_id=None).all() %} {% if ticket_atts %}
Attachments
{% for att in ticket_atts %} {{ att.filename }} ({{ (att.file_size/1024)|int }}KB) {% endfor %}
{% endif %} {% if ticket.resolution_notes %}
Resolution Notes
{{ ticket.resolution_notes }}
{% endif %}
Comments ({{ comments|length }})
{% for comment in comments %}
{{ comment.author.full_name[0].upper() }}
{{ comment.author.full_name }} {% if comment.author.is_it_staff %} IT STAFF {% endif %} {% if comment.is_internal %} INTERNAL NOTE {% endif %}
{{ comment.created_at.strftime('%b %d, %Y %H:%M') }} {% if current_user.is_it_staff or comment.author_id == current_user.id %}
{% endif %}
{{ comment.body }}
{% set c_atts = comment.attachments.all() %} {% if c_atts %}
{% for att in c_atts %} {{ att.filename }} {% endfor %}
{% endif %}
{% else %}
No comments yet. Be the first to add an update.
{% endfor %} {% if ticket.status not in ('closed',) %}
Add Comment
{% if current_user.is_it_staff %}
{% endif %}
{% endif %}
{% if current_user.is_it_staff %}
Update Ticket
{% endif %}
Ticket Details
{% macro info_row(icon, label, value) %}
{{ label }}
{{ value | safe }}
{% endmacro %} {{ info_row('bi-hash', 'Number', ''~ticket.ticket_number~'') }} {{ info_row('bi-tag', 'Category', ticket.category.replace('_',' ').title()) }} {{ info_row('bi-person', 'Submitted by', ticket.creator.full_name) }} {{ info_row('bi-person-check', 'Assigned to', ticket.assignee.full_name if ticket.assignee else '—') }} {{ info_row('bi-calendar3', 'Created', ticket.created_at.strftime('%b %d, %Y')) }} {{ info_row('bi-calendar-check', 'Updated', ticket.updated_at.strftime('%b %d, %Y')) }} {% if ticket.due_date %}{{ info_row('bi-alarm', 'Due Date', ticket.due_date.strftime('%b %d, %Y')) }}{% endif %} {% if ticket.resolved_at %}{{ info_row('bi-check-circle', 'Resolved', ticket.resolved_at.strftime('%b %d, %Y')) }}{% endif %}
{% if history %}
Change History
{% for h in history %}
{# ── Field label ── #} {% if h.field_name == 'assigned_to' %} Assigned To {% elif h.field_name == 'status' %} Status {% elif h.field_name == 'priority' %} Priority {% else %} {{ h.field_name.replace('_',' ').title() }} {% endif %} {# ── Values — format status/priority nicely; keep others as-is ── #} {% set old = h.old_value or 'Unassigned' %} {% set new = h.new_value or 'Unassigned' %} {% if h.field_name in ('status', 'priority') %} {% set old = old.replace('_',' ').title() %} {% set new = new.replace('_',' ').title() %} {% endif %} changed from {{ old }} to {{ new }}
by {{ h.changer.full_name }} · {{ h.changed_at.strftime('%b %d %H:%M') }}
{% endfor %}
{% endif %}
{% endblock %}