{% macro pagination(report, current_url, current_page, tab = None) %}
  <div class="pagination">
    <span class="totalItems">{{ report.total_count }}</span> Results
    {% if report.total_pages > 1 %}
    &hellip;
    {% if current_page > 1 %}
    <a href="{{ current_url }}&amp;page={{ current_page - 1 }}{{ tab }}">&larr; Prev</a>
    {% endif %}
    {% for page in range(1, report.total_pages + 1) %}
      {% if page == current_page %}
        <strong>{{ page }}</strong>
      {% elif page > 2 and page < (report.total_pages - 2) %}
        {% if current_page < 3 and page == 7 %}
          &hellip;
        {% elif current_page > 6 and page == 3 %}
          &hellip;
        {% elif page > (current_page - 3) and page < (current_page + 3) %}
          <a href="{{ current_url }}&amp;page={{ page }}{{ tab }}">{{ page }}</a>
        {% elif page == (report.total_pages - 3) %}
          &hellip;
        {% endif %}
      {% else %}
        <a href="{{ current_url }}&amp;page={{ page }}{{ tab }}">{{ page }}</a>
      {% endif %}
    {% endfor %}
    {% if report.total_pages > current_page %}
      <a href="{{ current_url }}&amp;page={{ current_page + 1 }}{{ tab }}">Next &rarr;</a>
    {% endif %}
    {% endif %}
  </div>
{%- endmacro %}
