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

{% block breadcrumbs %}
  <li class="breadcrumb-item"><a href="{% url 'plugins:netbox_inventory:supplier_list' %}">Suppliers</a></li>
{% endblock %}

{% block extra_controls %}
  {% if perms.netbox_inventory.add_purchase %}
    <a href="{% url 'plugins:netbox_inventory:purchase_add' %}?supplier={{ object.pk }}" class="btn btn-sm btn-primary">
      <i class="mdi mdi-plus-thick" aria-hidden="true"></i> Add purchase
    </a>
  {% endif %}
{% endblock extra_controls %}

{% block content %}
  <div class="row mb-3">
    <div class="col col-md-6">
      <div class="card">
        <h5 class="card-header">Supplier</h5>
        <div class="card-body">
          <table class="table table-hover attr-table">
            <tr>
              <th scope="row">Name</th>
              <td>{{ object.name }}</td>
            </tr>
            <tr>
              <th scope="row">Description</th>
              <td>{{ object.description }}</td>
            </tr>
            <tr>
              <th scope="row">Purchases</th>
              <td>
                <a href="{% url 'plugins:netbox_inventory:purchase_list' %}?supplier_id={{ object.pk }}">{{ purchase_count }}</a>
              </td>
            </tr>
            <tr>
              <th scope="row">Assets</th>
              <td>
                <a href="{% url 'plugins:netbox_inventory:asset_list' %}?supplier_id={{ object.pk }}">{{ asset_count }}</a>
              </td>
            </tr>
          </table>
        </div>
      </div>
      {% include 'inc/panels/tags.html' %}
    </div>
    <div class="col col-md-6">
      {% include 'inc/panels/custom_fields.html' %}
      {% include 'inc/panels/comments.html' %}
      {% include 'inc/panels/contacts.html' %}
    </div>
  </div>
  <div class="row mb-3">
    <div class="col col-md-12">
      <div class="card">
        <h5 class="card-header">Supplied Assets</h5>
        <div class="card-body table-responsive">
          {% render_table asset_table 'inc/table.html' %}
          {% include 'inc/paginator.html' with paginator=asset_table.paginator page=asset_table.page %}
        </div>
      </div>
    </div>
{% endblock content %}
