<h4><%=t :report %><%= @report_title %></h4>

<div>
  <div style="margin-bottom: 1em;">
    <%= form_tag({:action => params[:action]}, :method => :get) do %>
      <table width="100%">
        <tfoot>
          <tr>
            <td colspan="2"><%= submit_tag t(:report_search) %></td>
          </tr>
        </tfoot>
        <tbody>
          <tr>
            <th width="15%"><label for="start_date"><%=t :report_start %></label></th>
            <td width="85%"><%= text_field_tag "start_date", @start_date, :size => 10 %></td>
          </tr>
          <tr>
            <th><label for="end_date"><%=t :report_end %></label></th>
            <td><%= text_field_tag "end_date", @end_date, :size => 10 %></td>
          </tr>
          <tr>
            <th><label for="limit"><%=t :report_limit %></label></th>
            <td><%= text_field_tag "limit", @limit, :size => 5 %></td>
          </tr>
          <tr>
            <td><label for="level"><%=t :report_level %></label></td>
            <td><%= user_level_select_tag "level", include_blank: true, selected: @level %></td>
          </tr>
        </tbody>
      </table>
    <% end %>
  </div>

  <div>
    <table width="100%" class="highlightable">
      <thead>
        <tr>
          <th width="15%"><%=t :report_user %></th>
          <th width="10%"><%=t :report_changes %></th>
          <th width="75%"><%=t :report_percent %></th>
        </tr>
      </thead>
      <tfoot>
        <td><%=t :report_total %></td>
        <td><%= @users[0]["sum"].to_i %></td>
        <td></td>
      </tfoot>
      <tbody>
        <% @users.each do |user| %>
          <tr class="<%= cycle 'even', 'odd' %>">
            <% if not user['id'].nil? %>
              <td><%= link_to(user['name'], :controller => :user, :action => :show, :id => user['id'])%></td>
              <td><%= link_to(user['change_count'], @change_params.call(user['id']))%></td>
            <% else %>
              <td><%= user['name'] %></td>
              <td><%= user['change_count'] %></td>
            <% end %>
            <td><%= number_to_percentage 100 * user["change_count"] / user["sum"], :precision => 1 %></td>
          </tr>
        <% end %>
      </tbody>
    </table>
  </div>
</div>

<% content_for :subnavbar do %>
  <li><%= link_to t(:report_tags), :action => "tag_updates", :start_date => @start_date, :end_date => @end_date %></li>
  <li><%= link_to t(:report_notes), :action => "note_updates", :start_date => @start_date, :end_date => @end_date %></li>
  <li><%= link_to t(:report_wiki), :action => "wiki_updates", :start_date => @start_date, :end_date => @end_date %></li>
  <li><%= link_to t(:report_uploads), :action => "post_uploads", :start_date => @start_date, :end_date => @end_date %></li>
<% end %>
