app/views/payforms/_payform_list.html.erb
<div id="right_stuff">
<fieldset class="index" id="payform_switch">
<% if params[:printed].nil? %>
<div>
<%= link_to payforms_path(unsubmitted: true, submitted: true, skipped: true, approved: true, printed: true, start_date: @start_date, end_date: @end_date), class: 'btn btn-default' do %>
<i class="fa fa-eye"></i>
Show Finalized Payforms
<% end %>
</div>
<% else %>
<div>
<%= link_to payforms_path(start_date: @start_date, end_date: @end_date), class: 'btn btn-default' do %>
<i class="fa fa-eye-slash"></i>
Hide Finalized Payforms
<% end %>
</div>
<% end %>
</fieldset>
</div>
<table id="payformList" width="100%">
<thead><tr>
<% if current_user.is_admin_of?(current_department) %>
<th>User</th>
<% end %>
<% if params[:unsubmitted] %>
<th>Unsubmitted</th>
<% end %>
<% if params[:submitted] %>
<th>Submitted</th>
<% end %>
<% if params[:skipped] %>
<th>Skipped</th>
<% end %>
<% if params[:approved] %>
<th>Approved</th>
<% end %>
<% if params[:printed] %>
<th>Finalized</th>
<% end %>
</tr></thead>
<%= render partial: "payform", collection: @payforms %>
<% if @payforms.empty? %>
<tr><td colspan="5">(No payforms to show)</td></tr>
<% end %>
<tfoot><tr>
<% if current_user.is_admin_of?(current_department) %>
<th>Total:</th>
<% end %>
<% if params[:unsubmitted] %>
<th><%= @payforms.select{|p|!p.submitted }.length %></th>
<% end %>
<% if params[:submitted] %>
<th><%= @payforms.select{|p| p.submitted && !p.approved}.length %></th>
<% end %>
<% if params[:skipped] %>
<th><%= @payforms.select{|p| p.skipped}.length %></th>
<% end %>
<% if params[:approved] %>
<th><%= @payforms.select{|p| p.approved && !p.printed }.length %></th>
<% end %>
<% if params[:printed] %>
<th><%= @payforms.select{|p| p.printed}.length %></th>
<% end %>
</tr></tfoot>
</table>