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

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

{% block meta_title %}{{ 'Payments history'|trans }}{% endblock %}

{% set profile = client.client_get %}

{% block content_before %}
    <h1>{{ 'Payments history'|trans }}</h1>
{% endblock %}

{% block content %}
    <table class="table table-hover table-striped">
        <thead>
            <tr>
                <th>{{ 'Amount'|trans }}</th>
                <th>{{ 'Description'|trans }}</th>
                <th>{{ 'Date'|trans }}</th>
            </tr>
        </thead>
        <tbody>
            {% set transactions = client.client_balance_get_list({ 'per_page': 10, 'page': request.page }) %}
            {% for i, tx in transactions.list %}
                <tr>
                    <td>{{ tx.amount | money(tx.currency) }}</td>
                    <td>{{ tx.description }}</td>
                    <td>{{ tx.created_at|date('Y-m-d h:i') }}</td>
                </tr>
            {% else %}
                <tr>
                    <td colspan="3">{{ 'The list is empty'|trans }}</td>
                </tr>
            {% endfor %}
        </tbody>

        <tfoot>
            <tr>
                <th class="currency" colspan="3">{{ 'Balance'|trans }}: {{ profile.balance|money(profile.currency) }}</th>
            </tr>
        </tfoot>
    </table>
    {% include '_pagination.phtml' with { 'list': transactions } %}

    <p class="text-center">
        <a class="btn btn-success" data-bs-toggle="modal" data-bs-target="#modalAddFunds">
            <i class="fa fa-cart-plus me-2"></i>{{ 'Add funds'|trans }}</a>
    </p>

    {% include 'Modal/_add-funds.phtml' %}
{% endblock %}
