Sha256: 6a473e722e56c401a52fa1094206f2e081e05521c5c61e9aa2d2959c9b075dba

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

class Spree::Admin::AdvancedReportOverviewController < Spree::Admin::BaseController
  def index
    @reports = Spree::Admin::ReportsController::ADVANCED_REPORTS
    @products = Spree::Product.all
    @taxons = Spree::Taxon.all
    if defined?(MultiDomainExtension)
      @stores = Store.all
    end
    @report = Spree::AdvancedReport::IncrementReport::Revenue.new({ :search => {} })
    @top_products_report = Spree::AdvancedReport::TopReport::TopProducts.new({ :search => {} }, 5)
    @top_customers_report = Spree::AdvancedReport::TopReport::TopCustomers.new({ :search => {} }, 5)
    @top_customers_report.ruportdata.remove_column(I18n.t("adv_report.units"))

    # From overview_dashboard, Cleanup eventually
    orders = Spree::Order.find(:all, :order => "completed_at DESC", :limit => 10, :include => :line_items, :conditions => "completed_at is not null")
    @last_orders = orders.inject([]) { |arr, o| arr << [o.bill_address.firstname, o.line_items.sum(:quantity), o.total, o.number]; arr }
    @best_taxons =  Spree::Taxon.connection.select_rows("select t.name, count(li.quantity) from spree_line_items li inner join spree_variants v on
           li.variant_id = v.id inner join spree_products p on v.product_id = p.id inner join spree_products_taxons pt on p.id = pt.product_id
           inner join spree_taxons t on pt.taxon_id = t.id where t.taxonomy_id = #{Spree::Taxonomy.last.id} group by t.name order by count(li.quantity) desc limit 5;")
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree_advanced_reporting-2.1.0 app/controllers/spree/admin/advanced_report_overview_controller.rb