39 lines
1.1 KiB
Ruby
39 lines
1.1 KiB
Ruby
class Origami::CheckInProcessController < BaseOrigamiController
|
|
|
|
def check_in_process
|
|
dining_charge = DiningCharge.select('charge_type','charge_block')
|
|
.where('dining_facility_id = ?',params[:dining_id])
|
|
.first()
|
|
|
|
checkout_at = Time.now.utc
|
|
|
|
if !dining_charge.nil?
|
|
hr = (dining_charge.charge_block.utc.strftime("%H").to_i).to_int
|
|
min = (dining_charge.charge_block.utc.strftime("%M").to_i).to_int
|
|
# if dining_charge.charge_type == 'hr'
|
|
checkout_at = checkout_at + hr.hour + min.minutes
|
|
# else
|
|
|
|
# end
|
|
end
|
|
@dining_facility = DiningFacility.find(params[:dining_id])
|
|
@dining_facility.status = "occupied"
|
|
@dining_facility.save!
|
|
|
|
if @dining_facility.type == "Table"
|
|
type = "TableBooking"
|
|
else
|
|
type = "RoomBooking"
|
|
end
|
|
|
|
@booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
|
|
:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign" })
|
|
@booking.save!
|
|
|
|
respond = {:status => 'ok'}
|
|
respond_to do |format|
|
|
format.json { render json: respond }
|
|
end
|
|
end
|
|
end
|