Added "ordergroups" view to list the ordergroups
* You can search in the name. * You can show only active order groups (order in last 3 months) * Future feature: generate text and pdf files for the box labels
This commit is contained in:
parent
e95cdad5ec
commit
e32e97d178
2 changed files with 21 additions and 12 deletions
|
|
@ -49,11 +49,19 @@ class FoodcoopController < ApplicationController
|
|||
@per_page = 20
|
||||
end
|
||||
|
||||
# if somebody uses the search field:
|
||||
conditions = ["name LIKE ?", "%#{params[:query]}%"] unless params[:query].blank?
|
||||
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)
|
||||
@order_groups = Ordergroup.paginate(:page => params[:page], :per_page => @per_page, :conditions => conditions, :order => "name")
|
||||
@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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue