class Panel::MemberStaff::FrontEnd::MemberStaffListsController < OrbitWidgetController

  helper  MemberHelper
  
  def initialize
    super
    @app_title = 'memberstaff'
  end
  
  # GET /member_lists
  # GET /member_lists.xml
  
  def index
    
    @item = Page.find(params[:page_id])
    @title = @item.title
    if !@item.frontend_data_count.blank?
      @page_num = @item.frontend_data_count
    else
      @page_num = 10
    end
  
    date_now = Time.now

    @role_id = RoleStatus.get_role_data("staff")
      
    @member_role = Role.where(:_id => @role_id)

    @member_subroles = SubRole.where(:role_id => @role_id, :disabled => false)
    
    @member_list_categorys = RoleCategory.can_display.any_in(:_id => params[:tag_id]).asc("key")

    @member_status = RoleStatus.can_display.any_in(:_id => params[:category_id]).asc("key")

    @mlcs = @member_list_categorys.map{|category| category.id.to_s }

    @mcs = params[:mcid].blank? ? @mlcs.first : params[:mcid]

    if !@member_list_categorys.blank? or !@member_status.blank?
     
      if !@mcs.blank? and @mlcs.include?(@mcs)
        @member_lists = User.where(:role_ids => @role_id,:role_category_ids => @mcs).asc(:position)
      else
        @member_lists = User.where(:role_ids => @role_id).asc(:position)
      end
    else
      # @member_lists = User.where(:role_ids => @role_id)
      @member_lists = ''
    end

  end
  
  def show
    @member = User.find(params[:id])
	  # get_categorys
  end
  
  
  protected
  
  # def get_categorys
  #   @member_list_categorys = MemberListCategory.excludes('disable' => true)
  # end
  
end
