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

{% block extra_css %}

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

{% endblock extra_css %}

{% block details %}

<div class="card">
    <div class="card-header">
        {% trans "Buyback Programs" %}
    </div>
    <table style="width: 100%; margin: auto;" class="table table-striped table-hover no-footer w-100">
        <thead>
            <tr>
                <th>{% trans "Name" %}</th>
                <th>{% trans "Location(s)" %}</th>
                <th>{% trans "Tax" %}</th>
                <th>{% trans "Manager" %}</th>
                <th>{% trans "Settings" %}</th>
                <th class="text-center" >{% trans "Actions" %}</th>
            </tr>
        </thead>
        <tbody>
            {% for program in programs %}
            <tr>
                <td>{{ program.name }} </td>

                <td>
                {% for location in program.location.all %}
                    <div>{{location.location_display_name}}</div>
                {% endfor %}
                </td>

                <td>{{ program.tax }} %</td>

                {% if program.is_corporation %}
                    <td >{{ program.owner.corporation }}</td>
                {% else %}
                    <td >{{ program.owner.character.character }}</td>
                {% endif %}
                <td>
                    {% for setting in program|program_setting %}
                        <i style="color: {{setting.color}};" class="fas {{setting.icon}}" title="{{setting.message}}"></i>
                    {% endfor %}

                </td>


                <td class="text-center">
                    <a class="btn btn-success btn-sm" href="{% url 'buybackprogram:program_calculate' program_pk=program.id %}">
                        {% trans "Use" %}
                    </a>

                    {% if perms.buybackprogram.see_leaderboard %}
                        <a class="btn btn-sm btn-info" href="{% url 'buybackprogram:program_leaderboard' program_pk=program.id %}">{% trans "Leaderboard" %}</a>
                    {% endif %}

                    {% if program.owner.user == request.user or perms.buybackprogram.see_performance %}
                        <a class="btn btn-sm btn-info" href="{% url 'buybackprogram:program_performance' program_pk=program.id %}">{% trans "Performance" %}</a>
                    {% endif %}

                    <a class="btn btn-sm btn-warning" href="{% url 'buybackprogram:program_special_taxes' program_pk=program.id %}">{% trans "Special taxes" %}</a>

                    {% if perms.buybackprogram.manage_programs and program.owner.user == request.user %}
                        <a class="btn btn-sm btn-warning" href="{% url 'buybackprogram:program_edit' program_pk=program.id %}">{% trans "Edit program" %}</a>
                        <a class="btn btn-danger btn-sm" href="{% url 'buybackprogram:program_remove' program_pk=program.id %}">
                        {% trans "Delete" %}
                    </a>
                    {% endif %}

                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>


{% endblock %}

{% block extra_javascript %}
{% endblock %}

{% block extra_script %}
{% endblock %}
