update order queue printer

This commit is contained in:
Aung Myo
2017-06-29 10:52:12 +06:30
parent 173d824c27
commit 557ad06600
5 changed files with 34 additions and 31 deletions

View File

@@ -16,7 +16,7 @@ class Oqs::PrintController < ApplicationController
# print when complete click
print_settings = PrintSetting.find_by_unique_code(unique_code)
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_item(oqs, assigned_item.order_id, assigned_item.item_code, print_status, options )
order_queue_printer.print_order_item(print_settings,oqs, assigned_item.order_id, assigned_item.item_code, print_status, options )
# update print status for completed same order items
assigned_items.each do |ai|
@@ -46,7 +46,7 @@ class Oqs::PrintController < ApplicationController
# print when complete click
print_settings = PrintSetting.find_by_unique_code(unique_code)
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_booking_summary(oqs, booking.booking_id, print_status)
order_queue_printer.print_booking_summary(print_settings,oqs, booking.booking_id, print_status)
# update print status for completed same order items
assigned_items.each do |ai|

View File

@@ -1,6 +1,6 @@
class Printer::OrderQueuePrinter < Printer::PrinterWorker
def print_order_item(oqs,order_id, item_code, print_status, options="")
def print_order_item(print_settings,oqs,order_id, item_code, print_status, options="")
#Use CUPS service
#Generate PDF
#Print
@@ -10,7 +10,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
# check for item not to show
if order_item[0].price != 0
pdf = OrderItemPdf.new(order_item[0], print_status, options, oqs.use_alternate_name)
pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name)
pdf.render_file filename
if oqs.print_copy
@@ -26,7 +26,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
end
# Query for per order
def print_order_summary(oqs, order_id, order_items, print_status)
def print_order_summary(print_settings,oqs, order_id, order_items, print_status)
#Use CUPS service
#Generate PDF
#Print
@@ -41,7 +41,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
# check for item not to show
if odi.price != 0
pdf = OrderItemPdf.new(odi, print_status, options, oqs.use_alternate_name)
pdf = OrderItemPdf.new(print_settings,odi, print_status, options, oqs.use_alternate_name)
# pdf.render_file "tmp/order_item.pdf"
pdf.render_file filename
if oqs.print_copy
@@ -55,7 +55,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
# For Print Order Summary
else
filename = "tmp/order_summary_#{ order_id }" + ".pdf"
pdf = OrderSummaryPdf.new(order, print_status, order_items, oqs.use_alternate_name)
pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name)
pdf.render_file filename
if oqs.print_copy
self.print(filename, oqs.printer_name)
@@ -70,7 +70,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
end
# Print for orders in booking
def print_booking_summary(oqs, booking_id, print_status)
def print_booking_summary(print_settings,oqs, booking_id, print_status)
order=print_query('booking_summary', booking_id)
# For Print Per Item
if oqs.cut_per_item
@@ -81,7 +81,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
# check for item not to show
if odi.price != 0
pdf = OrderItemPdf.new(odi, print_status, options,oqs.use_alternate_name)
pdf = OrderItemPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name)
pdf.render_file filename
if oqs.print_copy
@@ -98,7 +98,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
# For Print Order Summary
else
filename = "tmp/booking_summary_#{ booking_id }" + ".pdf"
pdf = OrderSummaryPdf.new(order, print_status,oqs.use_alternate_name)
pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name)
pdf.render_file filename
if oqs.print_copy
self.print(filename, oqs.printer_name)

View File

@@ -1,6 +1,6 @@
class OrderItemPdf < Prawn::Document
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_status, options, alt_name)
def initialize(print_settings,order_item, print_status, options, alt_name)
self.page_width = 210
self.page_height = 1450
self.margin = 5
@@ -12,7 +12,7 @@ class OrderItemPdf < Prawn::Document
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])
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
# super(:margin => [10, 5, 30, 5], :page_size => [200,400])
# font "public/fonts/#{font_name}".to_s + ".ttf".to_s
@@ -87,8 +87,9 @@ class OrderItemPdf < Prawn::Document
if alt_name
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
font "public/fonts/Chinese.ttf"
text "(#{order_item.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
font("public/fonts/Chinese.ttf", :size => 14) do
text "(#{order_item.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
end
end
end

View File

@@ -1,6 +1,6 @@
class OrderSummaryPdf < Prawn::Document
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_status, order_items = nil,alt_name)
def initialize(print_settings,order, print_status, order_items = nil,alt_name)
self.page_width = 210
self.page_height = 1450
self.margin = 5
@@ -12,11 +12,11 @@ class OrderSummaryPdf < Prawn::Document
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])
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
# font "public/fonts/#{font_name}".to_s + ".ttf".to_s
font "public/fonts/Zawgyi-One.ttf"
font "public/fonts/padauk.ttf"
# font "public/fonts/Zawgyi-One.ttf"
font "public/fonts/padauk.ttf"
self.header_font_size = 12
self.item_font_size = 10
@@ -92,20 +92,26 @@ class OrderSummaryPdf < Prawn::Document
bounding_box([0,y_position], :width => self.item_width) do
text "#{odi.item_name}", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_width,y_position], :width => self.qty_width) do
text "#{odi.qty}", :size => self.item_font_size,:align => :left
end
move_down 3
if alt_name
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
font "public/fonts/Chinese.ttf"
text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left
end
bounding_box([0,y_position], :width => self.item_width) do
text "#{odi.item_name}", :size => self.item_font_size,:align => :left
end
if alt_name
move_down 4
font("public/fonts/Chinese.ttf") do
text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
end
end
move_down 5
# add option

View File

@@ -31,10 +31,6 @@ class ReceiptBillPdf < Prawn::Document
delimiter = ""
end
puts "hhhhhhhhhhh"
puts delimiter
puts printer_settings.precision
header( shop_details)
stroke_horizontal_rule
@@ -143,7 +139,7 @@ class ReceiptBillPdf < Prawn::Document
pad_top(15) {
text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
text_box "%.#{precision}f" % price, :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "#{qty}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[(item_name_width+4),y_position], :width =>self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
@@ -280,7 +276,7 @@ class ReceiptBillPdf < Prawn::Document
end
end
end
if member_info["status"] == true
if member_info["status"] == true && member_info["data"].present?
balance = 0
member_info["data"].each do |res|