Index: /branches/2.2/workflow/inc/local/classes/class.wf_orgchart.php
===================================================================
--- /branches/2.2/workflow/inc/local/classes/class.wf_orgchart.php	(revision 3167)
+++ /branches/2.2/workflow/inc/local/classes/class.wf_orgchart.php	(revision 3212)
@@ -155,4 +155,37 @@
 		$output = $result->GetArray(-1);
 
+		return $output;
+	}
+	
+	/**
+	 * Searches for all the supervisors of an organization.
+	 *
+	 * This method will search in table areas for all the supervisors and replacement in the organization., todas as áreas que pertencem à organização solicitada.
+	 * @param int $organizationID the ID of the Organization.
+	 * @return array Uma array seqüencial contendo as áreas de uma organização e seus titulares e substitutos. Cada linha do array conterá:
+	 * - area_id
+	 * - titular_funcionario_id: o id do funcionario titular da área. Corresponde ao uidNumber do funcionário no catálogo Ldap.
+	 * - substituto_funcionario_id: o id do funcionario que está substituindo o titular temporariamente
+	 * @access public
+	 */
+	function getOrganizationSupervisors($organizationID) {
+		$query = "  SELECT 
+						a.titular_funcionario_id, 
+						s.funcionario_id as substituto_funcionario_id, 
+						a.area_id
+					FROM 
+						area a 
+						LEFT OUTER JOIN substituicao s 
+						ON ((a.area_id = s.area_id) AND (CURRENT_DATE BETWEEN s.data_inicio AND s.data_fim))
+					WHERE 
+						a.titular_funcionario_id is not null 
+						and a.ativa = 'S' 
+						AND organizacao_id = ?
+					GROUP BY 
+						a.titular_funcionario_id,
+						s.funcionario_id, 
+						a.area_id";
+		$result = $this->db->query($query, array($organizationID));
+		$output = $result->GetArray(-1);
 		return $output;
 	}
Index: /branches/2.2/workflow/inc/class.CachedLDAP.inc.php
===================================================================
--- /branches/2.2/workflow/inc/class.CachedLDAP.inc.php	(revision 3167)
+++ /branches/2.2/workflow/inc/class.CachedLDAP.inc.php	(revision 3212)
@@ -72,4 +72,11 @@
 	*/
 	private $entryAttributes = array('uid', 'cn', 'givenname', 'mail', 'sn', 'accountstatus', 'uidnumber', 'dn', 'employeenumber', 'cpf', 'telephonenumber');
+	
+	/**
+	 * @var array $entryAttributesLDAP Os atributos que serão buscados somente no LDAP. 
+	 * (Alguns campos não são armazenados no banco, e o campo mobile pode ser mais do que um por funcionário)
+	 * @access private
+	 * */
+	private $entryAttributesLDAP = array('mobile','homephone');
 
 	/**
@@ -128,7 +135,11 @@
 		/* load the information and establish the connection */
 		$this->loadLDAP();
-
+		
+		$ldapfields = array();
+	
+		$ldapfields = array_merge($this->entryAttributes,$this->entryAttributesLDAP);
+		
 		/* perform the search */
-		$resourceIdentifier = ldap_search($this->dataSource, $this->userContext, $ldapQuery, $this->entryAttributes);
+		$resourceIdentifier = ldap_search($this->dataSource, $this->userContext, $ldapQuery, $ldapfields);
 		$entries = ldap_get_entries($this->dataSource, $resourceIdentifier);
 
@@ -136,12 +147,15 @@
 		if ($entries['count'] != 1)
 			return false;
+			
+	    //print_r($entries);
 
 		/* format the output */
 		$output = array();
-		foreach ($this->entryAttributes as $attribute)
+		foreach ($ldapfields as $attribute)
 			if ($attribute == 'dn')
 				$output[$attribute] = $entries[0][$attribute];
 			else
-				$output[$attribute] = $entries[0][$attribute][0];
+				$output[$attribute] = $entries[0][$attribute];
+				
 
 		/* insert the timestamp of the last update */
Index: /branches/2.2/workflow/inc/class.so_orgchart.inc.php
===================================================================
--- /branches/2.2/workflow/inc/class.so_orgchart.inc.php	(revision 3167)
+++ /branches/2.2/workflow/inc/class.so_orgchart.inc.php	(revision 3212)
@@ -1102,11 +1102,47 @@
 
 		$cachedLDAP = Factory::newInstance('CachedLDAP');
