{% trans_default_domain 'lcshop' %}

{% macro card_info(user) %}
    {% import '@LcShop/backend/default/block/macros.html.twig' as macros %}
    <div class="card card-primary card-outline">
        <div class="card-body box-profile">
            <h3 class="profile-username">
                <i class="fa fa-user"></i> &nbsp; {{ user.gender == 1 ? 'Mme.' : 'M.' }} {{ user.name }}

            </h3>
            <ul class="list-group list-group-unbordered">
                {% if user.age < 200 and user.age > 2 %}
                    <li class="list-group-item">
                        <b> <i class="fa fa-birthday-cake"></i> Age </b>
                        <span class="float-right"> {{ user.age }} &nbsp;  ans ({{ user.birthdate|date('d/m/Y') }})</span>
                    </li>
                {% endif %}

                <li class="list-group-item">
                    <b> <i class="fa fa-envelope"></i> Email</b>
                    <span class="float-right"> {{ user.email }}</span>
                </li>
                <li class="list-group-item">
                    <b> <i class="fa fa-phone"></i> Téléphone</b>
                    <span class="float-right"> {{ user.phone }}</span>
                </li>

                <li class="list-group-item">
                    <b><i class="fa fa-fw fa-bullhorn"></i> Newsletters</b>
                    {% for newsletter in user.newsletters %}
                        <span class="badge badge-success float-right">{{ newsletter }}</span>
                    {% else %}
                        <span class="badge badge-dark float-right">Aucune</span>
                    {% endfor %}
                </li>


                <li class="list-group-item">
                    <b> <i class="fa fa-users"></i> Groupes</b>
                    {% for group in user.groups %}
                        <span class="badge badge-info float-right">{{ group }}</span>&nbsp;
                    {% else %}
                        <span class="badge badge-dark float-right">Aucun</span>
                    {% endfor %}
                </li>
                {% if is_granted('ROLE_SUPER_ADMIN') == false %}
                    <li class="list-group-item">
                        <b> <i class="fa fa-user-shield"></i> Roles</b>
                        {% for role in user.roles %}
                            <span class="badge badge-danger float-right">{{ role }}</span>&nbsp;
                        {% endfor %}
                    </li>
                {% endif %}
            </ul>
            <br />
            <div>
            <a class="btn btn-sm btn-primary float-right" href="{{ path('easyadmin', {"action" : 'edit', 'entity': 'User', 'id': user.id}) }}">
                <i class="fa fa-pen"></i> Éditer l'utilisateur
            </a>
            </div>
        </div>
    </div>
{% endmacro card_info %}


{% macro box_rank_sum_order(user) %}
    {% embed '@LcShop/backend/default/block/embed_figure_box.twig' %}
        {% block class %}bg-maroon{% endblock %}
        {% block icon %}cubes{% endblock %}
        {% block label %} Classement par total dépensés{% endblock %}
        {% block value %}
            {% set rankSumOrder = orderUtils.rankSumOrderByUser(user) %}
            {% if rankSumOrder %}
                {{ rankSumOrder }} <small style="opacity: 0.7"> / {{ orderUtils.countUsersWithValidOrderShop() }}</small>
            {% else %}
                Non classé
            {% endif %}
        {% endblock %}
    {% endembed %}
{% endmacro box_rank_sum_order %}


{% macro box_total_spent(user) %}
    {% embed '@LcShop/backend/default/block/embed_figure_box.twig' %}
        {% trans_default_domain 'lcshop' %}
        {% block class %}bg-pink{% endblock %}
        {% block icon %}euro-sign{% endblock %}
        {% block label %}  Total dépensés{% endblock %}
        {% block value %}
            {{ orderUtils.totalSpentByUser(user)|format_price(false) }}

        {% endblock %}
    {% endembed %}
{% endmacro box_total_spent %}

{% macro box_rank_total_order(user) %}
    {% embed '@LcShop/backend/default/block/embed_figure_box.twig' %}
        {% block class %}bg-info{% endblock %}
        {% block icon %}cubes{% endblock %}
        {% block label %}Classement par nombre de commande {% endblock %}
        {% block value %}
            {% set rankTotalOrder = orderUtils.rankTotalOrderByUser(user) %}

            {% if rankTotalOrder %}
                {{ rankTotalOrder }} <small style="opacity: 0.7"> / {{ orderUtils.countUsersWithValidOrderShop() }}</small>
            {% else %}
                Non classé
            {% endif %}
        {% endblock %}
    {% endembed %}
{% endmacro box_rank_total_order %}


