{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}

{% import "macro_functions.phtml" as mf %}

{% block meta_title %}{{ 'My Products & Services'|trans }}{% endblock %}

{% block breadcrumb %}
<li class="service">{{ 'Orders'|trans }}</li>
{% endblock %}

{% block content %}
<div class="row">
    <article class="span12 data-block">
        <div class="data-container">
            <header>
                <h1>{{ 'Orders'|trans }}</h1>
                <p>{{ 'All of your orders are displayed here. Click on any order to get full information about it.'|trans }}</p>
            </header>

            <section>
                <table class="table table-striped table-bordered table-condensed table-hover">
            <thead>
                <tr>
                    <th>{{ 'Product/Service'|trans }}</th>
                    <th>{{ 'Price'|trans }}</th>
                    <th>{{ 'Next due date'|trans }}</th>
                    <th>{{ 'Status'|trans }}</th>
                    <th>&nbsp</th>
                </tr>
            </thead>
            <tbody>
                {% set orders = client.order_get_list({"per_page":10, "page":request.page, "hide_addons":1}) %}
                {% for i, order in orders.list %}
                <tr class="{{ cycle(['odd', 'even'], i) }}">
                    <td><a href="{{ '/order/service/manage'|link }}/{{order.id}}">{{ order.title }}</a></td>
                    <td>{{  order.total | money(order.currency) }} {% if order.period %}{{ order.period | period_title }}{% endif %}</td>
                    <td>{% if order.expires_at %}{{ order.expires_at|bb_date }}{% else %}-{% endif %}</td>
                    <td>
                        <span class="label {% if order.status == 'active' %}label-success{% elseif order.status == 'pending_setup' %}label-warning{% endif %}">{{ mf.status_name(order.status) }}</span>
                    </td>
                    <td class="actions">
                        <a class="bb-button" href="{{ '/order/service/manage'|link }}/{{order.id}}"><span class="dark-icon i-drag"></span></a>
                    </td>
                </tr>
                {% else %}
                <tr>
                    <td colspan="5">{{ 'The list is empty'|trans }}</td>
                </tr>
                {% endfor %}
            </tbody>

        </table>
                {% include "partial_pagination.phtml" with { 'list': orders } %}
            </section>
        </article>
    </div>
</div>
{% endblock %}
