add channel for checkin process

This commit is contained in:
phyusin
2017-12-13 15:58:44 +06:30
parent 5ba010c1e6
commit 211db16311
8 changed files with 81 additions and 4 deletions

View File

@@ -96,4 +96,26 @@ class DiningFacility < ApplicationRecord
end
end
end
def self.get_checkin_booking
bookings = Booking.where("booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null")
arr_booking = Array.new
if bookings
bookings.each do |booking|
now = Time.now.utc.getlocal
hr = (now.strftime("%H").to_i).to_int
min = (now.strftime("%M").to_i).to_int
if !booking.checkout_at.nil?
checkout_at = booking.checkout_at.utc.getlocal
checkout_at_hr = (checkout_at.strftime("%H").to_i).to_int
checkout_at_min = (checkout_at.strftime("%M").to_i).to_int
checkout_at_min -= min
if (checkout_at_hr <= hr) && (checkout_at_min <= 15)
arr_booking.push({'table_id' => booking.dining_facility_id})
end
end
end
end
return arr_booking
end
end