<% if @officer_assignments.any? %>

<%= t("officing.results.new.title", poll: @poll.name) %>

<%= form_tag(officing_poll_results_path(@poll), {id: "officer_assignment_form"}) do %>
<%= select_tag :officer_assignment_id, booths_for_officer_select_options(@officer_assignments), { prompt: t("officing.results.new.select_booth"), label: false } %>
<% @poll.questions.each do |question| %>

<%= question.title %>

<% question.question_answers.each_with_index do |answer, i| %>
<%= text_field_tag "questions[#{question.id}][#{i}]", answer_result_value(question.id, i), placeholder: "0" %>
<% end %>

<% end %>

<%= t("officing.results.new.ballots_white") %>

<%= text_field_tag :whites, params[:whites].presence, placeholder: "0" %>

<%= t("officing.results.new.ballots_null") %>

<%= text_field_tag :nulls, params[:nulls].presence, placeholder: "0" %>

<%= t("officing.results.new.ballots_total") %>

<%= text_field_tag :total, params[:total].presence, placeholder: "0" %>

<%= submit_tag t("officing.results.new.submit"), class: "button expanded" %>
<% end %> <% else %>

<%= @poll.name %>

<%= t("officing.results.new.not_allowed") %>
<% end %> <% if @partial_results.present? %>

<%= t("officing.results.new.results_list") %>

<% results_by_booth = @partial_results.group_by(&:booth_assignment_id) %> <% results_by_booth.keys.each do |booth_assignment| %> <% results_by_booth[booth_assignment].group_by(&:date).keys.each do |date| %> "> <% end %> <% end %>
<%= t("officing.results.new.date") %> <%= t("officing.results.new.booth") %>  
<%= l(date, format: :long) %> <%= results_by_booth[booth_assignment].first.booth_assignment.booth.name %> <%= link_to t("officing.results.new.see_results"), officing_poll_results_path(@poll, date: l(date), booth_assignment_id: booth_assignment) %>
<% end %>