<% if @statuses.empty? or rows.empty? %>
    <p><i><%=l(:label_no_data)%></i></p>
<% else %>
<table class="list issue-report-detailed">
<thead><tr>
<th></th>
<% for status in @statuses %>
<th><%= status.name %></th>
<% end %>
<th><strong><%=l(:label_open_issues_plural)%></strong></th>
<th><strong><%=l(:label_closed_issues_plural)%></strong></th>
<th><strong><%=l(:label_total)%></strong></th>
</tr></thead>
<tbody>
<% for row in rows %>
<tr>
  <td class="name"><%= link_to row.name, aggregate_path(@project, field_name, row, :subproject_id => nil) %></td>
  <% for status in @statuses %>
    <td><%= aggregate_link data, { field_name => row.id, "status_id" => status.id }, aggregate_path(@project, field_name, row, :status_id => status.id, :subproject_id => nil) %></td>
  <% end %>
  <td><%= aggregate_link data, { field_name => row.id, "closed" => 0 }, aggregate_path(@project, field_name, row, :status_id => "o", :subproject_id => nil) %></td>
  <td><%= aggregate_link data, { field_name => row.id, "closed" => 1 }, aggregate_path(@project, field_name, row, :status_id => "c", :subproject_id => nil) %></td>
  <td><%= aggregate_link data, { field_name => row.id }, aggregate_path(@project, field_name, row, :status_id => "*", :subproject_id => nil) %></td>
</tr>
<% end %>
</tbody>
<tfoot>
<tr class="total">
  <td><%= l(:label_total) %></td>
  <% for status in @statuses %>
  <td><%= aggregate data, { "status_id" => status.id } %></td>
  <% end %>
  <td><%= aggregate data, { "closed" => 0 } %></td>
  <td><%= aggregate data, { "closed" => 1 } %></td>
  <td><%= aggregate data, { } %></td>
</tr>
</tfoot>
</table>
<% other_formats_links do |f| %>
  <%= f.link_to_with_query_parameters 'CSV', {}, :onclick => "showModal('csv-export-options', '330px'); return false;" %>
<% end %>
<div id="csv-export-options" style="display: none;">
  <h3 class="title"><%= l(:label_export_options, :export_format => 'CSV') %></h3>
  <%= form_tag(project_issues_report_details_path(@project, :detail => params[:detail], :format => 'csv'), :method => :get, :id => 'csv-export-form') do %>
  <%= export_csv_encoding_select_tag %>
  <%= export_csv_separator_select_tag %>
  <p class="buttons">
    <%= submit_tag l(:button_export), :name => nil, :onclick => 'hideModal(this);', :data => {:disable_with => false} %>
    <%= link_to_function l(:button_cancel), 'hideModal(this);' %>
  </p>
  <% end %>
</div>

<div class="issue-report-graph hide-when-print" data-controller="reports--details" data-reports--details-title-value="<%= l(:label_issues_by, @report_title) %>">
  <template data-reports--details-target="labels">
    <%= rows.collect{|row| row.name}.to_json %>
  </template>
  <template data-reports--details-target="datasets">
    <%= @statuses.collect{|status| {"label" => status.name, "hidden" => status.is_closed?, "data" => rows.collect{|row| aggregate(data, {field_name => row.id, "status_id" => status.id})}}}.to_json %>
  </template>
  <canvas id="issues_by_<%= params[:detail] %>" data-reports--details-target="canvas"></canvas>
</div>
<div class="issue-report-graph hide-when-print" data-controller="reports--details" data-reports--details-title-value="<%= l(:label_issues_by, l(:field_status)) %>">
  <template data-reports--details-target="labels">
    <%= @statuses.collect{|status| status.name}.to_json %>
  </template>
  <template data-reports--details-target="datasets">
    <%= rows.collect{|row| {"label" => row.name, "data" => @statuses.collect{|status| aggregate(data, {field_name => row.id, "status_id" => status.id})}}}.to_json %>
  </template>
  <canvas id="issues_by_status" data-reports--details-target="canvas"></canvas>
</div>
<% end %>
