diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 9992d000..599e8da4 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -2104,25 +2104,36 @@ end condition = (params[:research_condition].nil? || params[:research_condition] == "name") ? "concat(lastname, firstname)" : params[:research_condition] if 0 == status if params[:research_condition] == "phone" && params[:research_contents].blank? - @users = User.order("#{@order_key} #{@us_order}") + @users = User.where(nil) else - @users = User.where("#{condition} like '%#{params[:research_contents]}%'").order("#{@order_key} #{@us_order}") + @users = User.where("#{condition} like '%#{params[:research_contents]}%'") end else if params[:research_condition] == "phone" && params[:research_contents].blank? - @users = User.where(:status => status).order("#{@order_key} #{@us_order}") + @users = User.where(:status => status) else - @users = User.where("status = #{status} and #{condition} like '%#{params[:research_contents]}%'").order("#{@order_key} #{@us_order}") + @users = User.where("status = #{status} and #{condition} like '%#{params[:research_contents]}%'") end end + if params[:identity] && params[:identity].to_i != -1 + @users = @users.includes(:user_extensions).where("user_extensions.identity = ?", params[:identity].to_i) + end + + if params[:auto_school] && params[:auto_school].to_i != 0 + @users = @users.includes(:user_extensions => [:school]).where("schools.auto_users_trial = ?", params[:auto_school].to_i == 1 ? 1 : 0) + end + if params[:school] && params[:school] != '' school_name = params[:school] school = School.where("name like '%#{school_name}%'") school_id = school.map(&:id) user_id = UserExtensions.where(:school_id => school_id).map(&:user_id) - @users = @users.where(:id => user_id).order("#{@order_key} #{@us_order}") + @users = @users.where(:id => user_id) end + + @users = @users.order("#{@order_key} #{@us_order}") + @page = (params['page'] || 1).to_i @users_count = @users.count @limit = 20 @@ -3186,25 +3197,44 @@ end search = params[:search] @status = trial_authorization_status(params[:status]) # @status = (params[:status].blank? || params[:status] == "0") ? 0 : [1,2] - if search.blank? - @authorizations = ApplyAction.where(:container_type => "TrialAuthorization", :status => @status).includes(:user) - else - user_id = User.find_by_sql("select id from users where concat(lastname,firstname) like '%#{search}%'") - @authorizations = ApplyAction.where(:container_type => "TrialAuthorization", :status => @status, :user_id => user_id).includes(:user) + user_id = [] + search = false + @authorizations = ApplyAction.where(:container_type => "TrialAuthorization", :status => @status) + + unless search.blank? + user_id = User.find_by_sql("select id from users where concat(lastname,firstname) like '%#{search}%'").map(&:id) end - if params[:sname] && params[:sname] != '' + if params[:sname] && params[:sname].strip != '' school_id = School.where("name like '%#{params[:sname]}%'") - user_id = UserExtensions.where(:school_id => school_id).map(&:user_id) - @authorizations = @authorizations.where(:user_id => user_id).order("updated_at desc") + new_user_id = UserExtensions.where(:school_id => school_id).map(&:user_id) + user_id = user_id.size == 0 ? new_user_id : user_id & new_user_id + search = true + end + + if params[:identity] && params[:identity].to_i != -1 + new_user_id = UserExtensions.where(:identity => params[:identity].to_i).map(&:user_id) + user_id = user_id.size == 0 ? new_user_id : user_id & new_user_id + search = true end + if params[:auto_school] && params[:auto_school].to_i != 0 + school_id = School.where(auto_users_trial: params[:auto_school].to_i == 1 ? 1 : 0) + new_user_id = UserExtensions.where(:school_id => school_id).map(&:user_id) + user_id = user_id.size == 0 ? new_user_id : user_id & new_user_id + search = true + end + + @authorizations = user_id.size == 0 && !search ? @authorizations.order("updated_at desc") : @authorizations.where(:user_id => user_id.uniq).order("updated_at desc") + @autu_count = @authorizations.count @limit = 15 @is_remote = true @autu_pages = Paginator.new @autu_count, @limit, params['page'] || 1 @offset ||= @autu_pages.offset @authorizations = paginateHelper @authorizations, @limit + + @authorizations = @authorizations.includes(:user) respond_to do |format| format.js format.html diff --git a/app/views/managements/trial_authorization.html.erb b/app/views/managements/trial_authorization.html.erb index 5f2c17a1..acdc4d69 100644 --- a/app/views/managements/trial_authorization.html.erb +++ b/app/views/managements/trial_authorization.html.erb @@ -28,11 +28,22 @@
-

+

全部 同意 拒绝

