{% extends 'dashboard/layout.html' %}
{% load currency_filters %}
{% load i18n %}

{% block title %}
    {% trans "Docdata Orders" %} | {{ block.super }}
{% endblock %}

{% block breadcrumbs %}
    <ul class="breadcrumb">
        <li>
            <a href="{% url 'dashboard:index' %}">{% trans "Dashboard" %}</a>
            <span class="divider">/</span>
        </li>
        <li class="active"><a href=".">{% trans "Docdata Orders" %}</a></li>
    </ul>
{% endblock %}

{% block header %}
    <div class="page-header">
        <h1>{% trans "Docdata Orders" %}</h1>
    </div>
{% endblock header %}

{% block dashboard_content %}
    <div class="table-header">
        <h3><i class="icon-search icon-large"></i>{% trans "Search" %}</h3>
    </div>
    <div class="well">
        <form action="." method="get" class="form-inline" id="search_form">
            {% for field in form %}
                {% if "order" in field.id_for_label %}
                    {% if field.is_hidden %}
                        {{ field }}
                    {% else %}
                        <span class="control-group {% if field.errors %}error{% endif %}">
                            {{ field.label_tag }}
                            {{ field }}
                            {% for error in field.errors %}
                                <ul class="help-block">
                                    <li>{{ error }}</li>
                                </ul>
                            {% endfor %}
                        </span>
                    {% endif %}
                {% endif %}
            {% endfor %}
            <input type="submit" value="{% trans 'Search' %}" class="btn btn-primary" />
        </form>
    </div>

    <table class="table table-striped table-bordered table-hover">
        <caption><i class="icon-shopping-cart icon-large"></i>{% trans "Docdata Orders" %}</caption>
        {% if object_list %}
            <thead>
                <tr>
                    <th>{% trans "Order ID" %}</th>
                    <th>{% trans "Payment cluster key" %}</th>
                    <th>{% trans "Total gross amount" %}</th>
                    <th>{% trans "Status" %}</th>
                    <th>{% trans "created" %}</th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
                {% for docdata_order in object_list %}
                    <tr>
                        <td><a href="{% url 'docdata-order-detail' pk=docdata_order.pk %}">{{ docdata_order.merchant_order_id }}</a></td>
                        <td>{{ docdata_order.order_key }}</td>
                        <td>{{ docdata_order.total_gross_amount|currency:docdata_order.currency }}</td>
                        <td>{{ docdata_order.get_status_display }}</td>
                        <td>{{ docdata_order.created }}</td>
                        <td>
                            <a class="btn btn-info" href="{% url 'docdata-order-detail' pk=docdata_order.pk %}">{% trans "View" %}</a>
                        </td>
                    </tr>
                {% endfor %}
            </tbody>

        {% else %}
            <tbody>
                <tr><td>{% trans "There are no docdata orders to display." %}</td></tr>
            </tbody>
        {% endif %}
    </table>
    {% include "partials/pagination.html" %}

{% endblock dashboard_content %}
