{% load i18n %}
{% load statistics %}
{% load locks %}
{% load watches %}
{% load submissions %}
{% load permissions %}
{% load webeditortags %}

{% if stats %}
{% url notification.views.notices as notices_url %}
<table id="stats_lang" class="stats_comp tablesorter">
   <thead>
    <tr>
      <th>{% trans "Project/Component" %}</th>
      <th class="alcenter">{% trans "Translations" %}</th>
      <th>{% trans "Options" %}</th>
    </tr>
   </thead>
   <tbody>
   {% for stat in stats %}
    {% get_permission "project_perm.submit_file" for request.user and stat as "can_submit_file" %}
      <tr class="{% number_range stat.trans_perc %}">
        <td class="left name" id="{{stat.object.full_name}}">
          <a href="{{stat.object.project.get_absolute_url}}" title="{% trans "Go to this project page" %}">{{stat.object.project.name}}</a> 
          <span class="stat_message" > &raquo; <a href="{{stat.object.get_absolute_url}}#{{stat.language.code}}" title="{% trans "Go to this component page" %}">{{stat.object.name}}</a></span>
          {% if stat.error %}
              <span class="i16 notice" title="{% trans "Could not generate statistics for this file" %}"></span>
          {% endif %}
        </td>
        {% with 140 as barwidth %}
        <td class="stats" style="width: {{ barwidth|add:"2" }}px;">
          <div class="stats_string_comp" title="{% trans "Trans:" %}{{stat.trans}} {% trans "Fuzzy:" %}{{stat.fuzzy}} {% trans "Untrans:" %}{{stat.untrans}}" >{{stat.trans_perc}}% <span class='trans_detail'>({{stat.trans}}/{{stat.fuzzy}}/{{stat.untrans}})</span></div> 
          {% stats_bar_full stat barwidth %}
        </td>
        {% endwith %}
        <td class="left actions">
          {% if stat.is_aggregated %}
            {% url component_language_detail stat.object.project.slug stat.object.slug stat.language_code as comp_lang_url %}
            <a class="i16 multifile nodecoration_icon" href="{{ comp_lang_url }}" title="{% trans "Click here to see the multiple files for" %} {{ stat.language_code }}"></a>
          {% else %}
           {% url component_view_file stat.object.project.slug stat.object.slug stat.filename as file_view_url %}
           {% url component_raw_file stat.object.project.slug stat.object.slug stat.filename as file_raw_url %}
           {% url component_edit_file stat.object.project.slug stat.object.slug stat.filename as file_edit_url %}
           <a class="i16 view nodecoration_icon" title="{% trans "View " %}{{stat.filename}}" href="{{file_view_url}}"></a>
           <a class="i16 get_file nodecoration_icon" title="{% trans "Download " %}{{stat.filename}}" href="{{file_raw_url}}"></a>
           {% pofile_lock stat %}
           {% if notices_url %}
             {% if perms.repowatch.add_watch or can_submit_file %}
                {% watch_toggle stat %}
             {% endif %}
           {% endif %}
           {% if request.user.is_authenticated and stat.object.allows_submission %}
             {% if perms.reviews.add_poreviewrequest or can_submit_file %}
               {% if file_edit_url and stat.total|webtrans_is_under_max %}
                 <a class="i16 edit_file nodecoration_icon" title="{% trans "Edit " %}{{stat.filename}}" href="{{file_edit_url}}"></a>
               {% endif %}
               {% pofile_submission stat %}
             {% endif %}
           {% endif %}
          {% endif %} 
        </td>
      </tr>
   {% endfor %}
   </tbody>
</table>
{%  endif %}
