{% extends 'buybacks2/page.html' %}
{% load i18n %}
{% load humanize %}
{% load bootstrap %}

{% block body %}
    <div class="pull-left">
        <h4>{{ program.name }} - Buyback Program</h4>
    </div>

    {% if perms.buybacks.manage_programs %}
        <div class="pull-right">
            <a class="btn btn-sm btn-warning" href="{% url 'buybacks2:program_edit' program_pk=program.id %}">
                Edit name
            </a>
            <a class="btn btn-sm btn-success" href="{% url 'buybacks2:program_add_item' program_pk=program.id %}">
                Add item & price
            </a>
            <a class="btn btn-sm btn-success" href="{% url 'buybacks2:program_add_location' program_pk=program.id %}">
                Add location
            </a>
        </div>
    {% endif %}

    <div style="clear: both; padding-top: 20px; display: flex;" class="table-responsive">
        <table style="width: 60%;" class="table table-striped table-condensed">
            <thead>
            <tr>
                <th style="width: 60%;">{% trans "Item Type" %}</th>
                <th class="text-center" style="width: 10%;">{% trans "Brokerage" %}</th>
{#                <th class="text-center" style="width: 20%;">{% trans "Refined Value" %}</th>#}
                {% if perms.buybacks.manage_programs %}
                    <th style="width: 10%;"></th>
                {% endif %}
            </tr>
            </thead>
            <tbody>
            {% for item in items %}
                <tr>
                    <td>{{ item.item_type.name }}</td>
                    <td class="text-center">{{ item.brokerage }}%</td>
{#                    <td class="text-center">{{ item.use_refined_value }}</td>#}
                    {% if perms.buybacks.manage_programs %}
                        <td class="text-center">
                            <a href="{% url 'buybacks2:program_remove_item' program_pk=program.id item_type_pk=item.item_type.id %}">delete</a>
                        </td>
                    {% endif %}
                </tr>
            {% endfor %}
            </tbody>
        </table>

        <table style="width: 35%; margin-left: 20px;" class="table table-striped table-condensed">
            <thead>
            <tr>
                <th style="width: 90%;">{% trans "Location" %}</th>
                {% if perms.buybacks.manage_programs %}
                    <th style="width: 10%;"></th>
                {% endif %}
            </tr>
            </thead>
            <tbody>
            {% for location in locations %}
                <tr>
                    <td>{{ location.office.location.name }}</td>
                    {% if perms.buybacks.manage_programs %}
                        <td>
                            <a href="{% url 'buybacks2:program_remove_location' program_pk=program.id office_pk=location.office.id %}">delete</a>
                        </td>
                    {% endif %}
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
{% endblock %}

{% block extra_javascript %}
{% endblock %}

{% block extra_css %}
{% endblock %}

{% block extra_script %}
{% endblock %}
