{% include 'header.twig' %}
<div class="container">
    <div class="row">
        <div class="col-md-8 col-md-offset-2">
            <div class="well  ">
                <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><br>
                            <small class="text-muted">{{ message["time"] }}</small>
                        </div><hr>
                    </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">
								Hello! {{ user["username"] }}, <br><br>
								{{ message["message"] }}<br><br>
								We wish you pleasant shopping!<br>
									Regards.
								</div>
                        </div> 
                        <div class="info">
                            <strong>Admin <img src="../img/verified.png" width="20"></strong><br>
                            <small class="text-muted">{{ message['time'] }}</small>
                        </div><hr>
                    </div>
                    <div class="col-md-1"></div>
                </div>
										{% endif %}
									  {% endfor %}
									{% endif %}
                
                									{% if messageList['ticket']['canmessage'] == 2 %}
									<form method="post" action="tickets/{{ messageList['ticket']['ticket_id'] }}">
									  {% if error %}
										<div class="alert alert-dismissible alert-danger">
										  <button type="button" class="close" data-dismiss="alert">×</button>
										  {{ errorText }}
										</div>
									  {% endif %}
									  {% if success %}
										<div class="alert alert-dismissible alert-success">
										  <button type="button" class="close" data-dismiss="alert">×</button>
										  {{ successText }}
										</div>
									  {% endif %}
                                       <div class="form-group message mt-5">
                                          <label for="message" class="control-label">Your message</label>
                                          <textarea class="form-control" rows="7" id="message" name="message" placeholder="Please enter your message..." style="height:150px!important"></textarea>
                                       </div>
									   <input type="hidden" name="_csrf" value="{{csrftoken}}">
                                       <button type="submit" class="btn btn-primary btn-lg btn-block">Reply</button>
                                    </form>
									{% endif %}
            </div>
        </div>
    </div>
</div>
</div>
{% include 'footer.twig' %}
