bugfix autocomplete
This commit is contained in:
parent
b9e8fec128
commit
3a0dab4478
@ -139,31 +139,38 @@ class Admin::PProductRefsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def autocomplete
|
def autocomplete
|
||||||
@p_product_refs = PProductRef.joins(:p_product).all
|
# @p_product_refs = PProductRef.joins(:p_product)
|
||||||
# @p_product_refs = PProductRef.for_search(params[:search]).limit(50)
|
@p_product_refs = PProductRef.limit(10).global_search(params[:search])
|
||||||
|
|
||||||
if params[:p_customer_id]
|
|
||||||
@p_customer = PCustomer.where(:id => params[:p_customer_id]).first
|
|
||||||
#@p_product_refs = @p_product_refs.where("p_products.p_customer_id IS NULL or p_products.p_customer_id = ? ", @p_customer.id).joins(:p_customer_cats).where(:p_customer_cats => {:id => @p_customer.p_customer_cat_id})
|
|
||||||
end
|
|
||||||
|
|
||||||
@p_product_refs = @p_product_refs.where(:p_products => {:enabled => true})
|
# @p_product_refs = PProductRef.joins(:p_product).all
|
||||||
|
# # @p_product_refs = PProductRef.for_search(params[:search]).limit(50)
|
||||||
|
|
||||||
if params[:not_assembled].to_s == "true"
|
# if params[:p_customer_id]
|
||||||
|
# @p_customer = PCustomer.where(:id => params[:p_customer_id]).first
|
||||||
|
# #@p_product_refs = @p_product_refs.where("p_products.p_customer_id IS NULL or p_products.p_customer_id = ? ", @p_customer.id).joins(:p_customer_cats).where(:p_customer_cats => {:id => @p_customer.p_customer_cat_id})
|
||||||
|
# end
|
||||||
|
|
||||||
@p_product_refs = @p_product_refs.not_assembleds
|
# @p_product_refs = @p_product_refs.where(:p_products => {:enabled => true})
|
||||||
|
|
||||||
end
|
# if params[:not_assembled].to_s == "true"
|
||||||
|
|
||||||
|
# @p_product_refs = @p_product_refs.not_assembleds
|
||||||
|
|
||||||
|
# end
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
|
|
||||||
|
|
||||||
@p_product_refs.distinct.all.each do |p_product_ref|
|
# @p_product_refs.distinct.all.each do |p_product_ref|
|
||||||
result << {:member_label => p_product_ref.member_label, :id => p_product_ref.id }
|
# result << {:member_label => p_product_ref.member_label, :id => p_product_ref.id }
|
||||||
end
|
# end
|
||||||
|
|
||||||
|
@p_product_refs.all.each do |p_product_ref|
|
||||||
|
result << {:member_label => p_product_ref.member_label, :id => p_product_ref.id }
|
||||||
|
end
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json { render json: result}
|
format.json { render json: result}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user