<h1>New Point Adjustment</h1>
    </br>
    </br>
    <table class="table table-striped table-bordered table-condensed">
        	<thead>
        		<tr>
        			<th>Wrestler Deducted</th>
        			<th>School Deducted</th>
        			<th>Points To Deduct</th>
        		</tr>
        	</thead>
        	<tbody>
              			<tr>
              				
              			<%= form_for Teampointadjust.new, :url => url_for(:controller => 'tournaments', :action => 'teampointadjust', :method => "post") do |f| %>
              			    <td><%= f.collection_select :wrestler_id, @tournament.wrestlers, :id, :name, :include_blank => true %></td>
              				<td><%= f.collection_select :school_id, @tournament.schools, :id, :name, :include_blank => true %></td>
              				<td><%= f.number_field  :points, :step => 'any' %></td>
              			</tr>
          	</tbody>
        </table>
                            <p>Please leave either wrestler or school blank. Please do not choose both (the team will be double decuted the points)</p>
                            <% if can? :manage, @tournament %>
                              <%= submit_tag "Deduct Points", :class=>"btn btn-success"%>
                            <% end %>
                        <% end %>
<br>
<% if @point_adjustments.size > 0 %>
    <h1>Point Adjustments</h1> 
    </br>
    </br>
    <table class="table table-striped table-bordered table-condensed">
        	<thead>
        		<tr>
        			<th>Against</th>
        			<th>Points Deducted</th>
        			<th></th>
        		</tr>
        	</thead>
        	<tbody>
        		<% @point_adjustments.each do |point_adjustment| %>
              			<tr>
              				<td><% if point_adjustment.school_id != nil %>
              				        <%= point_adjustment.school.name %>
              				    <% elsif point_adjustment.wrestler_id != nil %>
              				        <%= point_adjustment.wrestler.name %>
              				    <% end %>
              				</td>
              				<td><%= point_adjustment.points %></td>
              				<td><%= link_to 'Remove Point Adjustment', "/tournaments/#{@tournament.id}/#{point_adjustment.id}/remove_teampointadjust", data: { turbo_method: :delete, turbo_confirm: 'Are you sure?' }, :class=>"btn btn-danger btn-sm" %></td>
              			</tr>
            	
                <% end %>
          	</tbody>
        </table>
<% end %>
