class Admin::TicketsController < OrbitAdminController def index mp = current_user.member_profile rescue nil @tickets = {} if !mp.nil? authorizations = Authorization.where(:role_id.in => mp.roles.collect{|mm| mm.id}) if authorizations.count == 0 @categories = ModuleApp.find_by_key("ticket").categories rescue [] @categories.each do |category| if params[:status] == "closed" @tickets[category] = Ticket.closed.limit(5).desc(:created_at) else @tickets[category] = Ticket.open.limit(5).desc(:created_at) end end else @categories = authorizations.collect{|authorization| authorization.category} @categories.each do |category| if params[:status] == "closed" temp = Ticket.where(:category_id => category.id).closed.limit(5).desc(:created_at) @tickets[category] = temp if temp.count > 0 else temp = Ticket.where(:category_id => category.id).open.limit(5).desc(:created_at) @tickets[category] = temp if temp.count > 0 end end end end end def tickets_by_category @table_fields = [:ticket_number, :site_name, :subject, :issued_time, :tags, :status, :taken_by] @category = Category.find(params[:category_id]) rescue nil if !@category.nil? @tickets = Ticket.where(:category_id => @category.id, :status.in => ["open", "commenced"]).page(params[:page]).per(15).desc(:created_at) end end end