{% extends "tickets/base.html" %}

{% block content %}
  <h2>{{ found_tickets|length|default:0 }} search results for term "{{ query_string }}"</h2>
  {% for ticket in found_tickets %}
    <div class="card mb-3">
      <div class="row">
        <div class="col-md-8">
          <div class="card-body">
            <h5 class="card-title"><a href="{% url 'tickets:ticket_detail' ticket.pk %}">{{ ticket.title|truncatechars:48 }}</a></h5>
            <p class="card-text">{{ ticket.note|truncatechars:128 }}</p>
            <section class="card-text">
              <small class="text-body-secondary">Created at: {{ ticket.created_at }}</small><br>
              <small class="text-body-secondary">Due date: {{ ticket.due_date }}</small>
            </section>
          </div>
        </div>
        <div class="col-md-4">
          <div class="card-body">
            <b>In list:</b> <a href="{% url 'tickets:ticket_list_detail' ticket.ticket_list.pk %}">{{ ticket.ticket_list.name }}</a><br>
            <b>Created by:</b> {{ ticket.created_by_username }}<br>
            <b>Assigned to:</b> {% if ticket.assigned_to_username %}{{ ticket.assigned_to_username }}{% else %}Anyone{% endif %}<br>
            <b>Type:</b> {{ ticket.get_ticket_type_display }}<br>
            <b>Status:</b> {{ ticket.status }}<br>
            <b>Priority:</b> {{ ticket.priority }}
          </div>
        </div>
      </div>
    </div>
  {% empty %}
    <h4> No results to show :(</h4>
  {% endfor %}
{% endblock %}
