checkin checkout time fun:
This commit is contained in:
@@ -64,24 +64,35 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
dining_facility = DiningFacility.find(params[:dining_id])
|
||||
if dining_facility.status == "available"
|
||||
if params[:checkin_time]
|
||||
if dining_facility.check_time(params[:checkin_time], "checkin")
|
||||
booking = dining_facility.get_current_booking
|
||||
if booking.nil?
|
||||
checkin_at = Time.parse(params[:checkin_time]).utc
|
||||
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => "TableBooking",
|
||||
:checkin_by=>current_login_employee.name,:checkin_at => checkin_at,:checkout_at =>nil, :booking_status => "assign", :reserved_at => nil, :reserved_by => nil })
|
||||
if booking.save!
|
||||
dining_facility.status = "occupied"
|
||||
dining_facility.save!
|
||||
render :json => { :status => true, :booking_id => booking.booking_id, :checkin_at => booking.checkin_at.utc.getlocal.strftime("%Y-%m-%d %H:%M:%S"), :message => "Check-in success" }
|
||||
checkin_at = nil
|
||||
if !params[:checkin_time].empty?
|
||||
checkin_at = Time.parse(params[:checkin_time]).utc
|
||||
else
|
||||
checkin_at = Time.now.utc
|
||||
end
|
||||
|
||||
if !checkin_at.nil?
|
||||
if dining_facility.check_time(checkin_at, "checkin")
|
||||
booking = dining_facility.get_current_booking
|
||||
if booking.nil?
|
||||
|
||||
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => "TableBooking",
|
||||
:checkin_by=>current_login_employee.name,:checkin_at => checkin_at,:checkout_at =>nil, :booking_status => "assign", :reserved_at => nil, :reserved_by => nil })
|
||||
if booking.save!
|
||||
dining_facility.status = "occupied"
|
||||
dining_facility.save!
|
||||
render :json => { :status => true, :booking_id => booking.booking_id, :checkin_at => booking.checkin_at.utc.getlocal.strftime("%Y-%m-%d %H:%M:%S"), :message => "Check-in success" }
|
||||
else
|
||||
render :json => { :status => false, :error_message => "Booking does not create successfully!" }
|
||||
end
|
||||
else
|
||||
render :json => { :status => false, :error_message => "Booking does not create successfully!" }
|
||||
render :json => { :status => false, :error_message => "Booking already exist!" }
|
||||
end
|
||||
else
|
||||
render :json => { :status => false, :error_message => "Booking already exist!" }
|
||||
render :json => { :status => false, :error_message => "Checkin time not available!" }
|
||||
end
|
||||
else
|
||||
render :json => { :status => false, :error_message => "Checkin time not available!" }
|
||||
render :json => { :status => false, :error_message => "Operation failed!" }
|
||||
end
|
||||
else
|
||||
booking = dining_facility.get_current_checkout_booking
|
||||
@@ -181,8 +192,9 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
if !params[:booking_id].nil? && !params[:checkout_time].nil?
|
||||
booking = Booking.find(params[:booking_id])
|
||||
dining_facility = DiningFacility.find(booking.dining_facility_id)
|
||||
if dining_facility.check_time(params[:checkout_time], booking, "checkout")
|
||||
checkout_time = Time.parse(params[:checkout_time].strip).utc.getlocal
|
||||
checkout_at = Time.parse(params[:checkout_time]).utc
|
||||
if dining_facility.check_time(checkout_at, booking, "checkout")
|
||||
checkout_time = checkout_at.getlocal
|
||||
booking.checkout_at = checkout_time
|
||||
booking.reserved_at = checkout_time
|
||||
booking.reserved_by = current_login_employee.name
|
||||
|
||||
Reference in New Issue
Block a user