-
+		$cachedLDAP->setOperationMode($cachedLDAP->OPERATION_MODE_LDAP_DATABASE);
+
+		
 		/* here we need fresh information. Let's access ldap first */
-		$cachedLDAP->setOperationMode($cachedLDAP->OPERATION_MODE_LDAP_DATABASE);
 		$employeeEntry = $cachedLDAP->getEntryByID($employeeID);
-
+		
 		if ($entry === false)
 			return array('error' => 'Funcionário não encontrado.');
+		
+		$employeeInfo 				= $orgchart->getEmployee($employeeID);
+		$employeeStatusInfo 		= $orgchart->getEmployeeStatus($employeeInfo['funcionario_status_id']);
+		$account_id    				= $_SESSION['phpgw_info']['workflow']['account_id'];
+		$organization_supervisors 	= $orgchart->getOrganizationSupervisors($employeeInfo['organizacao_id']);
+		
+		/* 
+		 * Verify the supervisor of the organization
+		 * if the logged user is the supervisor of the selected user
+		 * then will show the mobile and homePhone number.
+		 */ 
+		$arr_supervisores = array();
+		foreach ($organization_supervisors as $supervisor) {
+			array_push($arr_supervisores,$supervisor['titular_funcionario_id']);
+			if ($supervisor['substituto_funcionario_id']) {
+				array_push($arr_supervisores,$supervisor['substituto_funcionario_id']);
+			}
+		}
+		
+		$mobile 	= '';
+		$homePhone  = '';
+		
+		if (in_array($account_id,$arr_supervisores) || ($account_id == $employeeID)) {
+			$mobile 	= $employeeEntry['mobile'];
+			$homePhone 	= $employeeEntry['homephone'];
+		} 
+		
+		$outputInfo[] = array(
+			'name' => 'Mobile',
+			'value' => ( ! empty( $mobile ) ? $mobile : '' ) );
+			
+		$outputInfo[] = array(
+			'name' => 'homePhone',
+			'value' => ( ! empty( $homePhone ) ? $homePhone : '' ) );
+
 
 		$outputInfo[] = array(
@@ -1129,6 +1165,5 @@
 			'value' => $employeeID);
 
-		$employeeInfo = $orgchart->getEmployee($employeeID);
-		$employeeStatusInfo = $orgchart->getEmployeeStatus($employeeInfo['funcionario_status_id']);
+		
 
 		$outputInfo[] = array(
Index: /branches/2.2/workflow/js/userinterface/orgchart.js
===================================================================
--- /branches/2.2/workflow/js/userinterface/orgchart.js	(revision 3167)
+++ /branches/2.2/workflow/js/userinterface/orgchart.js	(revision 3212)
@@ -673,4 +673,31 @@
 			card.appendChild( phone );
 		}
+		
+		var mobiles = card_data[ 'Mobile' ];
+		//var arr_mobiles = mobiles.split(',');
+		
+		for (var mob = 0; mob < mobiles.length; mob++) {
+			if ( card_data[ 'Mobile' ] ) {
+				card.appendChild( document.createElement( 'br' ) );
+				var phone = document.createElement('span');
+				phone.appendChild( document.createTextNode( mobiles[mob] ) );
+				phone.style.paddingLeft = '20px';
+				phone.style.whiteSpace = 'nowrap';
+				phone.style.background = 'url(templateFile.php?file=images/mobile.png) no-repeat 0 0';
+				card.appendChild( phone );
+			}
+		}
+
+		
+		if ( card_data[ 'homePhone' ] )	{
+			card.appendChild( document.createElement( 'br' ) );
+			var phone = document.createElement( ( workflowUserInterfaceClickToCall ) ? 'a' : 'span' );
+			phone.appendChild( document.createTextNode( card_data[ 'homePhone' ] ) );
+			phone.style.paddingLeft = '20px';
+			phone.style.whiteSpace = 'nowrap';
+			phone.style.background = 'url(templateFile.php?file=images/homePhone.png) no-repeat 0 0';
+
+			card.appendChild( phone );
+		}
 
 		card.appendChild( document.createElement( 'br' ) );
