add new check-in route

This commit is contained in:
phyusin
2018-11-27 11:56:56 +06:30
parent b152636e1f
commit 17d9b21beb
2 changed files with 25 additions and 9 deletions

View File

@@ -2,8 +2,17 @@ class Api::CheckInProcessController < Api::ApiController
# before_action :authenticate
def check_in_time
if params[:dining_id]
dining_facility = DiningFacility.find(params[:dining_id])
booking = dining_facility.get_current_checkout_booking
dining_facility = DiningFacility.find(params[:dining_id])
if params[:booking_id]
data = Booking.where("dining_facility_id = #{params[:dining_id]} AND booking_id = '#{params[:booking_id]}'")
if data.count > 0
booking = data[0]
else
booking = nil
end
else
booking = dining_facility.get_current_checkout_booking
end
if !booking.nil?
# DiningFacility.check_in_booking(params[:dining_id])
@@ -12,18 +21,23 @@ class Api::CheckInProcessController < Api::ApiController
#Send to background job for processing
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
else
from = ""
end
end
ActionCable.server.broadcast "check_in_booking_channel",table: table,from:from
check_out_time = nil
extra_minutes = nil
alert_time_min = 0
check_in_time = booking.checkin_at.utc.getlocal.strftime("%Y-%m-%d %H:%M")
check_out_time = booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M")
extra_minutes = (booking.checkout_at - booking.reserved_at) / 1.minutes
if booking.checkout_at
check_out_time = booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M")
if booking.reserved_at
extra_minutes = (booking.checkout_at - booking.reserved_at) / 1.minutes
end
end
lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
alert_time_min = 0
if !lookup_checkout_time.empty?
now = Time.now.utc
lookup_checkout_time.each do |checkout_time|
@@ -38,6 +52,7 @@ class Api::CheckInProcessController < Api::ApiController
else
render :json => { :status => true }
end
else
render :json => { :status => false, :error_message => "No current booking!" }
end

View File

@@ -77,6 +77,7 @@ scope "(:locale)", locale: /en|mm/ do
namespace :origami do
get "check_in/:dining_id" => "check_in_process#check_in_time"
get "check_in_time/:dining_id/:booking_id" => "check_in_process#check_in_time"
post "check_in" => "check_in_process#check_in_process"
post "request_time" => "check_in_process#request_time"
post "call_waiter" => "call_waiters#index"