shop code

This commit is contained in:
Myat Zin Wai Maw
2019-11-22 18:24:02 +06:30
parent 5a3f328789
commit d1ab2c194d
106 changed files with 834 additions and 895 deletions

View File

@@ -1,36 +1,35 @@
class Origami::DashboardController < BaseOrigamiController
def index
@shop = Shop.first
today = DateTime.now.strftime('%Y-%m-%d')
@display_type = Lookup.find_by_lookup_type("display_type")
@display_type = Lookup.where("shop_code='#{@shop.shop_code}'").find_by_lookup_type("display_type")
@sale_data = Array.new
@total_payment_methods = Sale.total_payment_methods(today,current_user)
@total_payment_methods = Sale.total_payment_methods(@shop,today,current_user)
if !@total_payment_methods.nil?
@total_payment_methods.each do |payment|
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" || payment.payment_method == "unionpay" || payment.payment_method == "alipay"
pay = Sale.payment_sale('card', today, current_user)
pay = Sale.payment_sale(@shop,'card', today, current_user)
@sale_data.push({'card' => pay.payment_amount})
else
pay = Sale.payment_sale(payment.payment_method, today, current_user)
pay = Sale.payment_sale(@shop,payment.payment_method, today, current_user)
@sale_data.push({payment.payment_method => pay.payment_amount})
end
end
else
@sale_data = nil
end
@summ_sale = Sale.summary_sale_receipt(today,current_user)
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(today,current_user,@from,@to,@from_time,@to_time)
@summ_sale = Sale.summary_sale_receipt(@shop,today,current_user)
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(@shop,today,current_user,@from,@to,@from_time,@to_time)
# @total_other_customer = Sale.total_other_customer(today,current_user)
@total_order = Sale.total_order(today,current_user)
@total_accounts = Sale.total_account(today,current_user)
@total_order = Sale.total_order(@shop,today,current_user)
@total_accounts = Sale.total_account(@shop,today,current_user)
@account_data = Array.new
if !@total_accounts.nil?
@total_accounts.each do |account|
acc = Sale.account_data(account.account_id, today,current_user)
acc = Sale.account_data(@shop,account.account_id, today,current_user)
if !acc.nil?
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
end
@@ -39,28 +38,28 @@ class Origami::DashboardController < BaseOrigamiController
@account_data = nil
end
@top_items = Sale.top_items(today,current_user)
@total_foc_items = Sale.total_foc_items(today,current_user)
@top_items = Sale.top_items(@shop,today,current_user)
@total_foc_items = Sale.total_foc_items(@shop,today,current_user)
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
@current_user = current_user
#dine-in cashier
dinein_cashier = Lookup.collection_of('dinein_cashier')
dinein_cashier = Lookup.where("shop_code='#{@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.collection_of('quick_service')
quick_service = Lookup.where("shop_code='#{@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.collection_of('food_court')
food_court = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('food_court')
@food_court = 0
@food_court_name = nil
if !food_court[0].nil?
@@ -69,7 +68,7 @@ class Origami::DashboardController < BaseOrigamiController
end
#order reservation
order_reservation = Lookup.collection_of('order_reservation')
order_reservation = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('order_reservation')
@order_reservation = 0
if !order_reservation.empty?
order_reservation.each do |order_reserve|
@@ -80,7 +79,7 @@ class Origami::DashboardController < BaseOrigamiController
end
#dashboard settings on/off for supervisor and cashier
dashboard_settings = Lookup.collection_of('dashboard_settings')
dashboard_settings = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('dashboard_settings')
@setting_flag = true
if !dashboard_settings.empty?
dashboard_settings.each do |setting|
@@ -91,7 +90,7 @@ class Origami::DashboardController < BaseOrigamiController
end
#reservation
reservation = Lookup.collection_of('reservation')
reservation = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('reservation')
@reservation = 0
if !reservation.empty?
reservation.each do |reserve|
@@ -103,13 +102,13 @@ class Origami::DashboardController < BaseOrigamiController
end
def get_all_menu
@menus = Menu.includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).active.all
@menus = Menu.includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).active.all.where("shop_code='#{@shop.shop_code}'")
@item_attributes = MenuItemAttribute.all.load
@item_options = MenuItemOption.all.load
end
def get_credit_sales
credit_sales = SalePayment.get_credit_sales(params)
credit_sales = SalePayment.get_credit_sales(params,@shop.shop_code)
if !credit_sales.nil?
result = {:status=> true, :data=> credit_sales }
else