Worker Details

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

Linked Participants

<% if @employments.present? %> <% @employments.each do |employment| %> <% participant = employment.participant %> <% end %>
Participant Name Start Date End Date Actions
<%= participant ? "#{participant.first_name} #{participant.last_name}" : 'No Participant 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 participant_path(participant), 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: [@worker, @employment], url: link_participant_worker_path(@worker), method: :post, class: 'row g-3') do |form| %>
<%= form.label :participant_name, "Add New Participant", class: 'form-label' %> <%= text_field_tag :participant_name, nil, id: 'participant-autocomplete', class: 'form-control', placeholder: 'Start typing participant name...' %> <%= hidden_field_tag 'employment[participant_id]', nil, id: 'selected-participant-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 Participant", class: 'btn btn-dark' %>
<% end %>

Linked Employers

<% if @worker.participants.any? %> <% @worker.participants.each do |participant| %> <% participant.employer_records.each do |employer_record| %> <% end %> <% end %>
Employer Name Start Date End Date Actions
<%= employer_record.employer.full_name %> <%= employer_record.start_date.strftime('%B %d, %Y') if employer_record.start_date %> <%= employer_record.end_date.strftime('%B %d, %Y') if employer_record.end_date %> <%= link_to employer_path(employer_record.employer), class: 'btn btn-sm btn-secondary' do %> <% end %> <%= link_to edit_employer_record_path(employer_record), class: 'btn btn-sm btn-info' do %> <% end %>
<% else %>

No linked employers.

<% end %> <%= form_with(model: [@worker, @employer_record], url: link_employer_worker_path(@worker), method: :post, class: 'row g-3') do |form| %>
<%= form.label :employer_name, "Add New Employer", class: 'form-label' %> <%= text_field_tag :employer_name, nil, id: 'employer-autocomplete', class: 'form-control', placeholder: 'Start typing employer name...' %> <%= hidden_field_tag 'employer_record[employer_id]', nil, id: 'selected-employer-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 Employer", class: 'btn btn-dark' %>
<% end %>
<%# JavaScript for Participant Autocomplete %> <%# JavaScript for Employer Autocomplete %>