<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.device.puavoHostname') %></th>
    <th><%= t('activeldap.attributes.device.puavoDeviceType') %></th>
    <th><%= t('activeldap.attributes.school.displayName') %></th>
  </tr>
<% @results.each do |term, matched, device| %>
  <tr>
    <td class="term"><%= term %></td>
    <% unless device %>
    <td colspan="5" class="noMatches"><%= t('extended_search.results.no_term_hits') %></td>
    <% else %>
    <td class="matched"><%= matched %></td>
    <td data-title="ID"><%= h device[:id] %></td>
    <td data-title="<%= t('activeldap.attributes.device.puavoHostname') %>">
      <% if device[:school] %>
      <%= link_to "#{device[:name]}", device_path(device[:school], device[:id]) %>
      <% else %>
      <%= device[:name] %>
      <% end %>
    </td>
    <td data-title="<%= t('activeldap.attributes.device.puavoDeviceType') %>"><%= h device[:type] %></td>
    <td data-title="<%= t('activeldap.attributes.school.displayName') %>">
      <% if device[:school] %>
      <%= link_to "#{device[:school].displayName}", school_path(device[:school]) %>
      <% else %>
      <span class="missingData"><%= t('extended_search.errors.unknown_school') %></span>
      <% end %>
    </td>
    <% end %>
  </tr>
<% end %>
</table>
<% else %>
<p class="noResults"><%= t('extended_search.results.no_results') %></p>
<% end %>
