{% load i18n %}
{% with table.needs_form_wrapper as needs_form_wrapper %}
<div class="table_wrapper">
  {% if needs_form_wrapper %}<form action="{{ table.get_full_url }}" method="POST">{% csrf_token %}{% endif %}
  {% with columns=table.get_columns rows=table.get_rows %}
{% block table %}
   <table id="{{ table.slugify_name }}" class="{% block table_css_classes %}table table-bordered datatable {{ table.css_classes }}{% endblock %}">
   <thead>
  {% block table_caption %}
      <tr class='table_caption'>
        <th class='table_header' colspan='{{ columns|length }}'>
          {% if not hidden_title %}
            <h3 class='table_title'>{{ table }}</h3>
          {% endif %}
          {{ table.render_table_actions }}
        </th>
      </tr>
  {% endblock table_caption %}
  {% block table_breadcrumb %}
      {% if table.breadcrumb %}
        <tr>
          <td class="breadcrumb_td" colspan="{{ table.get_columns|length }}">
            {{ table.breadcrumb.render }}
          </td>
        </tr>
      {% endif %}
  {% endblock table_breadcrumb %}
  {% block table_columns %}
      {% if not table.is_browser_table %}
      <tr>
        {% for column in columns %}
          <th {{ column.attr_string|safe }}>
            {{ column }}
            {% if column.help_text %}
              <span class="help-icon" data-toggle="tooltip" title="{{ column.help_text }}">
                <span class="fa fa-question-circle"></span>
              </span>
            {% endif %}
          </th>
        {% endfor %}
      </tr>
      {% endif %}
  {% endblock table_columns %}
    </thead>
  {% block table_body %}
    <tbody>
    {% for row in rows %}
      {{ row.render }}
    {% empty %}
    <tr class="{% cycle 'odd' 'even' %} empty">
      <td colspan="{{ table.get_columns|length }}">{{ table.get_empty_message }}</td>
    </tr>
    {% endfor %}
    </tbody>
  {% endblock table_body %}
  {% block table_footer %}
    {% if table.footer %}
    <tfoot>
      {% if table.needs_summary_row %}
      <tr class="summation">
        {% for column in columns %}
          {% if forloop.first %}
          <td>{% trans "Summary" %}</td>
          {% else %}
          <td>{{ column.get_summation|default_if_none:"&ndash;"}}</td>
          {% endif %}
        {% endfor %}
      </tr>
      {% endif %}
      <tr>
        <td colspan="{{ table.get_columns|length }}">
          <span class="table_count">{% blocktrans count counter=rows|length %}Displaying {{ counter }} item{% plural %}Displaying {{ counter }} items{% endblocktrans %}</span>
          {% if table.has_prev_data or table.has_more_data %}
            <span class="spacer">|</span>
          {% endif %}
          {% if table.has_prev_data %}
            <a href="?{{ table.get_prev_pagination_string }}">{% trans "&laquo;&nbsp;Prev" %}</a>
          {% endif %}
          {% if table.has_more_data %}
            <a href="?{{ table.get_pagination_string }}">{% trans "Next&nbsp;&raquo;" %}</a>
          {% endif %}
        </td>
      </tr>
    </tfoot>
    {% endif %}
  {% endblock table_footer %}
  </table>
{% endblock table %}
  {% endwith %}
  {% if needs_form_wrapper %}</form>{% endif %}
</div>
{% endwith %}
