Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into sqa-1804-001

This commit is contained in:
Aung Myo
2018-05-21 13:05:09 +06:30
28 changed files with 721 additions and 511 deletions

View File

@@ -181,6 +181,12 @@ puts params[:id]
@status, @booking = @order.generate
if @status && @booking
if params[:order_source] != "quick_service"
process_order_queue(@order.order_id,@order.table_id,@order.source)
end
end
# Order.send_customer_view(@booking)
if current_user.role != "waiter" && params[:create_type] == "create_pay"
@@ -188,8 +194,12 @@ puts params[:id]
@status, @sale = Sale.request_bill(@order,current_user,current_login_employee)
# for second display
#if ENV["SERVER_MODE"] != 'cloud'
ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale"
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
from = ""
end
ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale",from:from
#end
result = {:status=> @status, :data => @sale }
render :json => result.to_json
@@ -240,6 +250,81 @@ puts params[:id]
return false
end
end
def process_order_queue(order_id,table_id,order_source)
print_status = nil
cup_status = nil
#Send to background job for processing
order = Order.find(order_id)
sidekiq = Lookup.find_by_lookup_type("sidekiq")
if ENV["SERVER_MODE"] != 'cloud'
cup_status = `#{"sudo service cups status"}`
print_status = check_cup_status(cup_status)
end
if print_status
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(order_id, table_id)
else
if order
oqs = OrderQueueStation.new
oqs.process_order(order, table_id, order_source)
end
# assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
else
if ENV["SERVER_MODE"] != 'cloud'
cup_start = `#{"sudo service cups start"}`
cup_status = `#{"sudo service cups status"}`
print_status = check_cup_status(cup_status)
end
if print_status
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(order_id, table_id)
else
if order
oqs = OrderQueueStation.new
oqs.process_order(order, table_id, order_source)
end
# assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
else
if ENV["SERVER_MODE"] != 'cloud'
from = ""
msg = ' Print Error ! Please contact to service'
ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error',from:from
end
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(order_id, table_id)
else
if order
oqs = OrderQueueStation.new
oqs.process_order(order, table_id, order_source)
end
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
from = ""
end
assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from
end
end
end
end
def check_cup_status(status)
if status.include? "Active: active (running)" || "Active: active (exited)" #"Cup Server is already running"
return true
end
return false
end
private

View File

@@ -13,8 +13,12 @@ class Origami::SecondDisplayController < BaseOrigamiController
else
tax_profiles = nil
end
#if ENV["SERVER_MODE"] != 'cloud'
ActionCable.server.broadcast "second_display_view_channel",data: params[:data],tax_profiles: tax_profiles,status:params[:status]
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
from = ""
end
ActionCable.server.broadcast "second_display_view_channel",data: params[:data],tax_profiles: tax_profiles,status:params[:status],from:from
# end
end
#Shop Name in Navbor

View File

@@ -337,9 +337,13 @@ class Origami::SplitBillController < BaseOrigamiController
end
Promotion.promo_activate(sale)
#if ENV["SERVER_MODE"] != 'cloud'
ActionCable.server.broadcast "bill_channel",table: table
#end
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
from = ""
end
ActionCable.server.broadcast "bill_channel",table: table,from:from
render :json => { status: status }
else
render :json => { status: false, error_message: 'No Current Open Shift!'}