<% case @ticket.status 
  when "open"
    badge_class = "tk-open"
  when "closed"
    badge_class = "tk-close"
  when "commenced"
    badge_class = "tk-processing"
  end
%>
<% content_for :page_menu do %>
 	<ul class="list-sidebar">
    <li class="item-sidebar"><a class="btn-sidebar" href="<%= sites_path %>"><i class="fa fa-home" aria-hidden="true"></i><%= t("client_management.my_sites") %></a></li>
    <li class="item-sidebar active"><a class="btn-sidebar" href="/cpanel/site/<%= @site_construct.uid %>"><i class="fa fa-envelope" aria-hidden="true"></i><%= t("client_management.tickets") %></a></li>
    <li class="item-sidebar"><a class="btn-sidebar" href="<%= cpanel_add_new_site_path(:site => @site_construct.id) %>"><i class="fa fa-server" aria-hidden="true"></i><%= t("client_management.services") %></a></li>
    <li class="item-sidebar"><a class="btn-sidebar" href="#"><i class="fa fa fa-credit-card-alt" aria-hidden="true"></i><%= t("client_management.payments") %></a></li>
  </ul>
<% end %>
<section class="cp-content col-md-10">
  <div class="cp-bread">
   	<ol class="breadcrumb">
      <li><a href="/cpanel/sites">Sites</a></li>
      <li><a href="/cpanel/site/<%= @site_construct.uid %>"><%= @site_construct.title %></a></li>
      <li><a href="/cpanel/site/<%= @site_construct.uid %>">Tickets</a></li>
      <li class="active"><%= @ticket.uid %></li>
    </ol>
  </div>
  <h2 class="cp-page-title">
    Ticket number : #<%= @ticket.uid %> (Reopen)
  </h2>
  <div class="cp-function-box clear">
    <a href="/cpanel/ticket/<%= @ticket.id.to_s %>"  class="btn btn-gray pull-right">Cancel</a>
  </div>
  <div id="error-msg-area" class="cp-message-box hide">
    <div class="message-text">
      Sorry, we found nothing.
    </div>
  </div>
  <div class="cp-comments-ticket">
    <div class="header-comments">
      <span class="subject-ticket"><%= @ticket.subject %></span>
      <div class="info-ticket">
      	<span class="type-ticket"><i class="fa fa-user" area-hidden="true"></i><%= @ticket.author %></span>
        <span class="type-ticket"><i class="fa fa-file" aria-hidden="true"></i>Type : <%= @ticket.category.title %></span>
        <span class="time-ticket"><i class="fa fa-clock-o" aria-hidden="true"></i>Time : <%= @ticket.created_at.strftime("%d %B %y %H:%M") %></span>
        <span class="number-ticket"><i class="fa fa-tags" aria-hidden="true"></i>Number : <%= @ticket.uid %></span>
      </div>
      <span class="status-ticket <%= badge_class %>"><%= @ticket.status.capitalize %></span>
    </div>

    <!-- lopp here -->
    <% @ticket.ticket_queries.asc(:created_at).each do |query| %>
	    <div class="comments-group">
	      <div class="post-comments">
	      	<p><%= query.query.html_safe %></p>
	      </div>
	      <% responses = query.ticket_query_responses.for_clients.asc(:created_at) %>
	      <% if responses.count > 0 %>
	      	<div class="talk-comments">
		        <div class="box-talk">
		          <div class="header-talk">
		            <h3 class="talk-title"><i class="fa fa-commenting-o" aria-hidden="true"></i>Response</h3>
		          </div>
		          <% responses.each do |response| %>
			          <div class="response-talk">
			            <div class="author-talk">
			              <div class="pic-author">
			                <img src="<%= response.author.member_profile.avatar.thumb.url %>" alt="author">
			              </div>
			              <span class="name-author"><%= response.author.name %></span>
			              <span class="time-author"><%= response.created_at.strftime("%d %B %Y - %H:%M") %></span>
			            </div>
			            <div class="text-talk">
			              <%= response.response.html_safe %>
			            </div>
			          </div>
			        <% end %>
		        </div>
	      	</div>
	       <% end %>
	    </div>
	  <% end %>
    <div class="comments-group">
      <div class="post-comments" id="reopened-area">
        <%= form_for @ticket_query, :url => {:action => "create_ticket_query"} do |f| %>
          <%= f.cktext_area :query %>
          <div class="post-comments">
            <%= f.hidden_field :ticket_id, :value => @ticket.id %>
            <%= f.submit "Reopen", :class => "btn btn-primary" %>
            <a href="/cpanel/ticket/<%= @ticket.id.to_s %>"  class="btn btn-default">Cancel</a>
          </div>
        <% end %>
      </div>
    </div>
  </div>
</section>
<script type="text/javascript">
$(document).ready(function(){
  $("*").animate({scrollTop: $("#reopened-area").offset().top + "px"}, 300);
})
</script>