{% load urltools %}

<div id="{{ table_id }}-search" class="row-fluid">
    <form action="">
        <div class="span6"></div>
        <div class="span6">
            <div class="dataTables_filter" id="data-table-artist_filter">
                <label>Search: <input name="{{ table_id }}-search" value="{{ search_term }}" type="text" aria-controls="data-table-artist"></label>
            </div>
        </div>
    </form>
</div>

<table id="{{ table_id }}" {% if width %}style="width: {{ width }}" {% endif %}{% if bootstrap_theme %}class="table table-striped table-bordered" {% endif %}>
    <thead>
    <tr>
        {% for column in columns %}
            <th{% if title_class %} class="{{ title_class }}" {% endif %}>{{ column.title }}</th>
        {% endfor %}
    </tr>
    </thead>
    <tbody>
    {% if initial_data %}
        {% for row in rows %}
            <tr id="{{ row.row_id }}">
                {% for cell in row.cells %}
                    <td>{{ cell }}</td>
                {% endfor %}
            </tr>
        {% endfor %}
    {% else %}
        <tr>
            <td colspan="{{ columns|length }}">{% block loading_message %}{{ loading_message }}{% endblock %}</td>
        </tr>
    {% endif %}
    </tbody>
</table>

<div id="{{ table_id }}-pagination" class="row-fluid">
    <div class="span6">
        <div class="dataTables_info" id="data-table-artist_info">
            Showing {{ paginator.from }} to {{ paginator.to }} of {{ total }} entries
            {% if prev_total %}(filtered from {{ prev_total }} total entries){% endif %}
        </div>
    </div>
    <div class="span6">
        <div class="dataTables_paginate paging_bootstrap pagination">
            <ul>
                {% if paginator.has_prev %}
                    <li class="prev"><a href="{% modify_qs qs=paginator.prev_page %}">← Previous</a></li>
                {% else %}
                    <li class="prev disabled"><a href="#">← Previous</a></li>
                {% endif %}

                {% for link in paginator.prev_pages %}
                    <li><a href="{% modify_qs qs=link.1 %}">{{ link.0 }}</a></li>
                {% endfor %}

                <li class="active"><a href="#">{{ paginator.current }}</a></li>

                {% for link in paginator.next_pages %}
                    <li><a href="{% modify_qs qs=link.1 %}">{{ link.0 }}</a></li>
                {% endfor %}

                {% if paginator.has_next %}
                    <li class="next"><a href="{% modify_qs qs=paginator.next_page %}">Next → </a></li>
                {% else %}
                    <li class="next disabled"><a href="#">Next → </a></li>
                {% endif %}
            </ul>
        </div>
    </div>
</div>

{% if sql %}
    <h2>SQL</h2>
    <pre id="{{ table_id }}-sql" class="prettyprint lang-sql">{{ sql }}</pre>
{% endif %}

