diff --git a/app/controllers/admin/member_counselors_controller.rb b/app/controllers/admin/member_counselors_controller.rb index 4b99f39..9940333 100644 --- a/app/controllers/admin/member_counselors_controller.rb +++ b/app/controllers/admin/member_counselors_controller.rb @@ -5,8 +5,26 @@ class Admin::MemberCounselorsController < OrbitAdminController @table_fields = ["member_counselor.file_date","member_counselor.file_title", "member_counselor.downloaded_times", "member_counselor.account", "member_counselor.user_type", "actions"] end + def results + @files = HpsResult.all.desc(:created_at).page(params[:page]).per(10) + @table_fields = ["member_counselor.file_date","member_counselor.file_title", "member_counselor.downloaded_times", "member_counselor.account", "member_counselor.user_type", "actions"] + end + + def records + @records = HpsCounselingRecord.all.desc(:created_at).page(params[:page]).per(10) + @table_fields = ["member_counselor.file_date","member_counselor.title", "member_counselor.event_title", "member_counselor.account", "actions"] + end + def index - @counselors = HpsMember.all.desc(:created_at).page(params[:page]).per(10) + if !params[:user_type].present? + @counselors = HpsMember.all.desc(:created_at) + else + types = params[:user_type].collect{|ut| ut.to_i if ut.is_i?} + types.delete(nil) + @counselors = HpsMember.where(:user_type.in => params[:user_type]) + end + @counselors = search_data(@counselors,[:name, :account]).page(params[:page]).per(10) + @table_fields = ["member_counselor.account","member_counselor.name", "member_counselor.user_type"] end @@ -59,6 +77,31 @@ class Admin::MemberCounselorsController < OrbitAdminController redirect_to uploads_admin_member_counselors_path end + def destroy_result + hpresult = HpsResult.find(params[:id]) + hpresult.destroy + redirect_to results_admin_member_counselors_path + end + + def destroy_record + record = HpsCounselingRecord.find(params[:id]) + record.destroy + redirect_to records_admin_member_counselors_path + end + + def showrecord + @record = HpsCounselingRecord.find(params[:id]) + end + + def export_records + @records = HpsCounselingRecord.all.desc(:created_at) + respond_to do |format| + format.xlsx { + response.headers['Content-Disposition'] = 'attachment; filename="counselor_records.xlsx"' + } + end + end + private def counselor_params diff --git a/app/views/admin/member_counselors/export_records.xlsx.axlsx b/app/views/admin/member_counselors/export_records.xlsx.axlsx new file mode 100644 index 0000000..20fa9fa --- /dev/null +++ b/app/views/admin/member_counselors/export_records.xlsx.axlsx @@ -0,0 +1,51 @@ +# encoding: utf-8 + +wb = xlsx_package.workbook + +wb.add_worksheet(name: "Counselor Records") do |sheet| + + heading = sheet.styles.add_style(:b => true, :locked => true) + row = [] + row << "新增日期" + row << "縣市" + row << "對象" + row << "輔導日期" + row << "方式" + row << "會議/活動名稱" + row << "縣市輔導項目(可複選)" + row << "學校輔導項目(可複選)" + row << "內容記要(如:所輔導內容、所解決困難、所達成共識、待解決問題…):" + row << "委員建議(如:對該縣市健康促進計畫推動、輔導學校之建議…):" + + sheet.add_row row, :style => heading + + @records.each do |record| + row = [] + row << record.created_at.strftime("%Y-%m-%d %H:%M:%S") + row << (record.get_city.name rescue "") + "/" + (record.get_county.name rescue "") + row << record.get_school.name + row << record.counseling_date.strftime("%Y-%m-%d %H:%M:%S") + s = "" + record.counseling_method.each do |methd| + s = s + methd + end + s = s + (record.counseling_method_description rescue "") if record.counseling_method.include?("個別議題輔導") + row << s + row << record.event_title + s = "" + record.purpose_for_county.each do |methd| + s = s + methd + end + s = s + (record.purpose_for_county_extra rescue "") if record.purpose_for_county.include?("(8)其他(請填寫):") + row << s + s = "" + record.purpose_for_school.each do |methd| + s = s + methd + end + s = s + (record.purpose_for_school_extra rescue "") if record.purpose_for_school.include?("(7)其他(請填寫):") + row << record.minutes_of_event + row << record.evaluation_of_event + + sheet.add_row row + end +end \ No newline at end of file diff --git a/app/views/admin/member_counselors/index.html.erb b/app/views/admin/member_counselors/index.html.erb index 2aaf69f..fbffdc0 100644 --- a/app/views/admin/member_counselors/index.html.erb +++ b/app/views/admin/member_counselors/index.html.erb @@ -1,3 +1,37 @@ +<% content_for :right_nav do %> +
+ <%= record.created_at.strftime("%Y/%m/%d") %> + | ++ <%= record.get_title %> + | ++ <%= record.event_title %> + | ++ <%= record.hps_member.account %> + | ++ Delete + | +
+ <%= file.created_at.strftime("%Y/%m/%d") %> + | ++ <%= file.title %> + | ++ <%= file.download_count %> + | ++ <%= file.hps_member.account %> + | ++ <%= file.hps_member.get_user_type %> + | ++ Delete + | +
新增日期 | +<%= @record.created_at.strftime("%Y-%m-%d %H:%M:%S") %> | +
縣市 | ++ <%= @record.get_city.name rescue "" %>/<%= @record.get_county.name rescue "" %> + | +
對象 | ++ <%= @record.get_school.name rescue "" %> + | +
輔導日期 | ++ <%= @record.counseling_date.strftime("%Y-%m-%d %H:%M:%S") %> + | +
方式 | +
+ <% @record.counseling_method.each do |methd| %>
+ <%= methd %>
+ <% if methd != "個別議題輔導" %>
+ + <% end %> + <% end %> + <% if @record.counseling_method.include?("個別議題輔導") %> + <%= @record.counseling_method_description %> + <% end %> + |
+
會議/活動名稱 | ++ <%= @record.event_title %> + | +
+ 縣市輔導項目(可複選) + | +
+ <% @record.purpose_for_county.each do |methd| %>
+ <%= methd %>
+ <% if methd != "(8)其他(請填寫):" %>
+ + <% end %> + <% end %> + <% if @record.purpose_for_county.include?("(8)其他(請填寫):") %> + <%= @record.purpose_for_county_extra %> + <% end %> + |
+
學校輔導項目(可複選) | +
+ <% @record.purpose_for_school.each do |methd| %>
+ <%= methd %>
+ <% if methd != "(7)其他(請填寫):" %>
+ + <% end %> + <% end %> + <% if @record.purpose_for_school.include?("(7)其他(請填寫):") %> + <%= @record.purpose_for_school_extra %> + <% end %> + |
+
內容記要(如:所輔導內容、所解決困難、所達成共識、待解決問題…): | +<%= @record.minutes_of_event %> | +
委員建議(如:對該縣市健康促進計畫推動、輔導學校之建議…): | +<%= @record.evaluation_of_event %> | +
+ Back + | +