mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Sample prototype for ticket pdf
Added verticl layout of ticket pdf without QR code.
This commit is contained in:
parent
95fbd10153
commit
b9a540f4e2
5 changed files with 80 additions and 1 deletions
2
Gemfile
2
Gemfile
|
|
@ -128,6 +128,8 @@ gem 'country_select'
|
||||||
|
|
||||||
# as PDF generator
|
# as PDF generator
|
||||||
gem 'prawn_rails'
|
gem 'prawn_rails'
|
||||||
|
gem 'rqrcode'
|
||||||
|
gem 'prawn-qrcode', '~> 0.2.2.1'
|
||||||
|
|
||||||
# to render XLS spreadsheets
|
# to render XLS spreadsheets
|
||||||
gem 'axlsx', git: 'https://github.com/randym/axlsx.git'
|
gem 'axlsx', git: 'https://github.com/randym/axlsx.git'
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,7 @@ GEM
|
||||||
chart-js-rails (0.0.6)
|
chart-js-rails (0.0.6)
|
||||||
railties (> 3.1)
|
railties (> 3.1)
|
||||||
chronic (0.10.2)
|
chronic (0.10.2)
|
||||||
|
chunky_png (1.3.8)
|
||||||
cliver (0.3.2)
|
cliver (0.3.2)
|
||||||
cloudinary (1.1.6)
|
cloudinary (1.1.6)
|
||||||
aws_cf_signer
|
aws_cf_signer
|
||||||
|
|
@ -343,6 +344,9 @@ GEM
|
||||||
prawn (1.0.0)
|
prawn (1.0.0)
|
||||||
pdf-core (~> 0.2.2)
|
pdf-core (~> 0.2.2)
|
||||||
ttfunk (~> 1.1.1)
|
ttfunk (~> 1.1.1)
|
||||||
|
prawn-qrcode (0.2.2.1)
|
||||||
|
prawn (>= 0.11.1)
|
||||||
|
rqrcode (>= 0.4.1)
|
||||||
prawn_rails (0.0.11)
|
prawn_rails (0.0.11)
|
||||||
prawn (>= 0.11.1)
|
prawn (>= 0.11.1)
|
||||||
railties (>= 3.0.0)
|
railties (>= 3.0.0)
|
||||||
|
|
@ -429,6 +433,8 @@ GEM
|
||||||
mime-types (>= 1.16, < 3.0)
|
mime-types (>= 1.16, < 3.0)
|
||||||
netrc (~> 0.7)
|
netrc (~> 0.7)
|
||||||
rolify (5.1.0)
|
rolify (5.1.0)
|
||||||
|
rqrcode (0.10.1)
|
||||||
|
chunky_png (~> 1.0)
|
||||||
rspec (3.0.0)
|
rspec (3.0.0)
|
||||||
rspec-core (~> 3.0.0)
|
rspec-core (~> 3.0.0)
|
||||||
rspec-expectations (~> 3.0.0)
|
rspec-expectations (~> 3.0.0)
|
||||||
|
|
@ -611,6 +617,7 @@ DEPENDENCIES
|
||||||
phantomjs
|
phantomjs
|
||||||
piwik_analytics (~> 1.0.1)
|
piwik_analytics (~> 1.0.1)
|
||||||
poltergeist
|
poltergeist
|
||||||
|
prawn-qrcode (~> 0.2.2.1)
|
||||||
prawn_rails
|
prawn_rails
|
||||||
rails (~> 4.2)
|
rails (~> 4.2)
|
||||||
rails-assets-bootstrap-markdown!
|
rails-assets-bootstrap-markdown!
|
||||||
|
|
@ -631,6 +638,7 @@ DEPENDENCIES
|
||||||
redcarpet
|
redcarpet
|
||||||
responders (~> 2.0)
|
responders (~> 2.0)
|
||||||
rolify
|
rolify
|
||||||
|
rqrcode
|
||||||
rspec-activemodel-mocks
|
rspec-activemodel-mocks
|
||||||
rspec-rails
|
rspec-rails
|
||||||
rubocop (~> 0.48.1)
|
rubocop (~> 0.48.1)
|
||||||
|
|
|
||||||
|
|
@ -8,5 +8,8 @@ class PhysicalTicketController < ApplicationController
|
||||||
@physical_tickets = current_user.physical_tickets.by_conference(@conference)
|
@physical_tickets = current_user.physical_tickets.by_conference(@conference)
|
||||||
end
|
end
|
||||||
|
|
||||||
def show; end
|
def show
|
||||||
|
@file_name = "ticket_for_#{@conference.short_title}"
|
||||||
|
@user = @physical_ticket.user
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,10 @@ class PictureUploader < CarrierWave::Uploader::Base
|
||||||
"system/#{object_class_name}/#{mounted_as}/#{model.id}"
|
"system/#{object_class_name}/#{mounted_as}/#{model.id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def image
|
||||||
|
@image ||= MiniMagick::Image.open(file.file)
|
||||||
|
end
|
||||||
|
|
||||||
# Create different versions of your uploaded files:
|
# Create different versions of your uploaded files:
|
||||||
version :large do
|
version :large do
|
||||||
process resize_to_fit: [300, 300]
|
process resize_to_fit: [300, 300]
|
||||||
|
|
|
||||||
62
app/views/physical_ticket/show.pdf.prawn
Normal file
62
app/views/physical_ticket/show.pdf.prawn
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
prawn_document(filename: @file_name, page_layout: :portrait, :page_size =>'A4' ) do |pdf|
|
||||||
|
# Vertical Layout
|
||||||
|
top = pdf.bounds.top
|
||||||
|
bottom = pdf.bounds.bottom
|
||||||
|
left = pdf.bounds.left
|
||||||
|
right = pdf.bounds.right
|
||||||
|
mid_vertical = (pdf.bounds.top-pdf.bounds.bottom)/2
|
||||||
|
mid_horizontal = (pdf.bounds.right-pdf.bounds.left)/2
|
||||||
|
x = 0
|
||||||
|
|
||||||
|
pdf.move_down mid_vertical
|
||||||
|
pdf.dash(2, :space => 1)
|
||||||
|
pdf.stroke_horizontal_rule
|
||||||
|
pdf.stroke_vertical_line pdf.bounds.top, pdf.bounds.bottom, :at => mid_horizontal
|
||||||
|
pdf.move_up mid_vertical
|
||||||
|
pdf.draw_text "TICKET HOLDER", :at => [x,pdf.cursor-30], :size => 17
|
||||||
|
pdf.dash(2, :space => 0)
|
||||||
|
pdf.stroke_rectangle [x, pdf.cursor-50], 230, 150
|
||||||
|
pdf.move_down 80
|
||||||
|
pdf.draw_text "NAME", :at => [x+10,pdf.cursor], :size => 13
|
||||||
|
pdf.fill_color "808080"
|
||||||
|
pdf.draw_text "#{@user.name}", :at => [x+10,pdf.cursor-25], size: 20
|
||||||
|
pdf.fill_color "000000"
|
||||||
|
pdf.draw_text "EMAIL", :at => [x+10,pdf.cursor-50], :size => 13
|
||||||
|
pdf.fill_color "808080"
|
||||||
|
pdf.draw_text "#{@user.email}", :at => [x+10,pdf.cursor-75], size: 20
|
||||||
|
pdf.fill_color "000000"
|
||||||
|
pdf.move_up 20
|
||||||
|
if @conference.picture?
|
||||||
|
if 7 * @conference.picture.image[:width] > 12 * @conference.picture.image[:height]
|
||||||
|
pdf.image "#{Rails.root}/public#{@conference.picture_url}", :at => [mid_horizontal+30, pdf.cursor], :width => 120
|
||||||
|
else
|
||||||
|
pdf.image "#{Rails.root}/public#{@conference.picture_url}", :at => [mid_horizontal+30, pdf.cursor], :height => 70
|
||||||
|
end
|
||||||
|
else
|
||||||
|
pdf.image "#{Rails.root}/public/img/osem-logo.png", :at => [mid_horizontal+30, pdf.cursor], :height => 70
|
||||||
|
end
|
||||||
|
pdf.move_down 70
|
||||||
|
pdf.draw_text "#{@conference.title}", :at => [mid_horizontal+30,pdf.cursor-30], :size => 12
|
||||||
|
pdf.draw_text "#{@conference.organization.name}", :at => [mid_horizontal+30,pdf.cursor-50], :size => 12
|
||||||
|
pdf.draw_text "#{@conference.venue.name}", :at => [mid_horizontal+30,pdf.cursor-70]
|
||||||
|
pdf.move_up 130
|
||||||
|
pdf.move_down mid_vertical
|
||||||
|
pdf.draw_text "EVENT", :at => [x,pdf.cursor-40], :size => 15
|
||||||
|
pdf.fill_color "808080"
|
||||||
|
pdf.draw_text "#{@conference.title}", :at => [x,pdf.cursor-60], size: 12
|
||||||
|
pdf.draw_text "#{@conference.start_date.strftime('%B %d, %Y')}", :at => [x,pdf.cursor-80], size: 12
|
||||||
|
pdf.move_down 80
|
||||||
|
pdf.fill_color "000000"
|
||||||
|
pdf.draw_text "TICKET", :at => [x,pdf.cursor-30], :size => 15
|
||||||
|
pdf.fill_color "808080"
|
||||||
|
pdf.draw_text "#{@physical_ticket.ticket.title}", :at => [x,pdf.cursor-50], size: 12
|
||||||
|
pdf.move_down 50
|
||||||
|
pdf.fill_color "000000"
|
||||||
|
pdf.draw_text "TICKET REF.", :at => [x,pdf.cursor-30], :size => 15
|
||||||
|
pdf.fill_color "808080"
|
||||||
|
pdf.draw_text "#{@physical_ticket.ticket_purchase.id}", :at => [x,pdf.cursor-50], size: 12
|
||||||
|
pdf.move_down 50
|
||||||
|
pdf.fill_color "000000"
|
||||||
|
pdf.draw_text "Powered By OSEM", :at => [(mid_horizontal-left-100)/2,pdf.cursor-100], :size => 11
|
||||||
|
pdf.move_up 180
|
||||||
|
end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue