126 lines
4.1 KiB
Ruby
126 lines
4.1 KiB
Ruby
class Origami::DashboardController < BaseOrigamiController
|
|
|
|
def index
|
|
@display_type = Lookup.find_by_lookup_type("display_type")
|
|
|
|
@sale_data = Array.new
|
|
|
|
@total_payment_methods = Sale.total_payment_methods(current_user)
|
|
|
|
if !@total_payment_methods.nil?
|
|
|
|
@total_payment_methods.each do |payment|
|
|
pay = Sale.payment_sale(payment.payment_method, current_user)
|
|
@sale_data.push({payment.payment_method => pay.payment_amount})
|
|
end
|
|
else
|
|
@sale_data = nil
|
|
end
|
|
|
|
@summ_sale = Sale.summary_sale_receipt(current_user)
|
|
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(current_user,@from,@to)
|
|
# @total_other_customer = Sale.total_other_customer(today,current_user)
|
|
|
|
@total_order = Sale.total_order(current_user)
|
|
|
|
@total_accounts = Account.select("accounts.id as account_id, accounts.title as title")
|
|
@account_data = Array.new
|
|
if !@total_accounts.nil?
|
|
|
|
@total_accounts.each do |account|
|
|
acc = Sale.account_data(account.account_id, current_user)
|
|
if !acc.nil?
|
|
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
|
|
end
|
|
end
|
|
@total_accounts = @total_accounts.reject.with_index { |x, i| @account_data[i].nil? }
|
|
else
|
|
@account_data = nil
|
|
end
|
|
|
|
|
|
@top_items = Sale.top_items(current_user)
|
|
@total_foc_items = Sale.total_foc_items(current_user)
|
|
|
|
|
|
# get printer info
|
|
@print_settings = PrintSetting.get_precision_delimiter()
|
|
@current_user = current_user
|
|
#dine-in cashier
|
|
dinein_cashier = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('dinein_cashier')
|
|
@dinein_cashier = 0
|
|
if !dinein_cashier[0].nil?
|
|
@dinein_cashier = dinein_cashier[0][1]
|
|
end
|
|
|
|
#quick service
|
|
quick_service = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('quick_service')
|
|
@quick_service = 0
|
|
if !quick_service[0].nil?
|
|
@quick_service = quick_service[0][1]
|
|
end
|
|
|
|
#fourt court
|
|
food_court = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('food_court')
|
|
@food_court = 0
|
|
@food_court_name = nil
|
|
if !food_court[0].nil?
|
|
@food_court = food_court[0][1]
|
|
@food_court_name = food_court[0][0]
|
|
end
|
|
|
|
#order reservation
|
|
order_reservation = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('order_reservation')
|
|
@order_reservation = 0
|
|
if !order_reservation.empty?
|
|
order_reservation.each do |order_reserve|
|
|
if order_reserve[0] == 'OrderReservation'
|
|
@order_reservation = order_reserve[1]
|
|
end
|
|
end
|
|
end
|
|
|
|
#dashboard settings on/off for supervisor and cashier
|
|
dashboard_settings = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('dashboard_settings')
|
|
@setting_flag = true
|
|
if !dashboard_settings.empty?
|
|
dashboard_settings.each do |setting|
|
|
if setting[0].to_s.downcase == current_user.role.downcase && setting[1] == '0'
|
|
@setting_flag = false
|
|
end
|
|
end
|
|
end
|
|
|
|
#reservation
|
|
reservation = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('reservation')
|
|
@reservation = 0
|
|
if !reservation.empty?
|
|
reservation.each do |reserve|
|
|
if reserve[0] == 'Reservation'
|
|
@reservation = reserve[1]
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
def get_all_menu
|
|
|
|
@menus = Menu.includes(:menu_categories => :children).includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).includes(:menu_categories => {:menu_items => {:item_sets => :menu_item_instances}}).active.shop
|
|
|
|
@item_attributes = MenuItemAttribute.all.load
|
|
@item_options = MenuItemOption.all.load
|
|
end
|
|
|
|
def get_credit_sales
|
|
credit_sales = SalePayment.get_credit_sales(params)
|
|
if !credit_sales.nil?
|
|
result = {:status=> true, :data=> credit_sales }
|
|
else
|
|
result = {:status=> false, :message=>"There is no record." }
|
|
end
|
|
|
|
render :json => result.to_json
|
|
end
|
|
|
|
end
|