From 47c12c6faac2de3e93f0e36f81f9b7f6e4159e5d Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Tue, 26 Nov 2019 17:07:56 +0630 Subject: [PATCH] dashboard check current_user for sales --- app/controllers/home_controller.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 3353a3a5..fd45ed1d 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -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)