+ +
@@ -91,59 +102,55 @@ }); /* ----------------------- 已审批(全部) ------------------------- */ - $("#audit_all_authentication").on("click", function(){ - var iName = $("#audit_search_name").val(); - var sName = $("#school_search_name").val(); - - $.ajax({ - url: "<%= trial_authorization_managements_path %>" + ".js", - data: { name: iName, status: [1, 2], sname: sName } - }); - }); + $("#audit_all_authentication").on("click", function(){search_func([1, 2]);}); /* ----------------------- 已审批(同意) ------------------------- */ - $("#audit_agree_authentication").live("click", function(){ - var iName = $("#audit_search_name").val(); - var sName = $("#school_search_name").val(); - - $.ajax({ - url: "<%= trial_authorization_managements_path %>" +".js", - data: { name: iName, status: 1, sname: sName} - }); - }); + $("#audit_agree_authentication").live("click", function(){search_func(1);}); /* ----------------------- 已审批(拒绝) ------------------------- */ - $("#audit_reject_authentication").live("click", function(){ - var iName = $("#audit_search_name").val(); - var sName = $("#school_search_name").val(); + $("#audit_reject_authentication").live("click", function(){search_func(2);}); - $.ajax({ - url: "<%= trial_authorization_managements_path %>" +".js", - data: { name: iName, status: 2, sname: sName } - }); + /* ------------------- 按名字进行搜索(已审批)-------------------- */ + $("#audit_search").live("click", function(){search_func(0);}); + $("#user_identity").on("change", function(){search_func(0);}); + $("#auto_school").on("change", function(){search_func(0);}); + + $("#audit_search_name, #school_search_name").on("keydown", function(e){ + // 兼容FF和IE和Opera + var theEvent = e || window.event; + var code = theEvent.keyCode || theEvent.which || theEvent.charCode; + if (code == 13) { + //回车执行查询 + search_func(0); + } }); - /* ------------------- 按名字进行搜索(已审批)-------------------- */ - $("#audit_search").live("click", function(){ + function search_func(status){ var iName = $("#audit_search_name").val(); var sName = $("#school_search_name").val(); + var identity = $("#user_identity").val(); + var auto_school = $("#auto_school").val(); + var type = status; - var id = $("#audit_all_authentication").parent().find(".active").attr("id"); - var type = 0; + if(type == 0){ + var id = $("#audit_all_authentication").parent().find(".active").attr("id"); - if(id == "audit_all_authentication"){ - type = [1, 2]; - }else if(id=="audit_agree_authentication"){ - type = 1; - }else{ - type = 2; + if(id == "audit_all_authentication"){ + type = [1, 2]; + }else if(id=="audit_agree_authentication"){ + type = 1; + }else{ + type = 2; + } } -// alert(type); + $.ajax({ url: "<%= trial_authorization_managements_path %>" +".js", - data: { search: iName, status: type, sname: sName} + data: { search: iName, status: type, sname: sName, identity: identity, auto_school: auto_school} }); - }); + } + + // $(document).keyup(function(event){ // if(event.keyCode == 13){ diff --git a/app/views/managements/users.html.erb b/app/views/managements/users.html.erb index e707214e..9b01dab3 100644 --- a/app/views/managements/users.html.erb +++ b/app/views/managements/users.html.erb @@ -1,40 +1,53 @@
<%= form_tag(url_for(users_managements_path), :id => "managements_users_search", :method => "post", :remote => true) do %> -
-

全部状态

- -
    -
  • 全部状态
  • -
  • 活动的(<%= query_user_status_num 1 %>)
  • -
  • 未激活(<%= query_user_status_num 2 %>)
  • -
  • 已锁定(<%= query_user_status_num 3 %>)
  • -
-
-
-

真实姓名搜索

- -
    -
  • 真实姓名搜索
  • -
  • 用户id搜索
  • -
  • 邮箱地址搜索
  • -
  • 手机号码搜索
  • -
-
-
- -
-
  • - - -
    -
  • - +
    +

    全部状态

    + +
      +
    • 全部状态
    • +
    • 活动的(<%= query_user_status_num 1 %>)
    • +
    • 未激活(<%= query_user_status_num 2 %>)
    • +
    • 已锁定(<%= query_user_status_num 3 %>)
    • +
    +
    +
    +

    真实姓名搜索

    + +
      +
    • 真实姓名搜索
    • +
    • 用户id搜索
    • +
    • 邮箱地址搜索
    • +
    • 手机号码搜索
    • +
    +
    - 搜索 - 清除 + + - +
    + +
    +
  • + + +
    +
  • + + + 搜索 + 清除 + + 课堂添加成员 <% end %>
    @@ -42,7 +55,7 @@ <%= render :partial => "managements/user_list" %>