From 671aa155cdb9c0e0e6875132dd12f687ee727d80 Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Mon, 13 Aug 2018 14:37:41 +0630 Subject: [PATCH] Edit for checkin pdf --- app/controllers/api/bill_controller.rb | 5 ++++- app/controllers/api/check_in_process_controller.rb | 7 +++++-- app/controllers/origami/check_in_process_controller.rb | 6 +++++- app/controllers/origami/request_bills_controller.rb | 5 ++++- app/models/printer/order_queue_printer.rb | 4 ++-- 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index e1eff050..85ace00d 100755 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -63,6 +63,9 @@ class Api::BillController < Api::ApiController #check checkInOut pdf print check_booking = Booking.find_by_sale_id(@sale_id) checkout_time = Lookup.collection_of('checkout_time') + terminal_id = DiningFacility.find_by_id(check_booking.dining_facility_id) + terminal = CashierTerminal.find_by_id(terminal_id.zone_id) + if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server unique_code = "CheckInOutPdf" @@ -72,7 +75,7 @@ class Api::BillController < Api::ApiController order_queue_printer = Printer::OrderQueuePrinter.new(printer) if !printer.nil? - order_queue_printer.print_check_in_out(printer, check_booking, table) + order_queue_printer.print_check_in_out(printer,terminal, check_booking, table) end end diff --git a/app/controllers/api/check_in_process_controller.rb b/app/controllers/api/check_in_process_controller.rb index 1b8650f1..01985d89 100644 --- a/app/controllers/api/check_in_process_controller.rb +++ b/app/controllers/api/check_in_process_controller.rb @@ -76,9 +76,12 @@ class Api::CheckInProcessController < Api::ApiController dining_facility.status = "occupied" dining_facility.save! end + terminal_id = DiningFacility.find_by_id(booking.dining_facility_id) + terminal = CashierTerminal.find_by_id(terminal_id.zone_id) + if ENV["SERVER_MODE"] != "cloud" #no print in cloud server - + unique_code = "CheckInOutPdf" printer = PrintSetting.find_by_unique_code(unique_code) @@ -86,7 +89,7 @@ class Api::CheckInProcessController < Api::ApiController order_queue_printer = Printer::OrderQueuePrinter.new(printer) if !printer.nil? - order_queue_printer.print_check_in_out(printer, booking, dining_facility) + order_queue_printer.print_check_in_out(printer, terminal, booking, dining_facility) end end render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") } diff --git a/app/controllers/origami/check_in_process_controller.rb b/app/controllers/origami/check_in_process_controller.rb index 3d6b6d14..b6e67943 100644 --- a/app/controllers/origami/check_in_process_controller.rb +++ b/app/controllers/origami/check_in_process_controller.rb @@ -4,6 +4,7 @@ class Origami::CheckInProcessController < BaseOrigamiController lookup_checkout_time = Lookup.collection_of("checkout_time") today = Time.now.utc.getlocal checkout_at = Time.now.utc.getlocal + if !lookup_checkout_time.empty? lookup_checkout_time.each do |checkout_time| arr_time = checkout_time[0].split("-") @@ -26,6 +27,9 @@ class Origami::CheckInProcessController < BaseOrigamiController @booking = Booking.create({:dining_facility_id => params[:dining_id],:type => "TableBooking", :checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name }) + terminal_id = DiningFacility.find_by_id(@booking.dining_facility_id) + terminal = CashierTerminal.find_by_id(terminal_id.zone_id) + if @booking.save! @dining_facility.status = "occupied" @dining_facility.save! @@ -43,7 +47,7 @@ class Origami::CheckInProcessController < BaseOrigamiController order_queue_printer = Printer::OrderQueuePrinter.new(printer) if !printer.nil? - order_queue_printer.print_check_in_out(printer, booking, table) + order_queue_printer.print_check_in_out(printer, terminal, booking, table) end end end diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 5b71141e..fca27cb8 100755 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -70,6 +70,9 @@ class Origami::RequestBillsController < ApplicationController #check checkInOut pdf print check_booking = Booking.find_by_sale_id(@sale_id) checkout_time = Lookup.collection_of('checkout_time') + terminal_id = DiningFacility.find_by_id(check_booking.dining_facility_id) + terminal = CashierTerminal.find_by_id(terminal_id.zone_id) + if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server unique_code = "CheckInOutPdf" printer = PrintSetting.find_by_unique_code(unique_code) @@ -78,7 +81,7 @@ class Origami::RequestBillsController < ApplicationController order_queue_printer = Printer::OrderQueuePrinter.new(printer) if !printer.nil? - order_queue_printer.print_check_in_out(printer, check_booking, table) + order_queue_printer.print_check_in_out(printer, terminal, check_booking, table) end end end diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index 504dfab2..1d1d9d7f 100755 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -299,7 +299,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker end # Check in-out time - def print_check_in_out(print_settings,booking, table) + def print_check_in_out(print_settings, terminal, booking, table) #Use CUPS service #Generate PDF #Print @@ -330,7 +330,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker #no print in cloud server if ENV["SERVER_MODE"] != "cloud" - self.print(filename, print_settings.printer_name) + self.print(filename, terminal.printer_name) end end end