Created
March 5, 2009 22:57
-
-
Save spree/74623 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def collection | |
default_stop = (Date.today + 1).to_s(:db) | |
@filter = params.has_key?(:filter) ? OrderFilter.new(params[:filter]) : OrderFilter.new | |
scope = Order.scoped(:include => [:shipments, {:creditcards => :address}]) | |
scope = scope.by_number @filter.number unless @filter.number.blank? | |
scope = scope.by_customer @filter.customer unless @filter.customer.blank? | |
scope = scope.between(@filter.start, (@filter.stop.blank? ? default_stop : @filter.stop)) unless @filter.start.blank? | |
scope = scope.by_state @filter.state.classify.downcase.gsub(" ", "_") unless @filter.state.blank? | |
scope = scope.conditions "lower(addresses.firstname) LIKE ?", "%#{@filter.firstname.downcase}%" unless @filter.firstname.blank? | |
scope = scope.conditions "lower(addresses.lastname) LIKE ?", "%#{@filter.lastname.downcase}%" unless @filter.lastname.blank? | |
scope = scope.checkout_completed(@filter.checkout == '1' ? false : true) | |
@collection = scope.find(:all, :order => 'orders.created_at DESC', :include => :user, :page => {:size => Spree::Config[:orders_per_page], :current =>params[:p], :first => 1}) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment