{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% set active_menu = 'services' %}

{% import "macro_functions.html.twig" as mf %}

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

{% block body_class %}order-list{% endblock %}
{% block breadcrumb %}
    <li class="breadcrumb-item active" aria-current="page">{{ 'Services'|trans }}</li>
{% endblock %}

{% block content %}
    <div class="row">
        <div class="col-md-12">
            <div class="card mb-4">
                <div class="card-header py-3 py-3">
                    <div class="d-flex justify-content-between align-items-center">
                        <div>
                            <h1 class="mb-1">{{ 'Services'|trans }}</h1>
                            <span class="small text-muted">{{ 'All of your orders are displayed here. Click on any service to get full information about it.'|trans }}</span>
                        </div>
                    </div>
                </div>
                <div class="card-body table-responsive">
                    {% set orders = client.order_get_list({"per_page":10, "page":request.page, "hide_addons":1}) %}
                    {% if orders.list %}
                        <table class="table table-striped table-bordered table-hover">
                            <thead>
                            <tr>
                                <th>{{ 'Order ID'|trans }}</th>
                                <th>{{ 'Product/Service'|trans }}</th>
                                <th>{{ 'Price'|trans }}</th>
                                <th>{{ 'Next Due Date'|trans }}</th>
                                <th>{{ 'Status'|trans }}</th>
                                <th>{{ 'Actions'|trans }}</th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for i, order in orders.list %}
                                <tr>
                                    <td><a href='{{ "order/service/manage/#{order.id}"|url }}'>#{{ order.id }}</a></td>
                                    <td>
                                        <span>{{ order.title }}</span>
                                    </td>
                                    <td>{{ order.total|format_currency(order.currency ?? default_currency) }} {% if order.period %}{{ order.period|period_title }}{% endif %}</td>
                                    <td>{% if order.expires_at %}{{ order.expires_at|format_date }}{% else %}-{% endif %}</td>
                                    <td>
                                    {{ mf.status_badge(order.status, 'order') }}
                                    </td>
                                    <td class="actions">
                                        <a class="btn btn-sm btn-outline-primary" href='{{ "order/service/manage/#{order.id}"|url }}'>{{ 'Manage'|trans }}</a>
                                    </td>
                                </tr>
                            {% endfor %}
                            </tbody>
                        </table>
                    {% else %}
                        <div class="d-flex justify-content-center my-2 py-4">
                            <span class="m-0">{{ 'No orders yet'|trans }}</span>
                        </div>
                    {% endif %}
                    {{ include('partial_pagination.html.twig', { 'list': orders }) }}
                </div>
            </div>
        </div>
    </div>
{% endblock %}
