{% include 'header.twig' %}  
{# FontAwesome 6 Fix #}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css"> 

<style>
    
    /* Styling the table */
.table {
    width: 100%;
    margin: 20px 0;
    border-collapse: collapse;
}

.table th, .table td {
    padding: 12px;
    text-align: left;
}

.table th {
    background-color: #f8f9fa;
    font-weight: bold;
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: #f2f2f2;
}

.table-bordered {
    border: 1px solid #ddd;
}

.table-bordered th, .table-bordered td {
    border: 1px solid #ddd;
}

.table-hover tbody tr:hover {
    background-color: #f1f1f1;
}

.pagination {
    margin-top: 20px;
}

.pagination .page-item .page-link {
    border-radius: 50%;
    margin: 0 5px;
    padding: 8px 16px;
}

.pagination .page-item.active .page-link {
    background-color: #007bff;
    color: #fff;
}

.pagination .page-link {
    background-color: #fff;
    color: #007bff;
    border: 1px solid #ddd;
}

.pagination .page-item:hover .page-link {
    background-color: #e9ecef;
}

    
</style>
<div class="content">
    <!-- Page and other top info -->
    <div id="page_info">
        <!-- You can add page-specific information here if necessary -->
    </div>
    <!-- // page and other top info -->

    <div id="affiliates">
        <div class="container-fluid">
            <div class="row">
                {% if PageText %}
                    <div class="col-md-12">
                        <div class="card">
                            {{ contentText }}
                        </div>
                    </div>
                {% endif %}
            </div>
        </div>
    </div>

    <div class="col-md-12">
        <div class="card card_v2">
            <div class="card-body">
                <div class="col">
                    <div class="orders-history__margin-tab">
                        <div class="component_status_tabs">
                            <ul class="nav nav-pills tab">
                                <!-- Add tabs or other navigation elements here if needed -->
                            </ul><br>

                            <div class="row">
                                <div class="col">
                                    <div class="orders-history__margin-table">
                                        <div class="table-bg component_table">
                                            <table class="table table-striped table-bordered">
                                                <thead>
                                                    <tr>
                                                        <th><b>Service Id</b></th>
                                                        <th><b>Service Name</b></th>
                                                        <th><b>Description</b></th>
                                                        <th><b>Date</b></th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    {% for order in orders %}
                                                        <tr>
                                                            <td>{{ order['service_id'] }}</td>
                                                            <td>{{ order['service_name'] }}</td>
                                                            <td>{{ order['description'] }}</td>
                                                            <td>{{ order['date'] }}</td>
                                                        </tr>
                                                    {% endfor %}
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>

                                    {% if pagination["count"] > 1 %}
                                        <ul class="pagination justify-content-center">
                                            {% if pagination["current"] == 1 %}
                                                <li class="page-item">
                                                    <a class="page-link" href="updates/{{ status }}/{{ pagination["previous"] }}{% if search %}?search={{ search }}{% endif %}" aria-label="Previous">
                                                        <span aria-hidden="true">←</span>
                                                    </a>
                                                </li>
                                            {% endif %}

                                            {% set r, l = 3, 3 %}

                                            {% if pagination['current'] == 1 %}
                                                {% set r = 7 %}
                                            {% endif %}

                                            {% if pagination['current'] == 2 %}
                                                {% set r = 5 %}
                                            {% endif %}

                                            {% if pagination['current'] >= pagination['count'] %}
                                                {% set l = 5 %}
                                            {% endif %}

                                            {% for page in 1..pagination["count"] %}
                                                {% if page >= (pagination['current'] - l) and page <= (pagination['current'] + r) %}
                                                    <li class="page-item {% if page == pagination['current'] %}active{% endif %}">
                                                        <a class="page-link" href="updates/{{ status }}/{{ page }}{% if search %}?search={{ search }}{% endif %}">{{ page }}</a>
                                                    </li>
                                                {% endif %}
                                            {% endfor %}

                                            {% if pagination['current'] < pagination['count'] %}
                                                <li class="page-item">
                                                    <a class="page-link" href="updates/{{ status }}/{{ pagination['next'] }}{% if search %}?search={{ search }}{% endif %}" aria-label="Next">
                                                        <span aria-hidden="true">→</span>
                                                    </a>
                                                </li>
                                            {% endif %}
                                        </ul>
                                    {% endif %}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

{% include 'footer.twig' %}
