mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-08 17:04:23 -05:00
Search Phone Numbers
This commit is contained in:
@@ -142,7 +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)
|
||||||
where("name LIKE ?", "%#{search}%").order(:name)
|
customers = where("name LIKE ?", "%#{search}%").order(:name)
|
||||||
|
|
||||||
|
if customers.empty?
|
||||||
|
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.each do |customer|
|
||||||
|
customers << Customer.find_by_id(customer.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return customers
|
||||||
end
|
end
|
||||||
|
|
||||||
# proforms a bruteforce sync operation
|
# proforms a bruteforce sync operation
|
||||||
|
|||||||
Reference in New Issue
Block a user