{% extends "pbp_store/admin_base.html" %}
{% load url from future %}
{% load catalog_filters %}

{% block body %}
<h2>Orders</h2>

<ul class="nav nav-pills">
  <li {% if status == 'init' %} class="active" {% endif %}>
    <a href="?status=init">Initialized</a>
  </li>
  <li {% if status == 'submitted' %} class="active" {% endif %}><a href="?status=submitted">Submitted</a></li>
  <li {% if status == 'processed' %} class="active" {% endif %}><a href="?status=processed">Processed</a></li>
  <li {% if status == 'shipped' %} class="active" {% endif %}><a href="?status=shipped">Shipped</a></li>
  <li {% if status == 'cancelled' %} class="active" {% endif %}><a href="?status=cancelled">Cancelled</a></li>
  <li {% if status == 'all' %} class="active" {% endif %}><a href="?status=all">All</a></li>
</ul>

<table class="table">
    <thead>
        <tr>
            <th>Order Date</th>
            <th>Status</th>
            <th>Buyer</th>
            <th># of items</th>
            <th>Total Price</th>
            <th>Actions</th>
        </tr>
    </thead>
    <tbody>
{% for order in orders %}
    <tr>
        <td>{{ order.date }}</td>
        <td>{{ order.get_status_display }}</td>
        <td>{{ order.user }}</td>
        <td>{{ order.item_count }}</td>
        <td>{{ order.total|currency }}</td>
        <td>[<a href="{% url 'view_order_detail' order.pk %}">View</a>]</td>
    </tr>
{% empty %}
    <tr><td colspan="6">No Orders!</td></tr>
{% endfor %}
</table>

{% endblock body %}
