{% extends "hostingpackages/base.html" %}
{% load i18n %}

{% block title %}{{ block.super }} - {% spaceless %}
    {% if user == customer %}
        {% blocktranslate with package=hostingpackage.name trimmed %}
            Disk usage of your Hosting Package {{ package }}
        {% endblocktranslate %}
    {% else %}
        {% blocktranslate with package=hostingpackage.name full_name=customer.get_full_name trimmed %}
            Disk usage of Hosting Package {{ package }} of {{ full_name }}
        {% endblocktranslate %}
    {% endif %}
{% endspaceless %}{% endblock title %}

{% block page_title %}
    {% blocktranslate with package=hostingpackage.name package_url=hostingpackage.get_absolute_url trimmed %}
        Disk usage of Hosting Package <a href="{{ package_url }}">{{ package }}</a>
    {% endblocktranslate %}{% endblock page_title %}

{% block content %}
    {% with used_space=hostingpackage.get_used_disk_space_sum|filesizeformat disk_space=hostingpackage.get_disk_space|filesizeformat package_space=hostingpackage.get_package_space|filesizeformat space_level=hostingpackage.space_level %}
        <p>{% blocktranslate trimmed %}
            You use {{ used_space }} of the reserved disk space of {{ disk_space }} for your hosting package.
        {% endblocktranslate %}</p>
        <p class="lead"><span
                class="text-{% if space_level > 90.0 %}danger{% elif space_level > 80.0 %}warning{% else %}success{% endif %}">
            {% blocktranslate with space_level_percent=space_level|floatformat:1 trimmed %}
                {{ used_space }} of {{ disk_space }} ({{ space_level_percent }}%)
            {% endblocktranslate %}</span>
            <i class="bi-info-circle"
               title="{% blocktranslate trimmed %}
The package contributes {{ package_space }} the difference comes from disk space options
{% endblocktranslate %}"></i>
        </p>
        <h2>{% trans "Breakdown by usage" %}</h2>
        {% if mail_usage %}
            <h3>{% trans "Mailbox usage" %}</h3>
            <table class="table table-condensed table-striped">
                <thead>
                <tr>
                    <th>{% translate "Mailbox" %}</th>
                    <th>{% translate "Primary email address" %}</th>
                    <th class="text-end">{% translate "Used space" %}</th>
                </tr>
                </thead>
                <tbody>
                {% for line in mail_usage %}
                    <tr>
                        <td>{{ line.item }}</td>
                        <td>{% if line.email_address %}{{ line.email_address }}{% else %}-{% endif %}</td>
                        <td class="text-end">{{ line.size_in_bytes|filesizeformat }}</td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        {% endif %}
        {% if web_usage %}
            <h3>{% trans "Website usage" %}</h3>
            <table class="table table-condensed table-striped">
                <thead>
                <tr>
                    <th>{% translate "Website / Directory" %}</th>
                    <th class="text-end">{% translate "Used space" %}</th>
                </tr>
                </thead>
                <tbody>
                {% for line in web_usage %}
                    <tr>
                        <td>{{ line.item }}</td>
                        <td class="text-end">{{ line.size_in_bytes|filesizeformat }}</td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        {% endif %}
        {% if mysql_usage %}
            <h3>{% trans "MySQL/MariaDB database usage" %}</h3>
            <table class="table table-condensed table-striped">
                <thead>
                <tr>
                    <th>{% translate "Database" %}</th>
                    <th class="text-end">{% translate "Used space" %}</th>
                </tr>
                </thead>
                <tbody>
                {% for line in mysql_usage %}
                    <tr>
                        <td>{{ line.item }}</td>
                        <td class="text-end">{{ line.size_in_bytes|filesizeformat }}</td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        {% endif %}
        {% if pgsql_usage %}
            <h3>{% trans "PostgreSQL database usage" %}</h3>
            <table class="table table-condensed table-striped">
                <thead>
                <tr>
                    <th>{% translate "Database" %}</th>
                    <th class="text-end">{% translate "Used space" %}</th>
                </tr>
                </thead>
                <tbody>
                {% for line in pgsql_usage %}
                    <tr>
                        <td>{{ line.item }}</td>
                        <td class="text-end">{{ line.size_in_bytes|filesizeformat }}</td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        {% endif %}
    {% endwith %}

{% endblock content %}
