-
Notifications
You must be signed in to change notification settings - Fork 8
[WIP] 参加団体 連絡先一覧 出力機能 #255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kichikawa
wants to merge
6
commits into
develop
Choose a base branch
from
issue92
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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/ |
24 changes: 24 additions & 0 deletions
24
app/controllers/representative_contact_pages_controller.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
57 changes: 57 additions & 0 deletions
57
app/views/representative_contact_pages/representative_contact_sheet.pdf.erb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| <style type='text/css'> | ||
| body { | ||
| font-family: "IPAGothic" | ||
| } | ||
| table { | ||
| border-collapse: separate; | ||
| border-spacing: 0; | ||
| vertical-align: middle; | ||
| width: 100%; | ||
| table-layout: fixed; | ||
| word-wrap:break-word; | ||
| } | ||
| caption, th, td { | ||
| text-align: center; | ||
| font-weight: normal; | ||
| vertical-align: middle; | ||
| border: solid 1px; | ||
| padding: 0.5em; | ||
| } | ||
| .pagebreak{ | ||
| page-break-after: always; | ||
| } | ||
| </style> | ||
|
|
||
| <div> | ||
| <table align='center'> | ||
| <tbody> | ||
| <tr> | ||
| <td width="17%">団体名</td> | ||
| <td width="15%">役職</td> | ||
| <td width="20%">氏名</td> | ||
| <td>電話番号</td> | ||
| <td>メールアドレス</td> | ||
| </tr> | ||
| </tbody> | ||
| <% @groups.each do |group| %> | ||
| <% row_span = get_subrep_by_group(group.id).try(:length) %> | ||
| <tbody> | ||
| <tr> | ||
| <td rowspan= "<%= 1 + row_span %>" ><%= group.name %></td> | ||
| <td>代表者</td> | ||
| <td><%= get_user_detail_by_group(group.user_id).first.name_ja %></td> | ||
| <td><%= get_user_detail_by_group(group.user_id).first.tel %></td> | ||
| <td><%= User.where(id:group.user_id).first.email %></td> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. アソシエーションを設定しているので user_detail = get_user_detail_by_group(group.user_id)
user = user_detail.user.email # これで参照できる
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. そもそも group.user.email |
||
| </tr> | ||
| <tr> | ||
| <td rowspan="<%= row_span %>">副代表者</td> | ||
| <% get_subrep_by_group(group.id).each do |subrep| %> | ||
| <td><%= subrep.name_ja %></td> | ||
| <td><%= subrep.tel %></td> | ||
| <td><%= subrep.email %></td> | ||
| </tr> | ||
| <% end %> | ||
| </tbody> | ||
| <% end %> | ||
| </table> | ||
| </div> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_subrep_by_group(group.id)やget_user_detail_by_group(group.user_id)で取得したデータを変数に格納してはどうでしょうか.何回か同じメソッドを呼んでいますが引数が同じなので,一回取得して後はそれを使いまわすのが良いと思います.データベースに問い合わせする回数が減るので.