Created
August 7, 2009 16:49
-
-
Save patrick99e99/164010 to your computer and use it in GitHub Desktop.
This file contains 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
def shipping_label | |
@from_address = Setting.find_by_name("shipping_from_address").address | |
@to_address = Address.find(params[:file_name].split("_").last) | |
prawnto :prawn => { | |
:page_layout => :landscape, | |
:page_size => [79.2, 252.0], | |
:left_margin => 0, | |
:right_margin => 0, | |
:top_margin => 0, | |
:bottom_margin => 0 } | |
end |
This file contains 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
map.shipping_label 'contacts/shipping_label/:file_name.:format', :controller => 'contacts', :action => 'shipping_label' |
This file contains 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
address = @to_address # for some weird reason @to_address is null inside the block yet setting a local variable to it outside of the block works.. this is very weird. | |
from = @from_address | |
pdf.instance_eval do | |
font_size 7 | |
bounding_box [0,79], :width => 100, :height => 79 do | |
padded_box 5 do | |
text from.label | |
text [from.street_1, from.street_2].join(" ") | |
text [from.city, from.region.abbreviation].join(", ") | |
text from.country.name | |
end | |
end | |
font_size 9 | |
bounding_box [100,59], :width => 152, :height => 59 do | |
padded_box 5 do | |
text address.contact.full_name | |
text [address.street_1, address.street_2].join(" ") | |
text [address.city, address.region.abbreviation].join(", ") | |
text address.country.name | |
end | |
end | |
end |
This file contains 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
<%- @contact.addresses.map_with_index do |address, idx| -%> | |
<tr class="show"> | |
<%= content_tag :th, @contact.address.size > 1 ? "Addresses:" : "Address:", :rowspan => @contact.addresses.size if idx.zero? %> | |
<td><%= address.multi_line_with_breaks %><td> | |
<td class="action"><%= link_to 'Generate Label', shipping_label_path( :format => 'pdf', :file_name => "#{@contact.full_name.underscorize}_#{address.id}") %></td> | |
</tr> | |
<%- end -%> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment