diff --git a/app/controllers/admin/writing_conferences_controller.rb b/app/controllers/admin/writing_conferences_controller.rb
index a48161b..8ffc4a0 100644
--- a/app/controllers/admin/writing_conferences_controller.rb
+++ b/app/controllers/admin/writing_conferences_controller.rb
@@ -22,6 +22,28 @@ class Admin::WritingConferencesController < OrbitMemberController
end
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
+
+ def download_excel
+ year_start = params[:year_start].to_i
+ year_end = params[:year_end].to_i
+ @data = get_data_for_excel(year_start,year_end)
+ respond_to do |format|
+ format.xlsx {
+ response.headers['Content-Disposition'] = 'attachment; filename="conference_papers.xlsx"'
+ }
+ end
+ end
+
def create
if !conference_params['member_profile_id'].blank?
diff --git a/app/helpers/admin/personal_conferences_helper.rb b/app/helpers/admin/personal_conferences_helper.rb
index d14d126..8589a7c 100644
--- a/app/helpers/admin/personal_conferences_helper.rb
+++ b/app/helpers/admin/personal_conferences_helper.rb
@@ -129,4 +129,65 @@ module Admin::PersonalConferencesHelper
conference.member_profile = mp
conference.save
end
+ def get_data_for_excel(year_start,year_end)
+ data = []
+ roles = Role.where(:disabled => false, :title.ne => "", :title.ne => nil).asc(:key)
+ roles.each do |role|
+ d = {}
+ d["name"] = role.title
+ mps = role.member_profile_ids
+ d1 = DateTime.new(year_start,1,1,0,0)
+ d2 = DateTime.new(year_end,12,31,23,59)
+ d["data"] = WritingConference.where(:publication_date.gte => d1, :publication_date.lte => d2, :member_profile_id.in => mps) rescue []
+ data << d
+ end
+ return data
+ end
+
+ def get_chart_data(year_start,year_end,role,type)
+ case type
+ when "paper_type"
+ jls = ConferencePaperType.all
+ when "level_type"
+ jls = ConferencePaperLevel.all
+ when "author_type"
+ jls = ConferenceAuthorType.all
+ end
+
+ finaldata = []
+ role = Role.find(role) rescue nil
+ mps = []
+ if !role.nil?
+ mps = role.member_profile_ids
+ end
+ jls.each do |jl|
+ data = {}
+ data["name"] = jl.title
+ data["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 = jl.writing_conferences.where(:publication_date.gte => d1, :publication_date.lte => d2, :member_profile_id.in => mps).count rescue 0
+ data["data"][year.to_s] = t
+ end
+ finaldata << data
+ 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)
+ case type
+ when "paper_type"
+ t = WritingConference.where(:publication_date.gte => d1, :publication_date.lte => d2, :member_profile_id.in => mps, :conference_paper_type_id => nil).count rescue 0
+ when "level_type"
+ t = WritingConference.where(:publication_date.gte => d1, :publication_date.lte => d2, :member_profile_id.in => mps, :conference_paper_level_ids => nil).count rescue 0
+ when "author_type"
+ t = WritingConference.where(:publication_date.gte => d1, :publication_date.lte => d2, :member_profile_id.in => mps, :conference_paper_author_type_ids => nil).count rescue 0
+ end
+
+ data["data"][year.to_s] = t
+ end
+ finaldata << data
+ finaldata
+ end
end
\ No newline at end of file
diff --git a/app/views/admin/writing_conferences/analysis.html.erb b/app/views/admin/writing_conferences/analysis.html.erb
new file mode 100644
index 0000000..2a6ea3d
--- /dev/null
+++ b/app/views/admin/writing_conferences/analysis.html.erb
@@ -0,0 +1,116 @@
+<% # 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 %>
+
+
+
+ <% Role.where(:disabled => false, :title.ne => "", :title.ne => nil).asc(:key).each do |role| %>
+
+
<%= role.title %>
+
+
+
+
+ <% end %>
+
+
+
+
+
+
+
diff --git a/app/views/admin/writing_conferences/analysis_report.html.erb b/app/views/admin/writing_conferences/analysis_report.html.erb
new file mode 100644
index 0000000..b4e8aa4
--- /dev/null
+++ b/app/views/admin/writing_conferences/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/app/views/admin/writing_conferences/download_excel.xlsx.axlsx b/app/views/admin/writing_conferences/download_excel.xlsx.axlsx
new file mode 100644
index 0000000..5d0bf01
--- /dev/null
+++ b/app/views/admin/writing_conferences/download_excel.xlsx.axlsx
@@ -0,0 +1,99 @@
+# encoding: utf-8
+
+wb = xlsx_package.workbook
+@data.each_with_index do |role,idx|
+ data = role["data"]
+ wb.add_worksheet(name: role["name"] + "-" + idx.to_s) do |sheet|
+
+ heading = sheet.styles.add_style(:b => true, :locked => true)
+
+ row = ["Name"]
+
+ @site_in_use_locales.each do |locale|
+ row << t("personal_conference.paper_title") + " - " + t(locale.to_s)
+ end
+
+ @site_in_use_locales.each do |locale|
+ row << t("personal_conference.conference_title") + " - " + t(locale.to_s)
+ end
+
+ @site_in_use_locales.each do |locale|
+ row << t("personal_conference.location") + " - " + t(locale.to_s)
+ end
+
+ @site_in_use_locales.each do |locale|
+ row << t("personal_conference.sponsor") + " - " + t(locale.to_s)
+ end
+
+ @site_in_use_locales.each do |locale|
+ row << t("personal_conference.authors") + " - " + t(locale.to_s)
+ end
+
+ row << t("personal_conference.year")
+
+ row << t("personal_conference.language")
+
+ row << t("personal_conference.period_start_date")
+
+ row << t("personal_conference.period_end_date")
+
+ row << t("personal_conference.paper_level")
+
+ row << t("personal_conference.paper_type")
+
+ row << t("personal_conference.author_type")
+
+ row << t("personal_conference.number_of_authors")
+
+ row << t("personal_conference.isbn")
+
+ row << t("personal_conference.publication_date")
+
+ row << t("personal_conference.isi_number")
+
+ row << t("personal_conference.url")
+
+ row << t("personal_conference.keywords")
+
+ row << t("personal_conference.abstract")
+
+ row << t("personal_conference.note")
+
+ sheet.add_row row, :style => heading
+
+ data.each do |cp|
+ row = [cp.member_profile.name]
+ @site_in_use_locales.each do |locale|
+ row << cp.paper_title_translations[locale.to_s]
+ end
+ @site_in_use_locales.each do |locale|
+ row << cp.conference_title_translations[locale.to_s]
+ end
+ @site_in_use_locales.each do |locale|
+ row << cp.location_translations[locale.to_s]
+ end
+ @site_in_use_locales.each do |locale|
+ row << cp.sponsor_translations[locale.to_s]
+ end
+ @site_in_use_locales.each do |locale|
+ row << cp.authors_translations[locale.to_s]
+ end
+ row << cp.year
+ row << cp.language
+ row << cp.period_start_date.strftime("%Y-%m-%d") rescue ""
+ row << cp.period_end_date.strftime("%Y-%m-%d") rescue ""
+ row << (cp.conference_paper_levels.map{|jl| jl.title}.join(", ") rescue "")
+ row << (cp.conference_paper_type.title rescue "")
+ row << (cp.conference_author_types.map{|jl| jl.title}.join(", ") rescue "")
+ row << cp.number_of_authors
+ row << cp.isbn
+ row << cp.publication_date.strftime("%Y-%m-%d") rescue ""
+ row << cp.isi_number
+ row << cp.url
+ row << cp.keywords
+ row << cp.abstract
+ row << cp.note
+ sheet.add_row row
+ end
+ end
+end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 0c12e04..cdc5133 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -38,6 +38,7 @@ en:
file : "File"
file_name : "File Name"
description : "File Description"
+ graph_by : "Graph by"
frontend:
writing_conferences: "Conference Paper Front-end"
diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml
index a1db55e..8c45d0b 100644
--- a/config/locales/zh_tw.yml
+++ b/config/locales/zh_tw.yml
@@ -37,6 +37,7 @@ zh_tw:
file : "檔案"
file_name : "檔案名稱"
description : "描述"
+ graph_by : "Graph by"
frontend:
writing_conferences: "研討會論文前台"
diff --git a/config/routes.rb b/config/routes.rb
index 0175077..39920e2 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -9,6 +9,9 @@ Rails.application.routes.draw do
resources :writing_conferences do
collection do
get 'toggle_hide' => 'writing_conferences#toggle_hide'
+ get 'analysis'
+ get 'analysis_report'
+ get "download_excel"
end
end
diff --git a/lib/personal_conference/engine.rb b/lib/personal_conference/engine.rb
index 5e1393b..9387910 100644
--- a/lib/personal_conference/engine.rb
+++ b/lib/personal_conference/engine.rb
@@ -4,7 +4,7 @@ module PersonalConference
OrbitApp.registration "PersonalConference",:type=> 'ModuleApp' do
module_label 'module_name.personal_conference'
base_url File.expand_path File.dirname(__FILE__)
- personal_plugin :enable => true, :sort_number => '6', :app_name=>"WritingConference", :intro_app_name=>"PersonalConferenceIntro",:path=>"/plugin/personal_conference/profile",:front_path=>"/profile",:admin_path=>"/admin/writing_conferences",:i18n=>'module_name.personal_conference', :module_app_name=>'PersonalConference', :one_line_title => true, :field_modifiable => true
+ personal_plugin :enable => true, :sort_number => '6', :app_name=>"WritingConference", :intro_app_name=>"PersonalConferenceIntro",:path=>"/plugin/personal_conference/profile",:front_path=>"/profile",:admin_path=>"/admin/writing_conferences",:i18n=>'module_name.personal_conference', :module_app_name=>'PersonalConference', :one_line_title => true, :field_modifiable => true, :analysis => true, :analysis_path => "/admin/writing_conferences/analysis"
version "0.1"
desktop_enabled true