diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb
index 087fb2caf..fd2b85dc8 100644
--- a/config/initializers/mime_types.rb
+++ b/config/initializers/mime_types.rb
@@ -5,3 +5,5 @@
# Mime::Type.register_alias "text/html", :iphone
Mime::Type.register_alias "text/html", :mobile
+
+Mime::Type.register 'application/vnd.ms-excel',:xls
\ No newline at end of file
diff --git a/vendor/built_in_modules/survey_b/app/controllers/panel/survey_b/back_end/survey_b_controller.rb b/vendor/built_in_modules/survey_b/app/controllers/panel/survey_b/back_end/survey_b_controller.rb
index 20284f5b0..3893c5a6c 100644
--- a/vendor/built_in_modules/survey_b/app/controllers/panel/survey_b/back_end/survey_b_controller.rb
+++ b/vendor/built_in_modules/survey_b/app/controllers/panel/survey_b/back_end/survey_b_controller.rb
@@ -89,4 +89,64 @@ class Panel::SurveyB::BackEnd::SurveyBController < OrbitBackendController
end
end
+ def export
+
+ if params[:period] && @period = SurveyBPeriod.find(params[:period])
+ @answers = ::SurveyBAnswer.where(:created_at.gte => @period.start_date, :created_at.lte => @period.end_date)
+ @comment_question = ::SurveyBAnswer.where(:created_at.gte => @period.start_date, :created_at.lte => @period.end_date, :comment_question.nin => [''])
+ else
+ @answers = ::SurveyBAnswer.all
+ @comment_question = ::SurveyBAnswer.where(:comment_question.nin => [''])
+ end
+ @results = Hash[(t('survey_b.institutions').keys + [ 'all' ]).map do |i_key|
+ [i_key, Hash[(t('survey_b.questions').keys + ['count', 'sum', 'sum7'] ).map{|q_key| [q_key, 0] }].merge({ 'count' => 0, 'sum' => 0, 'sum7' => 0 })]
+ end]
+ [:good_institutions, :bad_institutions].each do |item|
+ @results[item] = Hash[t('survey_b.institutions').map{|k, i| [k, 0] }]
+ end
+ [:person_question, :rate_question, :quality_question].each do |item|
+ @results[item] = t("survey_b.#{item}_options").map{|o| 0 }
+ end
+ @answers.each do |answer|
+ t('survey_b.institutions').each do |i_key, institution|
+ if answer[i_key.to_s]
+ @results[i_key]['count'] += 1
+ t('survey_b.questions').keys.each do |q_key|
+ point = 10 - ( answer[i_key.to_s][q_key.to_s].to_i * 2 )
+ @results[i_key][q_key] += point
+ @results[i_key]['sum'] += point
+ if q_key != :question6
+ @results[i_key]['sum7'] += point
+ end
+ end
+ end
+ end
+ [:good_institutions, :bad_institutions].each do |item|
+ if answer[item.to_s]
+ answer[item.to_s].each do |institution|
+ @results[item][institution] += 1
+ end
+ end
+ end
+ [:person_question, :rate_question, :quality_question].each do |item|
+ if answer[item.to_s]
+ @results[item][answer[item.to_s].to_i] += 1
+ end
+ end
+ end
+ t('survey_b.institutions').each do |i_key, institution|
+ (t('survey_b.questions').keys + ['count', 'sum', 'sum7'] ).each do |q_key|
+ @results['all'][q_key] += @results[i_key][q_key]
+ end
+ end
+
+ @setting = SurveyBSetting.first
+
+ headers['Content-Type'] = "application/vnd.ms-excel"
+ headers['Content-Disposition'] = "attachment; filename=#{@period.title}.xls"
+ headers['Cache-Control'] = ''
+
+ render :layout => false
+ end
+
end
\ No newline at end of file
diff --git a/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/periods/_period.html.erb b/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/periods/_period.html.erb
index d52eaf483..13394fb47 100644
--- a/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/periods/_period.html.erb
+++ b/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/periods/_period.html.erb
@@ -14,6 +14,7 @@
<%= link_to t(:list_), panel_survey_b_back_end_survey_b_index_path(:period => period, :page => params[:page]) %>
<%= link_to t('edit'), edit_panel_survey_b_back_end_period_path(period, :page => params[:page]) %>
<%= link_to t(:delete_), panel_survey_b_back_end_period_path(period), :confirm => t('sure?'), :method => :delete %>
+ <%= link_to t('survey_b.export'), export_panel_survey_b_back_end_survey_b_index_path(:period => period, :page => params[:page]) %>
diff --git a/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/survey_b/export.html.erb b/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/survey_b/export.html.erb
new file mode 100644
index 000000000..4fa718ac7
--- /dev/null
+++ b/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/survey_b/export.html.erb
@@ -0,0 +1,257 @@
+
+
+ 標題 |
+ <%= @period.title rescue '' %> |
+
+
+ 問卷前言 |
+ <%= @setting.description rescue '' %> |
+
+
+ 填答人數 |
+ <%= @answers.count rescue '' %> |
+
+
+
+
+
+一 、 顧客滿意填表人身分分析
+
+
+ 身份 |
+ <% @results[:person_question].each_with_index do |count, option| %>
+ <%= t("survey_b.person_question_options")[option] %> |
+ <% end %>
+
+
+ 填答人數 |
+ <% @results[:person_question].each_with_index do |count, option| %>
+ <%= count %> |
+ <% end %>
+
+
+ 比例 |
+ <% @results[:person_question].each_with_index do |count, option| %>
+ <% @pcount = count.to_f / @answers.count %>
+ <%= @pcount == 0 ? "0" : sprintf("%.2f", @pcount * 100 ) %>% |
+ <% end %>
+
+
+
+
+
+二、 整體行政品質表現比較分析
+
+
+對於總務處這一、二年之行政品質表現,您感覺是
+
+
+ 行政品質表現 |
+ <% @results[:quality_question].each_with_index do |count, option| %>
+ <%= t("survey_b.quality_question_options")[option] %> |
+ <% end %>
+ |
+
+
+ 填答人數 |
+ <% @qcount = 0 %>
+ <% @results[:quality_question].each_with_index do |count, option| %>
+ <%= count %> |
+ <% @qcount = @qcount + count %>
+ <% end %>
+ <%= @qcount %> |
+
+
+ 比例 |
+ <% @tqcount = 0 %>
+ <% @results[:quality_question].each_with_index do |count, option| %>
+ <% @pcount = count.to_f / @qcount %>
+ <%= @pcount == 0 ? "0" : sprintf("%.2f", @pcount * 100 ) %>% |
+ <% @tqcount = @tqcount + @pcount %>
+ <% end %>
+ <%= @tqcount %> |
+
+
+
+
+對本處整體行政品質表現給予評鑑分數
+
+
+ 行政品質表現 |
+ <% @results[:rate_question].each_with_index do |count, option| %>
+ <%= t("survey_b.rate_question_options")[option] %> |
+ <% end %>
+ |
+
+
+ 填答人數 |
+ <% @rcount = 0 %>
+ <% @results[:rate_question].each_with_index do |count, option| %>
+ <%= count %> |
+ <% @rcount = @rcount + count %>
+ <% end %>
+ <%= @rcount %> |
+
+
+ 比例 |
+ <% @tqcount = 0 %>
+ <% @results[:rate_question].each_with_index do |count, option| %>
+ <% @pcount = count.to_f / @rcount %>
+ <%= @pcount == 0 ? "0" : sprintf("%.2f", @pcount * 100 ) %>% |
+ <% @tqcount = @tqcount + @pcount %>
+ <% end %>
+ <%= @tqcount %> |
+
+
+
+
+以您與總務處各單位接觸之經驗,您覺得以下哪一組的服務品質較優。 (可複選)
+
+
+ 組別 |
+ <% @results[:good_institutions].each do |institution, count| %>
+ <%= t("survey_b.institutions.#{institution}") %> |
+ <% end %>
+ |
+
+
+ 人數 |
+ <% @gcount = 0 %>
+ <% @results[:good_institutions].each do |institution, count| %>
+ <%= count %> |
+ <% @gcount = @gcount + count %>
+ <% end %>
+ <%= @gcount %> |
+
+
+ 比例 |
+ <% @tqcount = 0 %>
+ <% @results[:good_institutions].each do |institution, count| %>
+ <% @pcount = count.to_f / @gcount %>
+ <%= @pcount == 0 ? "0" : sprintf("%.2f", @pcount * 100 ) %>% |
+ <% @tqcount = @tqcount + @pcount %>
+ <% end %>
+ <%= @tqcount %> |
+
+
+
+
+以您與總務處各單位接觸之經驗,您覺得以下哪一組的服務品質尚待改進。 (可複選)
+
+
+ 組別 |
+ <% @results[:bad_institutions].each do |institution, count| %>
+ <%= t("survey_b.institutions.#{institution}") %> |
+ <% end %>
+ |
+
+
+ 人數 |
+ <% @bcount = 0 %>
+ <% @results[:bad_institutions].each do |institution, count| %>
+ <%= count %> |
+ <% @bcount = @bcount + count %>
+ <% end %>
+ <%= @bcount %> |
+
+
+ 比例 |
+ <% @tqcount = 0 %>
+ <% @results[:bad_institutions].each do |institution, count| %>
+ <% @pcount = count.to_f / @bcount %>
+ <%= @pcount == 0 ? "0" : sprintf("%.2f", @pcount * 100 ) %>% |
+ <% @tqcount = @tqcount + @pcount %>
+ <% end %>
+ <%= @tqcount %> |
+
+
+
+
+三、 各單位顧客滿意度調查分析
+
+
+ 組別 |
+ <% @results[:bad_institutions].each do |institution, count| %>
+ <%= t("survey_b.institutions.#{institution}") %> |
+ <% end %>
+ |
+
+
+ <% @tcount = 0 %>
+ <%= t('survey_b.answered_sum') %> |
+ <% t('survey_b.institutions').each do |i_key, institution| %>
+ <% if @results[i_key]['count'] == 0 %>
+ <%= t('survey_b.no_data') %> |
+ <% @tcount = @tcount + @results[i_key]['count'] %>
+ <% else %>
+ <%= ( ( @results[i_key]['sum'].to_f / t('survey_b.questions').count.to_f ) / @results[i_key]['count'].to_f ).round(2) %> |
+ <% @tcount = @tcount + (( @results[i_key]['sum'].to_f / t('survey_b.questions').count.to_f ) / @results[i_key]['count'].to_f ) %>
+ <% end %>
+ <% end %>
+ <%= @tcount %> |
+
+
+ <% @tcount = 0 %>
+ <%= t('survey_b.answered_sum7') %> |
+ <% t('survey_b.institutions').each do |i_key, institution| %>
+ <% if @results[i_key]['count'] == 0 %>
+ <%= t('survey_b.no_data') %> |
+ <% @tcount = @tcount + @results[i_key]['count'] %>
+ <% else %>
+ <%= ( ( @results[i_key]['sum7'].to_f / 7.0 ) / @results[i_key]['count'].to_f ).round(2) %> |
+ <% @tcount = @tcount + ( ( @results[i_key]['sum7'].to_f / 7.0 ) / @results[i_key]['count'].to_f ) %>
+ <% end %>
+ <% end %>
+ <%= @tcount %> |
+
+
+ <% @tcount = 0 %>
+ <%= t('survey_b.answered_count') %> |
+ <% t('survey_b.institutions').each do |i_key, institution| %>
+ <%= @results[i_key]['count'] %> |
+ <% @tcount = @tcount + @results[i_key]['count'] %>
+ <% end %>
+ <%= @tcount %> |
+
+<% t('survey_b.questions').each do |q_key, question| %>
+ <% @tcount = 0 %>
+
+ <%= question.sub /\d\./, '' %> |
+
+ <% t('survey_b.institutions').each do |i_key, institution| %>
+ <% if @results[i_key]['count'] == 0 %>
+ <%= t('survey_b.no_data') %> |
+ <% @tcount = @tcount + @results[i_key]['count'] %>
+ <% else %>
+ <%= ( @results[i_key][q_key].to_f / @results[i_key]['count'].to_f ).round(2) %> |
+ <% @tcount = @tcount + ( @results[i_key][q_key].to_f / @results[i_key]['count'].to_f ) %>
+ <% end %>
+ <% end %>
+ <%= @tcount %> |
+
+<% end %>
+
+
+
+
+您覺得本處之行政品質有那些地方尚待改進嗎?
+
+
+ 填答人數 |
+ <%= @comment_question.count %> |
+
+
+
+
+
+
+
+ 發佈日期 |
+ <%= display_date_time @period.start_date %> |
+
+
+ 截止日期 |
+ <%= display_date_time @period.end_date %> |
+
+
+
diff --git a/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/survey_b/result.html.erb b/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/survey_b/result.html.erb
index 0fc0a7a66..2e7c2769c 100644
--- a/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/survey_b/result.html.erb
+++ b/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/survey_b/result.html.erb
@@ -56,36 +56,77 @@
<% end %>
+
<% [:good_institutions, :bad_institutions, :person_question, :rate_question, :quality_question].each do |item| %>
-
-
+
+
<% end %>
\ No newline at end of file
diff --git a/vendor/built_in_modules/survey_b/config/locales/en.yml b/vendor/built_in_modules/survey_b/config/locales/en.yml
index fac061bf7..bcb9e5864 100644
--- a/vendor/built_in_modules/survey_b/config/locales/en.yml
+++ b/vendor/built_in_modules/survey_b/config/locales/en.yml
@@ -3,6 +3,7 @@ en:
survey_b:
survey_b: 滿意度調查
result: 結果
+ export: 匯出
setting: 設定
description: 前言
diff --git a/vendor/built_in_modules/survey_b/config/locales/zh_tw.yml b/vendor/built_in_modules/survey_b/config/locales/zh_tw.yml
index 2929e947e..790592b90 100644
--- a/vendor/built_in_modules/survey_b/config/locales/zh_tw.yml
+++ b/vendor/built_in_modules/survey_b/config/locales/zh_tw.yml
@@ -3,6 +3,7 @@ zh_tw:
survey_b:
survey_b: 滿意度調查
result: 結果
+ export: 匯出
setting: 設定
description: 前言
diff --git a/vendor/built_in_modules/survey_b/config/routes.rb b/vendor/built_in_modules/survey_b/config/routes.rb
index 62ceee74b..23fd4a666 100644
--- a/vendor/built_in_modules/survey_b/config/routes.rb
+++ b/vendor/built_in_modules/survey_b/config/routes.rb
@@ -7,6 +7,7 @@ Rails.application.routes.draw do
collection do
get 'result'
get 'delete'
+ get 'export'
end
end
resources :periods