{% extends "common/base.html" %}
{% load static i18n purchase django_htmx %}

{% block extrahead %}
    <link rel="stylesheet" href="{% static "purchase/css/reports.css" %}">
{% endblock %}

{% block content %}
    <h1>{% translate "Reports" %}</h1>
    <h2>{% translate "General" %}</h2>
    <ul>
        <li>{% translate "Total turnover:" %} {{ turnover|currency }}</li>
        <li>{% translate "Average basket:" %} {{ average_basket|currency }}</li>
    </ul>

    <h3>{% translate "By day" %}</h3>
    <h4>{% translate "Turnover" %}</h4>
    <ul>
        {% for date, turnover in turnover_by_day.items %}
            <li>{{ date }} : {{ turnover|currency }}</li>
        {% endfor %}
    </ul>
    <h4>{% translate "Average basket" %}</h4>
    <ul>
        {% for date, average in average_basket_by_day.items %}
            <li>{{ date }} : {{ average|currency }}</li>
        {% endfor %}
    </ul>

    {% include "purchase/snippets/htmx_plot.html" with url='purchase:by_hour_plot' %}

    <h2>{% translate "Products" %}</h2>
    {% include "purchase/snippets/report_products.html" %}
    {% include "purchase/snippets/htmx_plot.html" with url='purchase:products_plots' %}

    <h2>{% translate "Turnover by payment method" %}</h2>
    {% include "purchase/snippets/report_payment_methods.html" %}

    <h2>{% translate "Baskets without payment method" %}</h2>
    {% include "purchase/snippets/report_no_payment_method.html" %}
{% endblock %}

{% block extrascript %}
    <script src="{% static 'vendor/htmx-1.8.6/htmx.min.js' %}" defer></script>
    {% django_htmx_script %}
{% endblock %}
