{% extends 'buybackprogram/base.html' %}
{% load i18n %}
{% load humanize %}
{% load price_formats %}
{% load static %}
{% block details %}
<div class="panel-heading">
  <h3 class="panel-title">Details for {{contract.title}}</h3>
</div>
<div class="panel-body" style="min-height: 100px;">
    <div>
    {% for note in notes %}
        <div class="alert {{note.color}}" role="alert">
          <i class="fas {{note.icon}}"> {{note.message}}</i>
        </div>
    {% endfor %}
    </div>

    <div class="table-responsive">
        <h4>Contract information:</h4>
        <table style="width: 25%" class="tabletable-condensed">
            <tbody>
                <tr>
                    <th >{% trans "Date issued" %}</th>
                    <td>{{contract.date_issued}}</td>
                </tr>
                <tr>
                    <th >{% trans "Issued from" %}</th>
                    <td>{{contract.issuer_name}}</td>
                </tr>
                <tr>
                    <th >{% trans "Issued to" %}</th>
                    <td>{{contract.assignee_name}}</td>
                </tr>
                <tr>
                    <th >{% trans "Time pending" %}</th>
                    <td>{{contract.date_issued|timesince }}</td>
                </tr>
                <tr>
                    <th >{% trans "Status" %}</th>
                    <td>{{contract.status}}</td>
                </tr>
                <tr>
                    <th >{% trans "Tracking #" %}</th>
                    <td>{{contract.title}}</td>
                </tr>
                <tr>
                    <th >{% trans "Asking price" %}</th>
                    <td>{{contract.price|floatformat:0|intcomma}} ISK</td>
                </tr>
            </tbody>
        </table>
    </div>

    <div class="table-responsive" style="margin: 20px 0;">
        <h4>Invoice</h4>
            <p class="text-muted">List of expenses applied on your contract</p>
        <table id="contract" style="margin: 20px auto;" class="table table-striped table-condensed">
            <tr>
                <th>Price before expenses</th>
                <td>{{tracking.value|floatformat:0|intcomma}} ISK</td>
            </tr>
            <tr>
                <th>Program taxes</th>
              <td>{{tracking.taxes|floatformat:0|intcomma}} ISK</td>
            </tr>
            <tr>
                <th>Hauling cost</th>
                <td>{{tracking.hauling_cost|floatformat:0|intcomma}} ISK</td>
            </tr>
            <tr>
                <th>Donation amount</th>
                <td>{{tracking.donation|floatformat:0|intcomma}} ISK <i></i></td>
            </tr>
            <tr>
                <th style="border-top:2px dotted black;">Net price</th>
                {% if tracking.net_price >= 0 %}
                    <td style="border-top:2px dotted black;">{{tracking.net_price|floatformat:0|intcomma }} ISK</td>
                {% else %}
                    <td style="border-top:2px dotted black;">0 ISK <i><s>{{tracking.net_price|floatformat:0|intcomma }} ISK</s></i><td>
                {% endif %}
            </tr>

        </table>
    </div>

    <div class="table-responsive">
        <h4>Invoiced items</h4>
        <table class="table table-striped table-condensed">
            <thead>
                <tr>
                    <th >{% trans "Name" %}</th>
                    <th >{% trans "Quantity" %}</th>
                    <th >{% trans "Buy value" %}</th>
                </tr>
            </thead>
            <tbody>
                {% for item in tracking_items %}
                        <tr>
                            <td><img class="item-icon" src="https://image.eveonline.com/Type/{{item.eve_type.id}}_64.png" />{{item.eve_type.name}}</td>
                            <td>{{item.quantity|intcomma}}</td>
                            <td>{{item.buy_value|floatformat:0|intcomma}} ISK</td>
                        </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>


    <div class="table-responsive">
        <h4>Contract contains:</h4>
        <table class="table table-striped table-condensed">
            <thead>
                <tr>
                    <th >{% trans "Name" %}</th>
                    <th >{% trans "Quantity" %}</th>
                </tr>
            </thead>
            <tbody>
                {% for item in contract_items %}
                        <tr>
                            <td><img class="item-icon" src="https://image.eveonline.com/Type/{{item.eve_type.id}}_64.png" />{{item.eve_type.name}}</td>
                            <td>{{item.quantity|intcomma}}</td>
                        </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>

    <div>
        <a class="btn btn-warning btn-sm" href="{% url 'buybackprogram:my_stats' %}">
                                <i class="fas fa-arrow-left">Back to my stats</i>
        </a>
    </div>
</div>
{% endblock %}

{% block extra_javascript %}
{% endblock %}

{% block extra_css %}
<link rel="stylesheet" type="text/css" href="{% static 'buybackprogram/style.css' %}">
{% endblock %}

{% block extra_script %}
{% endblock %}
