<% show_attachments ||= false %>

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

<% content_for :email_heading do %>
  <%= link_to(easy_crm_case.to_s, easy_crm_case_url) -%>
<% end %>

<% content_for :email_attributes do %>

  <%= content_tag( :p, content_tag(:b,   EasyCrmCase.human_attribute_name(:assigned_to_id)) + ': ' +  (easy_crm_case.assigned_to ? link_to_user(easy_crm_case.assigned_to, :only_path => false) : '-')) %>
  <%= content_tag( :p, content_tag(:b,   EasyCrmCase.human_attribute_name(:contract_date)) + ': ' +  format_date(easy_crm_case.contract_date)) %>

  <%= content_tag( :p, content_tag(:b,   EasyCrmCase.human_attribute_name(:easy_crm_case_status)) + ': ' +  easy_crm_case.easy_crm_case_status.name) %>
  <%= content_tag( :p, content_tag(:b,   EasyCrmCase.human_attribute_name(:price)) + ': ' +  format_price(easy_crm_case.price, easy_crm_case.currency)) %>

  <%= content_tag( :p, content_tag(:b,   EasyCrmCase.human_attribute_name(:email)) + ': ' +  easy_crm_case.email) %>
  <%= content_tag( :p, content_tag(:b,   EasyCrmCase.human_attribute_name(:author_id)) + ': ' +  (easy_crm_case.author ? link_to_user(easy_crm_case.author, :only_path => false) : '-')) %>

  <%= content_tag( :p, content_tag(:b,   EasyCrmCase.human_attribute_name(:telephone)) + ': ' +  easy_crm_case.telephone)%>

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

<% if show_attachments && easy_crm_case.attachments.any? %>
  <%  content_for :email_prefooter do %>
    <p><b>
      <%=l :label_issue_attachments_heading %>
    </b></p>
    <ul class="attachments">
      <% easy_crm_case.attachments.each do |attachment| %>
        <li>
          <%= 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 %>
