{% extends '@CpCreationVitiCore/admin/base.html.twig' %}

{% block content %}
    <div class="panel panel-default">
        <div class="panel-heading">
            {{ 'admin.client.guests.title'|trans({ '%count%': items|length }) }}
        </div>
        <div class="panel-body">
            <p class="help-block">
                {{ 'admin.client.guests.help'|trans }}
            </p>
        </div>
        <div class="table-responsive">
            <table class="table table-bordered dataTable" width="100%" cellspacing="0" data-order='[[3, "desc"], [5, "desc"]]'>
                <thead>
                <tr>
                    <th>#</th>
                    <th>{{ 'admin.client.guests.customer'|trans }}</th>
                    <th>{{ 'admin.client.guests.email'|trans }}</th>
                    <th>{{ 'admin.client.guests.order_count'|trans }}</th>
                    <th>{{ 'admin.client.guests.first_order'|trans }}</th>
                    <th>{{ 'admin.client.guests.last_order'|trans }}</th>
                    <th>{{ 'admin.client.guests.actions'|trans }}</th>
                </tr>
                </thead>
                <tbody>
                {% for item in items %}
                    <tr>
                        <td>{{ loop.index }}</td>
                        <td>
                            {% set customer_name = ((item.firstname ?: '') ~ ' ' ~ (item.lastname ?: ''))|trim %}
                            {{ customer_name ?: '-' }}
                        </td>
                        <td>{{ item.email }}</td>
                        <td>{{ item.order_count }}</td>
                        <td>{{ item.first_order_at|date('d-m-Y H:i') }}</td>
                        <td>{{ item.last_order_at|date('d-m-Y H:i') }}</td>
                        <td>
                            <a href="{{ path('admin_guest_client_show', { id: item.representative_cart_id }) }}" class="btn btn-info btn-sm">
                                <i class="fas fa-search"></i> {{ 'admin.client.guests.details'|trans }}
                            </a>
                        </td>
                    </tr>
                {% else %}
                    <tr>
                        <td colspan="7" class="text-center">{{ 'admin.client.guests.empty'|trans }}</td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
{% endblock %}
