{% include 'header.twig' %}

<div class="container">
  <div class="row">
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
      <a href="/tickets" class="btn btn-info btn-sm mb-2" style="
    padding-bottom: 9px;
    padding-right: 21px;
    margin-bottom: -21px;
    margin-top: 3em;
"><i class="link-icon mdi mdi-chevron-left"></i><i class="material-icons" style="top: 6px;">keyboard_arrow_left
</i> Back</a>
      <div class="well  ">

      {% if error %}
        <div class="alert alert-dismissible alert-danger">
          <button type="button" class="close" data-dismiss="alert">&times;</button>
          {{ errorText }}
        </div>
      {% endif %}
      {% if success %}
        <div class="alert alert-dismissible alert-success">
          <button type="button" class="close" data-dismiss="alert">&times;</button>
          {{ successText }}
        </div>
      {% endif %}

    
        <div class="titcket-title">{{ messageList['ticket']['subject'] }} {% if messageList["ticket"]["canmessage"] == 1 %} <span class="badge"> This request has been closed by the administrator</span> {% endif %} </div>

              {% if messageList %}
                {% for message in messageList %}
                  {% if message["support"] == 1 %}
                    <div class="row ticket-message-block ticket-message-right">
                      <div class="col-md-1"></div>
                      <div class="col-md-11">
                        <div class="ticket-message">
                          <div class="message">{{ message["message"] }}</div>
                        </div>
                        <div class="info text-right">
                          <strong>{{ user["username"] }}</strong>
                          <small class="text-muted">{{ message["time"] }}</small>
                        </div>
                      </div>
                      <div class="col-md-1"></div>
                    </div>
                  {% elseif message["subject"] %}
                  {% else %}
                    <div class="row ticket-message-block ticket-message-left">
                      <div class="col-md-11">
                        <div class="ticket-message">
                          <div class="message">{{ message["message"] }}</div>
                        </div>
                        <div class="info">
                          <strong>Support manager</strong>
                          <small class="text-muted">{{ message["time"] }}</small>
                        </div>
                      </div>
                      <div class="col-md-1"></div>
                    </div>
                  {% endif %}

                {% endfor %}
              {% endif %}
            {% if messageList['ticket']['canmessage'] == 2 %}
              <div class="row">
                  <div class="col-md-12">
                    <form method="post" action="tickets/{{ messageList['ticket']['ticket_id'] }}">
                      <div class="form-group panel-border-top">
                        <label for="message" class="control-label">Your message</label>
                        <textarea id="message" rows="5" class="form-control" name="message">{{ data["message"] }}</textarea>
                      </div>
                      <button type="submit"  style="
    margin-top: 1em;
" class="btn btn-primary">Send</button>
                    </form>
                  </div>
                </div>
              </div>
            {% endif %}

    </div>
  </div>
</div>
{% include 'footer.twig' %}
