{% extends '@LcShop/backend/default/show.html.twig' %}
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %}
{% trans_default_domain 'lcshop' %}
{% block main %}
    <div class="row">

        <div class="col-4">

            {% embed '@LcShop/backend/default/block/embed_box.twig' %}
                {% trans_default_domain 'lcshop' %}
                {% block class %}bg-info{% endblock %}
                {% block icon %}toggle-on{% endblock %}
                {% block label %} {{ "field.default.status"|trans }}{% endblock %}
                {% block value %}
                    {{ form_start(form_ticket_status,{'attr' : {'id' : 'ticketStatusForm'}}) }}
                    {% form_theme form_ticket_status '@LcShop/backend/form/custom_bootstrap_4.html.twig' %}
                    {% for field in form_ticket_status.status %}
                        {{ form_widget(field, {'attr': {"class" : 'ticket-status'}}) }}
                    {% endfor %}
                    {{ form_end(form_ticket_status) }}

                {% endblock %}
            {% endembed %}

            {% if entity.user %}
            {{ macros.box_info('bg-info', 'user', "field.default.user"|trans, entity.user.summary) }}
            {% else %}
            {{ macros.box_info('bg-info', 'user-secret', "field.default.visitor"|trans, entity.user ? entity.user.summary : entity.visitorInfos) }}
            {% endif %}
            {{ macros.box_info('bg-warning', 'calendar', "field.default.date"|trans, entity.createdAt|date('d/m/Y')) }}
            {% set trad = "field.Ticket.typeOptions."~entity.type %}
            {{ macros.box_info('bg-success', 'archive', "field.default.category"|trans, trad|trans) }}
            {% set trad = "field.Ticket.statusOptions."~entity.status %}



            {% if entity.orderShop is not null %}
                {{ macros.box_info('bg-danger', 'credit-card', "field.default.order"|trans, entity.orderShop.reference) }}

            {% endif %}
        </div>
        <div class="col-8">
            {{ macros.card_start('Ticket.listMessages') }}
            <div class="col-12  direct-chat-primary">
                {% for message in entity.ticketMessages %}
                    <div class="direct-chat-msg {{ message.answerByAdmin ? 'right' }}">
                        <div class="direct-chat-infos clearfix">
                            <span class="direct-chat-name {{ message.answerByAdmin ? 'float-right' : 'float-left' }}">
                                {{ message.createdBy }}
                            </span>
                            <span class="direct-chat-timestamp  {{ message.answerByAdmin ? 'float-left' : 'float-right' }}">
                                {{ message.createdAt|date('d/m/Y H:i') }}
                            </span>
                        </div>
                        {% if message.answerByAdmin %}
                            <img src="{{ asset('assets/img/backend/logo-pdl.png') }}" alt="" class="direct-chat-img"/>
                        {% else %}
                            <div class="direct-chat-img align-items-center">
                                <i class="fa fa-user-circle" style="font-size: 2rem"></i>
                            </div>
                        {% endif %}
                        <div class="direct-chat-text">
                            {{ message.message|nl2br }}
                        </div>
                    </div>
                {% endfor %}
            </div>
            <hr />
            {{ form_start(form_add_ticket_message, {"attr" : {"class" : 'col-12', 'id' : 'addTicketMessageForm'}}) }}
            {% form_theme form_add_ticket_message '@LcShop/backend/form/custom_bootstrap_4.html.twig' %}
            <div class="row">
                <div class="col-12">
                    {{ form_row(form_add_ticket_message.message) }}
                </div>
            </div>
            {{ form_end(form_add_ticket_message) }}
            {{ macros.card_end() }}

            <div>

            </div>

        </div>
    </div>

{% endblock %}

{% block script_javascript %}
    {{ parent() }}
    <script src="{{ asset('bundles/lcshop/js/backend/script/ticket/init-edit.js') }}"></script>

{% endblock %}
