{% load i18n locale cache %}
{% load common_tags profile_tags %}
{% get_current_language as LANGUAGE_CODE %}
<table class="sortable stats" id="{{ table.id }}" lang="{{ LANGUAGE_CODE }}"
  dir="{% locale_dir %}" data-sort-cookie="browser-sorting-pref">
  <thead>
    <tr>
      {% for th in table.headings %}
      <th id="js-stats-{{ th.id }}" class="{{ th.class }}">
        {{ th.display_name }}
      </th>
      {% endfor %}
      <span class="js-mnt-visibility-toggle visibility-toggle"></span>
    </tr>
  </thead>
  <tbody class="stats js-browsing-table">
    {% for item in table.rows %}
    <tr class="item is-visible{% if item.is_disabled %} is-disabled{% endif %}{% if item.is_grayed %} is-grayed{% endif %}">
      {% if 'name' in table.fields %}
      <td class="stats-name {{ item.icon }}"{% if item.description %} title="{{ item.description|striptags }}"{% endif %}>
        {% if item.href %}<a href="{{ item.href }}" title="{{ item.title }}">{% endif %}
        <i class="icon-{{ item.icon }}"></i> <span>{{ item.title }}</span>
        {% if item.href %}</a>{% endif %}
      </td>
      {% endif %}
      {% if 'priority' in table.fields %}
      <td id="priority-{{ item.code|cssid }}" class="stats-number">
        {{ item.priority }}
      </td>
      {% endif %}
      {% if 'progress' in table.fields %}
      <td class="stats-graph">
	{% if item.stats.total and item.stats.untranslated != "---" %}
        <div id="translated-ratio-{{ item.code|cssid }}" class="sortkey">
	  {% widthratio item.stats.translated item.stats.total 1000 %}
	</div>
        <div id="progressbar-{{ item.code|cssid }}">
	  {% cache 10000 progress_bar item.stats.total item.stats.fuzzy item.stats.translated LANGUAGE_CODE %}
          {% progress_bar item.stats.total item.stats.fuzzy item.stats.translated %}
	  {% endcache %}
        </div>
	{% endif %}
      </td>
      {% endif %}
      {% if 'activity' in table.fields %}
      <td id="activity-{{ item.code|cssid }}" class="last-action stats not-inited" sorttable_customkey="{{ item.stats.last_submission.mtime }}">
        <a href="{{ item.stats.last_submission.profile_url }}">
	  {% if item.stats.last_submission.displayname %}
	  {% avatar item.stats.last_submission.username item.stats.last_submission.email 20 %}
	  <span class="user-name user-info">{{ item.stats.last_submission.displayname }}</span>
	  {% endif %}
	</a>
        {% if item.stats.last_submission.mtime %}
	<span class="not-inited muted">_XXX_LAST_SUBMISSION_{{ item.code }}_LAST_SUBMISSION_XXX_</span>
	{% endif %}
      </td>
      {% endif %}
      {% if 'critical' in table.fields %}
      <td id="critical-{{ item.code|cssid }}" class="stats-number critical{% if not item.stats.critical %} zero{% endif %}">
        {% if can_translate and item.stats.critical %}
        <a class="stats-data non-zero" href="{{ item.href_translate }}#filter=checks&category=critical{% if item.sort %}&sort={{ item.sort }}{% endif %}">{{ item.stats.critical_display }}</a>
        {% else %}
        <span class="{% if item.stats.critical %}stats-data non-zero{% else %}zero muted{% endif %}">{{ item.stats.critical_display }}</span>
        {% endif %}
      </td>
      {% endif %}
      {% if 'suggestions' in table.fields %}
      <td id="suggestions-{{ item.code|cssid }}" class="stats-number suggestions{% if not item.stats.suggestions %} zero{% endif %}">
        {% if can_translate and item.stats.suggestions %}
        <a class="stats-data non-zero" href="{{ item.href_translate }}#filter=suggestions{% if item.sort %}&sort={{ item.sort }}{% endif %}">{{ item.stats.suggestions_display }}</a>
        {% else %}
        <span class="{% if item.stats.suggestions %}stats-data non-zero{% else %}zero muted{% endif %}">{{ item.stats.suggestions_display }}</span>
        {% endif %}
      </td>
      {% endif %}
      {% if 'need-translation' in table.fields %}
      <td id="need-translation-{{ item.code|cssid }}" class="stats-number need-translation{% if not item.stats.incomplete %} zero{% endif %}">
        {% if can_translate and item.stats.incomplete %}
        <a class="stats-data non-zero" href="{{ item.href_translate }}#filter=incomplete{% if item.sort %}&sort={{ item.sort }}{% endif %}">{{ item.stats.incomplete_display }}</a>
        {% else %}
        <span class="{% if item.stats.incomplete %}stats-data non-zero{% else %}zero muted{% endif %}">{{ item.stats.incomplete_display }}</span>
        {% endif %}
      </td>
      {% endif %}
      {% if 'total' in table.fields %}
      <td id="total-words-{{ item.code|cssid }}" class="stats-number total not-inited">
        {% if can_translate and item.stats.untranslated != "---" %}
        <a class="stats-data non-zero" href="{{ item.href_translate }}{% if item.sort %}#sort={{ item.sort }}{% endif %}">{{ item.stats.total_display }}</a>
        {% else %}
        <span class="stats-data non-zero">{{ item.stats.total_display }}</span>
        {% endif %}
      </td>
      {% endif %}
      {% if 'last-updated' in table.fields %}
      <td id="last-updated-{{ item.code|cssid }}" class="stats last-updated not-inited" sorttable_customkey="{{ item.stats.last_created_unit.creation_time }}">
	<div id="last-updated-ratio-{{ item.code|cssid }}" class="sortkey">
	  {{ item.stats.last_created_unit.creation_time }}
	</div>
	{% if item.stats.last_created_unit.creation_time %}
	<span>_XXX_LAST_CREATED_{{ item.code }}_LAST_CREATED_XXX_</span>
	{% endif %}
      </td>
      {% endif %}
    </tr>
    {% endfor %}
  </tbody>
</table>
