{% extends extend_str %}
{% load crispy_forms_tags %}
{% load render_table from django_tables2 %}
{% load querystring from django_tables2 %}

{% block content %}
{% if header %}<h1> {{ header }} </h1>
<hr>{% endif %}
{% if sub_header %}<h2> {{ sub_header }} </h2>
<hr>{% endif %}

{% if form%}
<h3> {{ form_header }} </h3>
{% crispy form %}
{% endif %}
{% if filter %}
<h3> {{ filter_header }} </h3>
<h4> Filter Results </h4>
<form action="" method="get" enctype="multipart/form-data">
    {% crispy filter.form %}
</form>
{% endif %}
{% if agg_table %}
<h4>{{ agg_table_header }}</h4>
{% render_table agg_table %}
{% endif %}

<div class="row">
    {% if export %}
    <button type="button" class="btn">
        <a href="{% querystring '_export'='xlsx' %}">Export Excel (1000 Row Limit)</a>
    </button>
    {% endif %}
    {% if export_csv %}
    <button type="button" class="btn">
        <a href="{% querystring '_export'='csv' %}">Export CSV</a>
    </button>
    {% endif %}
    {% if url1 %}
    <h5 class='ml-4'><a href="{% url url1 %}"> {{ url1_text }} </a></h5>
    {% endif %}
    {% if url2 %}
    <h5 class='ml-4'><a href="{% url url2 %}"> {{ url2_text }} </a></h5>
    {% endif %}
    {% if url3 %}
    <h5 class='ml-4'><a href="{% url url3 %}"> {{ url3_text }} </a></h5>
    {% endif %}

    {% if furl1 %}
    <h5 class='ml-4'><a href="{{ furl1 }}"> {{ furl1_text }} </a></h5>
    {% endif %}
    {% if furl2 %}
    <h5 class='ml-4'><a href="{{ furl2 }}"> {{ furl2_text }} </a></h5>
    {% endif %}
    {% if furl3 %}
    <h5 class='ml-4'><a href="{{ furl3 }}"> {{ furl3_text }} </a></h5>
    {% endif %}
</div>

{% if submit_buttons %}
    <div class="row">
        <div id="form_card1" class="card-panel col s12">
            <form action="output">{% csrf_token %}
                {% for sb in submit_buttons %}
                <button class="btn btn-primary" name="{{ sb.name }}" type="submit"> {{ sb.desc }} </button>
                {% endfor %}
                {% render_table table %}
            </form>
        </div>
    </div>
{% else %}
    {% if table %}
        <h4>{{ table_header }}</h4>
        {% render_table table %}
    {% endif %}
{% endif %}

{% if plot1 %}
<div style="width:1200px;height:100">
    {{ plot1|safe }}
</div>
{% endif %}

{% if detail_header %}<h2> {{ detail_header }} </h2>
<hr>{% endif %}
{% if object.as_html %}
{% if show_as_html %}
{{ object.as_html }}
{% endif %}
{% endif %}

{% endblock content %}