crm print update
This commit is contained in:
@@ -110,6 +110,7 @@ GEM
|
|||||||
nokogiri (1.7.2)
|
nokogiri (1.7.2)
|
||||||
mini_portile2 (~> 2.1.0)
|
mini_portile2 (~> 2.1.0)
|
||||||
pdf-core (0.7.0)
|
pdf-core (0.7.0)
|
||||||
|
pg (0.20.0)
|
||||||
prawn (2.2.2)
|
prawn (2.2.2)
|
||||||
pdf-core (~> 0.7.0)
|
pdf-core (~> 0.7.0)
|
||||||
ttfunk (~> 1.5)
|
ttfunk (~> 1.5)
|
||||||
@@ -246,6 +247,7 @@ DEPENDENCIES
|
|||||||
kaminari (~> 0.16.3)
|
kaminari (~> 0.16.3)
|
||||||
listen (~> 3.0.5)
|
listen (~> 3.0.5)
|
||||||
mysql2 (>= 0.3.18, < 0.5)
|
mysql2 (>= 0.3.18, < 0.5)
|
||||||
|
pg
|
||||||
prawn
|
prawn
|
||||||
prawn-table
|
prawn-table
|
||||||
puma (~> 3.0)
|
puma (~> 3.0)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
class CrmOrderPdf < Prawn::Document
|
class CrmOrderPdf < Prawn::Document
|
||||||
attr_accessor :receipt_width,:price_column_width,:p_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_column_width,:item_description_width
|
attr_accessor :receipt_width,:price_column_width,:p_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_column_width,:item_description_width
|
||||||
def initialize(booking,order_items,print_settings)
|
def initialize(booking,order_items,printer_settings)
|
||||||
self.p_width = 200
|
self.p_width = 200
|
||||||
self.page_height = 1450
|
self.page_height = 1450
|
||||||
self.margin = 10
|
self.margin = 10
|
||||||
@@ -18,20 +18,19 @@ class CrmOrderPdf < Prawn::Document
|
|||||||
@half_qty = @qty_width / 2
|
@half_qty = @qty_width / 2
|
||||||
#setting page margin and width
|
#setting page margin and width
|
||||||
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.p_width, self.page_height])
|
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.p_width, self.page_height])
|
||||||
self.header_font_size = 7
|
self.header_font_size = 10
|
||||||
self.item_font_size = 9
|
self.item_font_size = 9
|
||||||
|
|
||||||
header( booking.type, booking.dining_facility.name)
|
header( printer_settings.printer_name, printer_settings.name)
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
order_detail(booking.checkin_by,booking.checkin_at,booking.dining_facility.name)
|
cashier_info(booking)
|
||||||
line_items(order_items)
|
line_items(order_items)
|
||||||
#all_total(order_items)
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def header (type, name)
|
def header (printer_name, name)
|
||||||
text "#{type}", :size => self.header_font_size,:align => :center
|
text "#{printer_name}", :size => self.header_font_size,:align => :center
|
||||||
move_down 5
|
move_down 5
|
||||||
text "#{name}", :size => self.header_font_size,:align => :center
|
text "#{name}", :size => self.header_font_size,:align => :center
|
||||||
# move_down self.item_height
|
# move_down self.item_height
|
||||||
@@ -41,37 +40,37 @@ class CrmOrderPdf < Prawn::Document
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def order_detail(order_by,order_at,customer)
|
def cashier_info(booking)
|
||||||
move_down 5
|
move_down 5
|
||||||
move_down 2
|
move_down 2
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
qty_column_width = self.p_width * 0.2
|
bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do
|
||||||
item_description_width = self.p_width * 0.5
|
text "Order By:", :size => self.item_font_size,:align => :left
|
||||||
price_column_width = self.p_width * 0.3
|
end
|
||||||
|
|
||||||
|
bounding_box([self.price_width, y_position], :width =>self.receipt_width) do
|
||||||
|
text "#{booking.checkin_by}" , :size => self.item_font_size, :align => :left
|
||||||
stroke_horizontal_rule
|
end
|
||||||
move_down 5
|
move_down 5
|
||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
pad_top(15) {
|
bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do
|
||||||
# @item_width.to_i + @half_qty.to_i
|
text "Customer:", :size => self.item_font_size,:align => :left
|
||||||
text_box "Order By", :at =>[0,y_position], :width => @item_width.to_i - @half_qty.to_i , :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size
|
end
|
||||||
text_box "Order At", :at =>[@item_width.to_i - @half_qty.to_i,y_position], :width => @qty_width, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
bounding_box([self.price_width,y_position], :width =>self.price_width) do
|
||||||
text_box "Customer", :at =>[@item_width.to_i-@qty_width,y_position], :width => @half_qty, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
text "#{booking.customer_id}" , :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
}
|
|
||||||
|
|
||||||
move_down 5
|
move_down 5
|
||||||
stroke_horizontal_rule
|
|
||||||
y_position = cursor
|
|
||||||
pad_top(15) {
|
|
||||||
|
|
||||||
text_box "#{order_by}", :at =>[@item_width.to_i - @half_qty.to_i,y_position], :width => @qty_width, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
y_position = cursor
|
||||||
text_box "#{order_at.to_i}", :at =>[@item_width.to_i-@qty_width,y_position], :width => @half_qty, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do
|
||||||
text_box "#{customer}", :at =>[@item_width.to_i + @half_qty.to_i,y_position], :width => @double, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
text "Date:", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
}
|
bounding_box([self.price_width,y_position], :width =>self.price_width) do
|
||||||
|
text "#{booking.checkin_at.strftime('%Y %m %d %h:%m')}" , :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
# stroke_horizontal_rule
|
||||||
|
move_down 5
|
||||||
end
|
end
|
||||||
|
|
||||||
def line_items(order_items)
|
def line_items(order_items)
|
||||||
@@ -97,10 +96,41 @@ y_position = cursor
|
|||||||
move_down 5
|
move_down 5
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
|
|
||||||
|
add_line_item_row(order_items)
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def add_line_item_row(order_items)
|
||||||
|
y_position = cursor
|
||||||
|
move_down 5
|
||||||
|
sub_total = 0.0
|
||||||
|
order_items.each do |item|
|
||||||
|
|
||||||
|
sub_total += item.qty*item.price
|
||||||
|
qty = item.qty
|
||||||
|
total_price = item.qty*item.price
|
||||||
|
price = item.price
|
||||||
|
item_name = item.item_name
|
||||||
|
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
|
||||||
|
pad_top(15) {
|
||||||
|
# @item_width.to_i + @half_qty.to_i
|
||||||
|
text_box "#{item_name}", :at =>[0,y_position], :width => @item_width.to_i - @half_qty.to_i , :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size
|
||||||
|
text_box "#{price}", :at =>[@item_width.to_i - @half_qty.to_i,y_position], :width => @qty_width, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
||||||
|
text_box "#{qty.to_i}", :at =>[@item_width.to_i-@qty_width,y_position], :width => @half_qty, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
||||||
|
text_box "#{total_price}", :at =>[@item_width.to_i + @half_qty.to_i,y_position], :width => @double, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
||||||
|
|
||||||
|
}
|
||||||
|
move_down 3
|
||||||
|
end
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 5
|
||||||
|
y_position = cursor
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -116,7 +116,7 @@
|
|||||||
<button id="crm_print" value="" disabled="disabled" data-type="assign" class="btn crm_print btn-primary btn-lg btn-block" >
|
<button id="crm_print" value="" disabled="disabled" data-type="assign" class="btn crm_print btn-primary btn-lg btn-block" >
|
||||||
Print
|
Print
|
||||||
</button>
|
</button>
|
||||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Print <br/>Order<br/>Summary</button>
|
<!-- <button type="button" class="btn btn-primary btn-lg btn-block" disabled>Print <br/>Order<br/>Summary</button> -->
|
||||||
<button id="assign" value="" disabled="disabled" data-type="assign" class="btn assign btn-primary btn-lg btn-block">ASSIGN</button>
|
<button id="assign" value="" disabled="disabled" data-type="assign" class="btn assign btn-primary btn-lg btn-block">ASSIGN</button>
|
||||||
<button id="cancel" value="" disabled="disabled" data-type="cancel" class="btn btn-danger cancel btn-lg btn-block">CANCLE</button>
|
<button id="cancel" value="" disabled="disabled" data-type="cancel" class="btn btn-danger cancel btn-lg btn-block">CANCLE</button>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user