{% extends "kfet/base.html" %}
{% block extra_head %}{{ form.media }}{% endblock %}

{% block title %}Nouvelle caisse{% endblock %}
{% block content-header-title %}Création d'une caisse{% endblock %}

{% block content %}

{% include 'kfet/base_messages.html' %}
<form action="" method="post">
    {% csrf_token %}
    {{ form.non_field_errors}}
    {% for field in form %}
        {{ field.errors }}
        {{ field.label_tag }}
        <div style="position:relative">{{ field }}</div>
        {% if field.help_text %}
            <p class="help">{{ field.help_text|safe }}</p>
        {% endif %}
    {% endfor %}
    {% if not perms.kfet.add_checkout %}
        <input type="password" name="KFETPASSWORD">
    {% endif %}
    <input type="submit" value="Enregistrer">
</form>

<script type="text/javascript">

$(document).ready(function() {
    $('#id_valid_from').datetimepicker({
        format    : 'YYYY-MM-DD HH:mm',
        stepping  : 5,
        locale    : 'fr',
        showTodayButton: true,
    });
    $('#id_valid_to').datetimepicker({
        format    : 'YYYY-MM-DD HH:mm',
        stepping  : 5,
        useCurrent: false,
        locale    : 'fr',
        showTodayButton: true,
    });
    $("#id_valid_from").on("dp.change", function (e) {
        $('#id_valid_to').data("DateTimePicker").minDate(e.date);
    });
    $("#id_valid_to").on("dp.change", function (e) {
        $('#id_valid_from').data("DateTimePicker").maxDate(e.date);
    });
});

</script>

{% endblock %}
