Changeset 1269 for trunk/workflow/inc/class.so_userinterface.inc.php
- Timestamp:
- 08/04/09 14:42:23 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/workflow/inc/class.so_userinterface.inc.php
r1266 r1269 512 512 . " WHERE (f.area_id = a.area_id)" 513 513 . " AND (f.funcionario_status_id = s.funcionario_status_id)" 514 . " AND (f.organizacao_id = ?)" 514 515 . " AND (f.localidade_id = ?)" 515 516 . " AND (s.exibir = ?)"; 516 517 517 $result = $this -> db -> query( $query, array( $ locationID, 'S' ) );518 $result = $this -> db -> query( $query, array( $organizationID, $locationID, 'S' ) ); 518 519 519 520 $employees = $result -> GetArray( -1 ); … … 566 567 return $output; 567 568 } 569 570 /** 571 * Return the list of employees in alphabetical order 572 * @param int $organizationID The organization ID 573 * @return array The list o employees 574 * @access public 575 */ 576 function getAlphabeticalEmployees( $organizationID ) 577 { 578 $organizationID = ( int ) $organizationID; 579 580 // load the employees from the location 581 $query = "SELECT f.funcionario_id, f.organizacao_id, f.area_id, a.sigla AS area," 582 . " COALESCE(f.funcionario_categoria_id, 0) AS funcionario_categoria_id" 583 . " FROM funcionario f, funcionario_status s, area a" 584 . " WHERE (f.area_id = a.area_id)" 585 . " AND (f.funcionario_status_id = s.funcionario_status_id)" 586 . " AND (f.organizacao_id = ?)" 587 . " AND (s.exibir = ?)"; 588 589 $result = $this -> db -> query( $query, array( $organizationID, 'S' ) ); 590 591 $employees = $result -> GetArray( -1 ); 592 $cachedLDAP = $GLOBALS[ 'workflow' ][ 'factory' ] -> newInstance( 'CachedLDAP' ); 593 $cachedLDAP -> setOperationMode( $cachedLDAP -> OPERATION_MODE_LDAP_DATABASE ); 594 595 $categoriesCount = array( ); 596 for ( $i = 0; $i < count( $employees ); $i++ ) 597 { 598 // remove numeric fields 599 for ( $j = 0; $j < $result -> _numOfFields; $j++ ) 600 unset( $employees[ $i ][ $j ] ); 601 602 $employees[ $i ][ 'cn' ] = ''; 603 $employees[ $i ][ 'telephoneNumber' ] = ''; 604 605 // try to find the telephone number 606 $entry = $cachedLDAP -> getEntryByID( $employees[ $i ][ 'funcionario_id' ] ); 607 if ( $entry ) 608 { 609 $employees[ $i ][ 'telephoneNumber' ] = is_null( $entry[ 'telephonenumber' ] ) ? '' : $entry[ 'telephonenumber' ]; 610 $employees[ $i ][ 'cn' ] = is_null( $entry[ 'cn' ] ) ? '' : $entry[ 'cn' ]; 611 $employees[ $i ][ 'removed' ] = is_null( $entry[ 'last_update' ] ); 612 } 613 614 // count the number of employees in each category 615 $categoryID = $employees[ $i ][ 'funcionario_categoria_id' ]; 616 if ( isset( $categoriesCount[ $categoryID ] ) ) 617 $categoriesCount[ $categoryID ]++; 618 else 619 $categoriesCount[ $categoryID ] = 1; 620 } 621 622 $usedCategories = array_keys( $categoriesCount ); 623 $availableCategories = $this -> getCategoriesList( $organizationID ); 624 $output = array( ); 625 $output[ 'employees' ] = $employees; 626 $output[ 'categories' ] = array( ); 627 foreach ( $availableCategories as $category ) 628 { 629 if ( ! in_array( $category[ 'funcionario_categoria_id' ], $usedCategories ) ) 630 continue; 631 632 $category[ 'contagem' ] = $categoriesCount[ $category[ 'funcionario_categoria_id' ] ]; 633 $output[ 'categories' ][ ] = $category; 634 } 635 636 usort( $output[ 'employees' ], create_function( '$a,$b', 'return strcasecmp($a[\'cn\'],$b[\'cn\']);' ) ); 637 638 return $output; 639 } 568 640 } 569 641 ?>
Note: See TracChangeset
for help on using the changeset viewer.