From 9bf4047548d782fd6236587296412069bc2e4121 Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Wed, 4 Apr 2018 10:33:31 +0630 Subject: [PATCH] Add MoveTablePdf with multiple printer --- .../origami/movetable_controller.rb | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/app/controllers/origami/movetable_controller.rb b/app/controllers/origami/movetable_controller.rb index 09d9669e..20aaf0c5 100755 --- a/app/controllers/origami/movetable_controller.rb +++ b/app/controllers/origami/movetable_controller.rb @@ -56,19 +56,19 @@ class Origami::MovetableController < BaseOrigamiController end end - def moving - change_to = params[:change_to] #new - change_from = params[:change_from] #original - bookings = Booking.where('dining_facility_id=?',change_from) + def moving + change_to = params[:change_to] #new + change_from = params[:change_from] #original + bookings = Booking.where('dining_facility_id=?',change_from) - booking_array = Array.new - bookings.each do | booking | - if booking.sale_id.nil? && booking.booking_status != 'moved' - booking_array.push(booking) - end - end + booking_array = Array.new + bookings.each do | booking | + if booking.sale_id.nil? && booking.booking_status != 'moved' + booking_array.push(booking) + end + end - @get_type = Booking.update_dining_facility(booking_array,change_to,change_from) + @get_type = Booking.update_dining_facility(booking_array,change_to,change_from) # get printer info @from = (DiningFacility.find(change_from)).name @@ -78,9 +78,16 @@ class Origami::MovetableController < BaseOrigamiController @date = DateTime.now @shop = Shop::ShopDetail unique_code = "MoveTablePdf" - print_settings = PrintSetting.find_by_unique_code(unique_code) - printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_move_table(print_settings,@to,@from ,@shop,@date,@type,@moved_by) - end - + pdf_no = PrintSetting.where(:unique_code => unique_code).count + #print_settings = PrintSetting.find_by_unique_code(unique_code) + printer_array = [] + printer_array = PrintSetting.where(:unique_code => unique_code) + for i in 0..pdf_no + if i != pdf_no + print_settings = printer_array[i] + printer = Printer::ReceiptPrinter.new(print_settings) + printer.print_move_table(print_settings,@to,@from ,@shop,@date,@type,@moved_by) + end + end + end end