dashboard check current_user for sales

This commit is contained in:
Thein Lin Kyaw
2019-11-26 17:07:56 +06:30
parent 2892dcfe4c
commit 47c12c6faa

View File

@@ -109,6 +109,13 @@ class HomeController < ApplicationController
@sales = @sales.date_on(today)
end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
if shift = ShiftSale.current_open_shift(current_user.id)
@orders = @orders.where(shift_sale_id: shift.id)
@sales = @sales.where(shift_sale_id: shift.id)
end
end
@top_products = Sale.top_bottom_products(today,current_user,@from,@to,@from_time,@to_time,"top")
@bottom_products = Sale.top_bottom_products(today,current_user,@from,@to,@from_time,@to_time,"bottom")
@hourly_sales = Sale.hourly_sales(today,current_user,@from,@to,@from_time,@to_time)