176 lines
6.5 KiB
Ruby
Executable File
176 lines
6.5 KiB
Ruby
Executable File
class Origami::HomeController < BaseOrigamiController
|
|
authorize_resource :class => false
|
|
before_action :set_dining, only: [:show]
|
|
|
|
def index
|
|
@shop = Shop.current_shop
|
|
@webview = check_mobile
|
|
|
|
|
|
@tables = Table.unscope(:order).includes(:zone).all.active.order('status desc')
|
|
@rooms = Room.unscope(:order).includes(:zone).all.active.order('status desc')
|
|
@complete = Sale.completed_sale("cashier")
|
|
@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')
|
|
|
|
|
|
@customers = Customer.pluck("customer_id, name")
|
|
@occupied_table = DiningFacility.where("shop_code='#{@shop.shop_code}' and status='occupied'").count
|
|
@shift = ShiftSale.current_open_shift(current_user)
|
|
end
|
|
|
|
# origami table detail
|
|
def show
|
|
@shop = Shop.current_shop
|
|
# get printer info
|
|
@print_settings = PrintSetting.get_precision_delimiter()
|
|
@webview = check_mobile
|
|
|
|
|
|
@tables = Table.unscope(:order).includes(:zone).all.active.order('status desc')
|
|
@rooms = Room.unscope(:order).includes(:zone).all.active.order('status desc')
|
|
@complete = Sale.completed_sale("cashier")
|
|
@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')
|
|
|
|
@customers = Customer.pluck("customer_id, name")
|
|
@shift = ShiftSale.current_open_shift(current_user)
|
|
|
|
@status_order = ""
|
|
@status_sale = ""
|
|
@sale_array = Array.new
|
|
|
|
@membership = MembershipSetting.find_by_shop_code(@shop.shop_code)
|
|
@payment_methods = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'")
|
|
@dining_booking = @dining.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ")
|
|
#@dining_booking = @dining.bookings.active.where("created_at between '#{DateTime.now.utc - 12.hours}' and '#{DateTime.now.utc}'")
|
|
@order_items = Array.new
|
|
@dining_booking.each do |booking|
|
|
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
|
@order_items = Array.new
|
|
# @assigned_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|
|
|
@order_items.push(item)
|
|
# assigned_order_items = AssignedOrderItem.find_by_item_code_and_instance_code_and_order_id(item.item_code,item.item_instance_code,item.order_id)
|
|
# if !assigned_order_items.nil?
|
|
# @assigned_order_items.push({item.order_items_id => assigned_order_items.assigned_order_item_id})
|
|
# end
|
|
end
|
|
@account_arr = Array.new
|
|
if @customer.tax_profiles
|
|
accounts = @customer.tax_profiles
|
|
@account_arr =[]
|
|
accounts.each do |acc|
|
|
account = TaxProfile.find_by_id(acc)
|
|
if !account.nil?
|
|
@account_arr.push(account)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
@status_order = 'order'
|
|
else
|
|
sale = Sale.find(booking.sale_id)
|
|
if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != 'spoile' && sale.sale_status != 'waste'
|
|
@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_by_id(acc)
|
|
if !account.nil?
|
|
@account_arr.push(account)
|
|
end
|
|
end
|
|
end
|
|
@sale_taxes = []
|
|
sale_taxes = SaleTax.where("sale_id = ?", sale.sale_id)
|
|
if !sale_taxes.empty?
|
|
sale_taxes.each do |sale_tax|
|
|
@sale_taxes.push(sale_tax)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
#for bank integration
|
|
@checkout_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_time')
|
|
@checkout_alert_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_alert_time')
|
|
|
|
accounts = TaxProfile.where("shop_code='#{@shop.shop_code}' and group_type = ?","cashier").order("order_by ASC")
|
|
@tax_arr =[]
|
|
accounts.each do |acc|
|
|
@tax_arr.push(acc.name)
|
|
end
|
|
|
|
lookup_spit_bill = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('split_bill')
|
|
@split_bill = 0
|
|
if !lookup_spit_bill[0].nil?
|
|
@split_bill = lookup_spit_bill[0][1]
|
|
end
|
|
|
|
#for edit order on/off
|
|
@edit_order_origami = true
|
|
lookup_edit_order = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('edit_order')
|
|
if !lookup_edit_order.empty?
|
|
lookup_edit_order.each do |edit_order|
|
|
if edit_order[0].downcase == "editorderorigami"
|
|
if edit_order[1] == '0' && (current_login_employee.role == 'cashier' || current_login_employee.role == 'waiter')
|
|
@edit_order_origami = false
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
#for changable on/off
|
|
@changable_tax = true
|
|
lookup_changable_tax = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('changable_tax')
|
|
if !lookup_changable_tax.empty?
|
|
lookup_changable_tax.each do |changable_tax|
|
|
if changable_tax[0].downcase == "change"
|
|
if changable_tax[1] == '0'
|
|
@changable_tax = false
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
def check_emp_access_code
|
|
pin_code = params[:code]
|
|
employee = Employee.find_by_emp_id(pin_code)
|
|
if employee && (employee.role == "manager" || employee.role == "supervisor")
|
|
result = {:status=> true, :message=>"Success" }
|
|
else
|
|
result = {:status=> false, :message=>"Invalid Access Code" }
|
|
end
|
|
render :json => result.to_json
|
|
|
|
end
|
|
|
|
private
|
|
|
|
def set_dining
|
|
@dining = DiningFacility.find(params[:dining_id])
|
|
end
|
|
|
|
end
|