{% extends '@LcShop/backend/default/show.html.twig' %}
{% trans_default_domain 'lcshop' %}
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %}
{% import '@LcShop/backend/user/macros.html.twig' as user_macros %}

 {% block global_actions %}
     {% if entity is not null %}
         {% set action = {label : "action.user.switch",  icon:  'user-secret', css_class: 'btn btn-sm btn-danger'} %}
         {% include '@LcShop/backend/user/block/user-switch.html.twig' with {item: entity, is_dropdown: false, action: action, translation_domain: 'lcshop', trans_parameters: {}, item_id: entity.id}%}

         <button id="btn-ticket-write-to-user"
                 data-url="{{ path('easyadmin', {'entity': 'Ticket', 'action': 'new'}) }}"
                 data-user="{{ entity.id }}"
                 class="btn-sm btn-success"
                 type="button"><i class="fa fa-pen-alt"></i> {{ "action.ticket.writeToUser"|trans }}
         </button>
     {% endif %}
 {% endblock %}

{% block main %}

    <div class="lc-vue-js-container" id="lc-user">
        <div class="row">
            <div class="col-3">
                {{ user_macros.card_info(entity) }}
            </div>
            <div class="col-3">
                {{ user_macros.box_rank_total_order(entity) }}
                {{ user_macros.box_total_order(entity) }}
            </div>
            <div class="col-3">
                {{ user_macros.box_rank_sum_order(entity) }}
                {{ user_macros.box_total_spent(entity) }}
            </div>
            <div class="col-3">
                {{ user_macros.box_register_since(entity) }}
                {{ user_macros.box_login_since(entity) }}
            </div>
            <div class="col-6">
                {% set redeliveries = orderUtils.getRedeliveryByUser(entity) %}
                {% if redeliveries|length %}
                    {{ macros.card_start('Redelivery.list', 'danger card-outline', true) }}
                    {{ user_macros.list_order_product_redelivery(redeliveries) }}
                    {{ macros.card_end() }}
                {% endif %}

                {% set tickets = ticketUtils.getTicketsByUser(entity) %}
                {% if tickets|length %}
                    {{ macros.card_start('Ticket.listMessages', 'warning card-outline', false) }}
                    {{ macros.list_tickets(tickets) }}
                    {{ macros.card_end() }}
                {% endif %}

                {% if entity.reductionCredits|length %}
                    {{ macros.card_start('ReductionCredit.list', 'warning card-outline', false) }}
                    {{ macros.list_reduction_credits(entity.reductionCredits) }}
                    {{ macros.card_end() }}
                {% endif %}

                {% set reductionCartsAvailable = orderUtils.getReductionCartsAvailableByUser(entity) %}
                {% if reductionCartsAvailable|length %}
                    {{ macros.card_start('ReductionCart.list', 'success card-outline', false) }}
                    {{ macros.list_reduction_carts(reductionCartsAvailable, entity) }}
                    {{ macros.card_end() }}
                {% endif %}
            </div>

            <div class="col-6">


                {{ macros.card_start('OrderShop.list', 'primary card-outline', false) }}
                {{ user_macros.list_order_shops(orderUtils.getOrderShops({'user': entity})) }}
                {{ macros.card_end() }}


            </div>

        </div>
    </div>
{% endblock %}
