{% extends '_base.html' %}
{% load helpers %}

{% block content %}
<div class="row">
    <div class="col-sm-8 col-md-9">
        <ol class="breadcrumb">
            <li><a href="{% url 'tenancy:tenant_list' %}">Tenants</a></li>
            {% if tenant.group %}
                <li><a href="{% url 'tenancy:tenant_list' %}?group={{ tenant.group.slug }}">{{ tenant.group }}</a></li>
            {% endif %}
            <li>{{ tenant }}</li>
        </ol>
    </div>
    <div class="col-sm-4 col-md-3">
        <form action="{% url 'tenancy:tenant_list' %}" method="get">
            <div class="input-group">
                <input type="text" name="q" class="form-control" placeholder="Name" />
                <span class="input-group-btn">
                    <button type="submit" class="btn btn-primary">
                        <span class="fa fa-search" aria-hidden="true"></span>
                    </button>
                </span>
            </div>
        </form>
    </div>
</div>
<div class="pull-right">
    {% if perms.tenancy.change_tenant %}
		<a href="{% url 'tenancy:tenant_edit' slug=tenant.slug %}" class="btn btn-warning">
			<span class="fa fa-pencil" aria-hidden="true"></span>
			Edit this tenant
		</a>
    {% endif %}
    {% if perms.tenancy.delete_tenant %}
		<a href="{% url 'tenancy:tenant_delete' slug=tenant.slug %}" class="btn btn-danger">
			<span class="fa fa-trash" aria-hidden="true"></span>
			Delete this tenant
		</a>
    {% endif %}
</div>
<h1>{% block title %}{{ tenant }}{% endblock %}</h1>
{% include 'inc/created_updated.html' with obj=tenant %}
<div class="row">
	<div class="col-md-7">
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Tenant</strong>
            </div>
            <table class="table table-hover panel-body attr-table">
                <tr>
                    <td>Group</td>
                    <td>
                        {% if tenant.group %}
                            <a href="{{ tenant.group.get_absolute_url }}">{{ tenant.group }}</a>
                        {% else %}
                            <span class="text-muted">None</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>Description</td>
                    <td>
                        {% if tenant.description %}
                            {{ tenant.description }}
                        {% else %}
                            <span class="text-muted">N/A</span>
                        {% endif %}
                    </td>
                </tr>
            </table>
        </div>
        {% with tenant.get_custom_fields as custom_fields %}
            {% include 'inc/custom_fields_panel.html' %}
        {% endwith %}
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Comments</strong>
            </div>
            <div class="panel-body">
                {% if tenant.comments %}
                    {{ tenant.comments|gfm }}
                {% else %}
                    <span class="text-muted">None</span>
                {% endif %}
            </div>
        </div>
	</div>
	<div class="col-md-5">
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Stats</strong>
            </div>
            <div class="row panel-body">
                <div class="col-md-4 text-center">
                    <h2><a href="{% url 'dcim:site_list' %}?tenant={{ tenant.slug }}" class="btn {% if stats.site_count %}btn-primary{% else %}btn-default{% endif %} btn-lg">{{ stats.site_count }}</a></h2>
                    <p>Sites</p>
                </div>
                <div class="col-md-4 text-center">
                    <h2><a href="{% url 'dcim:rack_list' %}?tenant={{ tenant.slug }}" class="btn {% if stats.rack_count %}btn-primary{% else %}btn-default{% endif %} btn-lg">{{ stats.rack_count }}</a></h2>
                    <p>Racks</p>
                </div>
                <div class="col-md-4 text-center">
                    <h2><a href="{% url 'dcim:device_list' %}?tenant={{ tenant.slug }}" class="btn {% if stats.device_count %}btn-primary{% else %}btn-default{% endif %} btn-lg">{{ stats.device_count }}</a></h2>
                    <p>Devices</p>
                </div>
                <div class="col-md-4 text-center">
                    <h2><a href="{% url 'ipam:vrf_list' %}?tenant={{ tenant.slug }}" class="btn {% if stats.vrf_count %}btn-primary{% else %}btn-default{% endif %} btn-lg">{{ stats.vrf_count }}</a></h2>
                    <p>VRFs</p>
                </div>
                <div class="col-md-4 text-center">
                    <h2><a href="{% url 'ipam:prefix_list' %}?tenant={{ tenant.slug }}" class="btn {% if stats.prefix_count %}btn-primary{% else %}btn-default{% endif %} btn-lg">{{ stats.prefix_count }}</a></h2>
                    <p>Prefixes</p>
                </div>
                <div class="col-md-4 text-center">
                    <h2><a href="{% url 'ipam:ipaddress_list' %}?tenant={{ tenant.slug }}" class="btn {% if stats.ipaddress_count %}btn-primary{% else %}btn-default{% endif %} btn-lg">{{ stats.ipaddress_count }}</a></h2>
                    <p>IP addresses</p>
                </div>
                <div class="col-md-4 text-center">
                    <h2><a href="{% url 'ipam:vlan_list' %}?tenant={{ tenant.slug }}" class="btn {% if stats.vlan_count %}btn-primary{% else %}btn-default{% endif %} btn-lg">{{ stats.vlan_count }}</a></h2>
                    <p>VLANs</p>
                </div>
                <div class="col-md-4 text-center">
                    <h2><a href="{% url 'circuits:circuit_list' %}?tenant={{ tenant.slug }}" class="btn {% if stats.circuit_count %}btn-primary{% else %}btn-default{% endif %} btn-lg">{{ stats.circuit_count }}</a></h2>
                    <p>Circuits</p>
                </div>
                <div class="col-md-4 text-center">
                    <h2><a href="{% url 'virtualization:virtualmachine_list' %}?tenant={{ tenant.slug }}" class="btn {% if stats.virtualmachine_count %}btn-primary{% else %}btn-default{% endif %} btn-lg">{{ stats.virtualmachine_count }}</a></h2>
                    <p>Virtual machines</p>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
