check checkin time is available or valid time

This commit is contained in:
phyusin
2018-02-01 17:00:57 +06:30
parent ae4746acfc
commit f608aa8516
2 changed files with 32 additions and 24 deletions

View File

@@ -42,6 +42,7 @@ class Api::CheckInProcessController < Api::ApiController
lookup_checkout_time = Lookup.collection_of("checkout_time")
if !lookup_checkout_time.empty?
today = Time.now.utc.getlocal
checkout_at = Time.now.utc.getlocal
lookup_checkout_time.each do |checkout_time|
@@ -53,6 +54,7 @@ class Api::CheckInProcessController < Api::ApiController
end
end
if checkout_at.strftime("%Y-%m-%d %H:%M%p") > today.strftime("%Y-%m-%d %H:%M%p")
dining_facility.status = "occupied"
dining_facility.save!
@@ -70,6 +72,9 @@ class Api::CheckInProcessController < Api::ApiController
else
render :json => { :status => true }
end
else
render :json => { :status => true }
end
else
error_message = "#{dining_facility.type} is not available!"
render :json => { :status => false, :error_message => error_message }

View File

@@ -2,6 +2,7 @@ class Origami::CheckInProcessController < BaseOrigamiController
def check_in_process
lookup_checkout_time = Lookup.collection_of("checkout_time")
today = Time.now.utc.getlocal
checkout_at = Time.now.utc.getlocal
if !lookup_checkout_time.empty?
lookup_checkout_time.each do |checkout_time|
@@ -13,6 +14,7 @@ class Origami::CheckInProcessController < BaseOrigamiController
end
end
if checkout_at.strftime("%Y-%m-%d %H:%M%p") > today.strftime("%Y-%m-%d %H:%M%p")
@dining_facility = DiningFacility.find(params[:dining_id])
@dining_facility.status = "occupied"
@dining_facility.save!
@@ -27,6 +29,7 @@ class Origami::CheckInProcessController < BaseOrigamiController
:checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name })
@booking.save!
end
end
respond = {:status => 'ok'}
respond_to do |format|
format.json { render json: respond }