source: branches/1.2/workflow/inc/class.ui_userinterface.inc.php @ 1349

Revision 1349, 6.0 KB checked in by niltonneto, 15 years ago (diff)

Ticket #561 - Inclusão do módulo Workflow faltante nessa versão.

  • Property svn:executable set to *
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                $tabs = array(
77                        'Tarefas Pendentes',
78                        'Processos',
79                        'Acompanhamento',
80                        'Aplicações Externas',
81                        'Organograma'
82                );
83
84                $smarty->assign('header', $smarty->expressoHeader);
85                $smarty->assign('footer', $smarty->expressoFooter);
86                $smarty->assign('txt_loading', lang("loading"));
87                $smarty->assign('javaScripts', $javaScripts);
88                $smarty->assign('css', $css);
89                $smarty->assign('tabs', $tabs);
90                $smarty->assign('startTab', $tabIndex);
91                $smarty->display('userinterface.tpl');
92        }
93
94        function printArea()
95        {
96                /* set some session variables */
97                $this->set_wf_session();
98
99                /* create some objects */
100                require_once 'class.so_userinterface.inc.php';
101                $so = new so_userinterface();
102                $smarty = CreateObject('workflow.workflow_smarty');
103
104                /* get the user's organization */
105                $organizationInfo = $so->getUserOrganization($_SESSION['phpgw_info']['workflow']['account_id']);
106                if ($organizationInfo === false)
107                        return false;
108
109                $organizationID = $organizationInfo['organizacao_id'];
110                $areaID = (int) $_REQUEST['areaID'];
111
112                /* load the entire orgchart */
113                $areaStack = $so->getHierarchicalArea($organizationID, null, 0);
114
115                /* if requested, load only one area */
116                if ($areaID !== 0)
117                {
118                        $selectedArea = null;
119                        while (($currentArea = array_pop($areaStack)) !== null)
120                        {
121                                if ($currentArea['area_id'] == $areaID)
122                                {
123                                        $selectedArea = $currentArea;
124                                        break;
125                                }
126
127                                foreach ($currentArea['children'] as &$child)
128                                        $areaStack[] = $child;
129                        }
130
131                        if (is_null($selectedArea))
132                                return false;
133
134                        $areaStack = array(&$selectedArea);
135                }
136                else
137                {
138                        $areaStack = array_reverse($areaStack);
139                        $smarty->assign('organizationName', $organizationInfo['descricao']);
140                }
141
142                /* make the array flat (for a simpler handling) */
143                $flatAreas = array();
144                while (count($areaStack) > 0)
145                {
146                        $currentArea = &$areaStack[count($areaStack) - 1];
147                        unset($areaStack[count($areaStack) - 1]);
148
149                        $currentArea['children'] = array_reverse($currentArea['children']);
150                        foreach ($currentArea['children'] as &$item)
151                        {
152                                $item['orgchartPath'] = $currentArea['orgchartPath'] . $currentArea['sigla'] . ' &rarr; ';
153                                $areaStack[count($areaStack)] = &$item;
154                        }
155                        unset($currentArea['children']);
156
157                        $employees = $so->getAreaEmployees($currentArea['area_id'], $organizationID);
158                        if (is_array($employees))
159                                $currentArea['employees'] = $employees['employees'];
160                        else
161                                $currentArea['employees'] = array();
162                        $flatAreas[] = $currentArea;
163                }
164
165                /* get the CSS and JS links */
166                $javaScripts = $this->get_js_link('workflow', 'jquery', 'jquery-1.2.6');
167                $javaScripts .= $this->get_js_link('workflow', 'userinterface', 'orgchartPrint');
168
169                $css = $this->get_css_link('orgchartPrint', 'print');
170                $css .= $this->get_css_link('orgchartPrintPreview');
171
172                /* pass variables to smarty */
173                $smarty->assign('areasInfo', $flatAreas);
174                $smarty->assign('javaScripts', $javaScripts);
175                $smarty->assign('css', $css);
176
177                /* render the page */
178                $smarty->display('orgchartPrint.tpl');
179        }
180}
181?>
Note: See TracBrowser for help on using the repository browser.