print settings ActionCable
This commit is contained in:
@@ -91,61 +91,29 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
|
||||
#Bill Receipt Print
|
||||
def print_receipt_bill(printer_settings, kbz_pay_status, qr_code, cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
if printer_settings
|
||||
if !printer_settings.unique_code.match?(/receiptbillorder/i)
|
||||
if Lookup.collection_of("print_settings").any? { |x| x == ["ReceiptBillA5Pdf", "1"] } #print_settings with name:ReceiptBillA5Pdf
|
||||
pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
|
||||
if Lookup.collection_of('print_settings').none? { |x| x == ["ActionCable", "1"] }
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
if printer_settings
|
||||
if !printer_settings.unique_code.match?(/receiptbillorder/i)
|
||||
if Lookup.collection_of("print_settings").any? { |x| x == ["ReceiptBillA5Pdf", "1"] } #print_settings with name:ReceiptBillA5Pdf
|
||||
pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
|
||||
else
|
||||
pdf = PrintSetting.where("unique_code REGEXP ?", "receipt.*bill.*pdf").first.unique_code.constantize.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
|
||||
end
|
||||
else
|
||||
pdf = PrintSetting.where("unique_code REGEXP ?", "receipt.*bill.*pdf").first.unique_code.constantize.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
|
||||
#doemal online order pdf template
|
||||
pdf = ReceiptBillOrderPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation)
|
||||
end
|
||||
else
|
||||
#doemal online order pdf template
|
||||
pdf = ReceiptBillOrderPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation)
|
||||
|
||||
# print as print copies in printer setting
|
||||
count = printer_settings.print_copies
|
||||
end
|
||||
|
||||
if ENV["SERVER_MODE"] == "cloud"
|
||||
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
|
||||
queue: "Cashier",
|
||||
unique_code: print_settings.unique_code,
|
||||
print_copies: print_settings.print_copies,
|
||||
data: {
|
||||
shop_details: shop_details.as_json,
|
||||
body: { sale_data: sale_data,
|
||||
booking: sale_data.bookings,
|
||||
dining_facility: sale_data.bookings[0].dining_facility.as_json(methods: :type),
|
||||
sale_taxes: sale_data.sale_taxes,
|
||||
latest_order_no: latest_order_no,
|
||||
sale_items: sale_items,
|
||||
precision: print_settings.precision,
|
||||
delimiter: print_settings.delimiter,
|
||||
member_info: member_info,
|
||||
customer_name: customer_name,
|
||||
rebate_amount: rebate_amount,
|
||||
current_balance: balance,
|
||||
card_data: card_data,
|
||||
card_balance_amount: card_balance_amount,
|
||||
discount_price_by_accounts: discount_price_by_accounts,
|
||||
item_price_by_accounts: item_price_by_accounts,
|
||||
sale_payments: sale_data.sale_payments,
|
||||
},
|
||||
footer: { printed_status: printed_status, footer_text: "Thank You! See you Again" }
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
# print as print copies in printer setting
|
||||
count = printer_settings.print_copies
|
||||
|
||||
# override print copies for print worker loop
|
||||
# print_settings.print_copies = 1
|
||||
# print_settings.save!
|
||||
end
|
||||
directory_name = 'public/receipts'
|
||||
Dir.mkdir(directory_name) unless File.exists?(directory_name)
|
||||
Rails.logger.debug "############## dir::" + directory_name
|
||||
directory_name = 'public/receipts'
|
||||
Dir.mkdir(directory_name) unless File.exists?(directory_name)
|
||||
Rails.logger.debug "############## dir::" + directory_name
|
||||
if count == 1
|
||||
filename = directory_name + "/receipt_bill_#{sale_data.receipt_no}.pdf"
|
||||
pdf.render_file filename
|
||||
@@ -169,12 +137,44 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
end
|
||||
end
|
||||
end
|
||||
Rails.logger.debug "############## filename::" + filename
|
||||
return filename, sale_data.receipt_no, cashier_terminal.printer_name
|
||||
|
||||
Rails.logger.debug "############## filename::" + filename
|
||||
return filename, sale_data.receipt_no, cashier_terminal.printer_name
|
||||
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: {
|
||||
shop_details: shop_details.as_json,
|
||||
body: { sale_data: sale_data,
|
||||
booking: sale_data.bookings,
|
||||
dining_facility: sale_data.bookings[0].dining_facility.as_json(methods: :type),
|
||||
sale_taxes: sale_data.sale_taxes,
|
||||
latest_order_no: latest_order_no,
|
||||
sale_items: sale_items,
|
||||
precision: print_settings.precision,
|
||||
delimiter: print_settings.delimiter,
|
||||
member_info: member_info,
|
||||
customer_name: customer_name,
|
||||
rebate_amount: rebate_amount,
|
||||
current_balance: balance,
|
||||
card_data: card_data,
|
||||
card_balance_amount: card_balance_amount,
|
||||
discount_price_by_accounts: discount_price_by_accounts,
|
||||
item_price_by_accounts: item_price_by_accounts,
|
||||
sale_payments: sale_data.sale_payments
|
||||
},
|
||||
footer: {
|
||||
printed_status: printed_status, footer_text: "Thank You! See you Again"
|
||||
}
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
# 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 = StockResultPdf.new(print_settings,stockcheck, stockcheck_items,checker_name, shop_details)
|
||||
pdf.render_file "tmp/print_stock_check_result.pdf"
|
||||
#no print in cloud server
|
||||
@@ -197,37 +197,39 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
end
|
||||
|
||||
#Move Table Print
|
||||
def print_move_table(printer_settings,to,from,shop_detail,date,type,moved_by,order_items,oqs)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
pdf = MoveTablePdf.new(printer_settings,to,from,shop_detail,date,type,moved_by,order_items)
|
||||
pdf.render_file "tmp/print_move_table.pdf"
|
||||
def print_move_table(printer_settings, to, from, shop_detail, date, type, moved_by, order_items, oqs)
|
||||
if Lookup.collection_of('print_settings').none? { |x| x == ["ActionCable", "1"] }
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
pdf = MoveTablePdf.new(printer_settings, to, from, shop_detail, date, type, moved_by, order_items)
|
||||
pdf.render_file "tmp/print_move_table.pdf"
|
||||
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
if oqs.print_copy
|
||||
self.print("tmp/print_move_table.pdf",oqs.printer_name)
|
||||
else
|
||||
print_settings.print_copies = 1
|
||||
print_settings.save!
|
||||
#no print in cloud server
|
||||
self.print("tmp/print_move_table.pdf", oqs.printer_name)
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
if oqs.print_copy
|
||||
self.print("tmp/print_move_table.pdf",oqs.printer_name)
|
||||
else
|
||||
print_settings.print_copies = 1
|
||||
print_settings.save!
|
||||
#no print in cloud server
|
||||
self.print("tmp/print_move_table.pdf", oqs.printer_name)
|
||||
end
|
||||
end
|
||||
else
|
||||
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
|
||||
queue: oqs.station_name,
|
||||
unique_code: print_settings.unique_code,
|
||||
print_copies: print_settings.print_copies,
|
||||
data: {
|
||||
type: type,
|
||||
body: {
|
||||
to: to,
|
||||
from: from,
|
||||
date: date,
|
||||
moved_by: moved_by,
|
||||
order_items: order_items.as_json,
|
||||
},
|
||||
}
|
||||
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
|
||||
queue: oqs.station_name,
|
||||
unique_code: print_settings.unique_code,
|
||||
print_copies: print_settings.print_copies,
|
||||
data: {
|
||||
type: type,
|
||||
body: {
|
||||
to: to,
|
||||
from: from,
|
||||
date: date,
|
||||
moved_by: moved_by,
|
||||
order_items: order_items.as_json,
|
||||
},
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user