lib/reports_generator.rb
# Accepts the following parameters:
# month - Display results for specific month

Accepts the following parameters:
month - Display results for specific month
Accepts the following parameters : month - Display results for specific month
def attendance_report_by_users
      range = @when_start.beginning_of_day .. @when_end.end_of_day
      activity = Activity.get_activity 'submit questionnaire_answer'
      result = []
      if @users_group_id != 0
        userlist = UserList.where(:users_group_id => @users_group_id).includes([:user, {:user => :activities}])
        userlist.all().each { |ul|
          unless ul.user.nil?
            ul.user.first_name = ul.first_name
            ul.user.last_name = ul.last_name
            user = ul.user
            has_user = true
          else
            user = ul
            has_user = false
          end
          result << fill_in_months_4user(user, range, activity.id, has_user)
        }
      else
        User.all(:include => :user_activities).each { |user|
          result << fill_in_months_4user(user, range, activity.id)
        }
      end
      result.sort_by { |u|
        [
            order_by_total == 1 ? 100-u.total_attended : u.status,
            u.status,
            u.user[:last_name] ? u.user[:last_name] : '',
            u.user[:first_name] ? u.user[:first_name] : '',
            u.user[:email] ? u.user[:email] : '',
            100-u.total_attended,
        ]
      }
    end
def attendance_report_by_users range = @when_start . beginning_of_day .. @when_end . end_of_day activity = Activity . get_activity 'submit questionnaire_answer' result = [ ] if @users_group_id != 0 userlist = UserList . where ( :users_group_id => @users_group_id ) . includes ( [ :user , { :user => :activities } ] ) userlist . all ( ) . each { | ul | unless ul . user . nil? ul . user . first_name = ul . first_name ul . user . last_name = ul . last_name user = ul . user has_user = true else user = ul has_user = false end result << fill_in_months_4user ( user , range , activity . id , has_user ) } else User . all ( :include => :user_activities ) . each { | user | result << fill_in_months_4user ( user , range , activity . id ) } end result . sort_by { | u | [ order_by_total == 1 ? 100 - u . total_attended : u . status , u . status , u . user [ :last_name ] ? u . user [ :last_name ] : '' , u . user [ :first_name ] ? u . user [ :first_name ] : '' , u . user [ :email ] ? u . user [ :email ] : '' , 100 - u . total_attended , ] } end
Accepts the following parameters:
month - Display results for specific month
Accepts the following parameters : month - Display results for specific month
# :include => [:user, {:user => :activities}]
 # All users
