def get_paged_search_results(params,user:nil,model:nil)
			params[:per_page] = 10 if params[:per_page].blank?
			params[:page] = 1 if params[:page].blank?
			# a ghetto user check, but for some reason a devise user is not a devise user...
			user = User.new if user.blank? or !user.class.to_s == User.to_s

			# get the model in question
			# there has got to be a better way to do this... I just can't find it
			# model = params[:controller].blank? ? self.class.name.gsub('Controller','').singularize.constantize : params[:controller].classify.constantize
			if model.blank? 
				model = request.params[:table_name].classify.constantize unless request.params[:table_name].blank?
				return nil if model.blank?
			end

			# initialize un-paged filtered result set
			result_set = model.none

			# create where clauses to filter result to just the customers the current user has access to
			customer_filter = ""
			user.customers.each do |cust|
				if model.column_names.include? "cust_id"
					customer_filter << "(cust_id = '#{cust.cust_id(true)}') OR " unless cust.cust_id.blank?
				elsif model.attribute_alias? "cust_id"
					customer_filter << "(#{model.attribute_alias "cust_id"} = '#{cust.cust_id(true)}') OR " unless cust.cust_id.blank?
				elsif model.column_names.include? "order_number"
					customer_filter << "(order_number like '#{cust.prefix}%') OR " unless cust.prefix.blank?
				elsif model.attribute_alias? "order_number"
					customer_filter << "(#{model.attribute_alias "order_number"} like '#{cust.prefix}%') OR " unless cust.prefix.blank?
				end
			end
			customer_filter << " (1=0)"

			# create where clauses for each search parameter
			if params[:columns].blank?
				result_set = model.where(customer_filter)
			else
				where_clause = ""
				params[:columns].each do |name, value|
					where_clause << "(#{model.table_name}.#{name} like '%#{value}%') AND " unless value.blank?
				end
				where_clause << " (1=1)"

				result_set = model.where(customer_filter).where(where_clause)
			end

			instances = model.paginate(page: params[:page], per_page: params[:per_page]).merge(result_set).order(updated_at: :desc)
			return {instances:instances,params:params}
		end
def get_paged_search_results(params,user:nil,model:nil)
			params[:per_page] = 10 if params[:per_page].blank?
			params[:page] = 1 if params[:page].blank?
			# a ghetto user check, but for some reason a devise user is not a devise user...
			user = User.new if user.blank? or !user.class.to_s == User.to_s

			# get the model in question
			# there has got to be a better way to do this... I just can't find it
			# model = params[:controller].blank? ? self.class.name.gsub('Controller','').singularize.constantize : params[:controller].classify.constantize
			if model.blank? 
				model = request.params[:table_name].classify.constantize unless request.params[:table_name].blank?
				return nil if model.blank?
			end

			# initialize un-paged filtered result set
			result_set = model.none

			# create where clauses to filter result to just the customers the current user has access to
			customer_filter = ""
			user.customers.each do |cust|
				if model.column_names.include? "cust_id"
					customer_filter << "(cust_id = '#{cust.cust_id(true)}') OR " unless cust.cust_id.blank?
				elsif model.attribute_alias? "cust_id"
					customer_filter << "(#{model.attribute_alias "cust_id"} = '#{cust.cust_id(true)}') OR " unless cust.cust_id.blank?
				elsif model.column_names.include? "order_number"
					customer_filter << "(order_number like '#{cust.prefix}%') OR " unless cust.prefix.blank?
				elsif model.attribute_alias? "order_number"
					customer_filter << "(#{model.attribute_alias "order_number"} like '#{cust.prefix}%') OR " unless cust.prefix.blank?
				end
			end
			customer_filter << " (1=0)"

			# create where clauses for each search parameter
			if params[:columns].blank?
				result_set = model.where(customer_filter)
			else
				where_clause = ""
				params[:columns].each do |name, value|
					where_clause << "(#{model.table_name}.#{name} like '%#{value}%') AND " unless value.blank?
				end
				where_clause << " (1=1)"

				result_set = model.where(customer_filter).where(where_clause)
			end

			instances = model.paginate(page: params[:page], per_page: params[:per_page]).merge(result_set).order(updated_at: :desc)
			return {instances:instances,params:params}
		end
Assumes the existance of a User model