= 2; $can_delete = lookupUserPermission('module_client') >= 3 && !empty($config_destructive_deletes_enable); $can_support = lookupUserPermission('module_support') >= 1; $client = ''; if (!$client_url) { // Client Filter if (!empty($_GET['client'])) { $client = intval($_GET['client']); $client_query = "AND location_client_id = $client"; } } // Tags Filter - a location with any of them if (isset($_GET['tags']) && is_array($_GET['tags']) && !empty($_GET['tags'])) { $tag_filter = implode(",", array_map('intval', $_GET['tags'])); $tag_query = "AND locations.location_id IN (SELECT location_id FROM location_tags WHERE tag_id IN ($tag_filter))"; } else { $tag_filter = 0; $tag_query = ''; } // Only these sort - filter_header.php will hand through any lowercase word, and // an unknown column takes the page down with a mysqli exception $sortable_columns = ['location_name', 'location_address', 'location_city', 'location_phone', 'location_hours', 'contact_name', 'client_name', 'location_created_at']; if (!in_array($sort, $sortable_columns, true)) { $sort = 'location_name'; } $sql = mysqli_query( $mysqli, "SELECT SQL_CALC_FOUND_ROWS locations.location_id, location_name, location_description, location_address, location_city, location_state, location_zip, location_country, location_phone, location_phone_country_code, location_phone_extension, location_fax, location_fax_country_code, location_hours, location_photo, location_primary, location_archived_at, location_client_id, location_contact_id, client_id, client_name, contact_name, contact_photo, contact_title, contact_archived_at FROM locations LEFT JOIN clients ON client_id = location_client_id LEFT JOIN contacts ON contact_id = location_contact_id AND contact_client_id = location_client_id WHERE $archive_query $tag_query AND (location_name LIKE '%$q%' OR location_description LIKE '%$q%' OR location_address LIKE '%$q%' OR location_city LIKE '%$q%' OR location_state LIKE '%$q%' OR location_zip LIKE '%$q%' OR location_country LIKE '%$q%' OR location_phone LIKE '%$phone_query%' OR location_notes LIKE '%$q%' OR contact_name LIKE '%$q%' OR client_name LIKE '%$q%' OR locations.location_id IN (SELECT location_id FROM location_tags JOIN tags USING (tag_id) WHERE tag_name LIKE '%$q%')) " . clientScopeSql('location_client_id') . " $client_query ORDER BY location_primary DESC, $sort $order, location_name ASC LIMIT $record_from, $record_to" ); $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); $locations = []; while ($row = mysqli_fetch_assoc($sql)) { $locations[intval($row['location_id'])] = $row; } // Tags and what is on site for the whole page at once, not per row $locations_tags = tagsForRecords('location', array_keys($locations)); $locations_counts = locationCounts(array_keys($locations)); ?>

Locations

Archived
text-nowrap table-light"> $row) { $client_id = intval($row['client_id']); $client_name = escapeHtml($row['client_name']); $location_name = escapeHtml($row['location_name']); $location_description = escapeHtml($row['location_description']); $location_street = escapeHtml($row['location_address']); $location_place = escapeHtml(formatAddress('', $row['location_city'], $row['location_state'], $row['location_zip'], $row['location_country'], ', ')); $location_address_text = locationAddressText($row, true); $location_map_url = locationMapUrl($row); $location_directions_url = locationDirectionsUrl($row); $location_phone = contactPhoneLink($row['location_phone'], $row['location_phone_country_code'], $row['location_phone_extension']); $location_hours = escapeHtml($row['location_hours']); $location_primary = intval($row['location_primary']); $location_archived_at = escapeHtml($row['location_archived_at']); $location_tags = $locations_tags[$location_id] ?? []; $counts = $locations_counts[$location_id]; $location_url = "location.php?client_id=$client_id&location_id=$location_id"; ?>
Location Address Phone & hours Ask for On site Client
Primary Archived
-
-
!empty($row['contact_archived_at'])]) ?> -
Nothing yet
'locations', 'icon' => 'fa-map-marker-alt', 'filtered' => $q || $tag_query, 'text' => 'Their offices and sites, with the address and phone of each.', 'actions' => $can_edit ? array_merge( [['label' => 'New Location', 'modal' => "modals/location/location_add.php?$client_url", 'size' => 'lg']], $client_url ? [['label' => 'Import', 'modal' => "modals/location/location_import.php?$client_url", 'icon' => 'fa-upload']] : [] ) : [], ]; require_once "../includes/filter_footer.php"; ?>