From 13e11bf77788f04e2a4474197358eb2d69062540 Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Thu, 7 Jun 2018 16:11:34 +0630 Subject: [PATCH] Cloud mode in reprint --- app/controllers/origami/payments_controller.rb | 11 ++++++++++- app/views/origami/home/show.html.erb | 2 +- app/views/origami/sales/show.html.erb | 15 +++++++++++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 0e6709d8..3082d0e3 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -452,7 +452,16 @@ 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, "Re-print",current_balance,card_data) + filename, receipt_no, cashier_printer = 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, "Re-print",current_balance,card_data) + + result = { + :filepath => filename, + :printer_model => print_settings.brand_name, + :printer_url => print_settings.api_settings + } + + # Mobile Print + render :json => result.to_json end end diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 986bed5f..aef45973 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -776,7 +776,6 @@ if (isConfirm) { var sale_id = $('#sale_id').val(); var ajax_url = "/origami/sale/" + sale_id + "/first_bill"; - var server_mode = $.ajax({ type: "GET", @@ -788,6 +787,7 @@ // For Server Print - from jade if ($("#server_mode").val() == "cloud") { + alert("Hello"); code2lab.printFile(result.filepath.substr(6), result.printer_url); } location.reload(); diff --git a/app/views/origami/sales/show.html.erb b/app/views/origami/sales/show.html.erb index fe99ecf5..55ed2203 100755 --- a/app/views/origami/sales/show.html.erb +++ b/app/views/origami/sales/show.html.erb @@ -18,6 +18,7 @@ Orders + ">
@@ -423,8 +424,18 @@ $(document).on('click', '.access_modal', function(event){ $('#re-print').click(function() { var sale_id = $('#sale_id').val(); - window.location.href = '/origami/'+ sale_id + "/reprint" - + var ajax_url = '/origami/'+ sale_id + "/reprint" // return false; + $.ajax({ + type: "GET", + url: ajax_url, + success: function (result) { + // For Server Print - from jade + if ($("#server_mode").val() == "cloud") { + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } + location.reload(); + } + }); });