{#
 # This file is part of SolidInvoice package.
 #
 # (c) Pierre du Plessis <open-source@solidworx.co>
 #
 # This source file is subject to the MIT license that is bundled
 # with this source code in the file LICENSE.
 #}

<div class="col-6">
    <div class="card mt-2">
        <div class="card-header{% if clients is not empty%} border-bottom-0{% endif %}">
            <h5 class="card-title">
                {{ icon('group') }} {{ 'dashboard.client.recent'|trans }}
            </h5>
        </div>
        {% if clients is not empty %}
            <div class="card-body p-0 border-0">
                <ul class="list-group dashboard-widget">
                    {% for client in clients %}
                        <li class="list-group-item">
                            <div class="btn-group">
                                <button type="button" class="btn btn-secondary btn-xs dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                                    {{ icon('cog') }}
                                </button>
                                <ul class="dropdown-menu" role="menu">
                                    <li class="nav-item">
                                        <a href="{{ path('_clients_view', {'id' : client.id}) }}" class="nav-link">
                                            {{ icon('eye') }} {{ 'dashboard.client.actions.view'|trans }}
                                        </a>
                                    </li>
                                    <li class="nav-item">
                                        <a href="{{ path('_clients_edit', {'id' : client.id}) }}" class="nav-link">
                                            {{ icon('edit') }} {{ 'dashboard.client.actions.edit'|trans }}
                                        </a>
                                    </li>
                                    <li class="divider"></li>
                                    <li class="nav-item">
                                        <a href="{{ path('_quotes_create', {'client' : client.id}) }}" class="nav-link">
                                            {{ icon('file-text-o') }} {{ 'dashboard.client.actions.create.quote'|trans }}
                                        </a>
                                    </li>
                                    <li class="nav-item">
                                        <a href="{{ path('_invoices_create', {'client' : client.id}) }}" class="nav-link">
                                            {{ icon('file-text-o') }} {{ 'dashboard.client.actions.create.invoice'|trans }}
                                        </a>
                                    </li>
                                </ul>
                            </div>

                            {{ client_label(client.status) }}

                            <a href="{{ path('_clients_view', {'id' : client.id}) }}">
                                {{ client.name }}
                            </a>

                            <div class="float-right">
                                <strong>
                                    {{ 'dashboard.client.actions.created'|trans }}
                                </strong> {{ client.created|diff }}
                            </div>
                        </li>
                    {% endfor %}
                </ul>
            </div>
            <div class="card-footer text-center border-top-0">
                <a href="{{ path('_clients_index') }}" class="uppercase">
                    {{ 'dashboard.client.view_all'|trans }}
                </a>
            </div>
        {% else %}
            <div class="card-body">
                <div class="text-center">
                    <h6>
                        {{ 'dashboard.client.empty'|trans }}
                    </h6>
                    <a href="{{ path('_clients_add') }}">
                        {{ icon('plus') }} {{ 'dashboard.client.create'|trans }}
                    </a>
                </div>
            </div>
        {% endif %}
    </div>
</div>
