{% extends "layout.html" %}
{% load i18n %}

{% block breadcrumbs %}
<ul class="breadcrumb">
    <li>
        <a href="{% url promotions:home %}">{% trans 'Home' %}</a>
        <span class="divider">/</span>
    </li>
    <li>
        <a href="{% url customer:summary %}">{% trans 'Account' %}</a>
        <span class="divider">/</span>
    </li>
    <li class="active"><a href=".">{% trans 'Authorisation' %}</a></li>
</ul>
{% endblock %}

{% block title %}
{% trans 'Authorisation' %} | {{ block.super }}
{% endblock %}

{% block header %}
{% endblock header %}

{% block content %}
<div class="generalbox">
    <h2>Authorisation</h2>
    {% block subpage_links %}
    {% endblock subpage_links %}
    {{ block.super }}
</div>

{% block filter_form %}
<form action="." method="get">
    {% include "partials/form_fields.html" with form=form %}
    <button type="submit" class="btn btn-primary">{% trans 'Filter results' %}</button>
    <a href="{% url customer:order-list %}" class="btn">{% trans 'Reset' %}</a>
</form>
{% endblock %}

<table class="table table-striped table-bordered">
    <tr>
        {% block table_headers %}
        <th>{% trans 'Order placed' %}</th>
        <th>{% trans 'Order number' %}</th>
        <th>{% trans 'Product' %}</th>
        <th>{% trans 'Ordered by' %}</th>
        {% endblock %}
        {% block table_actions_header %}
        <th></th>
        {% endblock table_actions_header %}
    </tr>
{% for object in object_list %}
    <tr>
        {% block columns %}
        <td>{{ object.order.date_placed }}</td>
        <td>{{ object.order.number }}</td>
        <td>{% block product %}{{ object.product }}{% endblock product %}</td>
        <td>{{ object.order.user.first_name }} {{ object.order.user.last_name }}</td>
        {% endblock %}
        {% block table_actions_column %}
        <td>
            {% block action_buttons %}
                <form action="{% url approval:order-line-approve object.pk %}" method="post">
                    {% csrf_token %}
                    <button type="submit" class="btn btn-success">{% trans 'Approve' %}</button>
                </form>
                <form action="{% url approval:order-line-reject object.pk %}" method="post">
                    {% csrf_token %}
                    <button type="submit" class="btn btn-success">{% trans 'Reject' %}</button>
                </form>
            {% endblock action_buttons %}
        </td>
        {% endblock table_actions_column %}
    </tr>
{% endfor %}
</table>
{% if page_obj %}
    {% include "catalogue/partials/pagination.html" %}
{% endif %}
{% endblock content %}
