<% issue_estimated_hours = !issue.estimated_hours.nil?
issue_fixed_version = !issue.fixed_version.nil?
show_attachments ||= false
%>
<% content_for :email_title do %>
    <% if EasySetting.value('show_issue_id', issue.project) -%>
        <%= "##{issue.id} - #{issue.subject}" -%>
    <% else -%>
        <%= issue.subject -%>
    <% end -%>
<% end %>
<% content_for :email_heading do %>
  <h1 class="issue-detail-header">
    <% if EasySetting.value('show_issue_id', issue.project) -%>
        <%= link_to("##{issue.id} - #{issue.subject}", issue_url) -%>
    <% else -%>
        <%= link_to(issue.subject, issue_url) -%>
    <% end -%>
  </h1>
<% end %>
<div id="issue-detail">
  <div class="attributes-wrapper"><table class="attributes"><tbody>
  <tr class="spacer"><td colspan="4"></td></tr>
    <%= issue_fields_table_rows do |rows|
      unless issue.disabled_core_fields.include?('assigned_to_id')
        rows.left 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
        rows.left l(:field_tracker), h(issue.tracker.name), :class => 'category'
      end
      rows.left l(:field_status), h(issue.status.name), :class => 'status'
      rows.left 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')
        rows.left l(:field_category), h(issue.category ? issue.category.name : '-'), :class => 'category'
      end


      unless issue.disabled_core_fields.include?('start_date')
        rows.right l(:field_start_date), format_date(issue.start_date), :class => 'start-date'
      end
      unless issue.disabled_core_fields.include?('due_date')
        rows.right l(:field_due_date), format_date(issue.due_date), :class => "due-date #{'overdue' if issue.due_date && issue.due_date < Date.today}"
      end
      rows.right(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?
          rows.right l(:field_estimated_hours), format_hours(issue.estimated_hours), :class => 'estimated-hours'
        end
      end

      rows.right( l(:field_fixed_version), h(issue.fixed_version), :class => 'fixed-version') unless issue.disabled_core_fields.include?('fixed_version_id') || issue.fixed_version.nil?
    end %>
    <tr class="spacer"><td colspan="4"></td></tr>
    <% if issue.custom_field_values.any? %>
      <tr class="spacer"><td colspan="4"></td></tr>
        <% issue.visible_custom_field_values.each do |c| %>
          <% next if !c.custom_field.mail_notification || !c.custom_field.visible? %>
          <tr class="attribute">
            <th>
              <%= content_tag :span,  h(c.custom_field.translated_name) +':'  -%>
            </th>
            <td colspan="3">
              <%= content_tag :span, show_value(c) -%>
            </td>
          </tr>
        <% end %>
      <tr class="spacer"><td colspan="4"></td></tr>
    <% end %>
      <%= call_hook(:view_mailer_issue_show_html_bottom, :issue => issue) %>
  </tbody></table></div>
  <%= textilizable(issue, :description, {:headings => false, :only_path => false}) -%>
</div>

<% if show_attachments && issue.attachments.any? %>
  <%  content_for :email_prefooter do %>
    <h4>
      <%=l :label_issue_attachments_heading %>
    </h4>
    <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 %>
