{% extends "base.html" %}
{% load i18n %}
{% block title %}{{ block.super }} - {% blocktranslate with full_name=dashboard_user.get_full_name trimmed %}
    Dashboard for {{ full_name }}
{% endblocktranslate %}{% endblock title %}
{% block page_title %}{% blocktranslate with full_name=dashboard_user.get_full_name trimmed %}
    Dashboard for {{ full_name }}
{% endblocktranslate %}{% endblock page_title %}
{% block content %}
    <h2>{% translate "Hosting packages" %}</h2>
    <div class="row">
        <div class="col-12">
            {% if hosting_packages %}
                <table class="table">
                    <thead>
                    <tr>
                        <th>{% translate "Name" %}</th>
                        <th>{% translate "Disk space" %}</th>
                        <th>{% translate "Mailboxes" %}</th>
                        <th>{% translate "Databases" %}</th>
                        <th>{% translate "Actions" %}</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for package in hosting_packages %}
                        <tr>
                            <th><a href="{{ package.get_absolute_url }}"
                                   title="{% blocktranslate with packagename=package.name trimmed %}
                                           Show details for {{ packagename }}
{% endblocktranslate %}">{{ package.name }}</a>
                            </th>
                            <th>
                                {% with diskspace=package.get_disk_space %}
                                    <span title="{% blocktranslate trimmed %}
                                            The reserved disk space for your hosting package is {{ diskspace }} bytes.
{% endblocktranslate %}">{{ diskspace|filesizeformat }}</span>
                                {% endwith %}
                            </th>
                            <th>
                                {% blocktranslate with num=package.used_mailbox_count total=package.mailbox_count trimmed %}
                                    used {{ num }} of {{ total }}
                                {% endblocktranslate %}</th>
                            <th>{% for dbtype in package.get_databases %}
                                {{ dbtype.number }}
                                {% include "userdbs/snippets/db_type.html" with db_type=dbtype.db_type %}
                                {% if not forloop.last %} / {% endif %}
                            {% endfor %}</th>
                            <th></th>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
            {% else %}
                <p class="text-info">
                    {% if user == object %}{% translate "You have no hosting packages yet." %}{% else %}
                        {% translate "This user has no hosting packages assigned yet." %}{% endif %}</p>
            {% endif %}
            {% if user.is_staff %}
                <a href="{% url "create_customer_hosting_package" user=object.username %}"
                   class="btn btn-primary">{% translate "Add hosting package" %}</a>
            {% endif %}
        </div>
    </div>
{% endblock content %}