ActiveAdmin.register JamRuby::User, :as => 'User Progression' do
  PROGRESSION_DATE = '%Y-%m-%d %H:%M' unless defined?(PROGRESSION_DATE)

  menu :label => 'Progression', :parent => 'Users'

  config.sort_order = 'updated_at DESC'
  config.batch_actions = false
  config.clear_action_items!
  config.filters = false

  index do
    column :email do |user| link_to(truncate(user.email, {:length => 12}), resource_path(user), {:title => "#{user.name} (#{user.email})"}) end
    column :updated_at do |uu| uu.updated_at.strftime(PROGRESSION_DATE)  end
    column :created_at do |uu| uu.created_at.strftime(PROGRESSION_DATE)  end
    column :city
    column :musician
    column 'Client DL'  do |uu| 
      if dd = uu.first_downloaded_client_at
        dd.strftime(PROGRESSION_DATE)  
      else
        ''
      end
    end
    column 'Client Run'  do |uu| 
      if dd = uu.first_ran_client_at
        dd.strftime(PROGRESSION_DATE)  
      else
        ''
      end
    end
    column 'Certified Gear'  do |uu| 
      if dd = uu.first_certified_gear_at
        dd.strftime(PROGRESSION_DATE)  
      else
        ''
      end
    end
    column 'Any Session'  do |uu| 
      if dd = uu.first_music_session_at
        dd.strftime(PROGRESSION_DATE)  
      else
        ''
      end
    end
    column 'Real Session'  do |uu| 
      if dd = uu.first_real_music_session_at
        dd.strftime(PROGRESSION_DATE)  
      else
        ''
      end
    end
    column 'Good Session'  do |uu| 
      if dd = uu.first_good_music_session_at
        dd.strftime(PROGRESSION_DATE)  
      else
        ''
      end
    end
    column 'Invited'  do |uu| 
      if dd = uu.first_invited_at
        dd.strftime(PROGRESSION_DATE)  
      else
        ''
      end
    end
    column 'Friended'  do |uu| 
      if dd = uu.first_friended_at
        dd.strftime(PROGRESSION_DATE)  
      else
        ''
      end
    end
    column 'Recorded'  do |uu|
      if dd = uu.first_recording_at
        dd.strftime(PROGRESSION_DATE)
      else
        ''
      end
    end
    column 'Promoted'  do |uu| 
      if dd = uu.first_social_promoted_at
        dd.strftime(PROGRESSION_DATE)  
      else
        ''
      end
    end
  end

end
