{% extends "base.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n crispy_forms_tags %}

{% block content %}
<div class="card bg-white mb-3">
  <h3 class="card-header text-center">
    {{ title }}
  </h3>
  <div class="card-body">
    <form method="post">
      {% csrf_token %}
      {{ form|crispy }}
      <button class="btn btn-primary" type="submit">{% trans "Submit" %}</button>
    </form>
  </div>
</div>
{% endblock %}

{% block extrajavascript %}
<script>
  var date_end = document.getElementById("id_date_end");
  var date_start = document.getElementById("id_date_start");

  function update_date_end (){
    if(date_end.value=="" || date_end.value<date_start.value){
      date_end.value = date_start.value;
    };
  };

  function update_date_start (){
    if(date_start.value=="" || date_end.value<date_start.value){
      date_start.value = date_end.value;
    };
  };

  date_start.addEventListener('focusout', update_date_end);
  date_end.addEventListener('focusout', update_date_start);
  
</script>
{% endblock %}
