{% extends 'buybacks2/base.html' %}
{% load dict %}
{% load i18n %}
{% load humanize %}
{% load dict %}
{% load number %}

{% block details %}
    <div class="table-responsive">
        <table style="width: 100%; margin: auto;" class="table table-striped table-condensed">
            <thead>
            <tr>
                {% if not mine %}
                    <th>{% trans "User" %}</th>
                {% endif %}
                <th>{% trans "Buyback Program" %}</th>
                <th>{% trans "Corporation" %}</th>
                <th>{% trans "Location" %}</th>
                {% if mine or perms.buybacks.manage_programs %}
                    <th class="text-center">{% trans "Actions" %}</th>
                {% endif %}
            </tr>
            </thead>
            <tbody>
            {% for notification in bb_notifications %}
                <tr>
                    {% if not mine %}
                        <td style="line-height: 35px;">{{ notification.user.username }}</td>
                    {% endif %}
                    <td style="line-height: 35px;">{{ notification.program_location.program.name }}</td>
                    <td style="line-height: 35px;">{{ notification.program_location.program.corporation }}</td>
                    <td style="line-height: 35px;">{{ notification.program_location.office }}</td>
                    {% if mine or perms.buybacks.manage_programs %}
                        <td class="text-center">
                            <a class="btn btn-sm btn-warning" href="{% url 'buybacks2:notification_edit' notification_pk=notification.id %}?mine={{ mine }}">
                                Edit
                            </a>
                            <a class="btn btn-sm btn-danger" href="{% url 'buybacks2:notification_remove' notification_pk=notification.id %}?mine={{ mine }}">
                                Delete
                            </a>
                        </td>
                    {% endif %}
                </tr>
                <tr>
                    <td colspan="4" style="padding: 20px;">
                        <div class="table-responsive">
                            <table style="width: 60%; margin: auto;" class="table table-striped table-condensed">
                                <thead>
                                <tr>
                                    <th style="width: 75%">Item</th>
                                    <th style="width: 25%; text-align: center;">Quantity</th>
                                </tr>
                                </thead>
                                <tbody>
                                {% for id, quantity in notification.items|json|entries %}
                                    <tr>
                                        <td>{{ items|lookup:id }}</td>
                                        <td style="text-align: right;">{{ quantity|floatformat:"0g" }}</td>
                                    </tr>
                                {% endfor %}
                                </tbody>
                            </table>

                            <div style="text-align: center; margin-top: 20px;">
                                <p class="text-muted">
                                    Total Contract Value:
                                    <span class="text-primary" id="total">{{ notification.total|floatformat:"0g" }}</span>
                                    ISK
                                </p>
                            </div>
                        </div>
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
{% endblock %}

{% block extra_javascript %}
{% endblock %}

{% block extra_css %}
{% endblock %}

{% block extra_script %}
{% endblock %}
