<p class="resultStatistics">
<%= t('extended_search.results.statistics',
      :total => @total,
      :elapsed => @elapsed,
      :num_terms => @num_terms,
      :num_hits => @num_hits,
      :num_misses => @num_misses) %>
</p>

<% unless @results.empty? %>
<table class="list">
  <tr class="thead">
    <th><%= t('extended_search.results.search_term_title') %></th>
    <th class="matched"><%= t('extended_search.results.matched_string') %></th>
    <th>ID</th>
    <th><%= t('activeldap.attributes.group.displayName') %></th>
    <th><%= t('activeldap.attributes.group.cn') %></th>
    <th><%= t('activeldap.attributes.group.puavoEduGroupType') %></th>
    <th><%= t('activeldap.attributes.school.displayName') %></th>
  </tr>
<% @results.each do |term, matched, group| %>
  <tr>
    <td class="term"><%= term %></td>
    <% unless group %>
    <td colspan="6" class="noMatches"><%= t('extended_search.results.no_term_hits') %></td>
    <% else %>
    <td class="matched"><%= matched %></td>
    <td data-title="ID"><%= h group[:id] %></td>
    <td data-title="<%= t('activeldap.attributes.group.displayName') %>">
      <% if group[:school] %>
      <%= link_to "#{group[:name]}", group_path(group[:school], group[:id]) %>
      <% else %>
      <%= group[:name] %>
      <% end %>
    </td>
    <td data-title="<%= t('activeldap.attributes.group.cn') %>"><%= group[:abbr] %></td>
    <td data-title="<%= t('activeldap.attributes.group.puavoEduGroupType') %>">
      <% if group[:type].nil? %>
      <span class="missingData"><%= t('missing_data') %></span>
      <% else %>
      <%= group[:type][0] %>
      <% end %>
    </td>
    <td data-title="<%= t('activeldap.attributes.school.displayName') %>">
      <% if group[:school] %>
      <%= link_to "#{group[:school].displayName}", school_path(group[:school]) %>
      <% else %>
      <span class="missingData"><%= t('extended_search.errors.unknown_school') %></span>
      <% end %>
    <% end %>
  </tr>
<% end %>
</table>
<% else %>
<p class="noResults"><%= t('extended_search.results.no_results') %></p>
<% end %>
