From 49a9a5d145eca4e302a0928da9f497b40f02b580 Mon Sep 17 00:00:00 2001
From: Peter Rotich <peter@osticket.com>
Date: Wed, 23 Apr 2014 13:51:32 +0000
Subject: [PATCH] Show account manager on org profile

---
 include/class.organization.php | 5 ++++-
 include/class.team.php         | 6 +++++-
 include/class.user.php         | 2 +-
 include/staff/org-view.inc.php | 2 +-
 4 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/include/class.organization.php b/include/class.organization.php
index e1e3f4435..3801bba3a 100644
--- a/include/class.organization.php
+++ b/include/class.organization.php
@@ -46,9 +46,12 @@ class OrganizationModel extends VerySimpleModel {
         if (!isset($this->_manager)) {
             if ($this->manager[0] == 't')
                 $this->_manager = Team::lookup(substr($this->manager, 1));
-            if ($this->manager[0] == 's')
+            elseif ($this->manager[0] == 's')
                 $this->_manager = Staff::lookup(substr($this->manager, 1));
+            else
+                $this->_manager = ''; // None.
         }
+
         return $this->_manager;
     }
 
diff --git a/include/class.team.php b/include/class.team.php
index 8d1c22bb0..2d79a987f 100644
--- a/include/class.team.php
+++ b/include/class.team.php
@@ -52,7 +52,11 @@ class Team {
     }
 
     function asVar() {
-        return $this->getName();
+        return $this->__toString();
+    }
+
+    function __toString() {
+        return (string) $this->getName();
     }
 
     function getId() {
diff --git a/include/class.user.php b/include/class.user.php
index 083368fc6..89a35ab46 100644
--- a/include/class.user.php
+++ b/include/class.user.php
@@ -643,7 +643,7 @@ class PersonsName {
         $format = $cfg ? $cfg->getDefaultNameFormat() : 'original';
         list(,$func) = static::$formats[$format];
         if (!$func) $func = 'getFull';
-        return call_user_func(array($this, $func));
+        return (string) call_user_func(array($this, $func));
     }
 
     static function allFormats() {
diff --git a/include/staff/org-view.inc.php b/include/staff/org-view.inc.php
index 7f6403765..970acab91 100644
--- a/include/staff/org-view.inc.php
+++ b/include/staff/org-view.inc.php
@@ -28,7 +28,7 @@ if(!defined('OSTSCPINC') || !$thisstaff || !is_object($org)) die('Invalid path')
                 </tr>
                 <tr>
                     <th>Account Manager:</th>
-                    <td>&nbsp; </td>
+                    <td><?php echo $org->getAccountManager(); ?>&nbsp;</td>
                 </tr>
             </table>
         </td>
-- 
GitLab