diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index c446af72..06167bb5 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -28,8 +28,21 @@ class Origami::PaymentsController < BaseOrigamiController end if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf # Print for First Bill to Customer unique_code = "ReceiptBillPdf" + if !receipt_bill_a5_pdf.empty? + receipt_bill_a5_pdf.each do |receipt_bilA5| + if receipt_bilA5[0] == 'ReceiptBillA5Pdf' + if receipt_bilA5[1] == '1' + unique_code = "ReceiptBillA5Pdf" + else + unique_code = "ReceiptBillPdf" + end + end + end + end + #shop detail shop_details = Shop::ShopDetail # customer= Customer.where('customer_id=' +.customer_id) @@ -117,7 +130,20 @@ class Origami::PaymentsController < BaseOrigamiController # For Print if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf unique_code = "ReceiptBillPdf" + if !receipt_bill_a5_pdf.empty? + receipt_bill_a5_pdf.each do |receipt_bilA5| + if receipt_bilA5[0] == 'ReceiptBillA5Pdf' + if receipt_bilA5[1] == '1' + unique_code = "ReceiptBillA5Pdf" + else + unique_code = "ReceiptBillPdf" + end + end + end + end + customer= Customer.find(saleObj.customer_id) # get member information @@ -150,9 +176,9 @@ class Origami::PaymentsController < BaseOrigamiController discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, print_copies, 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, "Paid",current_balance,card_data) + 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, "Paid",current_balance,card_data) - render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :count => print_copies, :printer_name => printer_name}) + render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name}) if params[:type] == "quick_service" booking = Booking.find_by_sale_id(sale_id) @@ -440,20 +466,30 @@ class Origami::PaymentsController < BaseOrigamiController end #print function for receipt - def print - # byebug + def print filename = params[:filename] - receipt_no = parmas[:receipt_no] - print_copies = params[:print_copies] + receipt_no = params[:receipt_no] printer_name = params[:printer_name] - puts "print params" - puts params - - print_receipt_pdf(filename,receipt_no,print_copies,printer_name) - - redirect_to origami_path - # render json: JSON.generate({:status => true}) + receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf + unique_code = "ReceiptBillPdf" + if !receipt_bill_a5_pdf.empty? + receipt_bill_a5_pdf.each do |receipt_bilA5| + if receipt_bilA5[0] == 'ReceiptBillA5Pdf' + if receipt_bilA5[1] == '1' + unique_code = "ReceiptBillA5Pdf" + else + unique_code = "ReceiptBillPdf" + end + end + end + end + # get printer info + print_settings=PrintSetting.find_by_unique_code(unique_code) + printer = Printer::ReceiptPrinter.new(print_settings) + printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name) + + render :json => {status: true} end #Shop Name in Navbor diff --git a/app/models/ability.rb b/app/models/ability.rb index 33372ac9..29f66d34 100755 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -65,7 +65,8 @@ class Ability can :create, :payment can :reprint, :payment can :rounding_adj, :payment - can :foc, :payment + can :foc, :payment + can :print, :payment can :move_dining, :movetable can :moving, :movetable @@ -122,6 +123,7 @@ class Ability can :create, :payment can :reprint, :payment can :rounding_adj, :payment + can :print, :payment can :move_dining, :movetable can :moving, :movetable @@ -180,6 +182,7 @@ class Ability can :show, :payment can :reprint, :payment can :rounding_adj, :payment + can :print, :payment can :manage, Commission can :manage, Commissioner diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index dac1778f..d544c908 100755 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -218,7 +218,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker count -= 1 end until count == 0 - return filename, sale_data.receipt_no, count, cashier_terminal.printer_name + return filename, sale_data.receipt_no, cashier_terminal.printer_name end # stock check @@ -260,16 +260,21 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker #print receipt pdf from js def print_receipt_pdf(filename,receipt_no,print_copies,printer_name) - begin - if print_copies == 1 - self.print("public"+filename, cashier_terminal.printer_name) - else - filename = "public/receipts/receipt_bill_#{receipt_no}_#{print_copies}.pdf" - self.print(filename, cashier_terminal.printer_name) - end + count = print_copies.to_i + # if count == 0 + # self.print("public"+filename, printer_name) + # else + begin + if count == 1 + self.print("public"+filename, printer_name) + else + filename = "public/receipts/receipt_bill_#{receipt_no}_#{count}.pdf" + self.print(filename, printer_name) + end - print_copies -= 1 - end until print_copies == 0 + count -= 1 + end until count == 0 + # end end end diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index d1ef34b4..6c467d66 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -1,4 +1,4 @@ -
+
@@ -387,7 +387,7 @@
-