mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-08 17:04:23 -05:00
Update customer.rb
This commit is contained in:
@@ -142,18 +142,18 @@ class Customer < ActiveRecord::Base
|
|||||||
|
|
||||||
# Searchs the database for a customer by name
|
# Searchs the database for a customer by name
|
||||||
def self.search(search)
|
def self.search(search)
|
||||||
customers = where("name LIKE ?", "%#{search}%").order(:name)
|
customers = where("name LIKE ?", "%#{search}%")
|
||||||
|
|
||||||
if customers.empty?
|
if customers.empty?
|
||||||
service = Qbo.get_base(:customer).service
|
service = Qbo.get_base(:customer).service
|
||||||
results = service.query("Select Id From Customer Where ((PrimaryPhone LIKE '%#{search}%') OR (Mobile LIKE '%#{search}%') Order By DisplayName")
|
results = service.query("Select Id From Customer Where PrimaryPhone LIKE '%#{search}%' OR Mobile LIKE '%#{search}%'")
|
||||||
|
|
||||||
results.each do |customer|
|
results.each do |customer|
|
||||||
customers << Customer.find_by_id(customer.id)
|
customers << Customer.find_by_id(customer.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return customers
|
return customers.order(:name)
|
||||||
end
|
end
|
||||||
|
|
||||||
# proforms a bruteforce sync operation
|
# proforms a bruteforce sync operation
|
||||||
|
|||||||
Reference in New Issue
Block a user