{% extends 'generic/object.html' %}
{% load render_table from django_tables2 %}
{% block breadcrumbs %}
  {{ block.super }}
  <li class="breadcrumb-item"><a href="{% url 'plugins:netbox_contract:contract_list' %}?external_partie={{ object.external_partie.pk }}">{{ object.external_partie }}</a></li>
{% endblock %}
{% block content %}
  <div class="row mb-3">
    <div class="col col-md-6">
      <div class="card">
        <h5 class="card-header">Contract</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">External partie</th>
              <td>
                <a href="{{ object.external_partie.get_absolute_url }}">{{ object.external_partie.name }}</a>
              </td>
            </tr>
            <tr>
              <th scope="row">Status</th>
              <td>{{ object.status }}</td>
            </tr>
            <tr>
              <th scope="row">External reference</th>
              <td>{{ object.external_reference }}</td>
            </tr>
            <tr>
              <th scope="row">Internal partie</th>
              <td>{{ object.internal_partie }}</td>
            </tr>
            <tr>
              <th scope="row">Tenant</th>
              <td>{{ object.tenant }}</td>
            </tr>
            <tr>
              <th scope="row">Start date</th>
              <td>{{ object.start_date }}</td>
            </tr>
            <tr>
              <th scope="row">End date</th>
              <td>{{ object.end_date }}</td>
            </tr>
            <tr>
              <th scope="row">Initial term</th>
              <td>{{ object.initial_term }}</td>
            </tr>
            <tr>
              <th scope="row">Renewal term</th>
              <td>{{ object.renewal_term }}</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">Monthly recuring costs</th>
              <td>{{ object.mrc }}</td>
            </tr>
            <tr>
              <th scope="row">Non recuring costs</th>
              <td>{{ object.nrc }}</td>
            </tr>
            <tr>
              <th scope="row">Invoice frequency</th>
              <td>{{ object.invoice_frequency }}</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>
      {% include 'inc/panels/custom_fields.html' %}
    </div>
    <div class="col col-md-6">
      {% include 'inc/panels/tags.html' %}
      {% include 'inc/panels/comments.html' %}
    </div>
  </div>
  <div class="row">
    <div class="col col-md-12">
      <div class="card">
        <h5 class="card-header">Circuits</h5>
        <div class="card-body table-responsive">
          {% render_table circuit_table %}
        </div>
      </div>
    </div>
  </div>
  <div class="row">
    <div class="col col-md-12">
      <div class="card">
        <h5 class="card-header">Invoices</h5>
        <div class="card-body table-responsive">
          {% render_table invoices_table %}
        </div>
        <div class="card-footer text-end noprint">
          <a href="{% url 'plugins:netbox_contract:invoice_add' %}?contracts={{ object.pk }}" class="btn btn-primary btn-sm">
              <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
              Add an invoice
          </a>
      </div>
      </div>
    </div>
  </div>
{% endblock content %}
