{% extends 'generic/object.html' %}
{% load helpers %}
{% load plugins %}
{% load render_table from django_tables2 %}

{% block breadcrumbs %}
  {{ block.super }}
  {% if object.group %}
    <li class="breadcrumb-item"><a href="{% url 'tenancy:contact_list' %}?group_id={{ object.group.pk }}">{{ object.group }}</a></li>
  {% endif %}
{% endblock breadcrumbs %}

{% block content %}
  <div class="row">
    <div class="col col-md-7">
      <div class="card">
        <h5 class="card-header">Contact</h5>
        <div class="card-body">
          <table class="table table-hover attr-table">
            <tr>
              <td>Group</td>
              <td>
                {% if object.group %}
                  <a href="{{ object.group.get_absolute_url }}">{{ object.group }}</a>
                {% else %}
                  <span class="text-muted">None</span>
                {% endif %}
              </td>
            </tr>
            <tr>
              <td>Name</td>
              <td>{{ object.name }}</td>
            </tr>
            <tr>
              <td>Title</td>
              <td>{{ object.title|placeholder }}</td>
            </tr>
            <tr>
              <td>Phone</td>
              <td>
                {% if object.phone %}
                  <a href="tel:{{ object.phone }}">{{ object.phone }}</a>
                {% else %}
                  <span class="text-muted">None</span>
                {% endif %}
              </td>
            </tr>
            <tr>
              <td>Email</td>
              <td>
                {% if object.email %}
                  <a href="mailto:{{ object.email }}">{{ object.email }}</a>
                {% else %}
                  <span class="text-muted">None</span>
                {% endif %}
              </td>
            </tr>
            <tr>
              <td>Address</td>
              <td>{{ object.address|linebreaksbr|placeholder }}</td>
            </tr>
            <tr>
              <th scope="row">Assignments</th>
              <td>{{ assignment_count }}</td>
            </tr>
          </table>
        </div>
      </div>
      {% include 'inc/panels/comments.html' %}
      {% plugin_left_page object %}
    </div>
    <div class="col col-md-5">
      {% include 'inc/panels/custom_fields.html' %}
      {% include 'inc/panels/tags.html' %}
      {% plugin_right_page object %}
    </div>
  </div>
  <div class="row mb-3">
    <div class="col col-md-12">
      <div class="card">
        <h5 class="card-header">Assignments</h5>
        <div class="card-body table-responsive">
          {% render_table assignments_table 'inc/table.html' %}
          {% include 'inc/paginator.html' with paginator=assignments_table.paginator page=assignments_table.page %}
        </div>
      </div>
      {% plugin_full_width_page object %}
    </div>
  </div>
{% endblock %}
