<% if User.current.allowed_to?(:view_helpdesk_tickets, @project) && @issue.is_ticket?  %>
<div id="ticket_data">
    <div class="contextual">
        <%= link_to l(:label_helpdesk_public_link), public_ticket_path(@issue.helpdesk_ticket, :hash => @issue.helpdesk_ticket.token), :class => "icon icon-public-link" if RedmineHelpdesk.public_tickets? && !@issue.is_private %>
        <%# link_to l(:label_helpdesk_spam),
          {:controller => 'helpdesk',
          :action => 'delete_spam',
          :project_id => @project,
          :issue_id => @issue},
          :method => :delete,
          :data => {:confirm => l(:text_are_you_sure)},
          :class => "icon icon-email-spam" if @issue.helpdesk_ticket.source == HelpdeskTicket::HELPDESK_EMAIL_SOURCE && @issue.customer.primary_email && User.current.allowed_to?(:send_response, @project) && User.current.allowed_to?(:delete_issues, @project) && User.current.allowed_to?(:delete_contacts, @project) %>
    </div>
	<span class="icon <%= helpdesk_ticket_source_icon(@issue.helpdesk_ticket) %>", title="<%=  l(:label_helpdesk_to_address) %>: <%= @issue.helpdesk_ticket.to_address %>">
    <%= @issue.helpdesk_ticket.is_incoming? ? l(:label_helpdesk_from) : l(:label_sent_to) %>
	</span>
	<span class="ticket_customer"  style="white-space: nowrap;display: inline-block;">
	  <%= contact_tag(@issue.customer, :type => "plain") %>
	  (<%= @issue.helpdesk_ticket.from_address %>)
	</span>
    <% if attachment = @issue.helpdesk_ticket.message_file %>
      <span class="attachment" style="white-space: nowrap;display: inline-block;">
        <%= link_to_attachment attachment, :text => l(:label_helpdesk_original), :download => true, :class => 'icon icon-attachment' -%>
        <%= h(" - #{attachment.description}") unless attachment.description.blank? %>
          <span class="size">(<%= number_to_human_size attachment.filesize %>)</span>
          <%= link_to_if_authorized image_tag('magnifier.png', :plugin => "redmine_contacts_helpdesk"),
                :controller => 'helpdesk', :action => 'show_original',
                :id => attachment, :project_id => @project %>
      </span>
    <% end %>
    <span class="helpdesk-message-date"><%= format_time(@issue.helpdesk_ticket.ticket_date) %></span>
    <br>
    <% unless @issue.helpdesk_ticket.cc_address.blank? %>
    <span class="helpdesk-message-date"><%=  l(:label_helpdesk_cc) %>: <%= @issue.helpdesk_ticket.cc_address.split(',').join(', ') %></span>
    <% end %>
</div>
<% if Redmine::VERSION.to_s > '3.2' %>
  <script type="text/javascript">
    $(document).ready(function() {
      $(".attributes").first().prepend($("#ticket_data"));
      $("#ticket_data").after("<hr>");
    });
  </script>
<% else %>
  <hr />
<% end %>

<%= issue_fields_rows do |rows|
  rows.left l(:label_helpdesk_ticket_reaction_time), distance_of_time_in_words(@issue.helpdesk_ticket.reaction_time, 0, :include_seconds => true) if @issue.helpdesk_ticket.reaction_time
  rows.left l(:label_helpdesk_ticket_resolve_time), distance_of_time_in_words(@issue.helpdesk_ticket.resolve_time, 0, :include_seconds => true) if @issue.helpdesk_ticket.resolve_time
  rows.right l(:label_helpdesk_contact_vote), show_customer_vote(@issue.helpdesk_ticket.vote, @issue.helpdesk_ticket.vote_comment) if @issue.helpdesk_ticket.vote && @issue.helpdesk_ticket.vote >= 0
  rows.right l(:label_helpdesk_ticket_first_response_time), distance_of_time_in_words(@issue.helpdesk_ticket.first_response_time, 0, :include_seconds => true) if @issue.helpdesk_ticket.first_response_time
  rows.right l(:label_helpdesk_ticket_last_response_time), distance_of_time_in_words(@issue.helpdesk_ticket.last_response_time, Time.now.utc) if @issue.helpdesk_ticket.last_response_time
end %>

<% end %>
