Merge branch 'master' of git@github.com:bennibu/foodsoft

This commit is contained in:
Benjamin Meichsner 2009-04-20 14:13:47 +02:00
commit a3fbc2d37b
5 changed files with 76 additions and 2 deletions

View file

@ -41,6 +41,34 @@ class FoodcoopController < ApplicationController
@groups = Workgroup.find :all, :order => "name"
end
def ordergroups
#@order_groups = Ordergroup.find :all, :order => "name"
if (params[:per_page] && params[:per_page].to_i > 0 && params[:per_page].to_i <= 100)
@per_page = params[:per_page].to_i
else
@per_page = 20
end
if (params[:only_active].to_i == 1)
if (! params[:query].blank?)
conditions = ["orders.starts >= ? AND name LIKE ?", Time.now.months_ago(3), "%#{params[:query]}%"]
else
conditions = ["orders.starts >= ?", Time.now.months_ago(3)]
end
else
# if somebody uses the search field:
conditions = ["name LIKE ?", "%#{params[:query]}%"] unless params[:query].blank?
end
@total = Ordergroup.count(:conditions => conditions, :include => "orders")
@order_groups = Ordergroup.paginate(:page => params[:page], :per_page => @per_page, :conditions => conditions, :order => "name", :include => "orders")
respond_to do |format|
format.html # index.html.erb
format.js { render :partial => "ordergroups" }
end
end
def group
end