2009-08-02 18:12:13 +02:00
|
|
|
class Foodcoop::OrdergroupsController < ApplicationController
|
|
|
|
|
|
|
|
def index
|
2012-09-30 21:15:55 +02:00
|
|
|
@ordergroups = Ordergroup.order('name DESC')
|
2009-08-02 18:12:13 +02:00
|
|
|
|
2012-10-08 16:20:24 +02:00
|
|
|
unless params[:name].blank? # Search by name
|
|
|
|
@ordergroups = @ordergroups.where('name LIKE ?', "%#{params[:name]}%")
|
|
|
|
end
|
|
|
|
|
|
|
|
if params[:only_active] # Select only active groups
|
|
|
|
@ordergroups = @ordergroups.joins(:orders).where("orders.starts >= ?", Time.now.months_ago(3)).uniq
|
|
|
|
end
|
|
|
|
|
|
|
|
@ordergroups = @ordergroups.page(params[:page]).per(@per_page)
|
2009-08-02 18:12:13 +02:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html # index.html.erb
|
2011-05-18 11:47:00 +02:00
|
|
|
format.js { render :layout => false }
|
2009-08-02 18:12:13 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|