Browse Source

User Edit: Only list Contacts not already assigned to a User. Contact Edit: Display button to User the Contact is assigned to (if any).

Nate 6 years ago
parent
commit
0d061e28b6
1 changed files with 7 additions and 3 deletions
  1. 7 3
      core/users/user_edit.php

+ 7 - 3
core/users/user_edit.php

@@ -730,9 +730,13 @@
 		echo "	<tr>";
 		echo "	<tr>";
 		echo "		<td class='vncell' valign='top'>".$text['label-contact']."</td>";
 		echo "		<td class='vncell' valign='top'>".$text['label-contact']."</td>";
 		echo "		<td class='vtable'>\n";
 		echo "		<td class='vtable'>\n";
-		$sql = " select contact_uuid, contact_organization, contact_name_given, contact_name_family, contact_nickname from v_contacts ";
-		$sql .= " where domain_uuid = '".escape($domain_uuid)."' ";
-		$sql .= " order by contact_organization desc, contact_name_family asc, contact_name_given asc, contact_nickname asc ";
+		$sql = "select contact_uuid, contact_organization, contact_name_given, contact_name_family, contact_nickname from v_contacts ";
+		$sql .= "where domain_uuid = '".escape($domain_uuid)."' ";
+		$sql .= "and ( ";
+		$sql .= "	contact_uuid = '".escape($contact_uuid)."' or ";
+		$sql .= "	contact_uuid not in (select contact_uuid from v_users where domain_uuid = '".escape($domain_uuid)."') ";
+		$sql .= ") ";
+		$sql .= "order by contact_organization desc, contact_name_family asc, contact_name_given asc, contact_nickname asc ";
 		$prep_statement = $db->prepare(check_sql($sql));
 		$prep_statement = $db->prepare(check_sql($sql));
 		$prep_statement->execute();
 		$prep_statement->execute();
 		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
 		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);