{% macro box_total_order(user) %}
    {% embed '@LcShop/backend/default/block/embed_figure_box.twig' %}
        {% trans_default_domain 'lcshop' %}
        {% block class %}bg-lightblue{% endblock %}
        {% block icon %}shopping-cart{% endblock %}
        {% block label %} Nombre de commandes{% endblock %}
        {% block value %}
            {{ orderUtils.countValidOrderShopByUser(user) }}
        {% endblock %}
    {% endembed %}
{% endmacro box_total_order %}

{% macro box_register_since(user) %}
    {% embed '@LcShop/backend/default/block/embed_figure_box.twig' %}
        {% trans_default_domain 'lcshop' %}
        {% block class %}bg-success{% endblock %}
        {% block icon %}calendar-plus{% endblock %}
        {% block label %}Date de l'inscription{% endblock %}
        {% block value %}
            {{ user.createdAt|date('d/m/Y H:i') }}
        {% endblock %}
    {% endembed %}
{% endmacro box_register_since %}

{% macro box_login_since(user) %}
    {% embed '@LcShop/backend/default/block/embed_figure_box.twig' %}
        {% trans_default_domain 'lcshop' %}
        {% block class %}bg-olive{% endblock %}
        {% block icon %}calendar-check{% endblock %}
        {% block label %}Date de dernière visite{% endblock %}
        {% block value %}
            {{ user.lastLogin|date('d/m/Y H:i') }}
        {% endblock %}
    {% endembed %}
{% endmacro box_login_since %}

{% macro list_order_product_redelivery(orderProductsRedelivery) %}

    <table class="table lc-table-list table-striped">
        <thead>
        <tr>
            <th>Id</th>
            <th>Produit</th>
            <th>Quantité</th>
            <th>Date de livraison</th>
            <th>Statut</th>
            <th></th>
        </tr>
        </thead>
        <tbody>
        {% for orderProduct in orderProductsRedelivery %}
            <tr>
                <td>{{ orderProduct.id }}</td>
                <td>{{ orderProduct.title }}</td>
                <td>{{ orderProduct.quantityOrder }}</td>

                <td>
                    {% include '@LcShop/backend/default/field/datetime.html.twig' with {value  : orderProduct.orderShop.deliveryDate} %}</td>
                <td>{% include '@LcShop/backend/order/field/order_status.html.twig' with {value : orderProduct.orderShop.orderStatus} %}</td>
                <td>
                    {% import '@LcShop/backend/default/block/macros.html.twig' as macros %}
                    {% if orderProduct.orderShop.isCart() %}
                        {{ macros.button('OrderProductRedelivery', 'edit',  orderProduct.id, 'primary') }} &nbsp;
                    {% endif %}

                    {{ macros.button('OrderShop', 'show',  orderProduct.orderShop.id) }}
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>

{% endmacro list_order_product_redelivery %}



{% macro list_order_shops(orderShops) %}
    <table class="table table-striped">
        <tbody>
        <thead>
        <tr>
            <th>Id</th>
            <th>WeekId</th>
            <th>Numéro de semaine</th>
            <th>Référence</th>
            <th>Montant TTC</th>
            <th>Statut</th>
            <th></th>
        </tr>
        </thead>
        <tbody>
        {% for orderShop in orderShops %}
            <tr>
                <td>{{ orderShop.id }}</td>
                <td>{{ orderShop.weekId }}</td>
                <td>{{ orderShop.weekNumber }}</td>
                <td>{{ orderShop.reference }}</td>
                <td>{{ priceUtils.getTotalWithTax(orderShop, true)|format_price(false) }}</td>
               <td>{% include '@LcShop/backend/order/field/order_status.html.twig' with {value : orderShop.orderStatus} %}</td>

                <td>
                    {% import '@LcShop/backend/default/block/macros.html.twig' as macros %}
                    {{ macros.button('OrderShop', 'show', orderShop.id) }}
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
{% endmacro list_order_shops %}
