diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d2564c2c..e2ab510f 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -33,15 +33,19 @@ class UsersController < ApplicationController sort_update @status = params[:status] ? params[:status].to_i : 1 - conditions = "status <> 0" - conditions = ["status=?", @status] unless @status == 0 + c = ARCondition.new(@status == 0 ? "status <> 0" : ["status = ?", @status]) + + unless params[:name].blank? + name = "%#{params[:name].strip.downcase}%" + c << ["LOWER(login) LIKE ? OR LOWER(firstname) LIKE ? OR LOWER(lastname) LIKE ?", name, name, name] + end - @user_count = User.count(:conditions => conditions) + @user_count = User.count(:conditions => c.conditions) @user_pages = Paginator.new self, @user_count, per_page_option, params['page'] @users = User.find :all,:order => sort_clause, - :conditions => conditions, + :conditions => c.conditions, :limit => @user_pages.items_per_page, :offset => @user_pages.current.offset diff --git a/app/views/users/list.rhtml b/app/views/users/list.rhtml index 77d45a6b..c4156375 100644 --- a/app/views/users/list.rhtml +++ b/app/views/users/list.rhtml @@ -6,8 +6,11 @@ <% form_tag({}, :method => :get) do %>
<%= l(:label_filter_plural) %> - + <%= select_tag 'status', users_status_options_for_select(@status), :class => "small", :onchange => "this.form.submit(); return false;" %> + +<%= text_field_tag 'name', params[:name], :size => 30 %> +<%= submit_tag l(:button_apply), :class => "small", :name => nil %>
<% end %>