use print_settings ActionCable fro call waiter, stock check, check in out

This commit is contained in:
Thein Lin Kyaw
2020-08-26 10:25:02 +06:30
parent c7cd353ba2
commit 63abafdbcc
3 changed files with 91 additions and 78 deletions

View File

@@ -170,6 +170,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
# Check in-out time # Check in-out time
def print_check_in_out(print_settings, cashier_terminal, booking, table) def print_check_in_out(print_settings, cashier_terminal, booking, table)
if Lookup.collection_of('print_settings').none? { |x| x == ["ActionCable", "1"] }
#Use CUPS service #Use CUPS service
#Generate PDF #Generate PDF
#Print #Print
@@ -177,16 +178,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
filename = "tmp/check_in_out_#{sale_id}" + ".pdf" filename = "tmp/check_in_out_#{sale_id}" + ".pdf"
pdf = CheckInOutPdf.new(print_settings,booking, table) pdf = CheckInOutPdf.new(print_settings,booking, table)
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
queue: cashier_terminal.printer_name,
unique_code: print_settings.unique_code,
print_copies: print_settings.print_copies,
data: {
booking: booking,
table: table,
table_type: table.type,
}
)
print_setting = PrintSetting.all print_setting = PrintSetting.all
# if order_item[0].price != 0 # if order_item[0].price != 0
@@ -212,5 +204,17 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
if ENV["SERVER_MODE"] != "cloud" if ENV["SERVER_MODE"] != "cloud"
self.print(filename, print_settings.printer_name) self.print(filename, print_settings.printer_name)
end end
else
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
queue: cashier_terminal.printer_name,
unique_code: print_settings.unique_code,
print_copies: print_settings.print_copies,
data: {
booking: booking,
table: table,
table_type: table.type,
}
)
end
end end
end end

View File

@@ -167,7 +167,6 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
# stock check # stock check
def print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker_name, shop_details) def print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker_name, shop_details)
pdf = StockCheckPdf.new(print_settings,stockcheck, stockcheck_items,checker_name, shop_details)
stock_items= [] stock_items= []
if stockcheck_items.length > 0 if stockcheck_items.length > 0
stockcheck_items.each do |sc| stockcheck_items.each do |sc|
@@ -178,6 +177,16 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
stock_items.push(stock_item) stock_items.push(stock_item)
end end
end end
if Lookup.collection_of('print_settings').none? { |x| x == ["ActionCable", "1"] }
pdf = StockCheckPdf.new(print_settings,stockcheck, stockcheck_items,checker_name, shop_details)
pdf.render_file "tmp/print_stock_check_result.pdf"
#no print in cloud server
if ENV["SERVER_MODE"] != "cloud"
self.print("tmp/print_stock_check_result.pdf")
end
else
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}", ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
queue: print_settings.printer_name, queue: print_settings.printer_name,
unique_code: print_settings.unique_code, unique_code: print_settings.unique_code,
@@ -189,10 +198,6 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
shop_details: shop_details, shop_details: shop_details,
} }
) )
pdf.render_file "tmp/print_stock_check_result.pdf"
#no print in cloud server
if ENV["SERVER_MODE"] != "cloud"
self.print("tmp/print_stock_check_result.pdf")
end end
end end
@@ -262,10 +267,18 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
#Queue No Print #Queue No Print
def print_call_waiter(printer_settings,table,time,shop_detail) def print_call_waiter(printer_settings,table,time,shop_detail)
if Lookup.collection_of('print_settings').none? { |x| x == ["ActionCable", "1"] }
#Use CUPS service #Use CUPS service
#Generate PDF #Generate PDF
#Print #Print
pdf = CallWaiterPdf.new(printer_settings,table,time,shop_detail) pdf = CallWaiterPdf.new(printer_settings,table,time,shop_detail)
pdf.render_file "tmp/print_call_waiter.pdf"
#no print in cloud server
if ENV["SERVER_MODE"] != "cloud"
self.print("tmp/print_call_waiter.pdf")
end
else
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}", ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
queue: print_settings.printer_name, queue: print_settings.printer_name,
unique_code: print_settings.unique_code, unique_code: print_settings.unique_code,
@@ -277,10 +290,6 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
time: time, time: time,
} }
) )
pdf.render_file "tmp/print_call_waiter.pdf"
#no print in cloud server
if ENV["SERVER_MODE"] != "cloud"
self.print("tmp/print_call_waiter.pdf")
end end
end end