<%
# Renders the workload data for one single user.
# Parameters:
#  * user: The user to render the data for.
#  * data: The data to render. A hash with issues as keys.
%>

<tbody class="user-total-workload" id="user-total-workload-<%= user.id %>">
  <tr>
	<th class="user-description <%= css_user_class(user&.id) %>" scope="row" title="<%= l(:workload_trigger_tooltip) %>">
	  <%= render :partial => 'trigger', :locals => { :trigger_for => css_user_class(user&.id) } %>
	  <%= "#{user.firstname} #{user.lastname}" %>
	  <% if data[:overdue_number]&.positive? || data[:unscheduled_number]&.positive? %>
		<dl class="additional-user-info">
		  <dt><%= l(:workload_overdue_issues_num) %></dt>
		  <dd><%= data[:overdue_number] %></dd>
		  <dt><%= l(:workload_overdue_issues_hours) %></dt>
		  <dd><%= "%0.2f" % data[:overdue_hours] %></dd>
			<dt class='mt-5'><%= l(:workload_unscheduled_issues_num) %></dt>
		  <dd class='mt-5'><%= data[:unscheduled_number] %></dd>
		  <dt><%= l(:workload_unscheduled_issues_hours) %></dt>
		  <dd><%= "%0.2f" % data[:unscheduled_hours] %></dd>
		</dl>
	  <% end %>
	</th>
	<% # Print the total workload for this user for each day %>
	<%= render :partial => 'total_workload', :locals => { :totalWorkload => data[:total], :user => user } %>
  </tr>
</tbody>

<% if data[:invisible].presence %>
  <tbody class="invisible-issues-summary <%= css_user_class(user&.id) %>">
	<tr>
	  <th class="invisible-workload-description" scope="row"><%= l(:workload_show_invisible_issues) %> </th>
	  <%= render :partial => 'summarized_workload_for_invisible_issues', :locals => { :assignee => user, :summarizedWorkload => data[:invisible] } %>
	</tr>
  </tbody>
<% end %>
<% # Iterate over all projects for the user %>
<% projects = data.keys.select{|x| x.kind_of?(Project)} %>
<% projects.each do |project| %>
   <%= render :partial => 'workload_for_project', :locals => { :group => nil, :user => user, :project => project, :data => data[project] } %>
<% end %>