{% extends request.ajax ? 'layout_blank.phtml' : 'layout_default.phtml' %}

{% import 'macro_functions.phtml' as mf %}

{% block meta_title %}{{ ticket.subject }}{% endblock %}

{% set profile = client.client_get %}

{% block content_before %}
    <h1>{{ ticket.subject }}</h1>
    <p class="text-secondary">{{ ticket.helpdesk.name }}</p>
    <ol class="breadcrumb">
        <li class="breadcrumb-item">
            <a href="{{ '/support'|link }}">{{ 'Support tickets'|trans }}</a>
        </li>
        <li class="breadcrumb-item active">#{{ ticket.id }} - {{ ticket.subject }}</li>
    </ol>
{% endblock %}

{% block content %}
    {% include 'Ticket/_header.phtml' %}
    <hr>
    <div class="row">
        {% for i, message in ticket.messages %}
            {% include 'Ticket/_message.phtml' %}
        {% endfor %}
    </div>
    <hr>
    {% if ticket.status != 'closed' %}
        <div class="col-12">
            <form method="post" class="api-form" data-api-url="{{ 'api/client/support/ticket_reply'|link }}" data-api-reload="1">
                <div class="mb-3">
                    <textarea class="form-control p-3" name="content" rows="10" maxlength="999" style="resize:none" required data-provide="markdown" data-iconlibrary="fa"></textarea>
                </div>
                <input type="hidden" name="id" value="{{ ticket.id }}">
                <div class="d-grid">
                    <button class="btn btn-primary" type="submit">{{ 'Post'|trans }}</button>
                </div>
            </form>
        </div>
        <hr>
    {% endif %}
    <div class="text-center">
        <a class="btn btn-default" href="{{ '/support'|link }}">
            <i class="fa fa-arrow-left me-2"></i>{{ 'Tickets list'|trans }}</a>
    </div>
{% endblock %}
