{% extends 'base/base.html' %}
{% load static %}
{% load field_type %}

{% block title %} {{ title }} {% endblock %}

{% block css %}
{{ form.media }}
{% endblock %}

{% block body %}
    {% include 'base/nav-bar.html' %}

    <div id="wrap">
        <div id="main">
            <div class="container">
                <div class="row">
                    <div class="col-md-8 offset-md-2 card">
                        <div class="card-block">
                            <h1 class="card-title">{{ heading }}</h1>

                            <hr>
                            <form action="" method="post" enctype="multipart/form-data">
                                {% csrf_token %}
                                {% for field in form %}
                                    <div class="form-group">
                                            {{ field.label_tag }}
                                            {{ field }}
                                            <small class="form-text text-muted">
                                                {{ field.help_text }}
                                            </small>
                                    </div>
                                {% endfor %}
                                <button type="submit" class="btn btn-primary">Submit</button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    {% include 'base/footer.html' %}

    <div class="notifications">
        {% if form.errors %}
            {% for field in form %}
                {% for error in field.errors %}
                    <div class="alert alert-danger alert-dismissable">
                        <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
                        {{ field.label }}: {{ error|escape }}
                    </div>
                {% endfor %}
            {% endfor %}
            {% for error in form.non_field_errors %}
                <div class="alert alert-danger alert-dismissable">
                    <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
                    {{ error|escape }}
                </div>
            {% endfor %}
        {% endif %}
    </div>

    <style>
        .container {
            margin-top: 30px;
        }

        .notifications {
            position: fixed;
            top: 90px;
            right: 0;
            z-index: 1000;
            font-size: 0.7em;
            max-width: 90%;
        }

        body {
            background-color: #fcfcfc;
        }
    </style>

    {% block script %}
        <script src="{% static 'base/js/jquery.min.js' %}"></script>
        <script src="{% static 'base/js/moment.min.js' %}"></script>
        <script src="{% static 'base/js/bootstrap-datetimepicker.min.js' %}"></script>
        <link href="{% static 'base/css/bootstrap-datetimepicker.min.css' %}" rel="stylesheet">

        <script type="text/javascript">
            $(function () {
                $('#datetimepicker1').datetimepicker({
                    icons: {
                        time: "fa fa-clock-o",
                        date: "fa fa-calendar",
                        up: "fa fa-arrow-up",
                        down: "fa fa-arrow-down"
                    },
                    format: 'YYYY-MM-DD',
                    widgetPositioning: {
                        horizontal: 'right',
                        vertical: 'top'
                    }
                });
            });


        </script>
    {% endblock %}


{% endblock %}
