{% load i18n %}
{% load humanize %}
{% load price_formats %}

<div id="tab-outstanding" class="tab-pane fade card card-default border-0 show active" role="tabpanel" aria-labelledby="tab-outstanding">
    <div class="card-body">
        <table class="table table-striped table-hover no-footer w-100">
            <thead>
                <tr>
                    <th >{% trans "Issuer" %}</th>
                    <th >{% trans "Assignee" %}</th>
                    <th >{% trans "Location" %}</th>
                    <th >{% trans "Date issued" %}</th>
                    <th >{% trans "Time pending" %}</th>
                    <th >{% trans "Status" %}</th>
                    <th >{% trans "Tracking #" %}</th>
                    <th >{% trans "Price" %}</th>
                    <th>{% trans "Notes" %}</th>
                    <th>{% trans "Action" %}</th>
                </tr>
            </thead>

            <tbody>
                {% for tracking in contracts %}
                    {% if tracking.contract.status == 'outstanding' %}
                        <tr>
                            <td>{{tracking.contract.issuer_name}}</td>
                            <td>{{tracking.contract.assignee_name}}</td>
                            <td>{{tracking.contract.location_name}}</td>
                            <td>{{tracking.contract.date_issued}}</td>
                            <td>{{tracking.contract.date_issued|timesince }}</td>
                            <td>{{tracking.contract.status}}</td>
                            <td>{{tracking.tracking_number}}</td>
                            <td>{{tracking.contract.price|custom_number_format:2|price}}</td>

                            <td>
                                {% for note in tracking.contract.notes %}
                                    <i style="color: {{note.color}};" class="fas {{note.icon}}" title="{{note.message}}"></i>
                                                {% endfor %}
                            </td>

                            <td><a class="btn btn-info btn-sm" href="{% url 'buybackprogram:contract_details' contract_title=tracking.tracking_number %}">
                                            {% trans "Details" %}</a></td>
                        </tr>
                    {% endif %}
                {% endfor %}
            </tbody>

            <tfoot>
            </tfoot>
        </table>
    </div>
</div>
