change checkout time and checkout alert time process

This commit is contained in:
phyusin
2018-01-16 10:15:28 +06:30
parent dc2637ed39
commit ca98efc756
4 changed files with 70 additions and 27 deletions

View File

@@ -16,11 +16,15 @@ class Api::CheckInProcessController < Api::ApiController
lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
alert_time_min = 0
if !lookup_checkout_time.nil?
if lookup_checkout_time[0][0] == 'min'
alert_time_min = (lookup_checkout_time[0][1]).to_i
else
alert_time_min = 15
end
now = Time.now.utc
lookup_checkout_time.each do |checkout_time|
arr_time = checkout_time[0].split("-")
start_time = Time.parse(arr_time[0].strip).utc.strftime("%H:%M%p")
end_time = Time.parse(arr_time[1].strip).utc.strftime("%H:%M%p")
if start_time <= now && now <= end_time
alert_time_min = checkout_time[1].to_i
end
end
end
render :json => { :status => true, :check_in_time => check_in_time, :check_out_time => check_out_time, :alert_time_min => alert_time_min, :extra_minutes => extra_minutes }
@@ -39,11 +43,12 @@ class Api::CheckInProcessController < Api::ApiController
if !lookup_checkout_time.empty?
checkout_at = Time.now.utc
if !lookup_checkout_time.nil?
if lookup_checkout_time[0][0] == 'hr'
checkout_at = checkout_at + (lookup_checkout_time[0][1]).to_i.hour
else
checkout_at = checkout_at + (lookup_checkout_time[0][1]).to_i.minutes
lookup_checkout_time.each do |checkout_time|
arr_time = checkout_time[0].split("-")
start_time = Time.parse(arr_time[0].strip).utc.strftime("%H:%M%p")
end_time = Time.parse(arr_time[1].strip).utc.strftime("%H:%M%p")
if start_time <= checkout_at && checkout_at <= end_time
checkout_at = checkout_at + (checkout_time[1]).to_i.minutes
end
end