This commit is contained in:
Nweni
2017-07-02 11:22:49 +06:30
parent 97c70fb72b
commit acca5b5a1d
5 changed files with 35 additions and 22 deletions

View File

@@ -16,11 +16,17 @@ class ShiftSale < ApplicationRecord
belongs_to :cashier_terminal
belongs_to :employee, :foreign_key => 'employee_id'
def self.current_shift
today_date = DateTime.now.strftime("%Y-%m-%d")
shift = ShiftSale.where("DATE(shift_started_at)=? and shift_started_at is not null and shift_closed_at is null",today_date).take
return shift
end
def self.current_open_shift(current_user)
#if current_user
#find open shift where is open today and is not closed and login by current cashier
today_date = DateTime.now.strftime("%Y-%m-%d")
shift = ShiftSale.where("DATE(shift_started_at)= #{ today_date } and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}").take
shift = ShiftSale.where("DATE(shift_started_at)=? and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}",today_date).take
return shift
#end
end