{% extends "core/base.jinja" %}
{% from 'core/macros.jinja' import user_profile_link %}

{% block title %}
  {% trans counter_name=counter %}{{ counter_name }} stats{% endtrans %}
{% endblock %}

{% block content %}
  <h3>{% trans counter_name=counter %}{{ counter_name }} stats{% endtrans %}</h3>
  <h4>
    {% trans counter_name=counter.name %}Top 100 {{ counter_name }}{% endtrans %} ({{ current_semester }})
  </h4>
  <table>
    <thead>
      <tr>
        <td>N°</td>
        <td>{% trans %}User{% endtrans %}</td>
        <td>{% trans %}Promo{% endtrans %}</td>
        <td>{% trans %}Total{% endtrans %}</td>
        <td>{% trans %}Percentage{% endtrans %}</td>
      </tr>
    </thead>
    <tbody>
      {% for customer in top_customers %}
        <tr class="{% if customer.user == request.user.id %}highlight{% endif %}">
          <td>{{ loop.index }}</td>
          <td>{{ customer.name }} {% if customer.nickname %} ({{ customer.nickname }}) {% endif %}</td>
          <td>{{ customer.promo or '' }}</td>
          <td>{{ "%.2f"|format(customer.selling_sum) }} €</td>
          <td>{{ '%.2f'|format(100 * customer.selling_sum / total_sellings) }}%</td>
        </tr>
      {% endfor %}
    </tbody>
  </table>

  <h4>
    {% trans counter_name=counter.name %}Top 100 barman {{ counter_name }}{% endtrans %} ({{ current_semester }})
  </h4>
  <table>
    <thead>
      <tr>
        <td>N°</td>
        <td>{% trans %}User{% endtrans %}</td>
        <td>{% trans %}Promo{% endtrans %}</td>
        <td>{% trans %}Time{% endtrans %}</td>
      </tr>
    </thead>
    <tbody>
      {% for barman in top_barman_semester %}
        <tr {% if barman.user == request.user.id %}class="highlight"{% endif %}>
          <td>{{ loop.index }}</td>
          <td>{{ barman.name }} {% if barman.nickname %}({{ barman.nickname }}){% endif %}</td>
          <td>{{ barman.promo or '' }}</td>
          <td>{{ barman.perm_sum|format_timedelta }}</td>
        </tr>
      {% endfor %}
    </tbody>
  </table>

  <h4>{% trans counter_name=counter.name %}Top 100 barman {{ counter_name }} (all semesters){% endtrans %}</h4>
  <table>
    <thead>
      <tr>
        <td>N°</td>
        <td>{% trans %}User{% endtrans %}</td>
        <td>{% trans %}Promo{% endtrans %}</td>
        <td>{% trans %}Time{% endtrans %}</td>
      </tr>
    </thead>
    <tbody>
      {% for barman in top_barman %}
        <tr {% if barman.user == request.user.id %}class="highlight"{% endif %}>
          <td>{{ loop.index }}</td>
          <td>{{ barman.name }} {% if barman.nickname %}({{ barman.nickname }}){% endif %}</td>
          <td>{{ barman.promo or '' }}</td>
          <td>{{ barman.perm_sum|format_timedelta }}</td>
        </tr>
      {% endfor %}
    </tbody>
  </table>
{% endblock %}



