Participant Details

Name <%= @participant.first_name %> <%= @participant.last_name %>
Address <%= @participant.address_line_1 %><%= ', ' + @participant.address_line_2 unless @participant.address_line_2.blank? %>
<%= "#{@participant.city}, #{@participant.state} #{@participant.zip}" %>
Phone <%= @participant.phone %>
Email <%= @participant.email %>
MCI <%= @participant.mci %>
DOB <%= @participant.dob.strftime('%B %d, %Y') if @participant.dob.present? %>
SSN <%= mask_ssn(@participant.ssn) %>
Gender <%= @participant.gender %>
<%= link_to 'Edit', edit_participant_path(@participant), class: "btn btn-dark" %> <%= link_to 'Back to List', participants_path, class: "btn btn-secondary" %>

Linked Workers

<% if @employments.present? %> <% @employments.each do |employment| %> <% end %>
Worker Name Start Date End Date Actions
<%= employment.worker&.full_name || 'No Worker Assigned' %> <%= employment.start_date.strftime('%B %d, %Y') if employment.start_date.present? %> <%= employment.end_date.strftime('%B %d, %Y') if employment.end_date.present? %> <%= link_to worker_path(employment.worker), class: 'btn btn-sm btn-secondary' do %> <% end %> <%= link_to edit_employment_path(employment), class: 'btn btn-sm btn-info' do %> <% end %>
<% else %>

No employments available.

<% end %>
<%= form_with(model: [@participant, @employment], url: link_worker_participant_path(@participant), method: :post, class: 'row g-3') do |form| %>
<%= form.label :worker_name, "Add New Worker", class: 'form-label' %> <%= text_field_tag :worker_name, nil, id: 'worker-autocomplete', class: 'form-control', placeholder: 'Start typing worker name...' %> <%= hidden_field_tag 'employment[worker_id]', nil, id: 'selected-worker-id' %>
<%= form.label :start_date, class: 'form-label' %> <%= form.date_field :start_date, class: 'form-control' %>
<%= form.label :end_date, class: 'form-label' %> <%= form.date_field :end_date, class: 'form-control' %>
<%= form.submit "Link Worker", class: 'btn btn-dark' %>
<% end %> <%# This is for autocompleting the Worker field to return users in the system %>

Linked Vendors

<% if @service_contracts.present? %> <% @service_contracts.each do |contract| %> <% end %>
Vendor Name Start Date End Date Actions
<%= contract.vendor&.name || 'No Vendor Assigned' %> <%= contract.start_date.strftime('%B %d, %Y') if contract.start_date.present? %> <%= contract.end_date.strftime('%B %d, %Y') if contract.end_date.present? %> <%= link_to vendor_path(contract.vendor), class: 'btn btn-sm btn-secondary' do %> <% end %> <%= link_to edit_service_contract_path(contract), class: 'btn btn-sm btn-info' do %> <% end %>
<% else %>

No service contracts available.

<% end %>
<%= form_with(model: [@participant, @service_contract], url: link_vendor_participant_path(@participant), method: :post, class: 'row g-3') do |form| %>
<%= form.label :vendor_name, "Add New Vendor", class: 'form-label' %> <%= text_field_tag :vendor_name, nil, id: 'vendor-autocomplete', class: 'form-control', placeholder: 'Start typing vendor name...' %> <%= hidden_field_tag 'service_contract[vendor_id]', nil, id: 'selected-vendor-id' %>
<%= form.label :start_date, class: 'form-label' %> <%= form.date_field :start_date, class: 'form-control' %>
<%= form.label :end_date, class: 'form-label' %> <%= form.date_field :end_date, class: 'form-control' %>
<%= form.submit "Link Vendor", class: 'btn btn-dark' %>
<% end %> <%# JavaScript for Vendor Autocomplete %>