diff --git a/app/controllers/admin/activities_controller.rb b/app/controllers/admin/activities_controller.rb index a43178e..038abe3 100644 --- a/app/controllers/admin/activities_controller.rb +++ b/app/controllers/admin/activities_controller.rb @@ -1,6 +1,6 @@ class Admin::ActivitiesController < OrbitMemberController layout "member_plugin" - #include Admin::PersonalActivitiesHelper + include Admin::PersonalActivitiesHelper before_action :set_activity, only: [:edit, :update, :destroy] #before_action :set_plugin @@ -50,6 +50,20 @@ class Admin::ActivitiesController < OrbitMemberController end end + def analysis + end + + def analysis_report + role = params[:role_id] + year_start = params[:year_start].to_i + year_end = params[:year_end].to_i + graph_by = params[:graph_by] + + @data = get_chart_data(year_start,year_end,role,params[:graph_by]) + + render :layout => false + end + private def set_activity diff --git a/app/helpers/admin/personal_activities_helper.rb b/app/helpers/admin/personal_activities_helper.rb new file mode 100644 index 0000000..2865c9c --- /dev/null +++ b/app/helpers/admin/personal_activities_helper.rb @@ -0,0 +1,21 @@ +module Admin::PersonalActivitiesHelper + def get_chart_data(year_start,year_end,role,type) + type = nil + + finaldata = [] + role = Role.find(role) rescue nil + mps = [] + if !role.nil? + mps = role.member_profile_ids + end + data = {"name" => "N/A", "data" => {}} + (year_start..year_end).each do |year| + d1 = DateTime.new(year,1,1,0,0) + d2 = DateTime.new(year,12,31,23,59) + t = Activity.where(:year.gte => year, :year.lte => year, :member_profile_id.in => mps).count rescue 0 + data["data"][year.to_s] = t + end + finaldata << data + finaldata + end +end diff --git a/app/views/admin/activities/analysis.html.erb b/app/views/admin/activities/analysis.html.erb new file mode 100644 index 0000000..3d8df9a --- /dev/null +++ b/app/views/admin/activities/analysis.html.erb @@ -0,0 +1,108 @@ +<% # encoding: utf-8 %> +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/fileupload" %> + <%= stylesheet_link_tag "lib/main-list" %> + <%= stylesheet_link_tag "lib/main-form-col2" %> + +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "//www.google.com/jsapi", "chartkick"%> + <%= javascript_include_tag "justgage.1.0.1.min" %> + <%= javascript_include_tag "raphael.2.1.0.min" %> + <%= javascript_include_tag "validator" %> +<% end %> +