<% @round = 1 %>
<% @pool = 1 %>
<% until @wrestlers.select{|w| w.pool == @pool}.blank? %>
	 <!-- Add another column for pools 5-8 on an 8 pool -->
	<% if @pool == 5 %>
		</td>
		<td>
	<% end %>
    <h5>Pool <%= @pool %></h5>
    <table class="table table-striped table-bordered table-condensed">
    	<thead>
    		<tr>
    			<th>Name</th>
    			<% until @matches.select{|m| m.round == @round}.blank? %>
    			 <% if @round <= @pools %>
    			    <th>R<%= @round %></th>
    			 <% end %>
    			 <% @round = @round + 1 %>
    			<% end %>
                <th>Placement</th>
    		</tr>
    	</thead>
    	<tbody>
    		<% @wrestlers.select{|w| w.pool == @pool}.sort_by{|w| w.bracket_line}.each do |w| %>
    		<tr>
    			<td> <%="#{w.long_bracket_name}" %></td>
    			<% @round = 1 %>
    			<% until @matches.select{|m| m.round == @round}.blank? %>
    			    <% if @round <= @pools %>
    			        <td><%= w.bout_by_round(@round) %><br><%= w.result_by_id(w.match_id_by_round(@round)) %></td>
    			    <% end %>
    			    <% @round = @round + 1 %>
    			<% end %>
                <td><%= w.pool_placement %><br><%= w.pool_placement_tiebreaker %></td>

    		</tr>
    		<% end %>
      	</tbody>
    </table>
<% @pool = @pool + 1 %>
<% @round = 1 %>
<% end %>
