{% extends "core/base.jinja" %}

{%- block additional_css -%}
  <link rel="stylesheet" href="{{ static('user/user_stats.scss') }}">
{%- endblock -%}

{% block title %}
  {% trans user_name=profile.get_display_name() %}{{ user_name }}'s stats{% endtrans %}
{% endblock %}

{% block content %}
  <div class="container">
    <div class="row">
      {% if total_perm_time %}
        <div>
          <h3>{% trans %}Permanencies{% endtrans %}</h3>
          <div class="flexed">
            {% for perm in perm_time %}
              <div>
                <span>{{ perm["counter__name"] }} :</span>
                <span>{{ perm["total"]|format_timedelta }}</span>
              </div>
            {% endfor %}
            <div><b>Total :</b><b>{{ total_perm_time|format_timedelta }}</b></div>
          </div>
        </div>
      {% endif %}
      <div>
        <h3>{% trans %}Buyings{% endtrans %}</h3>
        <div class="flexed">
          {% for sum in purchase_sums %}
            <div>
              <span>{{ sum["counter__name"] }}</span>
              <span>{{ sum["total"] }} €</span>
            </div>
          {% endfor %}
          <div><b>Total : </b><b>{{ total_purchases }} €</b></div>
        </div>
      </div>
    </div>
    <div>
      <h3>{% trans %}Product top 15{% endtrans %}</h3>
      <table>
        <thead>
          <tr>
            <td>{% trans %}Product{% endtrans %}</td>
            <td>{% trans %}Quantity{% endtrans %}</td>
          </tr>
        </thead>
        <tbody>
          {% for p in top_product %}
            <tr>
              <td>{{ p['product__name'] }}</td>
              <td>{{ p['product_sum'] }}</td>
            </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
  </div>
{% endblock %}