check checkin time is available or valid time
This commit is contained in:
@@ -42,6 +42,7 @@ class Api::CheckInProcessController < Api::ApiController
|
|||||||
lookup_checkout_time = Lookup.collection_of("checkout_time")
|
lookup_checkout_time = Lookup.collection_of("checkout_time")
|
||||||
|
|
||||||
if !lookup_checkout_time.empty?
|
if !lookup_checkout_time.empty?
|
||||||
|
today = Time.now.utc.getlocal
|
||||||
checkout_at = Time.now.utc.getlocal
|
checkout_at = Time.now.utc.getlocal
|
||||||
|
|
||||||
lookup_checkout_time.each do |checkout_time|
|
lookup_checkout_time.each do |checkout_time|
|
||||||
@@ -53,20 +54,24 @@ class Api::CheckInProcessController < Api::ApiController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
dining_facility.status = "occupied"
|
if checkout_at.strftime("%Y-%m-%d %H:%M%p") > today.strftime("%Y-%m-%d %H:%M%p")
|
||||||
dining_facility.save!
|
dining_facility.status = "occupied"
|
||||||
|
dining_facility.save!
|
||||||
|
|
||||||
if dining_facility.type == "Table"
|
if dining_facility.type == "Table"
|
||||||
type = "TableBooking"
|
type = "TableBooking"
|
||||||
|
else
|
||||||
|
type = "RoomBooking"
|
||||||
|
end
|
||||||
|
|
||||||
|
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
|
||||||
|
: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!
|
||||||
|
|
||||||
|
render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") }
|
||||||
else
|
else
|
||||||
type = "RoomBooking"
|
render :json => { :status => true }
|
||||||
end
|
end
|
||||||
|
|
||||||
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
|
|
||||||
: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!
|
|
||||||
|
|
||||||
render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") }
|
|
||||||
else
|
else
|
||||||
render :json => { :status => true }
|
render :json => { :status => true }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ class Origami::CheckInProcessController < BaseOrigamiController
|
|||||||
|
|
||||||
def check_in_process
|
def check_in_process
|
||||||
lookup_checkout_time = Lookup.collection_of("checkout_time")
|
lookup_checkout_time = Lookup.collection_of("checkout_time")
|
||||||
|
today = Time.now.utc.getlocal
|
||||||
checkout_at = Time.now.utc.getlocal
|
checkout_at = Time.now.utc.getlocal
|
||||||
if !lookup_checkout_time.empty?
|
if !lookup_checkout_time.empty?
|
||||||
lookup_checkout_time.each do |checkout_time|
|
lookup_checkout_time.each do |checkout_time|
|
||||||
@@ -13,19 +14,21 @@ class Origami::CheckInProcessController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@dining_facility = DiningFacility.find(params[:dining_id])
|
if checkout_at.strftime("%Y-%m-%d %H:%M%p") > today.strftime("%Y-%m-%d %H:%M%p")
|
||||||
@dining_facility.status = "occupied"
|
@dining_facility = DiningFacility.find(params[:dining_id])
|
||||||
@dining_facility.save!
|
@dining_facility.status = "occupied"
|
||||||
|
@dining_facility.save!
|
||||||
|
|
||||||
if @dining_facility.type == "Table"
|
if @dining_facility.type == "Table"
|
||||||
type = "TableBooking"
|
type = "TableBooking"
|
||||||
else
|
else
|
||||||
type = "RoomBooking"
|
type = "RoomBooking"
|
||||||
|
end
|
||||||
|
|
||||||
|
@booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
|
||||||
|
: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
|
||||||
|
|
||||||
@booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
|
|
||||||
: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 = {:status => 'ok'}
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|||||||
Reference in New Issue
Block a user