<%= textilizable(issue, :description, {headings: false, only_path: false}) %>

<% content_for :email_header do %>
  <%= greeting %>
<% end %>

<% content_for :email_heading do %>
    <% if EasySetting.value('show_issue_id', issue.project) %>
        <%= link_to("##{issue.id} - #{issue.subject}", issue_url) %>
    <% else %>
        <%= link_to(issue.subject, issue_url) %>
    <% end %>
<% end %>

<% content_for :email_attributes do %>

  <% unless issue.disabled_core_fields.include?('assigned_to_id') %>
       <%= content_tag( :p, content_tag(:b,  l(:field_assigned_to)) + ': ' + (issue.assigned_to ? link_to_user(issue.assigned_to, only_path: false) : "-"), class: 'assigned-to') %>
  <% end %>

  <% if issue.project.trackers.count > 1 %>
    <%=content_tag( :p, content_tag(:b, l(:field_tracker)) + ': ' + h(issue.tracker.name), class: 'category') %>
  <% end %>

  <%= content_tag(:p, content_tag( :b, l(:field_status)) + ': ' + h(issue.status.name), class: 'status') %>

  <%= content_tag(:p, content_tag( :b, l(:field_priority)) + ': ' + h(issue.priority.name), class: "priority-#{issue.priority.position} #{issue.priority.easy_color_scheme}")%>

  <% unless issue.disabled_core_fields.include?('category_id') || EasyExtensions::EasyProjectSettings.disabled_features[:others].include?('issue_categories') %>
    <%= content_tag(:p, content_tag( :b, l(:field_category)) + ': ' + h(issue.category ? issue.category.name : "-"), class: 'category') %>
  <% end %>


  <% unless issue.disabled_core_fields.include?('start_date') %>
    <%= content_tag(:p, content_tag(:b, l(:field_start_date)) + ': ' + format_date(issue.start_date), class: 'start-date') %>
  <% end %>

  <% unless issue.disabled_core_fields.include?('due_date') %>
    <%= content_tag(:p, content_tag(:b, l(:field_due_date)) + ': ' + format_date(issue.due_date), class: "due-date #{'overdue' if issue.due_date && issue.due_date < Date.today}") %>
  <% end %>

  <%= content_tag(:p, content_tag(:b, l(:field_author)) + ': ' + link_to_user(issue.author, only_path: false), class: 'author') %>

  <% unless issue.disabled_core_fields.include?('estimated_hours')%>
    <% unless issue.estimated_hours.nil? %>
      <%= content_tag(:p, content_tag(:b, l(:field_estimated_hours)) + ': ' + format_hours(issue.estimated_hours), class: 'estimated-hours') %>
    <% end %>
  <% end %>

  <%= content_tag(:p, content_tag(:b, l(:field_fixed_version)) + ': ' + h(issue.fixed_version), class: 'fixed-version') unless issue.disabled_core_fields.include?('fixed_version_id') || issue.fixed_version.nil? %>

  <% if issue.custom_field_values.any? %>
    <% issue.visible_custom_field_values.each do |c| %>
      <% next if !c.custom_field.mail_notification || !c.custom_field.visible? %>
      <p>
        <b><%= h(c.custom_field.translated_name) +': '%></b>
        <%= show_value(c) %>
      </p>
    <% end %>
  <% end %>
  <%= call_hook(:view_mailer_issue_show_html_bottom, issue: issue) %>
<% end %>

<% if issue.attachments.any? %>
  <% content_for :email_prefooter do %>
    <p><b>
      <%=l :label_issue_attachments_heading %>
    </b></p>
    <ul class="attachments">
      <% issue.attachments.each do |attachment| %>
        <li>
          <%= attachment.new_record? ? attachment.filename : link_to_attachment(attachment, {download: true, only_path: false}) %>
          <i>(<%= number_to_human_size(attachment.filesize) %>)</i>
          <%= " - v#{attachment.version}" %>
          <% unless attachment.description.blank? %>
            <p style="padding-left:10px">
              <%= " - #{attachment.description}" %>
            </p>
          <% end %>
        </li>
      <% end %>
    </ul>
  <% end %>
<% end %>
