Do not show Primary Contact or Location in clients listing or client details if Contact or Location was deleted aka archived

This commit is contained in:
johnnyq
2021-09-12 00:08:45 -04:00
parent 2e5e1aee52
commit 55a9e87604
2 changed files with 4 additions and 4 deletions

View File

@@ -82,10 +82,10 @@ if($_GET['canned_date'] == "custom" AND !empty($_GET['date_from'])){
//Rebuild URL
$url_query_strings_sortby = http_build_query(array_merge($_GET,array('sortby' => $sortby, 'order' => $order)));
$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM clients LEFT JOIN contacts ON clients.primary_contact = contacts.contact_id LEFT JOIN locations ON clients.primary_location = locations.location_id
$sql = mysqli_query($mysqli,"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
WHERE (client_name LIKE '%$query%' OR client_type LIKE '%$query%' OR client_support LIKE '%$query%' OR contact_email LIKE '%$query%' OR contact_name LIKE '%$query%' OR contact_phone LIKE '%$query%'
OR contact_mobile LIKE '%$query%' OR location_address LIKE '%$query%' OR location_city LIKE '%$query%' OR location_state LIKE '%$query%' OR location_zip LIKE '%$query%')
AND DATE(client_created_at) BETWEEN '$date_from' AND '$date_to'
AND DATE(client_created_at) BETWEEN '$date_from' AND '$date_to'
AND clients.company_id = $session_company_id $permission_sql
ORDER BY $sortby $order LIMIT $record_from, $record_to"
);