Refactored finance/ordergroups|transactions module.
This commit is contained in:
parent
fc1d130113
commit
ea6348bc5c
38 changed files with 967 additions and 443 deletions
31
app/controllers/finance/ordergroups_controller.rb
Normal file
31
app/controllers/finance/ordergroups_controller.rb
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
class Finance::OrdergroupsController < ApplicationController
|
||||
before_filter :authenticate_finance
|
||||
|
||||
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 params["sort"]
|
||||
sort = case params["sort"]
|
||||
when "name" then "name"
|
||||
when "account_balance" then "account_balance"
|
||||
when "name_reverse" then "name DESC"
|
||||
when "account_balance_reverse" then "account_balance DESC"
|
||||
end
|
||||
else
|
||||
sort = "name"
|
||||
end
|
||||
|
||||
@ordergroups = Ordergroup.order(sort)
|
||||
@ordergroups = @ordergroups.where(:name.matches => "%#{params[:query]}%") unless params[:query].nil?
|
||||
|
||||
@ordergroups = @ordergroups.paginate :page => params[:page], :per_page => @per_page
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js { render :layout => false }
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue