252 lines
8.4 KiB
Plaintext
252 lines
8.4 KiB
Plaintext
<div class="dropdown">
|
|
<button class="btn btn-secondary dropdown-toggle" type="button" id="demographicsDropdown" data-bs-toggle="dropdown" aria-expanded="false">
|
|
Demographics
|
|
</button>
|
|
<ul class="dropdown-menu" aria-labelledby="demographicsDropdown">
|
|
<li><a class="dropdown-item" href="<%= worker_bank_accounts_path(@worker) %>">Bank Information</a></li>
|
|
<li><a class="dropdown-item" href="<%= polymorphic_path([@worker, :onboardings]) %>">Onboarding</a></li>
|
|
</ul>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="container mt-5">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<h1 class="mb-4 text-center">Worker Details</h1>
|
|
</div>
|
|
|
|
<!-- Worker Information Table -->
|
|
<div class="col-12 mb-4">
|
|
<table class="table">
|
|
<tbody>
|
|
<tr>
|
|
<th>Name</th>
|
|
<td><%= @worker.first_name %> <%= @worker.last_name %></td>
|
|
</tr>
|
|
<tr>
|
|
<th>Address</th>
|
|
<td>
|
|
<%= @worker.address_line_1 %><%= ', ' + @worker.address_line_2 unless @worker.address_line_2.blank? %>
|
|
<br>
|
|
<%= "#{@worker.city}, #{@worker.state} #{@worker.zip}" %>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Phone</th>
|
|
<td><%= @worker.phone %></td>
|
|
</tr>
|
|
<tr>
|
|
<th>Email</th>
|
|
<td><%= @worker.email %></td>
|
|
</tr>
|
|
<tr>
|
|
<th>DOB</th>
|
|
<td><%= @worker.dob.strftime('%B %d, %Y') if @worker.dob.present? %></td>
|
|
</tr>
|
|
<tr>
|
|
<th>SSN</th>
|
|
<td><%= mask_ssn (@worker.ssn) %></td>
|
|
</tr>
|
|
<tr>
|
|
<th>Gender</th>
|
|
<td><%= @worker.gender %></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Action Buttons -->
|
|
<div class="row">
|
|
<div class="col-12 d-flex justify-content-between mb-4">
|
|
<%= link_to 'Edit', edit_worker_path(@worker), class: "btn btn-dark" %>
|
|
<%= link_to 'Back to List', workers_path, class: "btn btn-secondary" %>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="row mt-4">
|
|
<div class="col-md-6">
|
|
<h2 class="mt-4">Linked Participants</h2>
|
|
<% if @employments.present? %>
|
|
<table class="table table-striped">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Participant Name</th>
|
|
<th>Start Date</th>
|
|
<th>End Date</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<% @employments.each do |employment| %>
|
|
<tr>
|
|
<% participant = employment.participant %>
|
|
<td><%= participant ? "#{participant.first_name} #{participant.last_name}" : 'No Participant Assigned' %></td>
|
|
<td><%= employment.start_date.strftime('%B %d, %Y') if employment.start_date.present? %></td>
|
|
<td><%= employment.end_date.strftime('%B %d, %Y') if employment.end_date.present? %></td>
|
|
<td>
|
|
<%= link_to participant_path(participant), class: 'btn btn-sm btn-secondary' do %>
|
|
<i class="bi bi-eye"></i> <!-- Eyeball icon for 'Show' -->
|
|
<% end %>
|
|
<%= link_to edit_employment_path(employment), class: 'btn btn-sm btn-info' do %>
|
|
<i class="bi bi-pencil-fill" style="color: white;"></i> <!-- Pencil icon for 'Edit' with white color -->
|
|
<% end %>
|
|
</td>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
</table>
|
|
<% else %>
|
|
<p>No employments available.</p>
|
|
<% end %>
|
|
|
|
|
|
<%= form_with(model: [@worker, @employment], url: link_participant_worker_path(@worker), method: :post, class: 'row g-3') do |form| %>
|
|
<div class="col-md-6">
|
|
<%= 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' %>
|
|
</div>
|
|
|
|
<div class="col-md-3">
|
|
<%= form.label :start_date, class: 'form-label' %>
|
|
<%= form.date_field :start_date, class: 'form-control' %>
|
|
</div>
|
|
|
|
<div class="col-md-3">
|
|
<%= form.label :end_date, class: 'form-label' %>
|
|
<%= form.date_field :end_date, class: 'form-control' %>
|
|
</div>
|
|
|
|
<div class="col-12rai"> <!-- Added text-center for button alignment -->
|
|
<%= form.submit "Link Participant", class: 'btn btn-dark' %>
|
|
</div>
|
|
<% end %>
|
|
|
|
</div>
|
|
|
|
|
|
<div class="col-md-6">
|
|
<h2 class="mt-4">Linked Employers</h2>
|
|
<% if @worker.participants.any? %>
|
|
<table class="table table-striped">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Employer Name</th>
|
|
<th>Start Date</th>
|
|
<th>End Date</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<% @worker.participants.each do |participant| %>
|
|
<% participant.employer_records.each do |employer_record| %>
|
|
<tr>
|
|
<td><%= employer_record.employer.full_name %></td>
|
|
<td><%= employer_record.start_date.strftime('%B %d, %Y') if employer_record.start_date %></td>
|
|
<td><%= employer_record.end_date.strftime('%B %d, %Y') if employer_record.end_date %></td>
|
|
<td>
|
|
<%= link_to employer_path(employer_record.employer), class: 'btn btn-sm btn-secondary' do %>
|
|
<i class="bi bi-eye"></i> <!-- Eyeball icon for 'Show' -->
|
|
<% end %>
|
|
<%= link_to edit_employer_record_path(employer_record), class: 'btn btn-sm btn-info' do %>
|
|
<i class="bi bi-pencil-fill" style="color: white;"></i> <!-- Pencil icon for 'Edit' with white color -->
|
|
<% end %>
|
|
</td>
|
|
</tr>
|
|
<% end %>
|
|
<% end %>
|
|
</tbody>
|
|
</table>
|
|
<% else %>
|
|
<p>No linked employers.</p>
|
|
<% end %>
|
|
|
|
<%= form_with(model: [@worker, @employer_record], url: link_employer_worker_path(@worker), method: :post, class: 'row g-3') do |form| %>
|
|
<div class="col-md-6">
|
|
<%= 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' %>
|
|
</div>
|
|
|
|
<div class="col-md-3">
|
|
<%= form.label :start_date, class: 'form-label' %>
|
|
<%= form.date_field :start_date, class: 'form-control' %>
|
|
</div>
|
|
|
|
<div class="col-md-3">
|
|
<%= form.label :end_date, class: 'form-label' %>
|
|
<%= form.date_field :end_date, class: 'form-control' %>
|
|
</div>
|
|
|
|
<div class="col-12">
|
|
<%= form.submit "Link Employer", class: 'btn btn-dark' %>
|
|
</div>
|
|
<% end %>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<%# JavaScript for Participant Autocomplete %>
|
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
|
<script src="https://code.jquery.com/ui/1.13.0/jquery-ui.min.js"></script>
|
|
<link rel="stylesheet" href="//code.jquery.com/ui/1.13.0/themes/base/jquery-ui.css">
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
$('#participant-autocomplete').autocomplete({
|
|
source: function(request, response) {
|
|
$.ajax({
|
|
url: '/participants/search', // Updated endpoint for searching participants
|
|
dataType: "json",
|
|
data: { term: request.term },
|
|
success: function(data) {
|
|
response(data);
|
|
}
|
|
});
|
|
},
|
|
minLength: 2, // Minimum characters to trigger the search
|
|
select: function(event, ui) {
|
|
// Function to handle selection
|
|
$('#participant-autocomplete').val(ui.item.label); // ui.item.label should contain the name of the participant
|
|
$('#selected-participant-id').val(ui.item.value); // Set the participant ID in the hidden field
|
|
return false;
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
|
|
<%# JavaScript for Employer Autocomplete %>
|
|
<script>
|
|
$(document).ready(function() {
|
|
$('#employer-autocomplete').autocomplete({
|
|
source: function(request, response) {
|
|
$.ajax({
|
|
url: '/employers/search',
|
|
dataType: "json",
|
|
data: { term: request.term },
|
|
success: function(data) {
|
|
response(data);
|
|
}
|
|
});
|
|
},
|
|
minLength: 2,
|
|
select: function(event, ui) {
|
|
$('#employer-autocomplete').val(ui.item.label);
|
|
$('#selected-employer-id').val(ui.item.value);
|
|
return false;
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|