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

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

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

{% block content_before %}
    <h1 class="page-header">{{ 'Ordered Services'|trans }}</h1>
{% endblock %}

{% block content %}
    <div class="list-group mb-3">
        {% set orders = client.order_get_list({ 'per_page': 10, 'page': request.page, 'hide_addons': 1 }) %}
        
        {% for i, order in orders.list %}
            <a href="{{ '/order/service/manage'|link }}/{{ order.id }}" class="list-group-item {% if order.status == 'active' %}list-group-item-success{% elseif order.status == 'pending_setup' %}list-group-item-warning{% elseif order.status == 'failed_setup' %}list-group-item-danger{% endif %}">
                #{{ order.id }} - {{ order.title }} - {{ order.total|money(order.currency) }} {% if order.period %}{{ order.period|period_title }}{% endif %}
                {% if order.expires_at %}
                    <br><span class="text-secondary">{{ 'Expires at'|trans }}: {{ order.expires_at|date('Y-m-d h:i') }}</span>
                {% endif %}
                <span class="float-end badge {% if order.status == 'active' %}bg-success{% elseif order.status == 'pending_setup' %}bg-warning{% elseif order.status == 'failed_setup' %}bg-danger{% else %}bg-secondary{% endif %}">{{ mf.status_name(order.status) }}</span>
            </a>
        {% else %}
            <p class="text-secondary text-center">{{ 'The list is empty'|trans }}</p>
        {% endfor %}
    </div>
    {% include '_pagination.phtml' with { 'list': orders } %}
    
    <div class="text-center">
        <a class="btn btn-success" href="{{ 'order'|link }}"><i class="fa fa-shopping-cart me-2"></i>{{ 'New order'|trans }}</a>
    </div>
{% endblock %}
