From d74591afe61a9b2a874236d86f3056cdd272364a Mon Sep 17 00:00:00 2001 From: Rob H Date: Fri, 26 Oct 2012 13:44:13 +1100 Subject: [PATCH] Fixes to reports controller and addition of order cycles reports --- .../admin/reports_controller_decorator.rb | 435 +++++++++++++----- .../admin/reports/order_cycles.html.haml | 39 ++ config/routes.rb | 1 + 3 files changed, 348 insertions(+), 127 deletions(-) create mode 100644 app/views/spree/admin/reports/order_cycles.html.haml diff --git a/app/controllers/spree/admin/reports_controller_decorator.rb b/app/controllers/spree/admin/reports_controller_decorator.rb index a8cbd23f08..110a93dfd9 100644 --- a/app/controllers/spree/admin/reports_controller_decorator.rb +++ b/app/controllers/spree/admin/reports_controller_decorator.rb @@ -9,6 +9,7 @@ Spree::Admin::ReportsController.class_eval do Spree::Admin::ReportsController::AVAILABLE_REPORTS.merge!({:group_buys => {:name => "Group Buys", :description => "Orders by supplier and variant"}}) Spree::Admin::ReportsController::AVAILABLE_REPORTS.merge!({:bulk_coop => {:name => "Bulk Co-Op", :description => "Reports for Bulk Co-Op orders"}}) Spree::Admin::ReportsController::AVAILABLE_REPORTS.merge!({:payments => {:name => "Payment Reports", :description => "Reports for Payments"}}) + Spree::Admin::ReportsController::AVAILABLE_REPORTS.merge!({:order_cycles => {:name => "Order Cycle Reports", :description => "Reports for Order Cycles"}}) def orders_and_distributors params[:q] = {} unless params[:q] @@ -93,96 +94,98 @@ Spree::Admin::ReportsController.class_eval do case params[:report_type] when "bulk_coop_supplier_report" - + header = ["Supplier", "Product", "Unit Size", "Variant", "Weight", "Sum Total", "Sum Max Total"] - - columns = [ proc { |lis| lis.first.variant.product.supplier.name }, - proc { |lis| lis.first.variant.product.name }, - proc { |lis| "UNIT SIZE" }, - proc { |lis| lis.first.variant.options_text }, - proc { |lis| lis.first.variant.weight }, - proc { |lis| lis.sum { |li| li.quantity } }, + + columns = [ proc { |lis| lis.first.variant.product.supplier.name }, + proc { |lis| lis.first.variant.product.name }, + proc { |lis| "UNIT SIZE" }, + proc { |lis| lis.first.variant.options_text }, + proc { |lis| lis.first.variant.weight }, + proc { |lis| lis.sum { |li| li.quantity } }, proc { |lis| lis.sum { |li| li.max_quantity || 0 } } ] - - rules = [ { group_by: proc { |li| li.variant.product.supplier }, + + rules = [ { group_by: proc { |li| li.variant.product.supplier }, sort_by: proc { |supplier| supplier.name } }, - { group_by: proc { |li| li.variant.product }, - sort_by: proc { |product| product.name }, - summary_columns: [ proc { |lis| lis.first.variant.product.supplier.name }, - proc { |lis| lis.first.variant.product.name }, proc { |lis| "UNIT SIZE" }, - proc { |lis| "" }, proc { |lis| "" }, - proc { |lis| lis.sum { |li| li.quantity * li.variant.weight } }, + { group_by: proc { |li| li.variant.product }, + sort_by: proc { |product| product.name }, + summary_columns: [ proc { |lis| lis.first.variant.product.supplier.name }, + proc { |lis| lis.first.variant.product.name }, + proc { |lis| "UNIT SIZE" }, + proc { |lis| "" }, + proc { |lis| "" }, + proc { |lis| lis.sum { |li| li.quantity * li.variant.weight } }, proc { |lis| lis.sum { |li| (li.max_quantity || 0) * li.variant.weight } } ] }, - { group_by: proc { |li| li.variant }, + { group_by: proc { |li| li.variant }, sort_by: proc { |variant| variant.options_text } } ] - + when "bulk_coop_allocation" - + header = ["Customer", "Product", "Unit Size", "Variant", "Weight", "Sum Total", "Sum Max Total"] - - columns = [ proc { |lis| lis.first.order.bill_address.firstname + " " + lis.first.order.bill_address.lastname }, - proc { |lis| lis.first.variant.product.name }, - proc { |lis| "UNIT SIZE" }, - proc { |lis| lis.first.variant.options_text }, - proc { |lis| lis.first.variant.weight }, - proc { |lis| lis.sum { |li| li.quantity } }, - proc { |lis| lis.sum { |li| li.max_quantity || 0 } } ] - - rules = [ { group_by: proc { |li| li.variant.product }, - sort_by: proc { |product| product.name } }, - { group_by: proc { |li| li.variant }, - sort_by: proc { |variant| variant.options_text } }, - { group_by: proc { |li| li.order.user }, - sort_by: proc { |user| user.to_s } } ] - - when "bulk_coop_packing_sheets" - - header = ["Customer", "Product", "Variant", "Sum Total"] - - columns = [ proc { |lis| lis.first.order.bill_address.firstname + " " + lis.first.order.bill_address.lastname }, - proc { |lis| lis.first.variant.product.name }, - proc { |lis| lis.first.variant.options_text }, - proc { |lis| lis.sum { |li| li.quantity } } ] - - rules = [ { group_by: proc { |li| li.variant.product }, - sort_by: proc { |product| product.name } }, - { group_by: proc { |li| li.variant }, - sort_by: proc { |variant| variant.options_text } }, - { group_by: proc { |li| li.order.user }, - sort_by: proc { |user| user.to_s } } ] - - when "bulk_coop_customer_payments" - - header = ["Customer", "Date of Order", "Total Cost", "Amount Owing", "Amount Paid"] - - columns = [ proc { |lis| lis.first.order.bill_address.firstname + " " + lis.first.order.bill_address.lastname }, - proc { |lis| lis.first.order.created_at.to_s }, - proc { |lis| lis.map { |li| li.order }.uniq.sum { |o| o.total } }, - proc { |lis| lis.map { |li| li.order }.uniq.sum { |o| o.outstanding_balance } }, - proc { |lis| lis.map { |li| li.order }.uniq.sum { |o| o.payment_total } } ] - - rules = [ { group_by: proc { |li| li.order.user }, - sort_by: proc { |user| user.to_s } }, - { group_by: proc { |li| li.order }, - sort_by: proc { |order| order.created_at } } ] - - else # List all line items - - header = ["Supplier", "Product", "Unit Size", "Variant", "Weight", "Sum Total", "Sum Max Total"] - - columns = [ proc { |lis| lis.first.variant.product.supplier.name }, - proc { |lis| lis.first.variant.product.name }, - proc { |lis| "UNIT SIZE" }, - proc { |lis| lis.first.variant.options_text }, - proc { |lis| lis.first.variant.weight }, - proc { |lis| lis.sum { |li| li.quantity } }, + + columns = [ proc { |lis| lis.first.order.bill_address.firstname + " " + lis.first.order.bill_address.lastname }, + proc { |lis| lis.first.variant.product.name }, + proc { |lis| "UNIT SIZE" }, + proc { |lis| lis.first.variant.options_text }, + proc { |lis| lis.first.variant.weight }, + proc { |lis| lis.sum { |li| li.quantity } }, proc { |lis| lis.sum { |li| li.max_quantity || 0 } } ] - - rules = [ { group_by: proc { |li| li.variant.product.supplier }, - sort_by: proc { |supplier| supplier.name } }, - { group_by: proc { |li| li.variant.product }, - sort_by: proc { |product| product.name } }, - { group_by: proc { |li| li.variant }, + + rules = [ { group_by: proc { |li| li.variant.product }, + sort_by: proc { |product| product.name } }, + { group_by: proc { |li| li.variant }, + sort_by: proc { |variant| variant.options_text } }, + { group_by: proc { |li| li.order.user }, + sort_by: proc { |user| user.to_s } } ] + + when "bulk_coop_packing_sheets" + + header = ["Customer", "Product", "Variant", "Sum Total"] + + columns = [ proc { |lis| lis.first.order.bill_address.firstname + " " + lis.first.order.bill_address.lastname }, + proc { |lis| lis.first.variant.product.name }, + proc { |lis| lis.first.variant.options_text }, + proc { |lis| lis.sum { |li| li.quantity } } ] + + rules = [ { group_by: proc { |li| li.variant.product }, + sort_by: proc { |product| product.name } }, + { group_by: proc { |li| li.variant }, + sort_by: proc { |variant| variant.options_text } }, + { group_by: proc { |li| li.order.user }, + sort_by: proc { |user| user.to_s } } ] + + when "bulk_coop_customer_payments" + + header = ["Customer", "Date of Order", "Total Cost", "Amount Owing", "Amount Paid"] + + columns = [ proc { |lis| lis.first.order.bill_address.firstname + " " + lis.first.order.bill_address.lastname }, + proc { |lis| lis.first.order.created_at.to_s }, + proc { |lis| lis.map { |li| li.order }.uniq.sum { |o| o.total } }, + proc { |lis| lis.map { |li| li.order }.uniq.sum { |o| o.outstanding_balance } }, + proc { |lis| lis.map { |li| li.order }.uniq.sum { |o| o.payment_total } } ] + + rules = [ { group_by: proc { |li| li.order.user }, + sort_by: proc { |user| user.to_s } }, + { group_by: proc { |li| li.order }, + sort_by: proc { |order| order.created_at } } ] + + else # List all line items + + header = ["Supplier", "Product", "Unit Size", "Variant", "Weight", "Sum Total", "Sum Max Total"] + + columns = [ proc { |lis| lis.first.variant.product.supplier.name }, + proc { |lis| lis.first.variant.product.name }, + proc { |lis| "UNIT SIZE" }, + proc { |lis| lis.first.variant.options_text }, + proc { |lis| lis.first.variant.weight }, + proc { |lis| lis.sum { |li| li.quantity } }, + proc { |lis| lis.sum { |li| li.max_quantity || 0 } } ] + + rules = [ { group_by: proc { |li| li.variant.product.supplier }, + sort_by: proc { |supplier| supplier.name } }, + { group_by: proc { |li| li.variant.product }, + sort_by: proc { |product| product.name } }, + { group_by: proc { |li| li.variant }, sort_by: proc { |variant| variant.options_text } } ] end @@ -192,7 +195,7 @@ Spree::Admin::ReportsController.class_eval do @table = order_grouper.table(line_items) csv_file_name = "bulk_coop.csv" - generate_report(@header, @table, params[:csv], csv_file_name) + render_report(@header, @table, params[:csv], csv_file_name) end def payments @@ -219,72 +222,72 @@ Spree::Admin::ReportsController.class_eval do case params[:report_type] when "payments_by_payment_type" table_items = payments - + header = ["Payment State", "Distributor", "Payment Type", "Total ($)"] - columns = [ proc { |payments| payments.first.order.payment_state }, - proc { |payments| payments.first.order.distributor.name }, - proc { |payments| payments.first.payment_method.name }, + columns = [ proc { |payments| payments.first.order.payment_state }, + proc { |payments| payments.first.order.distributor.name }, + proc { |payments| payments.first.payment_method.name }, proc { |payments| payments.sum { |payment| payment.amount } } ] - rules = [ { group_by: proc { |payment| payment.order.payment_state }, - sort_by: proc { |payment_state| payment_state } }, - { group_by: proc { |payment| payment.order.distributor }, - sort_by: proc { |distributor| distributor.name } }, - { group_by: proc { |payment| payment.payment_method }, + rules = [ { group_by: proc { |payment| payment.order.payment_state }, + sort_by: proc { |payment_state| payment_state } }, + { group_by: proc { |payment| payment.order.distributor }, + sort_by: proc { |distributor| distributor.name } }, + { group_by: proc { |payment| payment.payment_method }, sort_by: proc { |method| method.name } } ] - + when "itemised_payment_totals" table_items = orders - + header = ["Payment State", "Distributor", "Product Total ($)", "Shipping Total ($)", "Outstanding Balance ($)", "Total ($)"] - - columns = [ proc { |orders| orders.first.payment_state }, - proc { |orders| orders.first.distributor.name }, - proc { |orders| orders.sum { |o| o.item_total } }, - proc { |orders| orders.sum { |o| o.ship_total } }, - proc { |orders| orders.sum { |o| o.outstanding_balance } }, + + columns = [ proc { |orders| orders.first.payment_state }, + proc { |orders| orders.first.distributor.name }, + proc { |orders| orders.sum { |o| o.item_total } }, + proc { |orders| orders.sum { |o| o.ship_total } }, + proc { |orders| orders.sum { |o| o.outstanding_balance } }, proc { |orders| orders.sum { |o| o.total } } ] - - rules = [ { group_by: proc { |order| order.payment_state }, - sort_by: proc { |payment_state| payment_state } }, - { group_by: proc { |order| order.distributor }, + + rules = [ { group_by: proc { |order| order.payment_state }, + sort_by: proc { |payment_state| payment_state } }, + { group_by: proc { |order| order.distributor }, sort_by: proc { |distributor| distributor.name } } ] - + when "payment_totals" table_items = orders header = ["Payment State", "Distributor", "Product Total ($)", "Shipping Total ($)", "Total ($)", "EFT ($)", "PayPal ($)", "Outstanding Balance ($)"] - columns = [ proc { |orders| orders.first.payment_state }, - proc { |orders| orders.first.distributor.name }, - proc { |orders| orders.sum { |o| o.item_total } }, - proc { |orders| orders.sum { |o| o.ship_total } }, - proc { |orders| orders.sum { |o| o.total } }, - proc { |orders| orders.sum { |o| o.payments.select { |payment| payment.completed? && (payment.payment_method.name.to_s.include? "EFT") }.sum { |payment| payment.amount } } }, - proc { |orders| orders.sum { |o| o.payments.select { |payment| payment.completed? && (payment.payment_method.name.to_s.include? "PayPal") }.sum{ |payment| payment.amount } } }, + columns = [ proc { |orders| orders.first.payment_state }, + proc { |orders| orders.first.distributor.name }, + proc { |orders| orders.sum { |o| o.item_total } }, + proc { |orders| orders.sum { |o| o.ship_total } }, + proc { |orders| orders.sum { |o| o.total } }, + proc { |orders| orders.sum { |o| o.payments.select { |payment| payment.completed? && (payment.payment_method.name.to_s.include? "EFT") }.sum { |payment| payment.amount } } }, + proc { |orders| orders.sum { |o| o.payments.select { |payment| payment.completed? && (payment.payment_method.name.to_s.include? "PayPal") }.sum{ |payment| payment.amount } } }, proc { |orders| orders.sum { |o| o.outstanding_balance } } ] - rules = [ { group_by: proc { |order| order.payment_state }, - sort_by: proc { |payment_state| payment_state } }, - { group_by: proc { |order| order.distributor }, + rules = [ { group_by: proc { |order| order.payment_state }, + sort_by: proc { |payment_state| payment_state } }, + { group_by: proc { |order| order.distributor }, sort_by: proc { |distributor| distributor.name } } ] else table_items = payments - + header = ["Payment State", "Distributor", "Payment Type", "Total ($)"] - columns = [ proc { |payments| payments.first.order.payment_state }, - proc { |payments| payments.first.order.distributor.name }, - proc { |payments| payments.first.payment_method.name }, + columns = [ proc { |payments| payments.first.order.payment_state }, + proc { |payments| payments.first.order.distributor.name }, + proc { |payments| payments.first.payment_method.name }, proc { |payments| payments.sum { |payment| payment.amount } } ] - rules = [ { group_by: proc { |payment| payment.order.payment_state }, - sort_by: proc { |payment_state| payment_state } }, - { group_by: proc { |payment| payment.order.distributor }, - sort_by: proc { |distributor| distributor.name } }, - { group_by: proc { |payment| payment.payment_method }, + rules = [ { group_by: proc { |payment| payment.order.payment_state }, + sort_by: proc { |payment_state| payment_state } }, + { group_by: proc { |payment| payment.order.distributor }, + sort_by: proc { |distributor| distributor.name } }, + { group_by: proc { |payment| payment.payment_method }, sort_by: proc { |method| method.name } } ] end @@ -294,11 +297,189 @@ Spree::Admin::ReportsController.class_eval do @header = header @table = order_grouper.table(table_items) csv_file_name = "payments.csv" - - generate_report(@header, @table, params[:csv], csv_file_name) + + render_report(@header, @table, params[:csv], csv_file_name) end - + + def order_cycles + params[:q] = {} unless params[:q] + + if params[:q][:created_at_gt].blank? + params[:q][:created_at_gt] = Time.zone.now.beginning_of_month + else + params[:q][:created_at_gt] = Time.zone.parse(params[:q][:created_at_gt]).beginning_of_day rescue Time.zone.now.beginning_of_month + end + + if params[:q] && !params[:q][:created_at_lt].blank? + params[:q][:created_at_lt] = Time.zone.parse(params[:q][:created_at_lt]).end_of_day rescue "" + end + params[:q][:meta_sort] ||= "created_at.desc" + + @search = Spree::Order.complete.search(params[:q]) + orders = @search.result + line_items = orders.map { |o| o.line_items }.flatten + #payments = orders.map { |o| o.payments.select { |payment| payment.completed? } }.flatten # Only select completed payments + + @distributors = Spree::Distributor.all + @report_type = params[:report_type] + + case params[:report_type] + when "order_cycle_supplier_totals" + table_items = line_items + @include_blank = 'All' + + header = ["Supplier", "Product", "Variant", "Amount", "Cost per Unit", "Total Cost", "Status", "Incoming Transport"] + + columns = [ proc { |line_items| line_items.first.variant.product.supplier.name }, + proc { |line_items| line_items.first.variant.product.name }, + proc { |line_items| line_items.first.variant.options_text }, + proc { |line_items| line_items.sum { |li| li.quantity } }, + proc { |line_items| line_items.first.variant.price }, + proc { |line_items| line_items.sum { |li| li.quantity * li.variant.price } }, + proc { |line_items| "status" }, + proc { |line_items| "incoming transport" } ] + + rules = [ { group_by: proc { |line_item| line_item.variant.product.supplier }, + sort_by: proc { |supplier| supplier.name } }, + { group_by: proc { |line_item| line_item.variant.product }, + sort_by: proc { |product| product.name } }, + { group_by: proc { |line_item| line_item.variant }, + sort_by: proc { |variant| variant.options_text } } ] + + when "order_cycle_supplier_totals_by_distributor" + table_items = line_items + @include_blank = 'All' + + header = ["Supplier", "Product", "Variant", "To Distributor", "Amount", "Cost per Unit", "Total Cost", "Shipping Method"] + + columns = [ proc { |line_items| line_items.first.variant.product.supplier.name }, + proc { |line_items| line_items.first.variant.product.name }, + proc { |line_items| line_items.first.variant.options_text }, + proc { |line_items| line_items.first.order.distributor.name }, + proc { |line_items| line_items.sum { |li| li.quantity } }, + proc { |line_items| line_items.first.variant.price }, + proc { |line_items| line_items.sum { |li| li.quantity * li.variant.price } }, + proc { |line_items| "shipping method" } ] + + rules = [ { group_by: proc { |line_item| line_item.variant.product.supplier }, + sort_by: proc { |supplier| supplier.name } }, + { group_by: proc { |line_item| line_item.variant.product }, + sort_by: proc { |product| product.name } }, + { group_by: proc { |line_item| line_item.variant }, + sort_by: proc { |variant| variant.options_text }, + summary_columns: [ proc { |line_items| line_items.first.variant.product.supplier.name }, + proc { |line_items| line_items.first.variant.product.name }, + proc { |line_items| line_items.first.variant.options_text }, + proc { |line_items| "TOTAL" }, + proc { |line_items| line_items.sum { |li| li.quantity } }, + proc { |line_items| line_items.first.variant.price }, + proc { |line_items| line_items.sum { |li| li.quantity * li.variant.price } }, + proc { |line_items| "" } ] }, + { group_by: proc { |line_item| line_item.order.distributor }, + sort_by: proc { |distributor| distributor.name } } ] + + when "order_cycle_distributor_totals_by_supplier" + table_items = line_items + @include_blank = 'All' + + header = ["Distributor", "Supplier", "Product", "Variant", "Amount", "Cost per Unit", "Total Cost", "Total Shipping Cost", "Shipping Method"] + + columns = [ proc { |line_items| line_items.first.order.distributor.name }, + proc { |line_items| line_items.first.variant.product.supplier.name }, + proc { |line_items| line_items.first.variant.product.name }, + proc { |line_items| line_items.first.variant.options_text }, + proc { |line_items| line_items.sum { |li| li.quantity } }, + proc { |line_items| line_items.first.variant.price }, + proc { |line_items| line_items.sum { |li| li.quantity * li.variant.price } }, + proc { |line_items| "" }, + proc { |line_items| "shipping method" } ] + + rules = [ { group_by: proc { |line_item| line_item.order.distributor }, + sort_by: proc { |distributor| distributor.name }, + summary_columns: [ proc { |line_items| line_items.first.order.distributor.name }, + proc { |line_items| "TOTAL" }, + proc { |line_items| "" }, + proc { |line_items| "" }, + proc { |line_items| "" }, + proc { |line_items| "" }, + proc { |line_items| line_items.sum { |li| li.quantity * li.variant.price } }, + proc { |line_items| "total shipping cost" }, + proc { |line_items| "" } ] }, + { group_by: proc { |line_item| line_item.variant.product.supplier }, + sort_by: proc { |supplier| supplier.name } }, + { group_by: proc { |line_item| line_item.variant.product }, + sort_by: proc { |product| product.name } }, + { group_by: proc { |line_item| line_item.variant }, + sort_by: proc { |variant| variant.options_text } } ] + + when "order_cycle_customer_totals" + table_items = line_items + @include_blank = false + + header = ["Customer", "Email", "Phone", "Product", "Variant", "Amount", "Total Cost", "Paid?", "Packed?", "Shipped?"] + + columns = [ proc { |line_items| line_items.first.order.bill_address.firstname + " " + line_items.first.order.bill_address.lastname }, + proc { |line_items| line_items.first.order.email }, + proc { |line_items| line_items.first.order.bill_address.phone }, + proc { |line_items| line_items.first.variant.product.name }, + proc { |line_items| line_items.first.variant.options_text }, + proc { |line_items| line_items.sum { |li| li.quantity } }, + proc { |line_items| line_items.sum { |li| li.quantity * li.variant.price } }, + proc { |line_items| "" }, + proc { |line_items| "" }, + proc { |line_items| "" } ] + + rules = [ { group_by: proc { |line_item| line_item.order.user }, + sort_by: proc { |user| user.to_s }, + summary_columns: [ proc { |line_items| line_items.first.order.bill_address.firstname + " " + line_items.first.order.bill_address.lastname }, + proc { |line_items| line_items.first.order.email }, + proc { |line_items| line_items.first.order.bill_address.phone }, + proc { |line_items| "TOTAL" }, + proc { |line_items| "" }, + proc { |line_items| "" }, + proc { |line_items| line_items.sum { |li| li.quantity * li.variant.price } }, + proc { |line_items| "work out whether paid or not" }, + proc { |line_items| "" }, + proc { |line_items| "" } ] }, + { group_by: proc { |line_item| line_item.variant.product }, + sort_by: proc { |product| product.name } }, + { group_by: proc { |line_item| line_item.variant }, + sort_by: proc { |variant| variant.options_text } } ] + + else + table_items = line_items + + header = ["Supplier", "Product", "Variant", "Amount", "Cost per Unit", "Total Cost", "Status", "Incoming Transport"] + + columns = [ proc { |line_items| line_items.first.variant.product.supplier.name }, + proc { |line_items| line_items.first.variant.product.name }, + proc { |line_items| line_items.first.variant.options_text }, + proc { |line_items| line_items.sum { |li| li.quantity } }, + proc { |line_items| line_items.first.variant.price }, + proc { |line_items| line_items.sum { |li| li.quantity * li.variant.price } }, + proc { |line_items| "status" }, + proc { |line_items| "incoming transport" } ] + + rules = [ { group_by: proc { |line_item| line_item.variant.product.supplier }, + sort_by: proc { |supplier| supplier.name } }, + { group_by: proc { |line_item| line_item.variant.product }, + sort_by: proc { |product| product.name } }, + { group_by: proc { |line_item| line_item.variant }, + sort_by: proc { |variant| variant.options_text } } ] + + end + + order_grouper = OpenFoodWeb::OrderGrouper.new rules, columns + + @header = header + @table = order_grouper.table(table_items) + csv_file_name = "order_cycles.csv" + + render_report(@header, @table, params[:csv], csv_file_name) + + end + def render_report (header, table, create_csv, csv_file_name) unless create_csv render :html => table diff --git a/app/views/spree/admin/reports/order_cycles.html.haml b/app/views/spree/admin/reports/order_cycles.html.haml new file mode 100644 index 0000000000..33bd97cb06 --- /dev/null +++ b/app/views/spree/admin/reports/order_cycles.html.haml @@ -0,0 +1,39 @@ += form_for @search, :url => spree.order_cycles_admin_reports_path do |f| + = label_tag nil, t(:date_range) + %br + .date-range-filter + %div{"class" => "left sub-field"} + = f.text_field :created_at_gt, :class => 'datepicker' + %br + = label_tag nil, t(:start), :class => 'sub' + %div{"class" => "right sub-field"} + = f.text_field :created_at_lt, :class => 'datepicker' + %br + = label_tag nil, t(:stop) + %br + = label_tag nil, "Distributor: " + = f.collection_select(:distributor_id_eq, @distributors, :id, :name, :include_blank => @include_blank) + %br + = label_tag nil, "Report Type: " + = select_tag(:report_type, options_for_select([['Order Cycle Supplier Totals',:order_cycle_supplier_totals], ['Order Cycle Supplier Totals by Distributor',:order_cycle_supplier_totals_by_distributor], ['Order Cycle Distributor Totals by Supplier',:order_cycle_distributor_totals_by_supplier], ['Order Cycle Customer Totals',:order_cycle_customer_totals]], @report_type)) + %br + %br + = check_box_tag :csv + = label_tag :csv, "Download as csv" + %br + = button t(:search) +%br +%br +%table#listing_orders.index + %thead + %tr{'data-hook' => "orders_header"} + - @header.each do |heading| + %th=heading + %tbody + - @table.each do |row| + %tr + - row.each do |column| + %td= column + - if @table.empty? + %tr + %td{:colspan => "2"}= t(:none) \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 7fde8d7b66..354e2d0dbd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -22,5 +22,6 @@ Spree::Core::Engine.routes.prepend do match '/admin/reports/group_buys' => 'admin/reports#group_buys', :as => "group_buys_admin_reports", :via => [:get, :post] match '/admin/reports/bulk_coop' => 'admin/reports#bulk_coop', :as => "bulk_coop_admin_reports", :via => [:get, :post] match '/admin/reports/payments' => 'admin/reports#payments', :as => "payments_admin_reports", :via => [:get, :post] + match '/admin/reports/order_cycles' => 'admin/reports#order_cycles', :as => "order_cycles_admin_reports", :via => [:get, :post] end