% reference = reference_question.response(@answer_sheet) %>
<% reference ||= Fe::ReferenceSheet.new %>
<% css_class = reference_question.required?(@answer_sheet, @page) ? "required" : "" %>
<% email_css_class = reference_question.required?(@answer_sheet, @page) ? "required email email" : "" %>
<% phone_css_class = reference_question.required?(@answer_sheet, @page) ? "required phone phone" : "" %>
<%#= hidden_field_tag "reference[#{reference.id}]", class: reference_question.required? && !reference.email_sent? ? "required" : "" %>
" class="desc"><%= _("First Name") %>
<%= text_field_tag "reference[#{reference.id}][first_name]", reference.first_name, class: "#{"form-control" if Fe.bootstrap} text #{css_class}", id: "name_#{reference.id}", readonly: reference.completed? || !@answer_sheet.try(:can_change_references?), disabled: reference.completed? || !@answer_sheet.try(:can_change_references?) %>
" class="desc"><%= _("Last Name") %>
<%= text_field_tag "reference[#{reference.id}][last_name]", reference.last_name, class: "#{"form-control" if Fe.bootstrap} text #{css_class}", id: "name_#{reference.id}", readonly: reference.completed? || !@answer_sheet.try(:can_change_references?), disabled: reference.completed? || !@answer_sheet.try(:can_change_references?) %>
" class="desc"><%= _("Relationship to You") %>
<%= text_field_tag "reference[#{reference.id}][relationship]", reference.relationship, class: "#{"form-control" if Fe.bootstrap} text #{css_class}", id: "name_#{reference.id}", readonly: reference.completed? || !@answer_sheet.try(:can_change_references?), disabled: reference.completed? || !@answer_sheet.try(:can_change_references?) %>
" class="desc"><%= _("E-mail") %>
<% if (!reference.email.blank?) %>
<%= _("Please be aware that any changes to this email address after your reference has started filling out their form will cause their answers to be lost.") %>
<% end %>
<%= text_field_tag "reference[#{reference.id}][email]", reference.email, class: "#{"form-control" if Fe.bootstrap} text #{email_css_class}", id: "email_#{reference.id}", readonly: reference.completed? || !@answer_sheet.try(:can_change_references?), disabled: reference.completed? || !@answer_sheet.try(:can_change_references?) %>
" class="desc"><%= _("Phone") %>
<%= text_field_tag "reference[#{reference.id}][phone]", reference.phone, class: "#{"form-control" if Fe.bootstrap} text #{phone_css_class}", id: "phone_#{reference.id}", readonly: reference.completed? || !@answer_sheet.try(:can_change_references?), disabled: reference.completed? || !@answer_sheet.try(:can_change_references?) %>
<% if reference.completed? %>
<%= _("This reference is completed") %>
<% else %>
<%= _("An invitation will be sent to this reference when you submit your application. If you would " \
"like to get a head start, please feel free to click "Send Email Invitation" below.") %>
<%= _("If you already submitted your application and have returned to update your reference information - you must click "Send Email Invitation" after you " \
"have edited the information in order for your reference to receive another email.") %>
<%= link_to(_("Send Email Invitation"), @answer_sheet ? send_reference_invite_fe_answer_sheet_path(@answer_sheet, reference_id: reference.id) : "#", class: "#{"form-control" if Fe.bootstrap} reference_send_invite button no-left-margin", disabled: !reference.all_affecting_questions_answered) %>
<% if reference.question && !reference.all_affecting_questions_answered %>
This button is disabled because there are questions that affect whether this reference is required that need to answered first:
<% reference.question.visibility_affecting_questions.each do |q| %>
<% next if q.has_response?(@answer_sheet) %>
"<%= q.pages.where(question_sheet_id: @answer_sheet.question_sheet_ids).first.label %>" Page: "<%= q.label %>"
<% end %>
<% end %>
<%= _("Invitation last sent:") %> <% if reference.email_sent_at.nil? -%><%= _("Never") %><% else %><%= reference.email_sent_at.strftime("%Y-%m-%d @ %I:%M%p") %><% end %>
<% end %>