mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 02:44:53 +00:00
Allow searching the main clients list by client tags.
- DB Change: Prefixed columns in client_tags table with client_tags_ - Updated existing SQL references to client_tags.client_id and client_tags.tag_id to new names - clients.php: Added SQL joins/where/groupby logic to allow searching via tags
This commit is contained in:
10
clients.php
10
clients.php
@@ -14,14 +14,20 @@ $sql = mysqli_query(
|
||||
"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
|
||||
LEFT JOIN client_tags on client_tags.client_tags_client_id = clients.client_id
|
||||
LEFT JOIN tags on tags.tag_id = client_tags.client_tags_tag_id
|
||||
WHERE (client_name LIKE '%$q%' OR client_type LIKE '%$q%' OR client_referral LIKE '%$q%' OR contact_email LIKE '%$q%' OR contact_name LIKE '%$q%' OR contact_phone LIKE '%$phone_query%'
|
||||
OR contact_mobile LIKE '%$phone_query%' OR location_address LIKE '%$q%' OR location_city LIKE '%$q%' OR location_state LIKE '%$q%' OR location_zip LIKE '%$q%')
|
||||
OR tag_name LIKE '%$q%'
|
||||
AND client_archived_at IS NULL
|
||||
AND DATE(client_created_at) BETWEEN '$dtf' AND '$dtt'
|
||||
AND clients.company_id = $session_company_id
|
||||
GROUP BY client_id
|
||||
ORDER BY $sb $o LIMIT $record_from, $record_to
|
||||
");
|
||||
|
||||
var_dump(mysqli_error($mysqli));
|
||||
|
||||
$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||
|
||||
?>
|
||||
@@ -128,11 +134,11 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||
$client_updated_at = htmlentities($row['client_updated_at']);
|
||||
$client_archive_at = htmlentities($row['client_archived_at']);
|
||||
|
||||
//Client Tags
|
||||
// Client Tags
|
||||
|
||||
$client_tag_name_display_array = array();
|
||||
$client_tag_id_array = array();
|
||||
$sql_client_tags = mysqli_query($mysqli, "SELECT * FROM client_tags LEFT JOIN tags ON client_tags.tag_id = tags.tag_id WHERE client_tags.client_id = $client_id");
|
||||
$sql_client_tags = mysqli_query($mysqli, "SELECT * FROM client_tags LEFT JOIN tags ON client_tags.client_tags_tag_id = tags.tag_id WHERE client_tags.client_tags_client_id = $client_id");
|
||||
while ($row = mysqli_fetch_array($sql_client_tags)) {
|
||||
|
||||
$client_tag_id = intval($row['tag_id']);
|
||||
|
||||
Reference in New Issue
Block a user