diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index f4edb65a2e..055c69af1c 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -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 @@ -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", diff --git a/app/views/requests/index.html.erb b/app/views/requests/index.html.erb index 0f923245f9..ff5f46e6d3 100644 --- a/app/views/requests/index.html.erb +++ b/app/views/requests/index.html.erb @@ -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? %>