Changeset 3212


Ignore:
Timestamp:
09/02/10 16:04:25 (14 years ago)
Author:
pereira.jair
Message:

Ticket #1186 - Organograma - Adicionado mobile e homePhone no cartão do funcionario

Location:
branches/2.2/workflow
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/workflow/inc/class.CachedLDAP.inc.php

    r3167 r3212  
    7272        */ 
    7373        private $entryAttributes = array('uid', 'cn', 'givenname', 'mail', 'sn', 'accountstatus', 'uidnumber', 'dn', 'employeenumber', 'cpf', 'telephonenumber'); 
     74         
     75        /** 
     76         * @var array $entryAttributesLDAP Os atributos que serão buscados somente no LDAP.  
     77         * (Alguns campos não são armazenados no banco, e o campo mobile pode ser mais do que um por funcionário) 
     78         * @access private 
     79         * */ 
     80        private $entryAttributesLDAP = array('mobile','homephone'); 
    7481 
    7582        /** 
     
    128135                /* load the information and establish the connection */ 
    129136                $this->loadLDAP(); 
    130  
     137                 
     138                $ldapfields = array(); 
     139         
     140                $ldapfields = array_merge($this->entryAttributes,$this->entryAttributesLDAP); 
     141                 
    131142                /* perform the search */ 
    132                 $resourceIdentifier = ldap_search($this->dataSource, $this->userContext, $ldapQuery, $this->entryAttributes); 
     143                $resourceIdentifier = ldap_search($this->dataSource, $this->userContext, $ldapQuery, $ldapfields); 
    133144                $entries = ldap_get_entries($this->dataSource, $resourceIdentifier); 
    134145 
     
    136147                if ($entries['count'] != 1) 
    137148                        return false; 
     149                         
     150            //print_r($entries); 
    138151 
    139152                /* format the output */ 
    140153                $output = array(); 
    141                 foreach ($this->entryAttributes as $attribute) 
     154                foreach ($ldapfields as $attribute) 
    142155                        if ($attribute == 'dn') 
    143156                                $output[$attribute] = $entries[0][$attribute]; 
    144157                        else 
    145                                 $output[$attribute] = $entries[0][$attribute][0]; 
     158                                $output[$attribute] = $entries[0][$attribute]; 
     159                                 
    146160 
    147161                /* insert the timestamp of the last update */ 
  • branches/2.2/workflow/inc/class.so_orgchart.inc.php

    r3167 r3212  
    11021102 
    11031103                $cachedLDAP = Factory::newInstance('CachedLDAP'); 
    1104  
     1104                $cachedLDAP->setOperationMode($cachedLDAP->OPERATION_MODE_LDAP_DATABASE); 
     1105 
     1106                 
    11051107                /* here we need fresh information. Let's access ldap first */ 
    1106                 $cachedLDAP->setOperationMode($cachedLDAP->OPERATION_MODE_LDAP_DATABASE); 
    11071108                $employeeEntry = $cachedLDAP->getEntryByID($employeeID); 
    1108  
     1109                 
    11091110                if ($entry === false) 
    11101111                        return array('error' => 'Funcionário não encontrado.'); 
     1112                 
     1113                $employeeInfo                           = $orgchart->getEmployee($employeeID); 
     1114                $employeeStatusInfo             = $orgchart->getEmployeeStatus($employeeInfo['funcionario_status_id']); 
     1115                $account_id                             = $_SESSION['phpgw_info']['workflow']['account_id']; 
     1116                $organization_supervisors       = $orgchart->getOrganizationSupervisors($employeeInfo['organizacao_id']); 
     1117                 
     1118                /*  
     1119                 * Verify the supervisor of the organization 
     1120                 * if the logged user is the supervisor of the selected user 
     1121                 * then will show the mobile and homePhone number. 
     1122                 */  
     1123                $arr_supervisores = array(); 
     1124                foreach ($organization_supervisors as $supervisor) { 
     1125                        array_push($arr_supervisores,$supervisor['titular_funcionario_id']); 
     1126                        if ($supervisor['substituto_funcionario_id']) { 
     1127                                array_push($arr_supervisores,$supervisor['substituto_funcionario_id']); 
     1128                        } 
     1129                } 
     1130                 
     1131                $mobile         = ''; 
     1132                $homePhone  = ''; 
     1133                 
     1134                if (in_array($account_id,$arr_supervisores) || ($account_id == $employeeID)) { 
     1135                        $mobile         = $employeeEntry['mobile']; 
     1136                        $homePhone      = $employeeEntry['homephone']; 
     1137                }  
     1138                 
     1139                $outputInfo[] = array( 
     1140                        'name' => 'Mobile', 
     1141                        'value' => ( ! empty( $mobile ) ? $mobile : '' ) ); 
     1142                         
     1143                $outputInfo[] = array( 
     1144                        'name' => 'homePhone', 
     1145                        'value' => ( ! empty( $homePhone ) ? $homePhone : '' ) ); 
     1146 
    11111147 
    11121148                $outputInfo[] = array( 
     
    11291165                        'value' => $employeeID); 
    11301166 
    1131                 $employeeInfo = $orgchart->getEmployee($employeeID); 
    1132                 $employeeStatusInfo = $orgchart->getEmployeeStatus($employeeInfo['funcionario_status_id']); 
     1167                 
    11331168 
    11341169                $outputInfo[] = array( 
  • branches/2.2/workflow/inc/local/classes/class.wf_orgchart.php

    r3167 r3212  
    155155                $output = $result->GetArray(-1); 
    156156 
     157                return $output; 
     158        } 
     159         
     160        /** 
     161         * Searches for all the supervisors of an organization. 
     162         * 
     163         * This method will search in table areas for all the supervisors and replacement in the organization., todas as áreas que pertencem à organização solicitada. 
     164         * @param int $organizationID the ID of the Organization. 
     165         * @return array Uma array seqüencial contendo as áreas de uma organização e seus titulares e substitutos. Cada linha do array conterá: 
     166         * - area_id 
     167         * - titular_funcionario_id: o id do funcionario titular da área. Corresponde ao uidNumber do funcionário no catálogo Ldap. 
     168         * - substituto_funcionario_id: o id do funcionario que está substituindo o titular temporariamente 
     169         * @access public 
     170         */ 
     171        function getOrganizationSupervisors($organizationID) { 
     172                $query = "  SELECT  
     173                                                a.titular_funcionario_id,  
     174                                                s.funcionario_id as substituto_funcionario_id,  
     175                                                a.area_id 
     176                                        FROM  
     177                                                area a  
     178                                                LEFT OUTER JOIN substituicao s  
     179                                                ON ((a.area_id = s.area_id) AND (CURRENT_DATE BETWEEN s.data_inicio AND s.data_fim)) 
     180                                        WHERE  
     181                                                a.titular_funcionario_id is not null  
     182                                                and a.ativa = 'S'  
     183                                                AND organizacao_id = ? 
     184                                        GROUP BY  
     185                                                a.titular_funcionario_id, 
     186                                                s.funcionario_id,  
     187                                                a.area_id"; 
     188                $result = $this->db->query($query, array($organizationID)); 
     189                $output = $result->GetArray(-1); 
    157190                return $output; 
    158191        } 
  • branches/2.2/workflow/js/userinterface/orgchart.js

    r3167 r3212  
    673673                        card.appendChild( phone ); 
    674674                } 
     675                 
     676                var mobiles = card_data[ 'Mobile' ]; 
     677                //var arr_mobiles = mobiles.split(','); 
     678                 
     679                for (var mob = 0; mob < mobiles.length; mob++) { 
     680                        if ( card_data[ 'Mobile' ] ) { 
     681                                card.appendChild( document.createElement( 'br' ) ); 
     682                                var phone = document.createElement('span'); 
     683                                phone.appendChild( document.createTextNode( mobiles[mob] ) ); 
     684                                phone.style.paddingLeft = '20px'; 
     685                                phone.style.whiteSpace = 'nowrap'; 
     686                                phone.style.background = 'url(templateFile.php?file=images/mobile.png) no-repeat 0 0'; 
     687                                card.appendChild( phone ); 
     688                        } 
     689                } 
     690 
     691                 
     692                if ( card_data[ 'homePhone' ] ) { 
     693                        card.appendChild( document.createElement( 'br' ) ); 
     694                        var phone = document.createElement( ( workflowUserInterfaceClickToCall ) ? 'a' : 'span' ); 
     695                        phone.appendChild( document.createTextNode( card_data[ 'homePhone' ] ) ); 
     696                        phone.style.paddingLeft = '20px'; 
     697                        phone.style.whiteSpace = 'nowrap'; 
     698                        phone.style.background = 'url(templateFile.php?file=images/homePhone.png) no-repeat 0 0'; 
     699 
     700                        card.appendChild( phone ); 
     701                } 
    675702 
    676703                card.appendChild( document.createElement( 'br' ) ); 
Note: See TracChangeset for help on using the changeset viewer.