source: companies/serpro/workflow/inc/class.ui_userinterface.inc.php @ 903

Revision 903, 6.1 KB checked in by niltonneto, 15 years ago (diff)

Importacao inicial do Expresso do Serpro

Line 
1<?php
2/**************************************************************************\
3* eGroupWare                                                               *
4* http://www.egroupware.org                                                *
5* --------------------------------------------                             *
6*  This program is free software; you can redistribute it and/or modify it *
7*  under the terms of the GNU General Public License as published by the   *
8*  Free Software Foundation; either version 2 of the License, or (at your  *
9*  option) any later version.                                              *
10\**************************************************************************/
11
12require_once(dirname(__FILE__) . SEP . 'class.ui_ajaxinterface.inc.php');
13/**
14 * @package Workflow
15 * @license http://www.gnu.org/copyleft/gpl.html GPL
16 * @author Mauricio Luiz Viani - viani@celepar.pr.gov.br
17 * @author Sidnei Augusto Drovetto Jr. - drovetto@gmail.com
18 */
19class ui_userinterface extends ui_ajaxinterface
20{
21        /**
22         * @var array public_functions
23         * @access public
24         */
25        var $public_functions = array(
26                'draw'  => true,
27                'printArea' => true
28        );
29
30        /**
31         * Constructor
32         * @access public
33         * @return object
34         */
35        function ui_userinterface() {
36
37        }
38
39        /**
40         * Draw the user interface
41         * @param int $tabIndex
42         */
43        function draw($tabIndex = null)
44        {
45                $this->set_wf_session();
46
47                if (is_null($tabIndex))
48                        $tabIndex = 1;
49
50                $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['workflow']['title'];
51                $GLOBALS['phpgw_info']['flags'] = array('noheader' => false, 'nonavbar' => false, 'currentapp' => 'workflow');
52                $smarty = CreateObject('workflow.workflow_smarty');
53
54                $javaScripts = $this->get_common_js();
55                $javaScripts .= $this->get_js_link('workflow','scriptaculous', 'prototype');
56                $javaScripts .= $this->get_js_link('workflow','userinterface', 'main');
57                $javaScripts .= $this->get_js_link('workflow','jscode', 'tigra_menu');
58                $javaScripts .= $this->get_js_link('workflow','userinterface', 'common_functions');
59                $javaScripts .= $this->get_js_link('workflow','userinterface', 'inbox');
60                $javaScripts .= $this->get_js_link('workflow','userinterface', 'inbox_group');
61                $javaScripts .= $this->get_js_link('workflow','userinterface', 'inbox_actions');
62                $javaScripts .= $this->get_js_link('workflow','userinterface', 'processes');
63                $javaScripts .= $this->get_js_link('workflow','userinterface', 'instances');
64                $javaScripts .= $this->get_js_link('workflow','userinterface', 'instances_group');
65                $javaScripts .= $this->get_js_link('workflow','userinterface', 'externals');
66                $javaScripts .= $this->get_js_link('workflow','userinterface', 'orgchart');
67                $javaScripts .= $this->get_js_link('workflow','scriptaculous', 'scriptaculous', 'load=effects');
68                $javaScripts .= $this->get_js_link('workflow','experience', 'experience');
69                $javaScripts .= $this->get_js_link('workflow','experience', 'experience.panorama');
70
71                $css = $this->get_common_css();
72                $css .= $this->get_css_link('userinterface');
73                $css .= $this->get_css_link('orgchart');
74                $css .= $this->get_css_link('experience.panorama');
75
76// Retirado Organograma
77//              $tabs = array(
78//                      'Tarefas Pendentes',
79//                      'Processos',
80//                      'Acompanhamento',
81//                      'Aplicações Externas',
82//                      'Organograma'
83//              );
84                $tabs = array(
85                        'Tarefas Pendentes',
86                        'Processos',
87                        'Acompanhamento',
88                        'Aplicações Externas'
89                );
90
91                $smarty->assign('header', $smarty->expressoHeader);
92                $smarty->assign('footer', $smarty->expressoFooter);
93                $smarty->assign('txt_loading', lang("loading"));
94                $smarty->assign('javaScripts', $javaScripts);
95                $smarty->assign('css', $css);
96                $smarty->assign('tabs', $tabs);
97                $smarty->assign('startTab', $tabIndex);
98                $smarty->display('userinterface.tpl');
99        }
100
101        function printArea()
102        {
103                /* set some session variables */
104                $this->set_wf_session();
105
106                /* create some objects */
107                require_once 'class.so_userinterface.inc.php';
108                $so = new so_userinterface();
109                $smarty = CreateObject('workflow.workflow_smarty');
110
111                /* get the user's organization */
112                $organizationInfo = $so->getUserOrganization($_SESSION['phpgw_info']['workflow']['account_id']);
113                if ($organizationInfo === false)
114                        return false;
115
116                $organizationID = $organizationInfo['organizacao_id'];
117                $areaID = (int) $_REQUEST['areaID'];
118
119                /* load the entire orgchart */
120                $areaStack = $so->getHierarchicalArea($organizationID, null, 0);
121
122                /* if requested, load only one area */
123                if ($areaID !== 0)
124                {
125                        $selectedArea = null;
126                        while (($currentArea = array_pop($areaStack)) !== null)
127                        {
128                                if ($currentArea['area_id'] == $areaID)
129                                {
130                                        $selectedArea = $currentArea;
131                                        break;
132                                }
133
134                                foreach ($currentArea['children'] as &$child)
135                                        $areaStack[] = $child;
136                        }
137
138                        if (is_null($selectedArea))
139                                return false;
140
141                        $areaStack = array(&$selectedArea);
142                }
143                else
144                {
145                        $areaStack = array_reverse($areaStack);
146                        $smarty->assign('organizationName', $organizationInfo['descricao']);
147                }
148
149                /* make the array flat (for a simpler handling) */
150                $flatAreas = array();
151                while (count($areaStack) > 0)
152                {
153                        $currentArea = &$areaStack[count($areaStack) - 1];
154                        unset($areaStack[count($areaStack) - 1]);
155
156                        $currentArea['children'] = array_reverse($currentArea['children']);
157                        foreach ($currentArea['children'] as &$item)
158                        {
159                                $item['orgchartPath'] = $currentArea['orgchartPath'] . $currentArea['sigla'] . ' &rarr; ';
160                                $areaStack[count($areaStack)] = &$item;
161                        }
162                        unset($currentArea['children']);
163
164                        $employees = $so->getAreaEmployees($currentArea['area_id'], $organizationID);
165                        if (is_array($employees))
166                                $currentArea['employees'] = $employees['employees'];
167                        else
168                                $currentArea['employees'] = array();
169                        $flatAreas[] = $currentArea;
170                }
171
172                /* get the CSS and JS links */
173                $javaScripts = $this->get_js_link('workflow', 'jquery', 'jquery-1.2.6');
174                $javaScripts .= $this->get_js_link('workflow', 'userinterface', 'orgchartPrint');
175
176                $css = $this->get_css_link('orgchartPrint', 'print');
177                $css .= $this->get_css_link('orgchartPrintPreview');
178
179                /* pass variables to smarty */
180                $smarty->assign('areasInfo', $flatAreas);
181                $smarty->assign('javaScripts', $javaScripts);
182                $smarty->assign('css', $css);
183
184                /* render the page */
185                $smarty->display('orgchartPrint.tpl');
186        }
187}
188?>
Note: See TracBrowser for help on using the repository browser.