<%
# Renders the workload data for one single issue.
# Parameters:
#  * user: The user to render the data for.
#  * issue: The issue to render the data for.
#  * data: The data to render. A hash with days as keys.
#  * index: Index of the issue for this user.
%>

<%
  klass  = (index % 2 == 0) ? 'even' : 'odd'
  klass += ' overdue' if !issue.due_date.nil? && (issue.due_date < @today)
%>

<tr class="issue-workloads <%= css_group_user_project_class(group&.id, user&.id, issue.project&.id) %> <%= klass %>">
  <th class="issue-description" scope="row">
    <div class="tooltip"><%= link_to_issue(issue) %>
      <span class="tip"><%= render_issue_tooltip(issue) %></span>
    </div>
  </th>
  <%

    data.keys.compact.sort.each do |day|
      dataForDay = data[day]
      hours = dataForDay[:hours]
      lowload = dataForDay[:lowload]
      normalload = dataForDay[:normalload]
      highload = dataForDay[:highload]
      klass  = 'hours'
      klass += ' active'        if  dataForDay[:active]
      klass += ' not-active'    if !dataForDay[:active]
      klass += ' holiday'       if  dataForDay[:holiday]
      klass += ' workingday'    if !dataForDay[:holiday]
      klass += ' not-estimated' if  dataForDay[:noEstimate]
      klass += ' estimated'     if !dataForDay[:noEstimate]
      klass += ' today'         if  @today === day
      klass += ' ' + load_class_for_hours(hours, lowload, normalload, highload)

      hoursString = (hours.abs < 0.01) ? '' : sprintf("%.1f", hours)
  %>
    <td class="<%= klass %>">
      <span>
        <%= hoursString %>
      </span>
    </td>
  <% end %>
</tr>