diff --git a/client_locations.php b/client_locations.php
index d5c12618..656f4365 100644
--- a/client_locations.php
+++ b/client_locations.php
@@ -13,8 +13,14 @@ if(isset($_GET['p'])){
if(isset($_GET['q'])){
$q = mysqli_real_escape_string($mysqli,$_GET['q']);
+ //Phone Numbers
+ $phone_query = preg_replace("/[^0-9]/", '',$q);
+ if(empty($phone_query)){
+ $phone_query = $q;
+ }
}else{
$q = "";
+ $phone_query = "";
}
if(!empty($_GET['sb'])){
@@ -41,7 +47,7 @@ $url_query_strings_sb = http_build_query(array_merge($_GET,array('sb' => $sb, 'o
$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM locations
WHERE location_client_id = $client_id
- AND (location_name LIKE '%$q%' OR location_address LIKE '%$q%' OR location_phone LIKE '%$q%')
+ AND (location_name LIKE '%$q%' OR location_address LIKE '%$q%' OR location_phone LIKE '%$phone_query%')
ORDER BY $sb $o LIMIT $record_from, $record_to");
$num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
diff --git a/client_vendors.php b/client_vendors.php
index 80fa4661..7e0cb211 100644
--- a/client_vendors.php
+++ b/client_vendors.php
@@ -13,8 +13,14 @@ if(isset($_GET['p'])){
if(isset($_GET['q'])){
$q = mysqli_real_escape_string($mysqli,$_GET['q']);
+ //Phone Numbers
+ $phone_query = preg_replace("/[^0-9]/", '',$q);
+ if(empty($phone_query)){
+ $phone_query = $q;
+ }
}else{
$q = "";
+ $phone_query = "";
}
if(!empty($_GET['sb'])){
@@ -41,8 +47,7 @@ $url_query_strings_sb = http_build_query(array_merge($_GET,array('sb' => $sb, 'o
$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM vendors
WHERE vendor_client_id = $client_id
- AND (vendor_name LIKE '%$q%' OR vendor_description LIKE '%$q%' OR vendor_account_number LIKE '%$q%' )
- ORDER BY $sb $o LIMIT $record_from, $record_to");
+ AND (vendor_name LIKE '%$q%' OR vendor_description LIKE '%$q%' OR vendor_account_number LIKE '%$q%' OR vendor_website LIKE '%$q%' OR vendor_contact_name LIKE '%$q%' OR vendor_email LIKE '%$q%' OR vendor_phone LIKE '%$phone_query%') ORDER BY $sb $o LIMIT $record_from, $record_to");
$num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
diff --git a/clients.php b/clients.php
index 44f58e1e..4e8a51c5 100644
--- a/clients.php
+++ b/clients.php
@@ -16,8 +16,14 @@ if(isset($_GET['p'])){
//Custom Query Filter
if(isset($_GET['query'])){
$query = mysqli_real_escape_string($mysqli,$_GET['query']);
+ //Phone Numbers
+ $phone_query = preg_replace("/[^0-9]/", '',$query);
+ if(empty($phone_query)){
+ $phone_query = $query;
+ }
}else{
$query = "";
+ $number_query = "";
}
//Column Filter
@@ -86,8 +92,8 @@ $url_query_strings_sortby = http_build_query(array_merge($_GET,array('sortby' =>
$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM clients
LEFT JOIN contacts ON clients.primary_contact = contacts.contact_id AND contact_archived_at IS NULL
LEFT JOIN locations ON clients.primary_location = locations.location_id AND location_archived_at IS NULL
- WHERE (client_name LIKE '%$query%' OR client_type LIKE '%$query%' OR contact_email LIKE '%$query%' OR contact_name LIKE '%$query%' OR contact_phone LIKE '%$query%'
- OR contact_mobile LIKE '%$query%' OR location_address LIKE '%$query%' OR location_city LIKE '%$query%' OR location_state LIKE '%$query%' OR location_zip LIKE '%$query%')
+ WHERE (client_name LIKE '%$query%' OR client_type LIKE '%$query%' OR contact_email LIKE '%$query%' OR contact_name LIKE '%$query%' OR contact_phone LIKE '%$phone_query%'
+ OR contact_mobile LIKE '%$phone_query%' OR location_address LIKE '%$query%' OR location_city LIKE '%$query%' OR location_state LIKE '%$query%' OR location_zip LIKE '%$query%')
AND DATE(client_created_at) BETWEEN '$date_from' AND '$date_to'
AND clients.company_id = $session_company_id
ORDER BY $sortby $order LIMIT $record_from, $record_to
diff --git a/global_search.php b/global_search.php
index 0b73e040..259173cf 100644
--- a/global_search.php
+++ b/global_search.php
@@ -6,9 +6,14 @@ if(isset($_GET['query'])){
$query = mysqli_real_escape_string($mysqli,$_GET['query']);
+ $phone_query = preg_replace("/[^0-9]/", '',$query);
+ if(empty($phone_query)){
+ $phone_query = $query;
+ }
+
$sql_clients = mysqli_query($mysqli,"SELECT * FROM clients LEFT JOIN locations ON clients.client_id = locations.location_client_id WHERE client_name LIKE '%$query%' AND clients.company_id = $session_company_id ORDER BY client_id DESC LIMIT 5");
- $sql_contacts = mysqli_query($mysqli,"SELECT * FROM contacts LEFT JOIN clients ON client_id = contact_client_id WHERE contact_name LIKE '%$query%' AND contacts.company_id = $session_company_id ORDER BY contact_id DESC LIMIT 5");
- $sql_vendors = mysqli_query($mysqli,"SELECT * FROM vendors WHERE vendor_name LIKE '%$query%' AND company_id = $session_company_id ORDER BY vendor_id DESC LIMIT 5");
+ $sql_contacts = mysqli_query($mysqli,"SELECT * FROM contacts LEFT JOIN clients ON client_id = contact_client_id LEFT JOIN departments ON contact_department_id = department_id WHERE (contact_name LIKE '%$query%' OR contact_title LIKE '%$query%' OR contact_email LIKE '%$query%' OR contact_phone LIKE '%$phone_query%' OR contact_mobile LIKE '%$phone_query%') AND contacts.company_id = $session_company_id ORDER BY contact_id DESC LIMIT 5");
+ $sql_vendors = mysqli_query($mysqli,"SELECT * FROM vendors WHERE (vendor_name LIKE '%$query%' OR vendor_phone LIKE '%$phone_query%') AND company_id = $session_company_id ORDER BY vendor_id DESC LIMIT 5");
$sql_products = mysqli_query($mysqli,"SELECT * FROM products WHERE product_name LIKE '%$query%' AND company_id = $session_company_id ORDER BY product_id DESC LIMIT 5");
$sql_documents = mysqli_query($mysqli, "SELECT * FROM documents LEFT JOIN clients on document_client_id = clients.client_id WHERE document_name LIKE '%$query%' AND documents.company_id = $session_company_id ORDER BY document_id DESC LIMIT 5");
$sql_tickets = mysqli_query($mysqli, "SELECT * FROM tickets LEFT JOIN clients on tickets.ticket_client_id = clients.client_id WHERE (ticket_subject LIKE '%$query%' OR ticket_number = '$query') AND tickets.company_id = $session_company_id ORDER BY ticket_id DESC LIMIT 5");
@@ -35,7 +40,6 @@ if(isset($_GET['query'])){
@@ -51,7 +55,6 @@ if(isset($_GET['query'])){
?>
Name
- Email
Phone