Changeset 1266 for trunk/workflow/inc


Ignore:
Timestamp:
08/04/09 11:51:39 (15 years ago)
Author:
rodsouza
Message:

Ticket #589 - Adicionando filtro por localidade.

Location:
trunk/workflow/inc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/workflow/inc/class.bo_userinterface.inc.php

    r1245 r1266  
    10061006                return $this -> so -> getAreaWithSubtituteBoss( $this -> organizationInfo[ 'organizacao_id' ] ); 
    10071007        } 
     1008 
     1009        /** 
     1010         * Retorna a lista de localidades 
     1011         * @return array lista de localidades 
     1012         * @access public 
     1013         */ 
     1014        function getManning( ) 
     1015        { 
     1016                /* check for access */ 
     1017                if ( ( $checkWarnings = $this->checkOrgchartAccess( ) ) !== true ) 
     1018                        return $checkWarnings; 
     1019 
     1020                return $this -> so -> getManning( $this -> organizationInfo[ 'organizacao_id' ] ); 
     1021        } 
     1022 
     1023        /** 
     1024         * Return the employees of a manning 
     1025         * @param $params parameters 
     1026         * @access public 
     1027         * @return array array of employees 
     1028         */ 
     1029        function getManningEmployees( $params ) 
     1030        { 
     1031                /* check for access */ 
     1032                if ( ( $checkWarnings = $this -> checkOrgchartAccess( ) ) !== true ) 
     1033                        return $checkWarnings; 
     1034 
     1035                $employees = $this -> so -> getManningEmployees( ( int ) $params[ 'locationID' ], $this -> organizationInfo[ 'organizacao_id' ] ); 
     1036 
     1037                if ( $employees === false ) 
     1038                        return array( 'error' => 'Localidade não encontrada.' ); 
     1039 
     1040                //usort( $employees['employees'], create_function( '$a,$b', 'return strcasecmp($a[\'cn\'],$b[\'cn\']);' ) ); 
     1041 
     1042                return $employees; 
     1043        } 
    10081044} 
    10091045?> 
  • trunk/workflow/inc/class.so_userinterface.inc.php

    r1245 r1266  
    475475                return $output; 
    476476        } 
     477 
     478        /** 
     479         * Get manning list 
     480         * @param int $organizationID The organization ID 
     481         * @return array The manning list 
     482         * @access public 
     483         */ 
     484        function getManning( $organizationID ) 
     485        { 
     486                $result = $this -> db -> query( 'SELECT localidade_id, descricao FROM localidade WHERE (organizacao_id = ?) ORDER BY descricao', array( $organizationID ) ); 
     487 
     488                $output = $result->GetArray( -1 ); 
     489                for ( $i = 0; $i < count($output); $i++ ) 
     490                        for ($j = 0; $j < $result->_numOfFields; $j++) 
     491                                unset($output[$i][$j]); 
     492 
     493                return $output; 
     494        } 
     495 
     496        /** 
     497         * Get employees from a specific location 
     498         * @param int $categoryID The category ID 
     499         * @param int $organizationID The organization ID 
     500         * @return array The list o employees of that location 
     501         * @access public 
     502         */ 
     503        function getManningEmployees( $locationID, $organizationID ) 
     504        { 
     505                $organizationID = ( int ) $organizationID; 
     506                $locationID = ( int ) $locationID; 
     507 
     508                // load the employees from the location 
     509                $query = "SELECT f.funcionario_id, f.organizacao_id, f.area_id, a.sigla AS area," 
     510                        . " COALESCE(f.funcionario_categoria_id, 0) AS funcionario_categoria_id" 
     511                        . " FROM funcionario f, funcionario_status s, area a" 
     512                        . " WHERE (f.area_id = a.area_id)" 
     513                        . " AND (f.funcionario_status_id = s.funcionario_status_id)" 
     514                        . " AND (f.localidade_id = ?)" 
     515                        . " AND (s.exibir = ?)"; 
     516 
     517                $result = $this -> db -> query( $query, array( $locationID, 'S' ) ); 
     518 
     519                $employees = $result -> GetArray( -1 ); 
     520                $cachedLDAP = $GLOBALS[ 'workflow' ][ 'factory' ] -> newInstance( 'CachedLDAP' ); 
     521                $cachedLDAP -> setOperationMode( $cachedLDAP -> OPERATION_MODE_LDAP_DATABASE ); 
     522 
     523                $categoriesCount = array( ); 
     524                for ( $i = 0; $i < count( $employees ); $i++ ) 
     525                { 
     526                        // remove numeric fields 
     527                        for ( $j = 0; $j < $result -> _numOfFields; $j++ ) 
     528                                unset( $employees[ $i ][ $j ] ); 
     529 
     530                        $employees[ $i ][ 'cn' ] = ''; 
     531                        $employees[ $i ][ 'telephoneNumber' ] = ''; 
     532 
     533                        // try to find the telephone number 
     534                        $entry = $cachedLDAP -> getEntryByID( $employees[ $i ][ 'funcionario_id' ] ); 
     535                        if ( $entry ) 
     536                        { 
     537                                $employees[ $i ][ 'telephoneNumber' ] = is_null( $entry[ 'telephonenumber' ] ) ? '' : $entry[ 'telephonenumber' ]; 
     538                                $employees[ $i ][ 'cn' ] = is_null( $entry[ 'cn' ] ) ? '' : $entry[ 'cn' ]; 
     539                                $employees[ $i ][ 'removed' ] = is_null( $entry[ 'last_update' ] ); 
     540                        } 
     541 
     542                        // count the number of employees in each category 
     543                        $categoryID = $employees[ $i ][ 'funcionario_categoria_id' ]; 
     544                        if ( isset( $categoriesCount[ $categoryID ] ) ) 
     545                                $categoriesCount[ $categoryID ]++; 
     546                        else 
     547                                $categoriesCount[ $categoryID ] = 1; 
     548                } 
     549 
     550                $usedCategories = array_keys( $categoriesCount ); 
     551                $availableCategories = $this -> getCategoriesList( $organizationID ); 
     552                $output = array( ); 
     553                $output[ 'employees' ] = $employees; 
     554                $output[ 'categories' ] = array( ); 
     555                foreach ( $availableCategories as $category ) 
     556                { 
     557                        if ( ! in_array( $category[ 'funcionario_categoria_id' ], $usedCategories ) ) 
     558                                continue; 
     559 
     560                        $category[ 'contagem' ] = $categoriesCount[ $category[ 'funcionario_categoria_id' ] ]; 
     561                        $output[ 'categories' ][ ] = $category; 
     562                } 
     563 
     564                usort( $output[ 'employees' ], create_function( '$a,$b', 'return strcasecmp($a[\'cn\'],$b[\'cn\']);' ) ); 
     565 
     566                return $output; 
     567        } 
    477568} 
    478569?> 
Note: See TracChangeset for help on using the changeset viewer.