Skip to content

Instantly share code, notes, and snippets.

@KamaKAzii
Created June 27, 2010 12:50
Show Gist options
  • Save KamaKAzii/454885 to your computer and use it in GitHub Desktop.
Save KamaKAzii/454885 to your computer and use it in GitHub Desktop.
<h1>Testing Area</h1>
<p>
<%
# Some stuff I need to start...
total_blocks_per_day = 32
todays_date = Date.today - 2
number_of_days_ahead = 6
number_of_days_behind = 0
total_number_of_days = number_of_days_ahead + number_of_days_behind + 1
number_of_bookings = @booking.length
# Lets generate that table bieeetch!...
%>
<table border="1">
<%
current_day = 0
while current_day < total_number_of_days
# The rows rows rows...
%>
<tr>
<td>
<% current_day_as_date = (todays_date + current_day) %>
<%= current_day_as_date.strftime("%A") %> <%= current_day_as_date %>
</td>
<%
# Make the columns for the blocks
current_block = 0
while (current_block + 1) <= (total_blocks_per_day + 1)
%><td>
<%
# This is the content for each block...
# Search for the current block in the current day
@booking.each do |booking|
ending_block = booking.starting_block + booking.duration
if (current_day_as_date == booking.bookingdate) && (current_block >= booking.starting_block) && (current_block <= ending_block)
%>x<%
end
end
%>
</td><%
current_block = current_block + 1
end
%>
</tr>
<%
current_day = current_day + 1
end
%>
</table>
<%
%>
</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment