move table
This commit is contained in:
@@ -12,10 +12,27 @@ class Booking < ApplicationRecord
|
||||
scope :active, -> {where("booking_status != 'moved'")}
|
||||
|
||||
def self.update_dining_facility(booking_arr, newd, old)
|
||||
booking_arr.each do |booking|
|
||||
booking.dining_facility_id = newd
|
||||
booking.save
|
||||
end
|
||||
table = DiningFacility.find(newd)
|
||||
exist = table.get_booking
|
||||
if exist
|
||||
# order exists
|
||||
booking_arr.each do |booking|
|
||||
booking.dining_facility_id = newd
|
||||
booking.booking_status = 'moved'
|
||||
booking.save
|
||||
booking.booking_orders.each do |bo|
|
||||
bo.booking_id = exist.booking_id
|
||||
bo.save
|
||||
end
|
||||
end
|
||||
else
|
||||
# new table
|
||||
booking_arr.each do |booking|
|
||||
booking.dining_facility_id = newd
|
||||
booking.save
|
||||
end
|
||||
end
|
||||
|
||||
new_dining = DiningFacility.find(newd)
|
||||
new_dining.make_occupied
|
||||
old_dining = DiningFacility.find(old)
|
||||
|
||||
@@ -6,7 +6,7 @@ class Customer < ApplicationRecord
|
||||
has_many :orders
|
||||
has_many :sales
|
||||
|
||||
validates_presence_of :name, :contact_no, :email,:company,:card_no
|
||||
validates_presence_of :name, :contact_no, :email,:card_no
|
||||
validates :contact_no, uniqueness: true
|
||||
validates :email, uniqueness: true
|
||||
validates :card_no, uniqueness: true
|
||||
@@ -34,7 +34,7 @@ class Customer < ApplicationRecord
|
||||
end
|
||||
|
||||
return response;
|
||||
|
||||
|
||||
end
|
||||
|
||||
def self.get_membership_transactions(customer)
|
||||
@@ -58,13 +58,13 @@ class Customer < ApplicationRecord
|
||||
end
|
||||
|
||||
return response;
|
||||
|
||||
|
||||
end
|
||||
|
||||
def self.search(search)
|
||||
if search
|
||||
# find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"])
|
||||
where("name LIKE ? OR contact_no LIKE ? OR card_no LIKE ?", "%#{search}%", "%#{search}%", "%#{search}%",)
|
||||
where("name LIKE ? OR contact_no LIKE ? OR card_no LIKE ?", "%#{search}%", "%#{search}%", "%#{search}%",)
|
||||
else
|
||||
find(:all)
|
||||
end
|
||||
@@ -80,8 +80,8 @@ class Customer < ApplicationRecord
|
||||
|
||||
end
|
||||
|
||||
WALKIN = "CUS-000000000001"
|
||||
TAKEAWAY = "CUS-000000000002"
|
||||
WALKIN = "CUS-000000000001"
|
||||
TAKEAWAY = "CUS-000000000002"
|
||||
|
||||
private
|
||||
def generate_custom_id
|
||||
|
||||
@@ -20,6 +20,8 @@ class DiningFacility < ApplicationRecord
|
||||
|
||||
def get_booking
|
||||
booking = self.get_current_booking
|
||||
puts "is bookig?"
|
||||
puts booking
|
||||
if booking
|
||||
if booking.dining_facility_id.to_i == self.id
|
||||
if booking.booking_status == 'assign'
|
||||
|
||||
Reference in New Issue
Block a user