{% extends 'buybackprogram/base.html' %}
{% load i18n %}
{% load humanize %}
{% load price_formats %}
{% load static %}

{% block details %}

<div class="row g-3 mb-3">

    <div class="col-md-6">
        <div class="card h-100">
            <div class="card-header">{% trans "Contract Information" %}</div>
            <div class="card-body p-0">
                <table class="table table-sm mb-0">
                    <tbody>
                        <tr>
                            <th class="ps-3">{% trans "Date issued" %}</th>
                            <td>{{ contract.date_issued|date:"Y-m-d H:i" }}</td>
                        </tr>
                        <tr>
                            <th class="ps-3">{% trans "Issued from" %}</th>
                            <td>{{ contract.issuer_name }}</td>
                        </tr>
                        <tr>
                            <th class="ps-3">{% trans "Issued to" %}</th>
                            <td>{{ contract.assignee_name }}</td>
                        </tr>
                        <tr>
                            <th class="ps-3">{% trans "Location" %}</th>
                            <td>{{ contract.location_name }}</td>
                        </tr>
                        <tr>
                            <th class="ps-3">{% trans "Time pending" %}</th>
                            <td>{{ contract.date_issued|timesince }}</td>
                        </tr>
                        <tr>
                            <th class="ps-3">{% trans "Status" %}</th>
                            <td>
                                {% if contract.status == 'outstanding' %}
                                    <span class="badge bg-warning text-dark">{{ contract.status }}</span>
                                {% elif contract.status == 'finished' %}
                                    <span class="badge bg-success">{{ contract.status }}</span>
                                {% else %}
                                    <span class="badge bg-secondary">{{ contract.status }}</span>
                                {% endif %}
                            </td>
                        </tr>
                        <tr>
                            <th class="ps-3">{% trans "Tracking #" %}</th>
                            <td><code>{{ contract.title }}</code></td>
                        </tr>
                        <tr>
                            <th class="ps-3">{% trans "Contract price" %}</th>
                            <td>{{ contract.price|custom_number_format:2 }} ISK</td>
                        </tr>
                        <tr>
                            <th class="ps-3">{% trans "Volume" %}</th>
                            <td>{{ contract.volume|intcomma }} m³</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <div class="col-md-6">
        <div class="card h-100">
            <div class="card-header">{% trans "Request" %}</div>
            <div class="card-body p-0">
                <table class="table table-sm mb-0">
                    <tbody>
                        <tr>
                            <th class="ps-3">{% trans "Program" %}</th>
                            <td>{% if tracking.program %}{{ tracking.program.name }}{% else %}—{% endif %}</td>
                        </tr>
                        <tr>
                            <th class="ps-3">{% trans "Requested at" %}</th>
                            <td>{{ tracking.created_at|date:"Y-m-d H:i" }}</td>
                        </tr>
                        <tr class="table-active fw-bold">
                            <th class="ps-3">{% trans "Calculated price" %}</th>
                            <td>{{ tracking.net_price|custom_number_format:2 }} ISK</td>
                        </tr>
                        {% if tracking.additional_notes %}
                        <tr>
                            <th class="ps-3">{% trans "Buyer notes" %}</th>
                            <td>{{ tracking.additional_notes }}</td>
                        </tr>
                        {% endif %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>

</div>

{% if notes %}
<div class="card mb-3">
    <div class="card-header">{% trans "Contract Notes" %}</div>
    <div class="card-body">
        {% include "buybackprogram/partials/details/warning.html" %}
    </div>
</div>
{% endif %}

<div class="card mb-3">
    <div class="card-header">{% trans "Contract Items" %}</div>
    <div class="card-body">
        <ul class="nav nav-tabs mb-3">
            <li class="nav-item" role="presentation">
                <a class="nav-link active" data-bs-toggle="tab" href="#tab-original" role="tab">
                    {% trans "Requested Items" %}
                </a>
            </li>
            <li class="nav-item" role="presentation">
                <a class="nav-link" data-bs-toggle="tab" href="#tab-contract" role="tab">
                    {% trans "Contract Items" %}
                </a>
            </li>
        </ul>
        <div class="tab-content mt-2">
            {% include "buybackprogram/partials/details/tabs/original-items.html" %}
            {% include "buybackprogram/partials/details/tabs/contract-items.html" %}
        </div>
    </div>
</div>

<a class="btn btn-secondary btn-sm" href="{% url 'buybackprogram:reverse_my_stats' %}">
    <i class="fas fa-arrow-left"></i> {% trans "Back to my stats" %}
</a>

{% endblock %}

{% block extra_css %}
{% include "buybackprogram/bundles/buybackprogram-css-light.html" %}
{% endblock %}
