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

@@ -39,7 +39,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
} }
) )
end end
return filename, order_id, oqs.printer_name return filename, order_id, oqs.printer_name
end end
@@ -170,47 +170,51 @@ 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)
#Use CUPS service if Lookup.collection_of('print_settings').none? { |x| x == ["ActionCable", "1"] }
#Generate PDF #Use CUPS service
#Print #Generate PDF
sale_id = booking.sale_id #Print
filename = "tmp/check_in_out_#{sale_id}" + ".pdf" sale_id = booking.sale_id
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
# if order_item[0].price != 0 print_setting = PrintSetting.all
if !print_setting.empty?
print_setting.each do |print_settings| # if order_item[0].price != 0
if print_settings.unique_code == 'CheckInOutPdf' if !print_setting.empty?
pdf = CheckInOutPdf.new(print_settings,booking, table) print_setting.each do |print_settings|
if print_settings.unique_code == 'CheckInOutPdf'
pdf = CheckInOutPdf.new(print_settings,booking, table)
end
end end
end end
end
pdf.render_file filename pdf.render_file filename
# Must be one print # Must be one print
if print_settings.print_copies == 0 if print_settings.print_copies == 0
print_settings.print_copies = 1 print_settings.print_copies = 1
print_settings.save! print_settings.save!
end end
# print_settings.print_copies = 1 # print_settings.print_copies = 1
# print_settings.save! # print_settings.save!
#no print in cloud server #no print in cloud server
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
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 end

View File

@@ -167,33 +167,38 @@ 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|
stock_item= { stock_item= {
count: sc.stock_count.to_s, count: sc.stock_count.to_s,
item_name: MenuItemInstance.get_item_name(sc.item_code) 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 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 end
#Queue No Print #Queue No Print
@@ -262,25 +267,29 @@ 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)
#Use CUPS service if Lookup.collection_of('print_settings').none? { |x| x == ["ActionCable", "1"] }
#Generate PDF #Use CUPS service
#Print #Generate PDF
pdf = CallWaiterPdf.new(printer_settings,table,time,shop_detail) #Print
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}", pdf = CallWaiterPdf.new(printer_settings,table,time,shop_detail)
queue: print_settings.printer_name,
unique_code: print_settings.unique_code, pdf.render_file "tmp/print_call_waiter.pdf"
print_copies: print_settings.print_copies, #no print in cloud server
data: { if ENV["SERVER_MODE"] != "cloud"
shop_name: shop_detail.name, self.print("tmp/print_call_waiter.pdf")
name: print_settings.name, end
table: table.name, else
time: time, ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
} queue: print_settings.printer_name,
) unique_code: print_settings.unique_code,
pdf.render_file "tmp/print_call_waiter.pdf" print_copies: print_settings.print_copies,
#no print in cloud server data: {
if ENV["SERVER_MODE"] != "cloud" shop_name: shop_detail.name,
self.print("tmp/print_call_waiter.pdf") name: print_settings.name,
table: table.name,
time: time,
}
)
end end
end end

View File

@@ -1274,7 +1274,7 @@
data: "remark="+ remark + "&sale_id=" + sale_id+ "&access_code=" + access_code, data: "remark="+ remark + "&sale_id=" + sale_id+ "&access_code=" + access_code,
success: function (result) { success: function (result) {
if (!$('#print_settings').data('action-cable')) { if (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade // For Server Print - from jade
if ($("#server_mode").val() == "cloud") { if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){ if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url); code2lab.printFile(result.filepath.substr(6), result.printer_url);