<%= render "/admin/poll/polls/poll_header" %>
<div id="poll-resources">
  <%= render "/admin/poll/polls/subnav" %>

  <h3><%= t("admin.recounts.index.title") %></h3>

  <% if @booth_assignments.empty? %>
    <div class="callout primary margin-top">
      <%= t("admin.recounts.index.no_recounts") %>
    </div>
  <% else %>
    <table class="fixed margin">
      <thead>
        <th><%= t("admin.recounts.index.table_booth_name") %></th>
        <th class="text-center"><%= t("admin.recounts.index.table_total_recount") %></th>
        <th class="text-center"><%= t("admin.recounts.index.table_system_count") %></th>
      </thead>
      <tbody>
        <% @booth_assignments.each do |booth_assignment| %>
          <% total_recounts = total_recounts_by_booth(booth_assignment) %>
          <% system_count = booth_assignment.voters.size %>
          <tr id="<%= dom_id(booth_assignment) %>_recounts" class="booth_recounts">
            <td>
              <strong>
                <%= link_to booth_assignment.booth.name, admin_poll_booth_assignment_path(@poll, booth_assignment, anchor: 'tab-recounts') %>
              </strong>
            </td>
            <td class="text-center <%= 'count-error' if total_recounts.to_i != system_count %>">
              <% if total_recounts.present? %>
                <strong><%= total_recounts %></strong>
              <% else %>
                <span>-</span>
              <% end %>
            </td>
            <td class="text-center">
              <% if system_count.present? %>
                <strong><%= system_count %></strong>
              <% else %>
                <span>0</span>
              <% end %>
            </td>
          </tr>
        <% end %>
      </tbody>
    </table>

    <%= paginate @booth_assignments %>
  <% end %>
</div>
