diff --git a/app/controllers/foodcourt/food_court_controller.rb b/app/controllers/foodcourt/food_court_controller.rb index 3010fafe..84ec921c 100644 --- a/app/controllers/foodcourt/food_court_controller.rb +++ b/app/controllers/foodcourt/food_court_controller.rb @@ -35,12 +35,13 @@ class Foodcourt::FoodCourtController < ApplicationController end end end - @app_order_new_count =Booking.joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id") + @app_order_new_count = Booking.select("bookings.*,customers.*") + .joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id") .joins("JOIN orders ON orders.order_id=booking_orders.order_id") .joins("JOIN order_items ON orders.order_id=order_items.order_id") .joins("JOIN customers ON orders.customer_id=customers.customer_id") - .where("orders.source='app' and bookings.shop_code='#{Shop.current_shop.shop_code}' and bookings.booking_status='assign'").uniq.length - puts @app_order_new_count + .where("orders.source='app' and bookings.shop_code='#{Shop.current_shop.shop_code}' and DATE(bookings.created_at) = '#{Date.today}' and bookings.booking_status='assign'").uniq.length + render "foodcourt/addorders/detail" end diff --git a/app/controllers/foodcourt/orders_controller.rb b/app/controllers/foodcourt/orders_controller.rb index ad6549a7..d0eafc62 100755 --- a/app/controllers/foodcourt/orders_controller.rb +++ b/app/controllers/foodcourt/orders_controller.rb @@ -62,18 +62,19 @@ class Foodcourt::OrdersController < BaseFoodcourtController .where("orders.source='app' and bookings.booking_id='#{params[:booking_id]}'").first @customer_id =@booking.customer_id @booking_id =@booking.booking_id + @order_id =@booking.order_id end @bookings = Booking.select("bookings.*,customers.*") .joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id") .joins("JOIN orders ON orders.order_id=booking_orders.order_id") .joins("JOIN order_items ON orders.order_id=order_items.order_id") .joins("JOIN customers ON orders.customer_id=customers.customer_id") - .where("orders.source='app' and DATE(bookings.created_at) = '#{Date.today}'").order("bookings.created_at desc").uniq + .where("orders.source='app' and DATE(bookings.created_at) = '#{Date.today}' and bookings.shop_code='#{Shop.current_shop.shop_code}'").order("bookings.created_at desc").uniq end def completed customer =Customer.find_by_customer_id(params[:customer_id]) phone_number =customer.contact_no - if Order.send_message(phone_number,params[:booking_id]) + if Order.send_message(phone_number,params[:order_id]) booking =Booking.find(params[:booking_id]) booking.booking_status ='completed' booking.save! diff --git a/app/models/order.rb b/app/models/order.rb index 9c05ec85..c0fc7b4b 100755 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -591,8 +591,8 @@ class Order < ApplicationRecord Rails.logger.debug '...... order sync completed .....' end end - def self.send_message(phone, booking_id) - url = "http://smspoh.com/api/http/send?key=5QfyN0OtGsFXnOqwtpVAGZCyPGP28nbX_Nm_oPsUw2ybq714T_951ycz3Ypl5URA&message=Your order "+booking_id.to_s+" is ready to pick up&recipients="+ phone.to_s + def self.send_message(phone, order_id) + url = "http://smspoh.com/api/http/send?key=5QfyN0OtGsFXnOqwtpVAGZCyPGP28nbX_Nm_oPsUw2ybq714T_951ycz3Ypl5URA&message=Your order "+order_id.to_s+" is ready to pick up&recipients="+ phone.to_s begin @result = HTTParty.get(url.to_str) diff --git a/app/views/foodcourt/orders/app_orders.html.erb b/app/views/foodcourt/orders/app_orders.html.erb index 42492fe5..ed21bb6f 100644 --- a/app/views/foodcourt/orders/app_orders.html.erb +++ b/app/views/foodcourt/orders/app_orders.html.erb @@ -50,8 +50,7 @@