move whole table

This commit is contained in:
Nweni
2017-06-21 05:36:58 +06:30
parent f69bee9b03
commit fa309fb89a
12 changed files with 558 additions and 8 deletions

View File

@@ -10,6 +10,19 @@ class Booking < ApplicationRecord
has_many :booking_orders
has_many :orders, :through => :booking_orders
def self.update_dining_facility(booking_arr, newd, old)
booking_arr.each do |booking|
booking.dining_facility_id = newd
booking.save
end
new_dining = DiningFacility.find(newd)
new_dining.make_occupied
old_dining = DiningFacility.find(old)
old_dining.make_available
return new_dining.type
end
private
def generate_custom_id
self.booking_id = SeedGenerator.generate_id(self.class.name, "BKI")

View File

@@ -8,6 +8,16 @@ class DiningFacility < ApplicationRecord
scope :active, -> {where(is_active: true)}
def make_available
self.status = 'available'
self.save
end
def make_occupied
self.status = 'occupied'
self.save
end
def get_current_booking
puts "enter booking"
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1)