diff --git a/app/admin/dashboard.rb b/app/admin/dashboard.rb index ca347b91..d147579e 100644 --- a/app/admin/dashboard.rb +++ b/app/admin/dashboard.rb @@ -60,6 +60,7 @@ column do panel "代表者一覧" do li link_to('[ダウンロード] 参加団体メーリングリスト', download_group_list_admin_groups_path(format: 'csv')) + li link_to('代表者連絡先一覧', representative_contact_pages_representative_contact_sheet_path(format: 'pdf')) end end end diff --git a/app/assets/javascripts/representative_contact_pages.coffee b/app/assets/javascripts/representative_contact_pages.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/representative_contact_pages.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/representative_contact_pages.scss b/app/assets/stylesheets/representative_contact_pages.scss new file mode 100644 index 00000000..b279ce3d --- /dev/null +++ b/app/assets/stylesheets/representative_contact_pages.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the RepresentativeContactPages controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/representative_contact_pages_controller.rb b/app/controllers/representative_contact_pages_controller.rb new file mode 100644 index 00000000..cc649930 --- /dev/null +++ b/app/controllers/representative_contact_pages_controller.rb @@ -0,0 +1,24 @@ +class RepresentativeContactPagesController < ApplicationController + def preview_pdf_page(template_name, output_file_name) + respond_to do |format| + format.pdf do + html = render_to_string template: "representative_contact_pages/#{template_name}" + + pdf = PDFKit.new(html, encoding: "UTF-8") + + send_data pdf.to_pdf, + filename: "参加団体連絡先_#{output_file_name}.pdf", + type: "application/pdf", + disposition: "inline" + end + end + end + + def representative_contact_sheet + this_year = FesYear.this_year + + @groups = Group.year(this_year) + + preview_pdf_page('representative_contact_sheet', "代表者連絡先一覧") + end +end diff --git a/app/helpers/representative_contact_pages_helper.rb b/app/helpers/representative_contact_pages_helper.rb new file mode 100644 index 00000000..e31bb54d --- /dev/null +++ b/app/helpers/representative_contact_pages_helper.rb @@ -0,0 +1,9 @@ +module RepresentativeContactPagesHelper + def get_subrep_by_group(group_id) + SubRep.where(group_id:group_id) + end + + def get_user_detail_by_group(group_user_id) + UserDetail.where(user_id:group_user_id) + end +end diff --git a/app/views/representative_contact_pages/representative_contact_sheet.pdf.erb b/app/views/representative_contact_pages/representative_contact_sheet.pdf.erb new file mode 100644 index 00000000..1cd53474 --- /dev/null +++ b/app/views/representative_contact_pages/representative_contact_sheet.pdf.erb @@ -0,0 +1,57 @@ + + +
+ + + + + + + + + + + <% @groups.each do |group| %> + <% row_span = get_subrep_by_group(group.id).try(:length) %> + + + + + + + + + + + <% get_subrep_by_group(group.id).each do |subrep| %> + + + + + <% end %> + + <% end %> +
団体名役職氏名電話番号メールアドレス
<%= group.name %>代表者<%= get_user_detail_by_group(group.user_id).first.name_ja %><%= get_user_detail_by_group(group.user_id).first.tel %><%= User.where(id:group.user_id).first.email %>
副代表者<%= subrep.name_ja %><%= subrep.tel %><%= subrep.email %>
+
diff --git a/config/routes.rb b/config/routes.rb index ec69a902..dc5b3cf2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -15,6 +15,7 @@ get 'rental_item_pages/for_pasting_room_sheet' get 'group_information_pages/group_information_sheet' + get 'representative_contact_pages/representative_contact_sheet' resources :group_project_names resources :stage_common_options