<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.user.displayName') %></th>
    <th><%= t('activeldap.attributes.user.uid') %></th>
    <th><%= t('activeldap.attributes.user.puavoEduPersonAffiliation') %></th>
    <th><%= t('users.show.marked_for_removal') %></th>
    <th><%= t('activeldap.attributes.school.displayName') %></th>
  </tr>
<% @results.each do |term, matched, user| %>
  <% if user && user[:marked_for_deletion] %>
  <tr class="deleted">
  <% else %>
  <tr>
  <% end %>
    <td class="term"><%= term %></td>
    <% unless user %>
    <td colspan="6" class="noMatches"><%= t('extended_search.results.no_term_hits') %></td>
    <% else %>
    <td class="matched"><%= matched %></td>
    <td data-title="ID"><%= h user[:id] %></td>
    <td data-title="<%= t('activeldap.attributes.user.displayName') %>">
      <% if user[:school] %>
      <%= link_to "#{user[:name]}", user_path(user[:school], user[:id]) %>
      <% else %>
      <%= user[:name] %>
      <% end %>
      <% if user[:locked]%><i class='icon-lock' title="<%= t('users.show.user_is_locked') %>"></i><% end %>
    </td>
    <td data-title="<%= t('activeldap.attributes.user.uid')%>"><%= h user[:uid] %></td>
    <td data-title="<%= t('activeldap.attributes.user.puavoEduPersonAffiliation')%>"><%= list_user_roles(user[:affiliation]) %></td>
    <td data-title="<%= t('activeldap.attributes.user.markedForDeletion') %>"><%= user[:exact_removal_time] %></td>
    <td data-title="<%= t('activeldap.attributes.school.displayName')%>">
      <% if user[:school] %>
      <%= link_to "#{user[:school].displayName}", school_path(user[: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 %>
