From 0eaab4e60ab129720271dec4c4bf1b1d69b5eb0b Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Sun, 6 Nov 2022 00:08:36 -0600 Subject: [PATCH] Add contact relation search --- app/contacts/contact_relation_edit.php | 93 ++++++++++++++++++-------- 1 file changed, 66 insertions(+), 27 deletions(-) diff --git a/app/contacts/contact_relation_edit.php b/app/contacts/contact_relation_edit.php index d7010dbb48..6f6f4f1706 100644 --- a/app/contacts/contact_relation_edit.php +++ b/app/contacts/contact_relation_edit.php @@ -187,6 +187,30 @@ unset($sql, $parameters, $row); } +//get contact details and contact_name + $sql = "select contact_uuid, contact_organization, contact_name_given, contact_name_family, contact_nickname "; + $sql .= "from v_contacts "; + $sql .= "where domain_uuid = :domain_uuid "; + $sql .= "and contact_uuid <> :contact_uuid "; + $sql .= "order by contact_organization desc, contact_name_given asc, contact_name_family asc "; + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['contact_uuid'] = $contact_relation_uuid; + $database = new database; + $contacts = $database->select($sql, $parameters, 'all'); + if (is_array($contacts) && is_uuid($row['relation_contact_uuid'])) { + foreach($contacts as $field) { + if ($field['contact_uuid'] == $row['relation_contact_uuid']) { + $name = array(); + if ($field['contact_organization'] != '') { $name[] = $field['contact_organization']; } + if ($field['contact_name_family'] != '') { $name[] = $field['contact_name_family']; } + if ($field['contact_name_given'] != '') { $name[] = $field['contact_name_given']; } + if ($field['contact_name_family'] == '' && $field['contact_name_given'] == '' && $field['contact_nickname'] != '') { $name[] = $field['contact_nickname']; } + $contact_name = implode(', ', $name); + break; + } + } + } + //create token $object = new token; $token = $object->create($_SERVER['PHP_SELF']); @@ -195,6 +219,43 @@ $document['title'] = $text['title-contact_relation']; require_once "resources/header.php"; +?> + + + +"; echo " function toggle_custom(field) {"; @@ -261,32 +322,10 @@ echo " ".$text['label-contact_relation_contact']."\n"; echo "\n"; echo "\n"; - $sql = "select contact_uuid, contact_organization, contact_name_given, contact_name_family from v_contacts "; - $sql .= "where domain_uuid = :domain_uuid "; - $sql .= "and contact_uuid <> :contact_uuid "; - $sql .= "order by contact_organization desc, contact_name_given asc, contact_name_family asc "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; - $parameters['contact_uuid'] = $contact_uuid; - $database = new database; - $result = $database->select($sql, $parameters, 'all'); - echo "\n"; + echo " \n"; + echo " \n"; echo "\n"; echo "\n"; @@ -342,4 +381,4 @@ //include the footer require_once "resources/footer.php"; -?> \ No newline at end of file +?>