<div id="ticket_search_results_holder" style="clear:both">
  {% if solr_error %}<p>{{solr_error}}</p>{% endif %}
  {{widget.fields['page_size'].display(page=page, count=count, limit=limit)}}
  {% if count %}
    <table class="ticket-list">
      <thead>
        <tr>
          {% for col in columns if col['active'] %}
            <th data-sort="{{col['sort_name']}}">
              {% if col['name'] == 'ticket_num' %}
                #
              {% else %}
                {{col['label']}}
              {% endif %}
            </th>
          {% endfor %}
          <th style="width:15px">
            <a href="#" id="col_menu" title="Select Columns"><b data-icon="{{g.icons['admin'].char}}" class="ico {{g.icons['admin'].css}}"></b></a>
          </th>
        </tr>
      </thead>
      <tbody>
        {% for t in tickets %}
          <tr class="{{loop.index0%2 and 'even' or ''}}">
            {% for col in columns if col['active'] %}
              {% if col['name'] == 'ticket_num' %}
                <td><a href="{{t.url()}}">{{t[col['name']]}}</a></td>
              {% elif col['name'] == 'summary' %}
              <td><a href="{{t.url()}}">{{t[col['name']]}}</a></td>
              {% elif col['name'] == 'status' %}
                <td class="{{t.open_or_closed}}">{{t.status}}</td>
              {% elif col['name'] == 'assigned_to' %}
                <td>{% if t.assigned_to_id %}{{t.assigned_to.display_name}}{% endif %}</td>
              {% else %}
                {% set fld = c.app.globals.get_custom_field(col['name']) %}
                {% if fld and fld.type == 'user' %}
                  {% set user = t.get_custom_user(col['name']) %}
                  <td>{% if user %}{{user.get_pref('display_name')}}{% endif %}</td>
                {% else %}
                  <td>{{t.custom_fields.get(col['name'])}}</td>
                {% endif %}
              {% endif %}
            {% endfor %}
            <td>&nbsp;</td>
          </tr>
        {% endfor %}
      </tbody>
    </table>
    <form action="." id="col_list_form" style="display:none">
      <input type="hidden" name="limit" value="{{limit}}">
      <input type="hidden" name="page" value="{{page}}">
      {% if sort %}
      <input type="hidden" name="sort" value="{{sort}}">
      {% endif %}
      <input type="hidden" name="q" value="{{query}}">
      <ul>
      {% for col in columns %}
        <li class="clear">
          <input type="hidden" name="columns-{{loop.index0}}.name" value="{{col['name']}}">
          <input type="hidden" name="columns-{{loop.index0}}.sort_name" value="{{col['sort_name']}}">
          <input type="hidden" name="columns-{{loop.index0}}.label" value="{{col['label']}}">
          <input type="checkbox" name="columns-{{loop.index0}}.active"{% if col['active'] %} checked="checked"{% endif %}> {{col['label']}}
        </li>
      {% endfor %}
      </ul>
      <div class="clear">&nbsp;</div>
      <input type="submit" value="Save">
    </form>
    {{widget.fields['lightbox'].display()}}
  {% endif %}
  {{widget.fields['page_list'].display(limit=limit, page=page, count=count)}}
  <script type="text/javascript">
    var q="{{query and h.urlquoteplus(query) or ''}}", count={{count}}, limit={{limit}}, page={{page}}, sort="{{sort}}";
  </script>
</div>
