Skip to content

Commit

Permalink
Scope query to org and order by date and show count in print button
Browse files Browse the repository at this point in the history
  • Loading branch information
norrismei committed Sep 3, 2024
1 parent b262ff2 commit 84c788b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions app/controllers/requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ def index
.undiscarded
.during(helpers.selected_range)
.class_filter(filter_params)

@unfulfilled_requests = current_organization
.requests
.includes(partner: [:profile])
.where(status: [:pending, :started])
.order(created_at: :desc)
@paginated_requests = @requests.page(params[:page])
@calculate_product_totals = RequestsTotalItemsService.new(requests: @requests).calculate
@items = current_organization.items.alphabetized
Expand Down Expand Up @@ -41,11 +45,9 @@ def start
end

def print_unfulfilled
requests = Request.includes(partner: [:profile]).where(status: [0, 1])

respond_to do |format|
format.any do
pdf = PicklistsPdf.new(current_organization, requests)
pdf = PicklistsPdf.new(current_organization, @unfulfilled_requests)
send_data pdf.compute_and_render,
filename: format("Picklists_%s.pdf", Time.current.to_fs(:long)),
type: "application/pdf",
Expand Down
2 changes: 1 addition & 1 deletion app/views/requests/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<% if @requests.any? { |request| request.status == "pending" || request.status == "started" } %>
<%= print_button_to(
print_unfulfilled_requests_path(format: :pdf),
text: "Print Unfulfilled Picklists",
text: "Print Unfulfilled Picklists (#{@unfulfilled_requests.size})",
size: "md") %>
<% end %>
<%= download_button_to(requests_path(format: :csv, filters: filter_params.merge(date_range: date_range_params)), {text: "Export Requests", size: "md"}) if @requests.any? %>
Expand Down

0 comments on commit 84c788b

Please sign in to comment.