diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index c863029a..773892f3 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -20,7 +20,7 @@ class Origami::HomeController < BaseOrigamiController @tables = Table.unscoped.all.active.order('status desc') @rooms = Room.unscoped.all.active.order('status desc') @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d')) - @orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @status_order = "" @status_sale = "" diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb index e5eb8c3a..739e15d7 100755 --- a/app/models/dining_facility.rb +++ b/app/models/dining_facility.rb @@ -179,14 +179,5 @@ class DiningFacility < ApplicationRecord end end end - - def get_current_booking_status - 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}'").limit(1) #and checkout_at is null - if booking.count > 0 then - return booking[0] - else - return nil - end - end end diff --git a/app/views/api/restaurant/zones/index.json.jbuilder b/app/views/api/restaurant/zones/index.json.jbuilder index bb05fb8f..e4d09977 100755 --- a/app/views/api/restaurant/zones/index.json.jbuilder +++ b/app/views/api/restaurant/zones/index.json.jbuilder @@ -6,7 +6,7 @@ if @zones #List all tables json.tables zone.tables do |table| if table.is_active - booking = table.get_current_booking_status + booking = table.get_current_booking json.id table.id json.name table.name json.status table.status @@ -18,7 +18,7 @@ if @zones json.rooms zone.rooms do |room| if room.is_active - booking = room.get_current_booking_status + booking = room.get_current_booking json.id room.id json.name room.name json.status room.status @@ -32,7 +32,7 @@ if @zones else #list all tables and rooms with out zones json.tables @all_tables do |table| if table.is_active - booking = table.get_current_booking_status + booking = table.get_current_booking json.id table.id json.name table.name json.status table.status @@ -44,7 +44,7 @@ else #list all tables and rooms with out zones json.rooms @all_rooms do |room| if room.is_active - booking = room.get_current_booking_status + booking = room.get_current_booking json.id room.id json.name room.name json.status room.status diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 2bd92cf3..211cc23b 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -146,7 +146,7 @@
<% order_status = "" - sale_order = SaleOrder.find_by_order_id(order) + sale_order = order.sale_orders.first if sale_order unless sale_order.sale_id.nil? sale = Sale.find(sale_order.sale_id)