update for addorder and printer

This commit is contained in:
Thein Lin Kyaw
2019-12-17 15:02:58 +06:30
parent 40ad724e77
commit e6392c3bd4
8 changed files with 193 additions and 336 deletions

View File

@@ -131,60 +131,62 @@ class Origami::AddordersController < BaseOrigamiController
customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
end
@order = Order.new
@order.source = params[:order_source]
@order.order_type = params[:order_type]
@order.customer_id = customer_id
@order.items = items_arr
@order.guest = params[:guest_info]
@order.table_id = params[:table_id] # this is dining facilities's id
@order.new_booking = true
@order.waiters = current_login_employee.name
@order.employee_name = current_login_employee.name
@order.is_extra_time = is_extra_time
@order.extra_time = extra_time
if booking.nil? || booking.sale_id.present? || booking.booking_status == 'moved'
Order.transaction do
@order = Order.new
@order.source = params[:order_source]
@order.order_type = params[:order_type]
@order.customer_id = customer_id
@order.items = items_arr
@order.guest = params[:guest_info]
@order.table_id = params[:table_id] # this is dining facilities's id
@order.new_booking = true
else
@order.new_booking = false
@order.booking_id = booking.booking_id
end
@order.waiters = current_login_employee.name
@order.employee_name = current_login_employee.name
@status, @booking = @order.generate
@order.is_extra_time = is_extra_time
@order.extra_time = extra_time
if @status && @booking
#send order broadcast to order_channel
if @order.table_id.to_i > 0
table = DiningFacility.find(@booking.dining_facility_id)
type = 'order'
from = getCloudDomain #get sub domain in cloud mode
ActionCable.server.broadcast "order_channel", table: table,type:type,from:from
if booking.nil? || booking.sale_id.present? || booking.booking_status == 'moved'
@order.new_booking = true
else
@order.new_booking = false
@order.booking_id = booking.booking_id
end
if params[:order_source] != "quick_service" && params[:order_source] != "food_court"
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"
if @status && @booking && (@order.source == 'quick_service') || (@order.source == 'food_court')
@status, @booking = @order.generate
@status, @sale = Sale.request_bill(@order,current_user,current_login_employee)
# for second display
if @order.source == 'quick_service'
if @status && @booking
#send order broadcast to order_channel
if @order.table_id.to_i > 0
table = DiningFacility.find(@booking.dining_facility_id)
type = 'order'
from = getCloudDomain #get sub domain in cloud mode
ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale",from:from
ActionCable.server.broadcast "order_channel", table: table,type:type,from:from
end
#end
result = {:status=> @status, :data => @sale }
if params[:order_source] != "quick_service" && params[:order_source] != "food_court"
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"
if @status && @booking && (@order.source == 'quick_service') || (@order.source == 'food_court')
@status, @sale = Sale.request_bill(@order,current_user,current_login_employee)
# for second display
if @order.source == 'quick_service'
from = getCloudDomain #get sub domain in cloud mode
ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale",from:from
end
#end
result = {:status=> @status, :data => @sale }
render :json => result.to_json
end
else
result = {:status=> @status, :data => 0 }
render :json => result.to_json
end
else
result = {:status=> @status, :data => 0 }
render :json => result.to_json
end
end
@@ -234,15 +236,9 @@ class Origami::AddordersController < BaseOrigamiController
sidekiq = Lookup.find_by_lookup_type("sidekiq")
if ENV["SERVER_MODE"] != 'cloud'
cup_status = `#{"sudo service cups status"}`
if !check_cup_status(cup_status)
cup_start = `#{"sudo service cups start"}`
cup_status = `#{"sudo service cups status"}`
if !check_cup_status(cup_status)
from = ''
msg = 'Print Error ! Please contact to service'
ActionCable.server.broadcast "call_waiter_channel", table: msg, time:'print_error', from: from
end
if Printer::PrinterWorker.printers.blank?
msg = 'Print Error ! Please contact to service'
ActionCable.server.broadcast "call_waiter_channel", table: msg, time:'print_error', from: ''
end
end