Files
sx-fc/app/controllers/foodcourt/food_court_controller.rb
2023-08-24 10:40:31 +06:30

99 lines
3.0 KiB
Ruby

class Foodcourt::FoodCourtController < ApplicationController
# before_action :set_dining, only: [:detail]
before_action :check_user
def check_user
if current_user.nil?
redirect_to root_path
end
end
def index
if !ShiftSale.current_shift.nil?
if params[:sale_id].present?
sale =Sale.find(params[:sale_id])
if sale
@sale_id =sale.sale_id
@booking_id =sale.bookings[0].booking_id
end
end
@zone = Zone.all.includes(:tables, :rooms).where("is_active= true")
today = Time.current
day = Date.today.wday
@menus = []
@menu = []
@cashier_type = "food_court"
#checked quick_service only
display_type = Lookup.find_by_lookup_type("display_type")
if !display_type.nil? && display_type.value.to_i ==2
@display_type = display_type.value
else
@display_type = nil
end
@quick_service_only = true
lookup_dine_in = Lookup.collection_of('dinein_cashier')
if !lookup_dine_in.empty?
lookup_dine_in.each do |dine_in|
if dine_in[0].downcase == "dineincashier"
if dine_in[1] == '1'
@quick_service_only = false
end
end
end
end
@app_order_new_count = Booking.select("bookings.*,customers.*")
.joins(" JOIN sales ON bookings.sale_id=sales.sale_id")
.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("bookings.booking_status !=? and sales.sale_status =? and sales.payment_status =? and orders.source='app' and DATE(bookings.created_at)=?",'completed','completed','paid',Date.today).order("bookings.created_at desc").uniq.length
render "foodcourt/addorders/detail"
else
if current_user.role == 'administrator' || current_user.role == 'manager'
redirect_to origami_dashboard_path
else
redirect_to new_foodcourt_shift_path
end
end
end
def get_menu_category ()
if (params[:id])
puts params[:id]
#Pull this menu
@menu = MenuCategory.find_by_id(params[:id])
# puts @menu.menu_items[1].item_attributes.to_json
return @menu
else
MenuCategory.current_menu
end
end
def get_menu_sub_category ()
id = params[:id]
if (id)
#Pull this menu
@sub_menu = MenuCategory.where("menu_category_id = #{id}").active
# puts @menu.menu_items[1].item_attributes.to_json
return @sub_menu
end
end
def get_all_product()
@product = Product.all
end
# render json for http status code
def return_json_status_with_code(code, msg)
render status: code, json: {
message: msg,
booking_id: booking_id
}.to_json
end
end