<% if preview %>
  <h1>PREVIEW ONLY</h1>
<% end %>

<p class="heading"><strong><u><%= t ".heading" %></u></strong></p>
<p><%= t ".instructions", releasable_name: "#{releasable.model_name.name.titleize}" %></p>

<% # Signer information %>
<dl>
  <% # Only guardian signs if talent is a minor %>
  <% unless releasable.minor? %>
    <dt><%= AppearanceRelease.human_attribute_name(:signature) %>:</dt>
    <dd>
    <% if preview %>
        <%= image_tag dummy_signature %>
    <% elsif releasable.signature.attached? %>
        <%= image_tag releasable.signature.variant(auto_orient: true, resize: "200x200") %>
    <% end %>
    </dd>
  <% end %>
  <%= description_list_pair t(".labels.#{releasable.model_name.param_key}.name", default: "Name"), releasable.name, append: ":" %>
  <% if releasable.model_name == "LocationRelease" %>
    <%= description_list_pair "Location Address:", releasable.address %>
    <%= description_list_pair "Owner Name", releasable.person_name, append: ":" %>
  <% end %>
  <%= description_list_pair t(".labels.#{releasable.model_name.param_key}.contact_person_address", default: "Contact Address"), releasable.contact_person.address, append: ":" %>
  <%= description_list_pair t(".labels.#{releasable.model_name.param_key}.contact_person_phone", default: "Contact Phone"), releasable.contact_person.phone, append: ":" %>
  <%= description_list_pair t(".labels.#{releasable.model_name.param_key}.contact_person_email", default: "Contact Email"), releasable.contact_person.email, append: ":" %>
  <% if releasable.model_name == "AppearanceRelease" %>
    <%= description_list_pair "Person Date of Birth:", releasable&.person_date_of_birth&.strftime("%D") %>
  <% end %>
  <%= description_list_pair_for releasable, :signed_on, append: ":" %>
  <% if releasable.model_name == "LocationRelease" %>
    <%= description_list_pair "Filming Started On:", releasable&.filming_started_on&.strftime("%D") %>
    <%= description_list_pair "Filming Ended On:", releasable&.filming_ended_on&.strftime("%D") %>
    <%= description_list_pair "Filming Hours:", releasable&.filming_hours %>
  <% end %>
  <% if contract_template.fee? %>
    <%= description_list_pair "Fee:", number_to_currency(contract_template.fee) %>
  <% end %>
  <% if releasable.model_name == "MaterialRelease" %>
    <%= description_list_pair "Description:", releasable.description %>
  <% end %>
</dl>

<% if releasable.minor? %>
  <br/>
  <p class="text-left"><strong>Guardian Information</strong></p>

  <% # Guardian information %>
  <dl>
    <dt><%= AppearanceRelease.human_attribute_name(:signature) %>:</dt>
    <dd>
      <% if preview %>
        <%= image_tag dummy_signature %>
      <% elsif releasable.signature.attached? %>
        <%= image_tag releasable.signature.variant(auto_orient: true, resize: "200x200") %>
      <% end %>
    </dd>
    <%= description_list_pair_for releasable, :guardian_name, append: ":" %>
    <%= description_list_pair_for releasable, :guardian_address, append: ":" %>
    <%= description_list_pair_for releasable, :guardian_phone, append: ":" %>
    <%= description_list_pair_for releasable, :guardian_email, append: ":" %>
    <%= description_list_pair_for releasable, :signed_on, append: ":" %>
  </dl>

  <% if releasable.respond_to?(:second_guardian_present?) && releasable.second_guardian_present? %>

    <br/>
    <p class="text-left"><strong>Second guardian Information</strong></p>

    <% # Second guardian information %>
    <dl>
      <%= description_list_pair_for releasable, :guardian_2_name, append: ":" %>
      <%= description_list_pair_for releasable, :guardian_2_address, append: ":" %>
      <%= description_list_pair_for releasable, :guardian_2_phone, append: ":" %>
      <%= description_list_pair_for releasable, :guardian_2_email, append: ":" %>
    </dl>

  <% end %>

<% end %>
