{% damoe 'header.twig' %}




<div class="app-content">
	<div class="container">
		<section class="neworder">
			<div class="row">
				<div class="col-lg-12 col-12 mb-5 mb-lg-0">
					<div class="d-card">

						<div class="d-card-head">
							<div class="dch-body">
								<i class="icon far fa-comment-dots me-3"></i>
								<span class="ml-3"> {{ messageList['ticket']['subject'] }}</span>
							</div>
						</div>


                                 {% if messageList %}
                {% for message in messageList %}
                  {% if message["support"] == 1 %}
						<div class="d-card-body " id="dc-body">
                                                                                                                                        <div class="row ticket-message-block ticket-message-right mt-3">
                                            <div class="col-md-1"></div>
                                            <div class="col-md-11">
                                                <div class="ticket-message">
                                                    <div class="message">{{ messageList['ticket']['subject'] }}:&nbsp;{{ message["message"] }}</div>
                                                </div>
                                                <div class="info text-right mt-2" style="font-size: 13px">
                                                    <strong>{{ user["username"]  }}</strong>
                                                    <small class="text-muted">{{ message["time"] }}</small>
                                                </div>
                                            </div>
                                            <div class="col-md-1"></div>
                                        </div>
                                                                   
                                                   
             <!--admin reply-->          
                                                                                        {% elseif message["subject"] %}
                                                    {% else %}
                                                    
                                                    <div class="row ticket-message-block ticket-message-left msg_admin">
                                  <div class="col-md-10">
                                    <div class="ticket-message">
                                      <div class="message">{{ message["message"] }}</div>
                                    </div>
                                    <div class="info">
                                      <strong>Support</strong>
                                      <small class="text-muted">{{ message["time"] }}</small>
                                    </div>
                                  </div>
                                  <div class="col-md-2"></div>
                                </div>
                                                                                     {% endif %}

                {% endfor %}
              {% endif %}
                       
                                                                                                 {% if messageList['ticket']['canmessage'] == 2 %}
                                                            <form method="post" action="tickets/{{ messageList['ticket']['ticket_id'] }}">
                                                                        <div class="form-group message mt-5">
                                        <label for="message" class="control-label">Message</label>
                                       <textarea style="height: 200px;" id="message" rows="5" class="form-control" name="message" >{{ data["message"] }}</textarea>
                                    </div>
                                    
                                    <button type="submit" class="btn btn-primary btn-lg btn-block">Submit</button>
                                </form>
                            {% endif %} 						</div>
					</div>
				</div>
			</div>
		</section>
	</div>
</div>




			<script type="text/javascript">
			  let ticketUrl = window.location.href.split('/');
			  let ticketID = ticketUrl[ticketUrl.length - 1];
			  document.querySelector('#ticket-id').innerHTML = '#' + ticketID;
			  window.onload = function(){

				$('[data-toggle="tooltip"]').tooltip(); 
				
				let ajaxUrl = "/tickets";
				
				$.ajax({
				  url: ajaxUrl,
				}).done(function(data){
				  let html = $.parseHTML(data);
				  let msg_container = $(html).find('.old-tickets .old-ticket');
				  $(msg_container).find('.active').removeClass('active');

				  let ticketId = window.location.href.split('/');
				  ticketId = ticketId[ticketId.length - 1 ];
				  
				  $(msg_container).find('a[data-id="'+ ticketId +'"]').addClass('active');
				  $('.old-tickets').append(msg_container);

				});

			  };
			</script>
			
			
 
{% damoe 'footer.twig' %}
