{% extends 'generic/object.html' %}
{% load render_table from django_tables2 %}
{% block breadcrumbs %}
  {{ block.super }}
  <li class="breadcrumb-item">
    {% for contract in object.contracts.all %}
    <a href="{% url 'plugins:netbox_contract:invoice_list' %}?contracts={{ contract.pk }}">{{ contract.name }}</a>
    {% endfor %}
  </li>
{% endblock %}
{% block content %}
  <div class="row mb-3">
    <div class="col col-md-6">
      <div class="card">
        <h5 class="card-header">Invoices</h5>
        <div class="card-body">
          <table class="table table-hover attr-table">
            <tr>
              <th scope="row">Number</th>
              <td>{{ object.number }}</td>
            </tr>
            <tr>
              <th scope="row">Date</th>
              <td>{{ object.date }}</td>
            </tr>
            <tr>
              <th scope="row">Period start</th>
              <td>{{ object.period_start }}</td>
            </tr>
            <tr>
              <th scope="row">Period end</th>
              <td>{{ object.period_end }}</td>
            </tr>
            <tr>
              <th scope="row">Currency</th>
              <td>{{ object.currency }}</td>
            </tr>
            <tr>
              <th scope="row">Accounting dimensions</th>
              <td>{{ object.accounting_dimensions }}</td>
            </tr>
            <tr>
              <th scope="row">Amount</th>
              <td>{{ object.amount }}</td>
            </tr>
            {% if object.documents %}
            <tr>
              <th scope="row">Documents</th>
                <td>
                  <a href="{{ object.documents }}" target="_blank">Documents</a>
                </td>
            </tr>
            {% endif %}
          </table>
        </div>
      </div>
      <div class="row">
        <div class="col col-md-12">
          <div class="card">
            <h5 class="card-header">Contracts</h5>
            <div class="card-body table-responsive">
              {% render_table contracts_table %}
            </div>
          </div>
        </div>
      </div>
      {% include 'inc/panels/custom_fields.html' %}
      {% include 'inc/panels/tags.html' %}
      {% include 'inc/panels/comments.html' %}
    </div>
  </div>
{% endblock content %}