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 %> +
+
+
+
+
+ +
+ <%= select_year(DateTime.now.year - 5, {:start_year => DateTime.now.year, :end_year => 1950}, {:name => 'start_year', :class => "span1"} ) %> + - + <%= select_year(DateTime.now.year, {:start_year => DateTime.now.year, :end_year => 1950}, {:name => 'end_year', :class => "span1"} ) %> +
+
+
+
+ + Export +
+
+
+
+ <% Role.where(:disabled => false, :title.ne => "", :title.ne => nil).asc(:key).each do |role| %> +
+

<%= role.title %>

+
+ loading +
+
+ <% end %> +
+
+ + + + + diff --git a/app/views/admin/activities/analysis_report.html.erb b/app/views/admin/activities/analysis_report.html.erb new file mode 100644 index 0000000..b4e8aa4 --- /dev/null +++ b/app/views/admin/activities/analysis_report.html.erb @@ -0,0 +1 @@ +<%= column_chart @data, :id => params[:role_id], :height => "350px", :xtitle => "Year", :ytitle => "Total number" %> \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 5cc04fc..590e732 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -11,3 +11,4 @@ en: activity_start_date: "Start Date" activity_end_date: "End Date" note: "Note" + graph_by: "Graphy By" diff --git a/config/routes.rb b/config/routes.rb index df52c1f..88dd939 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,14 +3,14 @@ Rails.application.routes.draw do scope "(:locale)", locale: Regexp.new(locales.join("|")) do namespace :admin do resources :activities do - #collection do + collection do # post 'merge_process' => 'books#merge_process' # get 'merge' => 'books#merge' # get 'toggle_hide' => 'books#toggle_hide' - # get 'analysis' - # get 'analysis_report' + get 'analysis' + get 'analysis_report' # get "download_excel" - #end + end end end end