mirror of
https://github.com/itflow-org/itflow
synced 2026-03-01 03:14:52 +00:00
Only show locations if an entity references the locations. Previously, all locations were listed in the location filter, even if no entites were assigned to them.
This commit is contained in:
10
contacts.php
10
contacts.php
@@ -146,7 +146,15 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||
<option value="">- All Locations -</option>
|
||||
|
||||
<?php
|
||||
$sql_locations_filter = mysqli_query($mysqli, "SELECT * FROM locations WHERE location_client_id = $client_id AND location_archived_at IS NULL ORDER BY location_name ASC");
|
||||
$sql_locations_filter = mysqli_query($mysqli, "
|
||||
SELECT DISTINCT location_id, location_name
|
||||
FROM locations
|
||||
LEFT JOIN contacts ON contact_location_id = location_id
|
||||
WHERE location_client_id = $client_id
|
||||
AND location_archived_at IS NULL
|
||||
AND contact_location_id != 0
|
||||
ORDER BY location_name ASC
|
||||
");
|
||||
while ($row = mysqli_fetch_array($sql_locations_filter)) {
|
||||
$location_id = intval($row['location_id']);
|
||||
$location_name = nullable_htmlentities($row['location_name']);
|
||||
|
||||
Reference in New Issue
Block a user