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

@@ -167,33 +167,38 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
# stock check
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= []
if stockcheck_items.length > 0
stockcheck_items.each do |sc|
stock_item= {
count: sc.stock_count.to_s,
item_name: MenuItemInstance.get_item_name(sc.item_code)
stockcheck_items.each do |sc|
stock_item= {
count: sc.stock_count.to_s,
item_name: MenuItemInstance.get_item_name(sc.item_code)
}
stock_items.push(stock_item)
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}",
queue: print_settings.printer_name,
unique_code: print_settings.unique_code,
print_copies: print_settings.print_copies,
data: {
stockcheck: stockcheck,
stockcheck_items: stock_items,
checker_name: checker_name,
shop_details: shop_details,
}
stock_items.push(stock_item)
end
)
end
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
queue: print_settings.printer_name,
unique_code: print_settings.unique_code,
print_copies: print_settings.print_copies,
data: {
stockcheck: stockcheck,
stockcheck_items: stock_items,
checker_name: checker_name,
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
#Queue No Print
@@ -262,25 +267,29 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
#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)
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
queue: print_settings.printer_name,
unique_code: print_settings.unique_code,
print_copies: print_settings.print_copies,
data: {
shop_name: shop_detail.name,
name: print_settings.name,
table: table.name,
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")
if Lookup.collection_of('print_settings').none? { |x| x == ["ActionCable", "1"] }
#Use CUPS service
#Generate PDF
#Print
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}",
queue: print_settings.printer_name,
unique_code: print_settings.unique_code,
print_copies: print_settings.print_copies,
data: {
shop_name: shop_detail.name,
name: print_settings.name,
table: table.name,
time: time,
}
)
end
end