2009-01-14 12:46:01 +01:00
|
|
|
class Admin::OrdergroupsController < ApplicationController
|
|
|
|
before_filter :authenticate_admin
|
|
|
|
|
|
|
|
def index
|
|
|
|
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 the search field is used
|
|
|
|
conditions = "name LIKE '%#{params[:query]}%'" unless params[:query].nil?
|
|
|
|
|
2009-02-11 15:23:59 +01:00
|
|
|
@total = Ordergroup.without_deleted.count(:conditions => conditions )
|
|
|
|
@ordergroups = Ordergroup.without_deleted.paginate(:conditions => conditions, :page => params[:page],
|
2009-01-14 12:46:01 +01:00
|
|
|
:per_page => @per_page, :order => 'name')
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html # index.html.erb
|
|
|
|
format.js { render :partial => "ordergroups" }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def show
|
|
|
|
@ordergroup = Ordergroup.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@ordergroup = Ordergroup.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
@ordergroup = Ordergroup.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2009-02-01 21:53:08 +01:00
|
|
|
@ordergroup = Ordergroup.new(params[:ordergroup])
|
2009-01-14 12:46:01 +01:00
|
|
|
|
|
|
|
if @ordergroup.save
|
|
|
|
flash[:notice] = 'Ordergroup was successfully created.'
|
|
|
|
redirect_to([:admin, @ordergroup])
|
|
|
|
else
|
|
|
|
render :action => "new"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@ordergroup = Ordergroup.find(params[:id])
|
|
|
|
|
2009-02-01 21:53:08 +01:00
|
|
|
if @ordergroup.update_attributes(params[:ordergroup])
|
2009-01-14 12:46:01 +01:00
|
|
|
flash[:notice] = 'Ordergroup was successfully updated.'
|
|
|
|
redirect_to([:admin, @ordergroup])
|
|
|
|
else
|
|
|
|
render :action => "edit"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@ordergroup = Ordergroup.find(params[:id])
|
|
|
|
@ordergroup.destroy
|
|
|
|
|
2009-02-11 15:23:59 +01:00
|
|
|
redirect_to(admin_ordergroups_url)
|
2009-01-14 12:46:01 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def memberships
|
|
|
|
@group = Ordergroup.find(params[:id])
|
|
|
|
end
|
|
|
|
end
|