{% extends "admin/header.html" %}

{% load admin_tags i18n lib_tags %}

{% block extra_css %}
  {{ block.super }}
  {% extra_static_content "domains" "css" user %}
{% endblock %}

{% block leftcol %}
<ul class="nav nav-sidebar">
  {% domains_menu "domains" user False %}
</ul>

{% get_extra_admin_content user "leftcol" selection %}
{% endblock %}

{% block apparea %}
  <h2>{{ object }} {% if not object.enabled %} <small>{% trans "(disabled)" %}</small>{% endif %}</h2>
  <hr>

  <div class="col-xs-12 col-sm-6">
    <div class="panel panel-info">
      <div class="panel-heading">
        <h3 class="panel-title">{% trans "Summary" %}</h3>
      </div>
      <table class="table">
        {% if enable_mx_checks or enable_dnsbl_checks %}
          <tr>
            <th>{% trans "DNS status" %}</th>
            <td>
              {% include "admin/_domain_dnschecks_status.html" %}
            </td>
          </tr>
        {% endif %}
        <tr>
          <th width="40%">{% trans "Creation date" %}</th>
          <td>{{ domain.creation }}</td>
        </tr>
        <tr>
          <th>{% trans "Last modification date" %}</th>
          <td>{{ domain.last_modification }}</td>
        </tr>
        <tr>
          <th>{% trans "Domain aliases" %}</th>
          <td>{{ domain.domainalias_count }}</td>
        </tr>
        <tr>
          <th><a href="{% url 'admin:identity_list' %}#list/?searchquery=@{{ object.name }}">{% trans "Mailboxes" %}</a></th>
          <td>{{ domain.mailbox_count }}</td>
        </tr>
        <tr>
          <th><a href="{% url 'admin:identity_list' %}#list/?searchquery=@{{ object.name }}">{% trans "Mailbox aliases" %}</a></th>
          <td>{{ domain.mbalias_count }}</td>
        </tr>
        <tr>
          <th>{% trans "Quota" %}</a></th>
          <td>{{ domain.quota }} {% trans "MB" %}</td>
        </tr>
        {% if domain.quota %}
          <tr>
            <th>{% trans "Usage" %}</a></th>
            <td>
              <div class="progress">
                <div class="{% progress_color used_quota_in_percent %}" style="width: {{ used_quota_in_percent }}%" title="{{ used_quota_in_percent }}% ({{ used_quota }} {% trans "MB" %}) {% trans 'used' context 'quota' %}"></div>
                <div class="{% progress_color domain.allocated_quota_in_percent %}" style="width: {{ allocated_quota }}%" title="{{ domain.allocated_quota_in_percent }}% ({{ domain.allocated_quota }} {% trans "MB" %}) {% trans 'allocated' %}"></div>
              </div>
            </td>
          </tr>
        {% endif %}
        <tr>
          <th>{% trans "Default mailbox quota" %}</a></th>
          <td>{{ domain.default_mailbox_quota }} {% trans "MB" %}</td>
        </tr>
      </table>
    </div>

    {% if object.domainalias_set.exists %}
    <div class="panel panel-info">
      <div class="panel-heading">
        <h3 class="panel-title">{% trans "Domain aliases" %}</h3>
      </div>
      <table class="table">
        {% for domainalias in object.domainalias_set.all %}
          <tr><td>{{ domainalias }}</td></tr>
        {% endfor %}
      </table>
    </div>
    {% endif %}

    {% for template in templates.left %}
      {% include template %}
    {% endfor %}
  </div>

  <div class="col-xs-12 col-sm-6">
    <div class="panel panel-info">
      <div class="panel-heading"><h3 class="panel-title">{% trans "Administrators" %}</h3></div>
      <table id="domadmins" class="table">
        <thead>
          <tr><th>{% trans "Username" %}</th><th>{% trans "Name" %}</th><th></th></tr>
        </thead>
        <tbody>
        {% for da in domain.admins %}
          <tr>
            <td>{{ da.username }}</td>
            <td>{{ da.fullname }}</td>
            <td name="actions">
              {% if perms.admin.change_domain %}
                <a name="removeperm" href="{% url 'admin:permission_remove' %}?domid={{ domain.id }}&daid={{ da.id }}" title="{% trans 'Remove this permission' %}"><span class="fa fa-trash"></span></a>
              {% endif %}
            </td>
          </tr>
        {% empty %}
          <tr><td colspan="3">{% trans "No domain administrator defined yet." %}</td></tr>
        {% endfor %}
        </tbody>
      </table>
    </div>
    
    {% for template in templates.right %}
      {% include template %}
    {% endfor %}
  </div>

{% endblock %}
