Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
Aung Myo
2018-08-14 17:21:23 +06:30
6 changed files with 31 additions and 22 deletions

View File

@@ -63,6 +63,9 @@ class Api::BillController < Api::ApiController
#check checkInOut pdf print #check checkInOut pdf print
check_booking = Booking.find_by_sale_id(@sale_id) check_booking = Booking.find_by_sale_id(@sale_id)
checkout_time = Lookup.collection_of('checkout_time') checkout_time = Lookup.collection_of('checkout_time')
terminal = DiningFacility.find_by_id(check_booking.dining_facility_id)
cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id)
if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server
unique_code = "CheckInOutPdf" unique_code = "CheckInOutPdf"
@@ -72,7 +75,7 @@ class Api::BillController < Api::ApiController
order_queue_printer = Printer::OrderQueuePrinter.new(printer) order_queue_printer = Printer::OrderQueuePrinter.new(printer)
if !printer.nil? if !printer.nil?
order_queue_printer.print_check_in_out(printer, check_booking, table) order_queue_printer.print_check_in_out(printer,cashier_terminal , check_booking, table)
end end
end end

View File

@@ -76,6 +76,8 @@ class Api::CheckInProcessController < Api::ApiController
dining_facility.status = "occupied" dining_facility.status = "occupied"
dining_facility.save! dining_facility.save!
end end
terminal = DiningFacility.find_by_id(booking.dining_facility_id)
cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id)
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
@@ -86,7 +88,7 @@ class Api::CheckInProcessController < Api::ApiController
order_queue_printer = Printer::OrderQueuePrinter.new(printer) order_queue_printer = Printer::OrderQueuePrinter.new(printer)
if !printer.nil? if !printer.nil?
order_queue_printer.print_check_in_out(printer, booking, dining_facility) order_queue_printer.print_check_in_out(printer, cashier_terminal, booking, dining_facility)
end end
end end
render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") } render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") }

View File

@@ -4,6 +4,7 @@ class Origami::CheckInProcessController < BaseOrigamiController
lookup_checkout_time = Lookup.collection_of("checkout_time") lookup_checkout_time = Lookup.collection_of("checkout_time")
today = Time.now.utc.getlocal today = Time.now.utc.getlocal
checkout_at = Time.now.utc.getlocal checkout_at = Time.now.utc.getlocal
if !lookup_checkout_time.empty? if !lookup_checkout_time.empty?
lookup_checkout_time.each do |checkout_time| lookup_checkout_time.each do |checkout_time|
arr_time = checkout_time[0].split("-") arr_time = checkout_time[0].split("-")
@@ -26,26 +27,28 @@ class Origami::CheckInProcessController < BaseOrigamiController
@booking = Booking.create({:dining_facility_id => params[:dining_id],:type => "TableBooking", @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 }) :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 })
cashier_terminal = CashierTerminal.find_by_id(@dining_facility.zone_id)
if @booking.save! if @booking.save!
@dining_facility.status = "occupied" @dining_facility.status = "occupied"
@dining_facility.save! @dining_facility.save!
end end
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
printer = PrintSetting.find_by_unique_code("CheckInOutPdf")
unique_code = "CheckInOutPdf"
booking = Booking.find_by_booking_id(@booking.booking_id)
table = DiningFacility.find(params[:dining_id])
# print when complete click
order_queue_printer = Printer::OrderQueuePrinter.new(printer)
if !printer.nil?
order_queue_printer.print_check_in_out(printer, cashier_terminal, booking, table)
end
end
end end
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
printer = PrintSetting.find_by_unique_code("CheckInOutPdf")
unique_code = "CheckInOutPdf"
booking = Booking.find_by_booking_id(@booking.booking_id)
table = DiningFacility.find(params[:dining_id])
# print when complete click
order_queue_printer = Printer::OrderQueuePrinter.new(printer)
if !printer.nil?
order_queue_printer.print_check_in_out(printer, booking, table)
end
end
end end
respond = {:status => 'ok'} respond = {:status => 'ok'}
respond_to do |format| respond_to do |format|

View File

@@ -70,6 +70,9 @@ class Origami::RequestBillsController < ApplicationController
#check checkInOut pdf print #check checkInOut pdf print
check_booking = Booking.find_by_sale_id(@sale_id) check_booking = Booking.find_by_sale_id(@sale_id)
checkout_time = Lookup.collection_of('checkout_time') checkout_time = Lookup.collection_of('checkout_time')
terminal = DiningFacility.find_by_id(check_booking.dining_facility_id)
cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id)
if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server
unique_code = "CheckInOutPdf" unique_code = "CheckInOutPdf"
printer = PrintSetting.find_by_unique_code(unique_code) printer = PrintSetting.find_by_unique_code(unique_code)
@@ -78,7 +81,7 @@ class Origami::RequestBillsController < ApplicationController
order_queue_printer = Printer::OrderQueuePrinter.new(printer) order_queue_printer = Printer::OrderQueuePrinter.new(printer)
if !printer.nil? if !printer.nil?
order_queue_printer.print_check_in_out(printer, check_booking, table) order_queue_printer.print_check_in_out(printer, cashier_terminal, check_booking, table)
end end
end end
end end

View File

@@ -299,7 +299,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
end end
# Check in-out time # Check in-out time
def print_check_in_out(print_settings,booking, table) def print_check_in_out(print_settings, cashier_terminal, booking, table)
#Use CUPS service #Use CUPS service
#Generate PDF #Generate PDF
#Print #Print
@@ -330,7 +330,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
#no print in cloud server #no print in cloud server
if ENV["SERVER_MODE"] != "cloud" if ENV["SERVER_MODE"] != "cloud"
self.print(filename, print_settings.printer_name) self.print(filename, cashier_terminal.printer_name)
end end
end end
end end

View File

@@ -163,9 +163,7 @@ class Sale < ApplicationRecord
booking.sale_id = self.id booking.sale_id = self.id
if !booking.checkout_at.nil? if !booking.checkout_at.nil?
if booking.checkout_at < Time.now.utc.getlocal
booking.checkout_at = Time.now.utc.getlocal booking.checkout_at = Time.now.utc.getlocal
end
else else
booking.checkout_at = Time.now.utc.getlocal booking.checkout_at = Time.now.utc.getlocal
end end