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

{% block body %}
<div class="panel-heading">
  <h3 class="panel-title">Program Special Taxes</h3>
</div>
<div class="panel-body" style="min-height: 100px;">
  {% if perms.buybackprogram.manage_programs and program.owner.user == request.user %}
    <a class="btn btn-sm btn-warning" href="{% url 'buybackprogram:program_edit_item' program_pk=program.id %}"><i class="fas fa-plus">Add item</i></a>
    <a class="btn btn-sm btn-warning" href="{% url 'buybackprogram:program_edit_marketgroup' program_pk=program.id %}"><i class="fas fa-plus">Add market group</i></a>
    <a class="btn btn-sm btn-danger" href="{% url 'buybackprogram:program_item_remove_all' program_pk=program.id %}"><i class="fas fa-trash">Deleta all items</i></a>
  {% endif %}
  <div class="table-responsive" style="margin: 20px 0;">
    <table id="program_items" style="margin: 20px auto;" class="table table-striped table-condensed">
      <thead>
        <th>Name</th>
        <th style="text-align: center;">Tax adjustment</th>
        <th style="text-align: center;">Total tax</th>
        <th style="text-align: center;">Is allowed</th>
        {% if perms.buybackprogram.manage_programs and program.owner.user == request.user %}
          <th style="text-align: center;">Actions</th>
        {% endif %}
      </thead>
      <tbody>
        {% for item in program_items %}
          <tr>
            <td>{{item.item_type.name}}</td>
            <td style="text-align: center;">{{item.item_tax}} %</td>
            <td style="text-align: center;">{{item.item_tax|add:program.tax }} %</td>
            {% if not item.disallow_item %}
               <td style="text-align: center;"><i class="fas fa-check" style="color:green;"></i></td>
            {% else %}
              <td style="text-align: center;"><i class="fas fa-times" style="color:red;"></i></td>
            {% endif %}
            {% if perms.buybackprogram.manage_programs and program.owner.user == request.user %}
              <td style="text-align: center;">
                <a class="btn btn-danger btn-sm" href="{% url 'buybackprogram:program_item_remove' item_pk=item.item_type.id program_pk=program.id %}">Delete</a>

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

  </div>
</div>
{% endblock %}

{% block extra_javascript %}
<script type="text/javascript" src="{% static 'buybackprogram/js/bootstrap-autocomplete.min.js' %}"></script>
<script type="text/javascript" src="{% static 'buybackprogram/js/autocomplete.js' %}"></script>
{% endblock %}

{% block extra_css %}
{% endblock %}

{% block extra_script %}
{% endblock %}
