{% extends "layout.html" %}

{% load currency_filters %}

{% block header %}
<h2>Order management</h2>
{% endblock header %}
{% block content %}
<form method="get" action="{% url order-management:list %}">
    {{ order_simple_search_form.as_p }}
    <input type="submit" nane="simple_search" value="Search" />
</form>
{% if orders.count %}

<table>
    <tr>
        <th>Order number</th>
        <th>Total inc tax</th>
        <th>Shipping status</th>
        <th>Customer</th>
        <th>Shipping address</th>
        <th>Billing address</th>
        <th>Date submitted</th>
        <th></th>
    </tr>
    {% for order in orders %}
    <tr>
        <td>{{ order.number }}</td>
        <td>{{ order.total_incl_tax|currency }}</td>
        <td>{{ order.shipping_status }}</td>
        <td>{{ order.user }}</td>
        <td>{{ order.shipping_address }}</td>
        <td>{{ order.billing_address }}</td>
        <td>{{ order.date_placed }}</td>
        <td>
            <a href="{% url order-management:detail order.number %}">View</a>
        </td>
    </tr>
    {% endfor %}

</table>

{% if page_obj %}
<div class="pagination">
    <span class="step-links">
    
        {% if page_obj.has_previous %}
            <a href="?page={{ page_obj.previous_page_number }}{{ search_params }}">previous</a>
        {% endif %}

        <span class="current">
            Page {{ page_obj.number }} of {{ paginator.num_pages }}.
        </span>

        {% if page_obj.has_next %}
            <a href="?page={{ page_obj.next_page_number }}{{ search_params }}">next</a>
        {% endif %}
    </span>
</div>
{% endif %}

{% else %}

<p>No orders found.</p>

{% endif %}

{% endblock content %}
