Ignore:
Timestamp:
04/05/10 15:30:21 (14 years ago)
Author:
pedroerp
Message:

Ticket #993 - Versão inicial da classe 'Settings' e substituicao de chamadas 'read_repository'.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/workflow/branches/993/inc/class.ui_orgchart.inc.php

    r2372 r2418  
    3737         * @access public 
    3838         */ 
    39         function ui_orgchart() 
     39        public function ui_orgchart() 
    4040        { 
    4141        } 
     
    4545         * @access public 
    4646         */ 
    47         function draw($tab_index = "") 
     47        public function draw($tab_index = "") 
    4848        { 
    4949                $this->workflow_acl = Factory::getInstance('workflow_acl'); 
     
    9292         * Show the graph 
    9393         * @access public 
    94          * @return void  
     94         * @return void 
    9595         */ 
    96         function graph() 
     96        public function graph() 
    9797        { 
    9898                if (!isset($_GET['organizationID'])) 
     
    104104                        die(); 
    105105 
    106                 $config_values = Factory::getInstance('config', 'workflow'); 
    107                 $config_values->read_repository(); 
    108                 $conf_db = $config_values->config_data; 
    109                 $db = Factory::getInstance('db'); 
    110                 $db->connect( 
    111                         $conf_db['database_name'], 
    112                         $conf_db['database_host'], 
    113                         $conf_db['database_port'], 
    114                         $conf_db['database_admin_user'], 
    115                         $conf_db['database_admin_password'], 
    116                         $conf_db['database_type'] 
    117                 ); 
    118                 $db = $db->Link_ID; 
     106                $db = &Factory::getInstance('WorkflowObjects')->getDBWorkflow()->Link_ID; 
     107 
    119108                $attributes = array(); 
    120109                $attributes['ranksep'] = '1.5 equally'; 
     
    122111                $graph = &Factory::getInstance('Process_GraphViz', true, $attributes); 
    123112 
    124  
    125                 /** 
    126                  * Get Hierarchical Area 
    127                  * @param organizationID  
    128                  * @param $parent  
    129                  * @param $depth 
    130                  * @param $db 
    131                  * @param $graph 
    132                  * @return  
    133                  */ 
    134                 function getHierarchicalArea($organizationID, $parent, $depth, $db, $graph) 
    135                 { 
    136                         /* orgchart graph configuration */ 
    137                         $color='black'; 
    138                         $fillcolor='lightblue2'; //blue TLS values 
    139                         $fontsize = '10'; 
    140                         $color = '0.25,1,0.28'; #dark green in TLS values 
    141                         $arrowsize = 0.8; 
    142  
    143                         if (is_null($parent)) 
    144                                 $result = $db->query("SELECT area_id, sigla, titular_funcionario_id FROM area WHERE (superior_area_id IS NULL) AND (organizacao_id = ?) AND (ativa = 'S') ORDER BY sigla", array($organizationID)); 
    145                         else 
    146                                 $result = $db->query("SELECT area_id, sigla, titular_funcionario_id FROM area WHERE (superior_area_id = ?) AND (ativa = 'S') ORDER BY sigla", array($parent)); 
    147  
    148                         $output = $result->GetArray(-1); 
    149  
    150                         if (is_null($parent) && (count($output) == 0)) 
    151                                 return false; 
    152  
    153                         $ldap = &Factory::getInstance('WorkflowLDAP'); 
    154                         for ($i = 0; $i < count($output); $i++) 
    155                         { 
    156                                 for ($j = 0; $j < $result->_numOfFields; $j++) 
    157                                         unset($output[$i][$j]); 
    158                                 if ($output[$i]['titular_funcionario_id'] != '') 
    159                                 { 
    160                                         $supervisor = $ldap->getName($output[$i]['titular_funcionario_id']); 
    161                                         $supervisor = str_replace(array(" da ", " de ", " do ", " das ", " dos "), " ", $supervisor); 
    162                                         $supervisorArray = explode(' ', $supervisor); 
    163                                         $supervisorName = ''; 
    164                                         for ($j = 0; $j < count($supervisorArray); $j++) 
    165                                                 $supervisorName .= (($j == 0) || ($j == count($supervisorArray) - 1)) ? $supervisorArray[$j] . ' ' : $supervisorArray[$j][0] . '. '; 
    166                                         $supervisorName = trim(str_replace("Junior", "Jr", $supervisorName)); 
    167                                 } 
    168                                 else 
    169                                         $supervisorName = ''; 
    170                                 /* add the area box */ 
    171                                 $graph->addNode($output[$i]['area_id'],array( 
    172                                         'URL'           => $output[$i]['area_id'], 
    173                                         'label'         => $output[$i]['sigla'] . '\n' . $supervisorName, 
    174                                         'shape'         => 'box', 
    175                                         'color'         => $color, 
    176                                         'fillcolor'     => $fillcolor, 
    177                                         'style'         => 'filled', 
    178                                         'fontsize'      => $fontsize, 
    179                                         'fontname'      => 'serif' 
    180                                         ) 
    181                                 ); 
    182  
    183                                 /* add the conection between areas */ 
    184                                 if (!is_null($parent)) 
    185                                         $graph->addEdge(array($parent => $output[$i]['area_id']), array('color'=>$color,arrowsize=>$arrowsize)); 
    186                                 $output[$i]['children'] = getHierarchicalArea($organizationID, $output[$i]['area_id'], $depth + 1, $db, $graph); 
    187                                 $output[$i]['depth'] = $depth; 
    188                         } 
    189  
    190                         return $output; 
    191                 } 
    192  
    193  
    194                 $result = getHierarchicalArea($organizationID, null, 0, $db, $graph); 
     113                $result = $this->getHierarchicalArea($organizationID, null, 0, $db, $graph); 
    195114                if ($result !== false) 
    196115                        $graph->image('png', '/tmp/grafico'); 
     
    198117                                die(); 
    199118        } 
     119 
     120 
     121        /** 
     122         * Get Hierarchical Area 
     123         * @param organizationID  
     124         * @param $parent  
     125         * @param $depth 
     126         * @param $db 
     127         * @param $graph 
     128         * @return  
     129         */ 
     130        private function getHierarchicalArea($organizationID, $parent, $depth, $db, $graph) 
     131        { 
     132                /* orgchart graph configuration */ 
     133                $color='black'; 
     134                $fillcolor='lightblue2'; //blue TLS values 
     135                $fontsize = '10'; 
     136                $color = '0.25,1,0.28'; #dark green in TLS values 
     137                $arrowsize = 0.8; 
     138 
     139                if (is_null($parent)) 
     140                        $result = $db->query("SELECT area_id, sigla, titular_funcionario_id FROM area WHERE (superior_area_id IS NULL) AND (organizacao_id = ?) AND (ativa = 'S') ORDER BY sigla", array($organizationID)); 
     141                else 
     142                        $result = $db->query("SELECT area_id, sigla, titular_funcionario_id FROM area WHERE (superior_area_id = ?) AND (ativa = 'S') ORDER BY sigla", array($parent)); 
     143 
     144                $output = $result->GetArray(-1); 
     145 
     146                if (is_null($parent) && (count($output) == 0)) 
     147                        return false; 
     148 
     149                $ldap = &Factory::getInstance('WorkflowLDAP'); 
     150                for ($i = 0; $i < count($output); $i++) 
     151                { 
     152                        for ($j = 0; $j < $result->_numOfFields; $j++) 
     153                                unset($output[$i][$j]); 
     154                        if ($output[$i]['titular_funcionario_id'] != '') 
     155                        { 
     156                                $supervisor = $ldap->getName($output[$i]['titular_funcionario_id']); 
     157                                $supervisor = str_replace(array(" da ", " de ", " do ", " das ", " dos "), " ", $supervisor); 
     158                                $supervisorArray = explode(' ', $supervisor); 
     159                                $supervisorName = ''; 
     160                                for ($j = 0; $j < count($supervisorArray); $j++) 
     161                                        $supervisorName .= (($j == 0) || ($j == count($supervisorArray) - 1)) ? $supervisorArray[$j] . ' ' : $supervisorArray[$j][0] . '. '; 
     162                                $supervisorName = trim(str_replace("Junior", "Jr", $supervisorName)); 
     163                        } 
     164                        else 
     165                                $supervisorName = ''; 
     166 
     167                        /* add the area box */ 
     168                        $graph->addNode($output[$i]['area_id'],array( 
     169                                'URL'           => $output[$i]['area_id'], 
     170                                'label'         => $output[$i]['sigla'] . '\n' . $supervisorName, 
     171                                'shape'         => 'box', 
     172                                'color'         => $color, 
     173                                'fillcolor'     => $fillcolor, 
     174                                'style'         => 'filled', 
     175                                'fontsize'      => $fontsize, 
     176                                'fontname'      => 'serif' 
     177                                ) 
     178                        ); 
     179 
     180                        /* add the conection between areas */ 
     181                        if (!is_null($parent)) 
     182                                $graph->addEdge(array($parent => $output[$i]['area_id']), array('color'=>$color,'arrowsize'=>$arrowsize)); 
     183                        $output[$i]['children'] = $this->getHierarchicalArea($organizationID, $output[$i]['area_id'], $depth + 1, $db, $graph); 
     184                        $output[$i]['depth'] = $depth; 
     185                } 
     186 
     187                return $output; 
     188        } 
    200189} 
    201190?> 
Note: See TracChangeset for help on using the changeset viewer.