2012-11-10 16:44:05 +01:00
|
|
|
class Finance::OrdergroupsController < Finance::BaseController
|
2011-06-09 21:35:05 +02:00
|
|
|
def index
|
2017-03-04 14:15:39 +01:00
|
|
|
m = /^(?<col>name|sum_of_class_\d+)(?<reverse>_reverse)?$/.match params["sort"]
|
|
|
|
if m
|
|
|
|
sort = m[:col]
|
|
|
|
sort += ' DESC' if m[:reverse]
|
2011-06-09 21:35:05 +02:00
|
|
|
else
|
|
|
|
sort = "name"
|
|
|
|
end
|
|
|
|
|
2013-03-16 17:53:24 +01:00
|
|
|
@ordergroups = Ordergroup.undeleted.order(sort)
|
2017-03-04 14:15:39 +01:00
|
|
|
@ordergroups = @ordergroups.include_transaction_class_sum
|
|
|
|
@ordergroups = @ordergroups.where('groups.name LIKE ?', "%#{params[:query]}%") unless params[:query].nil?
|
2011-06-09 21:35:05 +02:00
|
|
|
|
2012-11-10 16:44:05 +01:00
|
|
|
@ordergroups = @ordergroups.page(params[:page]).per(@per_page)
|
2011-06-09 21:35:05 +02:00
|
|
|
end
|
|
|
|
end
|