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

{% block content %}
{% if header %}<h1 class="text-center"> {{ header }} </h1>
<hr>{% endif %}
{% if sub_header %}<h2 class="text-center"> {{ sub_header }} </h2>
<hr>{% endif %}

<form method="post" enctype="multipart/form-data">{% csrf_token %}
    {% if form_helper %}
    {% crispy form form_helper %}
    {% else %}
    {% crispy form %}
    {% endif %}
    {% for fd in factories %}
    <h5>{{ fd.header }}</h5>
    {% if fd.helper %}
    {% crispy fd.factory fd.helper %}
    {% else %}
    {% crispy fd.factory %}
    {% endif %}
    {% endfor %}
    <div class="row ml-2">
        {% if add_lines_btn %}
        <div class="form-actions m-2">
            <input type="submit" name="addlines" value="Add Lines" class="btn btn-primary" id="submit-addline">
        </div>
        {% endif %}
        <div class="form-actions m-2">
            <input type="submit" name="save" value="Save" class="btn btn-primary" id="submit-save">
        </div>
        <div class="form-actions m-2">
            <input class="btn btn-warning" name="cancel" type="button" value="Cancel" onclick="history.back()">
        </div>
    </div>
</form>

{% if table %}
    <h4>{{ table_header }}</h4>
    {% render_table table %}
{% endif %}

{% endblock content %}

{% block extra_javascript %}
    {% for ejs in extra_js %}
        <script src="{% static ejs %}"></script>
    {% endfor %}
{% endblock %}