Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/controllers/accountants_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class AccountantsController < ApplicationController
before_action :confirm_data_access, only: [:index]
before_action :confirm_data_access_async, only: [:search, :edit]
before_action :find_patient, only: [:edit]
before_action :set_clinics, only: [:index]

def index
@patients = Patient.where(pledge_sent: true)
Expand All @@ -25,6 +26,11 @@ def edit

private

def set_clinics
@clinics = Clinic.all
@selected_clinics = (params[:clinic_id] || []).map(&:to_i)
end

def find_patient
@patient = Patient.find params[:id]
end
Expand Down
40 changes: 30 additions & 10 deletions app/views/accountants/_search_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,38 @@
method: 'GET' do |f| %>
<%= f.hidden_field :locale, value: params[:locale] %>
<%= f.text_field :search,
placeholder: t('accountants.search_placeholder'),
hide_label: true,
value: params[:search],
class: 'search_form_input accountant mr-4' %>

<%= f.select :clinic_id,
options_for_select(clinic_options.reject{ |x| x.blank? },
params[:clinic_id]),
placeholder: t("accountants.search_placeholder"),
hide_label: true,
include_blank: t('accountants.search_all_clinics'),
class: 'search_form_input accountant' %>
value: params[:search],
class: "search_form_input accountant mr-4" %>

<div class="dropdown">
<button
href="#"
data-toggle="dropdown"
class="btn dropdown-toggle"
id="clinic-dropdown"
data-bs-auto-close="outside"
aria-expanded="false"
>
Select a Clinic
</button>

<div class="dropdown-menu" aria-labelledby="clinic-dropdown">
<% @clinics.each do |clinic| %>
<li class="d-flex dropdown-item btn">
<%= check_box_tag(
:clinic_id,
clinic.id,
@selected_clinics.include?(clinic.id),
name: "clinic_id[]",
id: "clinic_id_#{clinic.id}"
) %>
<%= label_tag "clinic_id_#{clinic.id}", clinic.name %>
</li>
<% end %>
</div>
</div>
<%= f.button title: t('common.search'), class: 'btn btn-primary ml-4' do %>
<i class="fas fa-search"></i>
<% end %>
Expand Down