print format updating

This commit is contained in:
Yan
2017-06-14 10:15:35 +06:30
parent b133129389
commit b7f1a0a029
6 changed files with 123 additions and 91 deletions

View File

@@ -1,15 +1,16 @@
class OrderItemPdf < Prawn::Document
attr_accessor :receipt_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:item_description_width
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
def initialize(order_item, print_settings)
self.page_width = 300
self.page_height = 400
self.page_width = 254
self.page_height = 1450
self.margin = 10
self.price_width = 50
self.qty_width = 50
self.item_width = self.page_width - (self.price_width + self.qty_width)
self.price_width = 40 # No Need for item
self.qty_width = 34
self.total_width = 40 # No Need for item
self.item_width = self.page_width - (self.qty_width + (self.margin*4))
self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width)
self.receipt_width=130
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
self.label_width=80
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
# super(:margin => [10, 5, 30, 5], :page_size => [200,400])
@@ -17,10 +18,10 @@ class OrderItemPdf < Prawn::Document
# font "public/fonts/#{font_name}".to_s + ".ttf".to_s
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
self.header_font_size = 12
self.item_font_size = 10
self.header_font_size = 14
self.item_font_size = 12
text "#{order_item.dining}", :size => self.header_font_size,:align => :center
text "#{order_item.dining}", :size => self.header_font_size,:align => :center, :left_margin => -20
stroke_horizontal_rule
move_down 5
@@ -35,36 +36,43 @@ class OrderItemPdf < Prawn::Document
def order_info(order_by, order_at)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width - 50, :height => self.item_height) do
text "OrderBy:#{order_by} ", :size => self.item_font_size,:align => :left
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_width - 50,y_position], :width => self.item_width + 50, :height => self.item_height) do
text "Date:#{order_at.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
move_down 5
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Date: #{order_at.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
end
stroke_horizontal_rule
move_down 20
move_down 10
end
# Write Order items to PDF
def order_items(order_item)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Item", :size => self.item_font_size,:align => :left
end
# No Need for Order Item
# bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
# text "Item", :size => self.item_font_size,:align => :left
# end
bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do
text "Qty", :size => self.item_font_size,:align => :right
end
# bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do
# text "Qty", :size => self.item_font_size,:align => :right
# end
stroke_horizontal_rule
move_down 5
# stroke_horizontal_rule
# move_down 5
#Add Order Item
add_order_items(order_item)
dash(1, :space => 1, :phase => 1)
stroke_horizontal_line 0, self.page_width
move_down 5
end
# Add order items under order info
@@ -78,7 +86,7 @@ class OrderItemPdf < Prawn::Document
end
bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do
text "#{order_item.qty}", :size => self.item_font_size,:align => :right
text "[#{order_item.qty.to_i}]", :size => self.item_font_size,:align => :left
end
move_down 5

View File

@@ -1,15 +1,16 @@
class OrderSummaryPdf < Prawn::Document
attr_accessor :receipt_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:item_description_width
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
def initialize(order, print_settings)
self.page_width = 300
self.page_height = 400
self.page_width = 254
self.page_height = 1450
self.margin = 10
self.price_width = 60
self.qty_width = 60
self.item_width = self.page_width - (self.price_width + self.qty_width)
self.price_width = 40 # No Need for item
self.qty_width = 34
self.total_width = 40 # No Need for item
self.item_width = self.page_width - (self.qty_width + (self.margin*4))
self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width)
self.receipt_width=130
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
self.label_width=100
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
@@ -19,7 +20,7 @@ class OrderSummaryPdf < Prawn::Document
self.header_font_size = 12
self.item_font_size = 10
text "#{order[0].dining}", :size => self.header_font_size,:align => :center
text "#{order[0].dining}", :size => self.header_font_size,:align => :center, :left_margin => -20
stroke_horizontal_rule
move_down 5
@@ -35,17 +36,19 @@ class OrderSummaryPdf < Prawn::Document
def order_info(order_by, order_at)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width - 20, :height => self.item_height) do
text "OrderBy:#{order_by} ", :size => self.item_font_size,:align => :left
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_width - 20,y_position], :width => self.item_width + 20, :height => self.item_height) do
text "Date:#{order_at.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
move_down 5
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Date: #{order_at.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
end
stroke_horizontal_rule
move_down 20
move_down 10
end
# Write Order items to PDF
@@ -57,7 +60,7 @@ class OrderSummaryPdf < Prawn::Document
end
bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do
text "Qty", :size => self.item_font_size,:align => :right
text "Qty", :size => self.item_font_size,:align => :left
end
stroke_horizontal_rule
@@ -79,7 +82,7 @@ class OrderSummaryPdf < Prawn::Document
end
bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do
text "#{odi.qty}", :size => self.item_font_size,:align => :right
text "#{odi.qty}", :size => self.item_font_size,:align => :left
end
end