osem-fcy/app/views/admin/registrations/index.pdf.prawn

38 lines
1.1 KiB
Text
Raw Normal View History

prawn_document(force_download: true, filename: @pdf_filename, page_layout: :landscape) do |pdf|
2013-01-07 09:04:09 +01:00
table_array = []
header_array = ['Attended',
'Name',
'Nickname',
'Affiliation',
'Email',
'Arrival Date',
'Departure Date']
@conference.questions.each do |question|
header_array << question.title
end
2013-01-07 09:04:09 +01:00
table_array << header_array
@registrations.each do |registration|
row = []
row << ( registration.attended ? 'X' : '' )
2014-06-23 19:07:50 +03:00
row << registration.name
row << registration.nickname
row << registration.affiliation
2013-01-07 09:04:09 +01:00
row << registration.email
row << registration.arrival.to_s || ''
row << registration.departure.to_s || ''
2013-01-07 09:04:09 +01:00
@conference.questions.each do |question|
qa = registration.qanswers.find_by(question: question)
answer = ( qa ? qa.answer.title : '' )
row << answer
2013-01-07 09:04:09 +01:00
end
2013-01-07 09:04:09 +01:00
table_array << row
end
pdf.text "#{@conference.title} Registrations", font_size: 25
pdf.table table_array, header: true, cell_style: {size: 5, border_width: 1}
end