<h1>Listing users</h1>

<%= form_tag users_path, :method => 'get' do %>
  <%= hidden_field_tag :direction, params[:direction] %>
  <%= hidden_field_tag :sort, params[:sort] %>
  <p>
    <%= text_field_tag :search, params[:search] %>
    <%= submit_tag "Search", :name => nil %>
  </p>
<% end %>

<table id="usersTable" class="data">
  <tr>
    <th>
      Country
    </th>
    <th>
      Username
    </th>
    <th>
      Real name
    </th>
    <th>
      Steam ID
    </th>
    <th>
      Age
    </th>
    <% if cuser and cuser.admin? %>
      <th>
        Options
      </th>
    <% end %>
  </tr>

  <% @users.each do |user| %>
    <tr class="<%= cycle('even', 'odd') %>">
      <td><%= flag user.country %></td>
      <td><%= link_to (h user.username), user %></td>
      <td><%= h user.firstname %> <%=h user.lastname %></td>
      <td><%= h user.steamid %></td>
      <td><%= user.age %></td>
      <% if cuser and cuser.admin? %>
        <td>
          <%= link_to 'Edit', edit_user_path(user) %>
          <%= link_to 'Delete', user, :confirm => "Proceed to delete?", :method => :delete %>
        </td>
      <% end %>
    </tr>
  <% end %>
</table>

<p>
  <%= will_paginate @users %>
</p>
