{% extends 'shop/base.html' %}
{% load i18n static %}
{% block content %}
{% include 'shop/_manage_header.html' with active='orders' %}
{% trans "Search orders…" as list_search_placeholder %}
<div data-table data-page-size="25">
    {% include 'shop/_list_search.html' with placeholder=list_search_placeholder %}
    <table class="table table-striped align-middle">
        <thead><tr>
            <th data-sort="text">{% trans "Reference" %}</th>
            <th data-sort="text">{% trans "Buyer" %}</th>
            <th data-sort="text" data-sort-default="desc">{% trans "When" %}</th>
            <th data-sort="num">{% trans "Items" %}</th>
            <th data-sort="num">{% trans "Est. total" %}</th>
            <th data-sort="text">{% trans "Status" %}</th>
        </tr></thead>
        <tbody>
        {% for order in orders %}
        <tr data-name="{{ order.reference|lower }} {{ order.buyer.character_name|lower }}">
            <td><a href="{% url 'backoffice:order_detail' shop.pk order.reference %}"><code>#{{ order.reference }}</code></a></td>
            <td>{{ order.buyer.character_name }}</td>
            <td data-sort-value="{{ order.created_at|date:'Y-m-d H:i' }}">{{ order.created_at|date:"Y-m-d H:i" }}</td>
            <td data-sort-value="{{ order.lines.all|length }}">{{ order.lines.all|length }}</td>
            <td data-sort-value="{{ order.estimated_total }}">{{ order.estimated_total_display }}{% if order.has_ask %} <span class="text-warning small">· Ask</span>{% endif %}</td>
            <td>{% include 'shop/_order_status_badge.html' %}</td>
        </tr>
        {% empty %}
        <tr><td colspan="6" class="text-muted">{% trans "No orders yet." %}</td></tr>
        {% endfor %}
        </tbody>
    </table>
    <nav data-table-pager class="mt-2"></nav>
</div>
{% endblock %}
{% block extra_javascript %}
<script src="{% static 'shop/backoffice_tables.js' %}"></script>
{% endblock %}
