Files
sx-fc/app/controllers/origami/home_controller.rb

106 lines
3.8 KiB
Ruby
Executable File

class Origami::HomeController < BaseOrigamiController
authorize_resource :class => false
before_action :set_dining, only: [:show]
def index
@tables = Table.all.active.order('status desc')
@rooms = Room.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'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@shop = Shop::ShopDetail
# @shift = ShiftSale.current_open_shift(current_user.id)
end
# origami table detail
def show
@tables = Table.all.active.order('status desc')
@rooms = Room.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'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@status_order = ""
@status_sale = ""
@sale_array = Array.new
@shop = Shop::ShopDetail
@membership = MembershipSetting::MembershipSetting
@payment_methods = PaymentMethodSetting.all
@dining.bookings.active.each do |booking|
if booking.sale_id.nil? && booking.booking_status != 'moved'
@order_items = Array.new
if booking.booking_orders.empty?
@booking = booking
else
booking.booking_orders.each do |booking_order|
order = Order.find(booking_order.order_id)
if (order.status == "new")
@obj_order = order
@customer = order.customer
@date = order.created_at
@booking= booking
order.order_items.each do |item|
if !item.set_menu_items.nil?
instance_item_sets = JSON.parse(item.set_menu_items)
arr_instance_item_sets = Array.new
instance_item_sets.each do |instance_item|
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
arr_instance_item_sets.push(item_instance_name)
end
item.set_menu_items = arr_instance_item_sets
end
@order_items.push(item)
end
accounts = @customer.tax_profiles
@account_arr =[]
accounts.each do |acc|
account = TaxProfile.find(acc)
@account_arr.push(account)
end
end
end
end
@status_order = 'order'
else
sale = Sale.find(booking.sale_id)
if sale.sale_status != "completed" && sale.sale_status != 'void'
@sale_array.push(sale)
if @status_order == 'order'
@status_order = 'sale'
end
@booking= booking
@date = sale.created_at
@status_sale = 'sale'
@obj_sale = sale
@customer = sale.customer
accounts = @customer.tax_profiles
@account_arr =[]
accounts.each do |acc|
account = TaxProfile.find(acc)
@account_arr.push(account)
end
end
end
end
#for bank integration
@checkout_time = Lookup.collection_of('checkout_time')
@checkout_alert_time = Lookup.collection_of('checkout_alert_time')
#for split bill
lookup_spit_bill = Lookup.collection_of('split_bill')
@spit_bill = 0
if !lookup_spit_bill[0].nil?
@spit_bill = lookup_spit_bill[0][1]
end
end
private
def set_dining
@dining = DiningFacility.find(params[:dining_id])
end
end