change dynamic checkin checkout

This commit is contained in:
phyusin
2018-11-20 18:10:48 +06:30
parent cd33da68fa
commit d641a09d41
5 changed files with 155 additions and 51 deletions

View File

@@ -6,21 +6,39 @@ if @zones
#List all tables
json.tables zone.tables do |table|
if table.is_active
current_booking = table.get_current_booking
json.id table.id
json.name table.name
json.status table.status
json.zone_id table.zone_id #Add this zone_id to keep data structure consistance
json.current_booking table.get_current_booking.booking_id rescue ""
if !current_booking.nil?
json.current_booking current_booking.booking_id
json.checkin_at Time.parse(current_booking.checkin_at.strftime("%Y-%m-%d %H:%M:%S")).utc.getlocal.strftime("%Y-%m-%d %H:%M:%S")
json.checkout_at current_booking.checkout_at ? Time.parse(current_booking.checkout_at.strftime("%Y-%m-%d %H:%M:%S")).utc.getlocal.strftime("%Y-%m-%d %H:%M:%S") : ""
else
json.current_booking ""
json.checkin_at ""
json.checkout_at ""
end
end
end
json.rooms zone.rooms do |room|
if room.is_active
current_booking = room.get_current_booking
json.id room.id
json.name room.name
json.status room.status
json.zone_id room.zone_id #Add this zone_id to keep data structure consistance
json.current_booking room.get_current_booking.booking_id rescue ""
if !current_booking.nil?
json.current_booking current_booking.booking_id
json.checkin_at Time.parse(current_booking.checkin_at.strftime("%Y-%m-%d %H:%M:%S")).utc.getlocal.strftime("%Y-%m-%d %H:%M:%S")
json.checkout_at current_booking.checkout_at ? Time.parse(current_booking.checkout_at.strftime("%Y-%m-%d %H:%M:%S")).utc.getlocal.strftime("%Y-%m-%d %H:%M:%S") : ""
else
json.current_booking ""
json.checkin_at ""
json.checkout_at ""
end
end
end
end
@@ -28,21 +46,39 @@ if @zones
else #list all tables and rooms with out zones
json.tables @all_tables do |table|
if table.is_active
current_booking = table.get_current_booking
json.id table.id
json.name table.name
json.status table.status
json.zone_id table.zone_id #Add this zone_id to keep data structure consistance
json.current_booking table.get_current_booking.booking_id rescue ""
if !current_booking.nil?
json.current_booking current_booking.booking_id
json.checkin_at Time.parse(current_booking.checkin_at.strftime("%Y-%m-%d %H:%M:%S")).utc.getlocal.strftime("%Y-%m-%d %H:%M:%S")
json.checkout_at current_booking.checkout_at ? Time.parse(current_booking.checkout_at.strftime("%Y-%m-%d %H:%M:%S")).utc.getlocal.strftime("%Y-%m-%d %H:%M:%S") : ""
else
json.current_booking ""
json.checkin_at ""
json.checkout_at ""
end
end
end
json.rooms @all_rooms do |room|
if room.is_active
current_booking = room.get_current_booking
json.id room.id
json.name room.name
json.status room.status
json.zone_id room.zone_id #Add this zone_id to keep data structure consistance
json.current_booking room.get_current_booking.booking_id rescue ""
if !current_booking.nil?
json.current_booking current_booking.booking_id
json.checkin_at Time.parse(current_booking.checkin_at.strftime("%Y-%m-%d %H:%M:%S")).utc.getlocal.strftime("%Y-%m-%d %H:%M:%S")
json.checkout_at current_booking.checkout_at ? Time.parse(current_booking.checkout_at.strftime("%Y-%m-%d %H:%M:%S")).utc.getlocal.strftime("%Y-%m-%d %H:%M:%S") : ""
else
json.current_booking ""
json.checkin_at ""
json.checkout_at ""
end
end
end
end