mirror of https://github.com/itflow-org/itflow
Merge pull request #565 from wrongecho/ticket-global-search
Add functionality to perform global searches via full ticket number
This commit is contained in:
commit
b8ee87a139
|
|
@ -4,19 +4,21 @@
|
||||||
|
|
||||||
if(isset($_GET['query'])){
|
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);
|
$phone_query = preg_replace("/[^0-9]/", '',$query);
|
||||||
if(empty($phone_query)){
|
if(empty($phone_query)){
|
||||||
$phone_query = $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_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_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_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_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_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");
|
$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']);
|
$q = htmlentities($_GET['query']);
|
||||||
|
|
@ -266,6 +268,7 @@ if(isset($_GET['query'])){
|
||||||
<table class="table table-striped table-borderless">
|
<table class="table table-striped table-borderless">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>Ticket ID</th>
|
||||||
<th>Description</th>
|
<th>Description</th>
|
||||||
<th>Client</th>
|
<th>Client</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
|
|
@ -276,13 +279,16 @@ if(isset($_GET['query'])){
|
||||||
|
|
||||||
while($row = mysqli_fetch_array($sql_tickets)){
|
while($row = mysqli_fetch_array($sql_tickets)){
|
||||||
$ticket_id = $row['ticket_id'];
|
$ticket_id = $row['ticket_id'];
|
||||||
|
$ticket_prefix = $row['ticket_prefix'];
|
||||||
|
$ticket_number = $row['ticket_number'];
|
||||||
$ticket_subject = htmlentities($row['ticket_subject']);
|
$ticket_subject = htmlentities($row['ticket_subject']);
|
||||||
$ticket_client = htmlentities($row['client_name']);
|
$ticket_client = htmlentities($row['client_name']);
|
||||||
$ticket_status = htmlentities($row['ticket_status']);
|
$ticket_status = htmlentities($row['ticket_status']);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="ticket.php?ticket_id=<?php echo $ticket_id ?>"><?php echo $ticket_subject; ?></a></td>
|
<td><a href="ticket.php?ticket_id=<?php echo $ticket_id ?>"><?php echo $ticket_prefix . $ticket_number; ?></a></td>
|
||||||
|
<td><?php echo $ticket_subject; ?></td>
|
||||||
<td><?php echo $ticket_client; ?></td>
|
<td><?php echo $ticket_client; ?></td>
|
||||||
<td><?php echo $ticket_status; ?></td>
|
<td><?php echo $ticket_status; ?></td>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue