mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-28 01:53:25 +00:00
subreport filtering partial
This commit is contained in:
@@ -26,6 +26,12 @@ module ReportsHelper
|
||||
end.uniq
|
||||
end
|
||||
|
||||
def customer_email_options(order_customers)
|
||||
order_customers.map do |customer|
|
||||
[customer&.email, customer&.id]
|
||||
end
|
||||
end
|
||||
|
||||
def currency_symbol
|
||||
Spree::Money.currency_symbol
|
||||
end
|
||||
|
||||
@@ -13,7 +13,7 @@ module Spree
|
||||
include SetUnusedAddressFields
|
||||
|
||||
searchable_attributes :number, :state, :shipment_state, :payment_state, :distributor_id,
|
||||
:order_cycle_id, :email, :total
|
||||
:order_cycle_id, :email, :total, :customer_id
|
||||
searchable_associations :shipping_method, :bill_address
|
||||
searchable_scopes :complete, :incomplete
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_producers)
|
||||
.omega.fourteen.columns= select_tag(:supplier_id_in, options_from_collection_for_select(@data.orders_suppliers, :id, :name, params[:supplier_id_in]), {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_customers_cycle)
|
||||
.omega.fourteen.columns
|
||||
= f.select(:order_cycle_id_in, report_order_cycle_options(@data.order_cycles), {selected: params.dig(:q, :order_cycle_id_in)}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_customers)
|
||||
.omega.fourteen.columns
|
||||
= f.select(:customer_id_in, customer_email_options(@data.order_customers), {selected: params.dig(:q, :customer_id_in)}, {class: "select2 fullwidth", multiple: true})
|
||||
@@ -5,6 +5,8 @@
|
||||
%fieldset.no-border-bottom.print-hidden
|
||||
%legend{ align: 'center'}= t(:report_filters)
|
||||
= render partial: "admin/reports/filters/#{@report_type}", locals: { f: f }
|
||||
- if @report_subtype && lookup_context.exists?(@report_subtype, "admin/reports/filters/", true)
|
||||
= render partial: "admin/reports/filters/#{@report_subtype}", locals: { f: f }
|
||||
|
||||
%fieldset.print-hidden
|
||||
%legend{ align: 'center'}= t(:report_render_options)
|
||||
|
||||
@@ -44,6 +44,10 @@ module Reporting
|
||||
order('order_cycles.orders_close_at DESC')
|
||||
end
|
||||
|
||||
def order_customers
|
||||
Customer.where(id: visible_order_customer_ids).select("customers.id, customers.email")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
attr_reader :current_user
|
||||
@@ -51,5 +55,9 @@ module Reporting
|
||||
def permissions
|
||||
@permissions ||= OpenFoodNetwork::Permissions.new(current_user)
|
||||
end
|
||||
|
||||
def visible_order_customer_ids
|
||||
Permissions::Order.new(current_user).visible_orders.pluck(:customer_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user