{% load static %}
{% load django_ledger %}
{% load cache %}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>{% block page_title %}{% session_entity_name %} | {{ page_title }}{% endblock %}</title>

    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@1.0.4/css/bulma.min.css">
    <link rel="stylesheet" href="{% static 'django_ledger/css/djl_styles.css' %}">
    <link rel="stylesheet"
          href="https://cdn.rawgit.com/jenil/bulmaswatch/gh-pages/{{ DJANGO_LEDGER_THEME }}/bulmaswatch.min.css">

    <link rel="shortcut icon" type="image/jpg" href="{% static 'django_ledger/logo/favicon.png' %}">

    {% block header_extra_js %}{% endblock %}
    {% block header_extra_css %}{% endblock %}

</head>

<body>

{% block nav %}
    {% include 'django_ledger/includes/nav.html' %}
{% endblock %}

{% block header %}
    {% include 'django_ledger/includes/page_header.html' with header_title=header_title header_subtitle=header_subtitle %}
{% endblock %}

{% block breadcrumbs %}{% endblock %}
{% block messages %}
    {% include 'django_ledger/includes/messages.html' with messages=messages %}
{% endblock %}
{% block content %}{% endblock %}
{% block footer %}
    {% include 'django_ledger/includes/footer.html' %}
{% endblock %}

{% block script_bottom %}
    <script src="{% static 'django_ledger/bundle/djetler.bundle.js' %}"></script>

    <script>
        {% if entity_slug %}
            let entitySlug = "{{ view.kwargs.entity_slug }}"
        {% endif %}

        {% if from_date and to_date %}
            let fromDate = "{{ from_date | date:'Y-m-d' }}";
            let toDate = "{{ to_date | date:'Y-m-d' }}";
        {% endif %}

        {% if date_navigation_url %}
            let dateNavigationUrl = "{{ date_navigation_url }}"
            let datePickers = document.querySelectorAll("[id^='djl-datepicker']")
            datePickers.forEach(dp => djLedger.getCalendar(dp.attributes.id.value, dateNavigationUrl))
        {% endif %}
    </script>
{% endblock %}

{% block bottom_extra_js %}{% endblock %}

</body>
</html>