<% if (data.meta.user !== "") { %>
  <h2><%= gettext('Summary') %></h2>
  <table class="stats">
    <thead>
    <tr>
      <th><%= gettext('Period') %></th>
      <th><%= gettext('Action') %></th>
      <th class="number"><%= gettext('Amount') %></th>
      <th class="number">&times; <%= gettext('Rate') %></th>
      <th class="number"><%= gettext('Subtotal') %></th>
    </tr>
    </thead>
    <tbody>
    <% _.each(data.summary, function (row) { %>
      <tr class="item is-visible">
        <td><%= PTL.reports.dateRangeString(row.start, row.end, false) %></td>
        <td><%= row.action %></td>
        <td class="number"><%= interpolate(ngettext("%s word", "%s words", Math.round(row.amount)), [Math.round(row.amount)]) %></td>
        <td class="number"><%= row.rate %> <%= data.meta.user.currency %></td>
        <td class="number"><%= row.subTotal %> <%= data.meta.user.currency %></td>
        <td></td>
      </tr>
    <% }); %>
    <% _.each(data.paid_task_summary, function (row) { %>
      <%
        var amountStr;
        if (row.type === paidTaskTypes.hourlyWork) {
          amountStr = interpolate(ngettext("%s hour", "%s hours", Math.round(row.amount)), [Math.round(row.amount)]);
        } else if (row.type === paidTaskTypes.translation ||
                   row.type === paidTaskTypes.review) {
          amountStr = interpolate(ngettext("%s word", "%s words", Math.round(row.amount)), [Math.round(row.amount)]);
        } else {
          amountStr = row.amount;
        }
      %>
      <tr class="item is-visible">
        <td><%= row.period %></td>
        <td><%= row.action %> <%= gettext("(registered tasks)") %></td>
        <td class="number"><%= amountStr %></td>
        <td class="number"><%= row.rate %> <%= data.meta.user.currency %></td>
        <td class="number"><%= row.subTotal %> <%= data.meta.user.currency %></td>
        <td></td>
      </tr>
    <% }); %>
      <tr class="total">
          <td><%= interpolate(gettext('Total (%(currency)s)'), {'currency': data.meta.user.currency}, true) %></td>
          <td colspan="3"></td>
          <td class="number"><%= data.total.toFixed(2) %> <%= data.meta.user.currency %></td>
          <td></td>
      </tr>
    </tbody>
  </table>
<% } %>
