diff --git a/global_search.php b/global_search.php index 22ee2b5c..2d294143 100644 --- a/global_search.php +++ b/global_search.php @@ -4,19 +4,21 @@ if(isset($_GET['query'])){ - $query = strip_tags(mysqli_real_escape_string($mysqli,$_GET['query'])); + $query = trim(strip_tags(mysqli_real_escape_string($mysqli,$_GET['query']))); $phone_query = preg_replace("/[^0-9]/", '',$query); if(empty($phone_query)){ $phone_query = $query; } + $ticket_num_query = str_replace("$config_ticket_prefix", "", "$query"); + $sql_clients = mysqli_query($mysqli,"SELECT * FROM clients LEFT JOIN locations ON clients.primary_location = locations.location_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%' 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 MATCH(document_content_raw) AGAINST ('$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"); + $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 = '$ticket_num_query') AND tickets.company_id = $session_company_id ORDER BY ticket_id DESC LIMIT 5"); $sql_logins = mysqli_query($mysqli,"SELECT * FROM logins WHERE (login_name LIKE '%$query%' OR login_username LIKE '%$query%') AND company_id = $session_company_id ORDER BY login_id DESC LIMIT 5"); $q = htmlentities($_GET['query']); @@ -25,325 +27,329 @@ if(isset($_GET['query'])){

Search all things


- - 0){ ?> - + 0){ ?> -
-
-
-
Clients
+ + +
+
+
+
Clients
+
+
+ + + + + + + + + + + + + + + + + +
NamePhone
+
+
-
- - - - - - - - - - - - - - - - - -
NamePhone
-
-
-
- 0){ ?> + 0){ ?> - + -
-
-
-
Contacts
+
+
+
+
Contacts
+
+
+ + + + + + + + + + + + + + + + + + + + + +
NameEmailPhoneCell
+
+
+
+
-
- - - - - - - - - - - - - - - - - - - - - -
NameEmailPhoneCell
-
-
-
-
-
0){ ?> - -
-
-
-
Vendors
+ +
+
+
+
Vendors
+
+
+ + + + + + + + + + + + + + + + + + + +
NameDescriptionPhone
+
+
-
- - - - - - - - - - - - - - - - - - - -
NameDescriptionPhone
-
-
-
0){ ?> - -
-
-
-
Products
-
-
- - - - - - - - - + +
+
+
+
Products
+
+
+
NameDescription
+ - - + + - + + - -
NameDescription
+ while($row = mysqli_fetch_array($sql_products)){ + $product_name = htmlentities($row['product_name']); + $product_description = htmlentities($row['product_description']); + ?> + + + + + + + + + +
-
0){ ?> - -
-
-
-
Documents
-
-
- - - - - - - - - - + +
+
+
+
Documents
+
+
+
DocumentClientUpdated
+ - - - + + + - + + - -
DocumentClientUpdated
+ while($row = mysqli_fetch_array($sql_documents)){ + $document_name = htmlentities($row['document_name']); + $document_client_id = $row['document_client_id']; + $document_client = htmlentities($row['client_name']); + $document_updated = $row['document_updated_at']; + + ?> + + + + + + + + + + +
-
0){ ?> - -
-
-
-
Tickets
-
-
- - - - - - - - - - + +
+
+
+
Tickets
+
+
+
DescriptionClientStatus
+ - - - - + + + + - + + - -
Ticket IDDescriptionClientStatus
+ while($row = mysqli_fetch_array($sql_tickets)){ + $ticket_id = $row['ticket_id']; + $ticket_prefix = $row['ticket_prefix']; + $ticket_number = $row['ticket_number']; + $ticket_subject = htmlentities($row['ticket_subject']); + $ticket_client = htmlentities($row['client_name']); + $ticket_status = htmlentities($row['ticket_status']); + + ?> + + + + + + + + + + + + +
-
0){ ?> - -
-
-
-
Logins
-
-
- - - - - - - - - - + +
+
+
+
Logins
+
+
+
DescriptionUsernamePassword
+ - - - - - + + + - + + - -
DescriptionUsernamePassword
+ while($row = mysqli_fetch_array($sql_logins)){ + $login_name = htmlentities($row['login_name']); + $login_client_id = $row['login_client_id']; + $login_username = htmlentities($row['login_username']); + $login_password = htmlentities(decryptLoginEntry($row['login_password'])); + + ?> + + + + + + + + + + + + +
-