upate call waiter print
This commit is contained in:
@@ -6,6 +6,14 @@ class Api::CallWaitersController < ActionController::API
|
|||||||
@time = params[:time]
|
@time = params[:time]
|
||||||
@table = DiningFacility.find(@table_id)
|
@table = DiningFacility.find(@table_id)
|
||||||
CallWaiterJob.perform_later(@table,@time)
|
CallWaiterJob.perform_later(@table,@time)
|
||||||
|
|
||||||
|
# get printer info
|
||||||
|
@shop = Shop::ShopDetail
|
||||||
|
unique_code = "CallWaiterPdf"
|
||||||
|
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||||
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
|
printer.print_call_waiter(print_settings,@table,@time,@shop)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -117,4 +117,15 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
|||||||
pdf.render_file "tmp/print_crm_order.pdf"
|
pdf.render_file "tmp/print_crm_order.pdf"
|
||||||
self.print("tmp/print_crm_order.pdf")
|
self.print("tmp/print_crm_order.pdf")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#Queue No Print
|
||||||
|
def print_call_waiter(printer_settings,table,time,shop_detail)
|
||||||
|
#Use CUPS service
|
||||||
|
#Generate PDF
|
||||||
|
#Print
|
||||||
|
pdf = CallWaiterPdf.new(printer_settings,table,time,shop_detail)
|
||||||
|
pdf.render_file "tmp/print_call_waiter.pdf"
|
||||||
|
self.print("tmp/print_call_waiter.pdf")
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
71
app/pdf/call_waiter_pdf.rb
Normal file
71
app/pdf/call_waiter_pdf.rb
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
class CallWaiterPdf < 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(printer_settings, table,time,shop_detail)
|
||||||
|
self.page_width = printer_settings.page_width
|
||||||
|
self.page_height = printer_settings.page_height
|
||||||
|
self.margin = 5
|
||||||
|
self.price_width = 35
|
||||||
|
self.qty_width = 20
|
||||||
|
self.total_width = 35
|
||||||
|
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
|
||||||
|
self.item_height = 15
|
||||||
|
self.item_description_width = (self.page_width-20) / 2
|
||||||
|
self.label_width = 100
|
||||||
|
|
||||||
|
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||||
|
|
||||||
|
# db font setup
|
||||||
|
if printer_settings.font != ""
|
||||||
|
font_families.update("#{printer_settings.font}" => {
|
||||||
|
:normal => "public/fonts/#{printer_settings.font}.ttf",
|
||||||
|
:italic => "public/fonts/#{printer_settings.font}.ttf",
|
||||||
|
:bold => "public/fonts/#{printer_settings.font}.ttf",
|
||||||
|
:bold_italic => "public/fonts/#{printer_settings.font}.ttf"
|
||||||
|
})
|
||||||
|
|
||||||
|
font "#{printer_settings.font}"
|
||||||
|
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
|
||||||
|
end
|
||||||
|
|
||||||
|
self.header_font_size = 10
|
||||||
|
self.item_font_size = 8
|
||||||
|
|
||||||
|
header( shop_detail.name, printer_settings.name)
|
||||||
|
|
||||||
|
call_waiter(table)
|
||||||
|
stroke_horizontal_rule
|
||||||
|
|
||||||
|
# date_info(queue)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def header (shop_name, name)
|
||||||
|
text "#{shop_name}", :left_margin => -10, :size => self.header_font_size,:align => :center
|
||||||
|
text "#{name}", :size => self.header_font_size,:align => :center
|
||||||
|
# move_down self.item_height
|
||||||
|
move_down 5
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 5
|
||||||
|
end
|
||||||
|
|
||||||
|
def call_waiter (table)
|
||||||
|
move_down 3
|
||||||
|
text "Table Name : #{table.name}",:align => :center
|
||||||
|
end
|
||||||
|
|
||||||
|
# def date_info(queue)
|
||||||
|
# move_down 5
|
||||||
|
|
||||||
|
# y_position = cursor
|
||||||
|
# bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
|
# text "Date:", :size => self.item_font_size,:align => :left
|
||||||
|
# end
|
||||||
|
# bounding_box([self.label_width,y_position], :width => self.item_width) do
|
||||||
|
# text "#{queue.created_at.strftime('%Y-%m-%d %I:%M %p')}" , :size => self.item_font_size,:align => :left
|
||||||
|
# end
|
||||||
|
|
||||||
|
# move_down 5
|
||||||
|
|
||||||
|
# end
|
||||||
|
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user