diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index e5c0e741..348a518a 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -464,7 +464,7 @@ class Origami::PaymentsController < BaseOrigamiController # Re-call Sale Data saleObj = Sale.find(sale_id) - if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server unique_code = "ReceiptBillPdf" customer= Customer.find(saleObj.customer_id) @@ -478,7 +478,17 @@ class Origami::PaymentsController < BaseOrigamiController discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "FOC",nil,nil) + + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "FOC",nil,nil) + result = { + :status => true, + :filepath => filename, + :printer_model => print_settings.brand_name, + :printer_url => print_settings.api_settings + } + + # Mobile Print + render :json => result.to_json if params[:type] == "quick_service" booking = Booking.find_by_sale_id(sale_id) @@ -492,7 +502,7 @@ class Origami::PaymentsController < BaseOrigamiController Order.pay_process_order_queue(order.order_id,table_id) end end - end + # end end end @@ -538,6 +548,15 @@ class Origami::PaymentsController < BaseOrigamiController printer = Printer::ReceiptPrinter.new(print_settings) printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name) - render :json => {status: true} + result = { + :status => true, + :filepath => filename, + :printer_model => print_settings.brand_name, + :printer_url => print_settings.api_settings + } + + # Mobile Print + render :json => result.to_json + # render :json => {status: true} end end \ No newline at end of file diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index 00f9d76b..74e495ca 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -87,8 +87,6 @@ class Origami::VoidController < BaseOrigamiController if bookings[0].dining_facility_id.to_i>0 table = DiningFacility.find(bookings[0].dining_facility_id) end - - end if bookings[0].dining_facility_id.to_i > 0 @@ -100,7 +98,7 @@ class Origami::VoidController < BaseOrigamiController end - if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server unique_code = "ReceiptBillPdf" customer= Customer.find(sale.customer_id) @@ -120,9 +118,17 @@ class Origami::VoidController < BaseOrigamiController item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) - printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil) - end + printer = Printer::ReceiptPrinter.new(print_settings) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil) + result = { + :filepath => filename, + :printer_model => print_settings.brand_name, + :printer_url => print_settings.api_settings + } + + # Mobile Print + render :json => result.to_json + # end #end print diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 85fdf585..1251e529 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -726,9 +726,9 @@ createReceiptNoInFirstBillData(receipt_no,""); // For Server Print - from jade - // if ($("#server_mode").val() == "cloud") { + if ($("#server_mode").val() == "cloud") { code2lab.printFile(result.filepath, result.printer_url); - // } + } // console.log(result); // code2lab.printBill(result.filepath, result.printer_model, result.printer_url); @@ -920,8 +920,12 @@ type: 'POST', url: ajax_url, data: "remark="+ remark + "&sale_id=" + sale_id, - success: function () { - window.location.href = '/origami/'; + success: function (result) { + // For Server Print - from jade + if ($("#server_mode").val() == "cloud") { + code2lab.printFile(result.filepath, result.printer_url); + } + window.location.href = '/origami/'; } }); } diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 457bd6ab..e79ab813 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -420,11 +420,11 @@