app/controllers/admin/store/reports_controller.rb
# Number of orders places each day in the given date range
Number of orders places each day in the given date range
Number of orders places each day in the given date range
def daily_sales
    sql = <<-EOF
      select date(shp.created_at), count(*), sum(o.total)
      from store_shipments shp
      join store_orders o on o.id = shp.order_id
      where shp.created_at > '#{@start_date}' and shp.created_at < '#{@end_date}'
      and o.sales_channel LIKE '#{@selected_channel}'
      #{"and shp.fulfilled_by_id=" + params[:affiliate_id] if params[:affiliate_id].present?}
      group by date(shp.created_at)
      order by date(shp.created_at) desc;
    EOF
    @data = []
    ActiveRecord::Base.connection.execute(sql).each { |row| @data << row }
  end
def daily_sales sql = <<-EOF 
      select date(shp.created_at), count(*), sum(o.total)
      from store_shipments shp
      join store_orders o on o.id = shp.order_id
      where shp.created_at > ' #{ @start_date } ' and shp.created_at < ' #{ @end_date } '
      and o.sales_channel LIKE ' #{ @selected_channel } '
       #{ "and shp.fulfilled_by_id=" + params [ :affiliate_id ] if params [ :affiliate_id ] . present? } 
      group by date(shp.created_at)
      order by date(shp.created_at) desc;
     EOF @data = [ ] ActiveRecord :: Base . connection . execute ( sql ) . each { | row | @data << row } end
Number of orders places each day in the given date range
Number of orders places each day in the given date range