1 | <?php
|
---|
2 | /*************************************************************************************\
|
---|
3 | * Expresso Relatório *
|
---|
4 | * by Elvio Rufino da Silva (elviosilva@yahoo.com.br, elviosilva@cepromat.mt.gov.br) *
|
---|
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 |
|
---|
12 | class uireports_cota
|
---|
13 | {
|
---|
14 | var $public_functions = array
|
---|
15 | (
|
---|
16 | 'report_cota_group' => True,
|
---|
17 | 'report_cota_group_setor_print' => True,
|
---|
18 | 'report_users_cota_print_pdf' => True,
|
---|
19 | 'get_user_info' => True,
|
---|
20 | 'css' => True
|
---|
21 | );
|
---|
22 |
|
---|
23 | var $nextmatchs;
|
---|
24 | var $user;
|
---|
25 | var $functions;
|
---|
26 | var $current_config;
|
---|
27 | var $ldap_functions;
|
---|
28 | var $db_functions;
|
---|
29 | var $imap_functions;
|
---|
30 |
|
---|
31 | function uireports_cota()
|
---|
32 | {
|
---|
33 | $this->user = CreateObject('reports.user');
|
---|
34 | $this->nextmatchs = CreateObject('phpgwapi.nextmatchs');
|
---|
35 | $this->functions = CreateObject('reports.functions');
|
---|
36 | $this->ldap_functions = CreateObject('reports.ldap_functions');
|
---|
37 | $this->db_functions = CreateObject('reports.db_functions');
|
---|
38 | $this->imap_functions = CreateObject('reports.imap_functions');
|
---|
39 | $this->fpdf = CreateObject('reports.uireports_fpdf'); // Class para PDF
|
---|
40 | // $this->fpdf = CreateObject('reports.fpdf'); // Class para PDF
|
---|
41 |
|
---|
42 | $c = CreateObject('phpgwapi.config','reports'); // cria o objeto relatorio no $c
|
---|
43 | $c->read_repository(); // na classe config do phpgwapi le os dados da tabela phpgw_config where relatorio, como passagem acima
|
---|
44 | $this->current_config = $c->config_data; // carrega os dados em do array no current_config
|
---|
45 |
|
---|
46 | if(!@is_object($GLOBALS['phpgw']->js))
|
---|
47 | {
|
---|
48 | $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
|
---|
49 | }
|
---|
50 | $GLOBALS['phpgw']->js->validate_file('jscode','cc','reports');
|
---|
51 | }
|
---|
52 |
|
---|
53 | function report_cota_group()
|
---|
54 | {
|
---|
55 | $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
|
---|
56 | $manager_acl = $this->functions->read_acl($account_lid);
|
---|
57 | $raw_context = $acl['raw_context'];
|
---|
58 | $contexts = $manager_acl['contexts'];
|
---|
59 | $conta_context = count($manager_acl['contexts_display']);
|
---|
60 |
|
---|
61 | foreach ($manager_acl['contexts_display'] as $index=>$tmp_context)
|
---|
62 | {
|
---|
63 | $index = $index +1;
|
---|
64 |
|
---|
65 | if ($conta_context == $index)
|
---|
66 | {
|
---|
67 | $context_display .= $tmp_context;
|
---|
68 | }
|
---|
69 | else
|
---|
70 | {
|
---|
71 | $context_display .= $tmp_context.' | ';
|
---|
72 | }
|
---|
73 | }
|
---|
74 |
|
---|
75 | // Verifica se tem acesso a este modulo
|
---|
76 | if (!$this->functions->check_acl($account_lid,'list_sectors'))
|
---|
77 | {
|
---|
78 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/reports/inc/access_denied.php'));
|
---|
79 | }
|
---|
80 |
|
---|
81 | unset($GLOBALS['phpgw_info']['flags']['noheader']);
|
---|
82 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
|
---|
83 |
|
---|
84 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['reports']['title'].' - '.lang('report cota organization');
|
---|
85 | $GLOBALS['phpgw']->common->phpgw_header();
|
---|
86 |
|
---|
87 | $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
|
---|
88 | $p->set_file(array('groups' => 'report_cota_group.tpl'));
|
---|
89 | $p->set_block('groups','list','list');
|
---|
90 | $p->set_block('groups','row','row');
|
---|
91 | $p->set_block('groups','row_empty','row_empty');
|
---|
92 |
|
---|
93 | // Seta as variaveis padroes.
|
---|
94 | $var = Array(
|
---|
95 | 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'],
|
---|
96 | 'back_url' => $GLOBALS['phpgw']->link('/reports/index.php'),
|
---|
97 | 'context_display' => $context_display
|
---|
98 | );
|
---|
99 | $p->set_var($var);
|
---|
100 | $p->set_var($this->functions->make_dinamic_lang($p, 'list'));
|
---|
101 |
|
---|
102 |
|
---|
103 | $GLOBALS['organizacaodn'] = $_POST['organizacaodn'];
|
---|
104 |
|
---|
105 | $contextsdn = $GLOBALS['organizacaodn'];
|
---|
106 |
|
---|
107 | // Save query
|
---|
108 | $varorganizacao = explode(",",$contextsdn);
|
---|
109 | $varorganizacao_nome = trim(strtoupper(ereg_replace("ou=","",$varorganizacao[0])));
|
---|
110 | $varorganizacao_nome = trim(strtoupper(ereg_replace("DC=","",$varorganizacao_nome)));
|
---|
111 | $user_logon = $GLOBALS['phpgw_info']['user'][account_lid];
|
---|
112 |
|
---|
113 | // carrega os grupos no listbox
|
---|
114 | /************* DESCOMENTE ESTE PARTE DO CODIGO PARA LISTAR TODOS OS GRUPOS, SEM LISTAR POR USUSARIO LOGADO ***********
|
---|
115 | $sectors_info = $this->functions->get_groups_list($contexts,"*");
|
---|
116 | $sectors_info_dn = $this->functions->get_groups_list_dn($contexts,"*");
|
---|
117 | /* ************************************* FIM *********************************************************************** */
|
---|
118 |
|
---|
119 | $sectors_info = $this->functions->get_list_context_logon($user_logon,$contexts,0);
|
---|
120 | $sectors_info_dn = $this->functions->get_list_groups_dn($user_logon,$contexts,0);
|
---|
121 |
|
---|
122 | if (!count($sectors_info))
|
---|
123 | {
|
---|
124 | $p->set_var('notselect',lang('No matches found'));
|
---|
125 | }
|
---|
126 | else
|
---|
127 | {
|
---|
128 | foreach($sectors_info as $context=>$sector)
|
---|
129 | {
|
---|
130 | $sectordn = $sectors_info_dn[$context];
|
---|
131 |
|
---|
132 | $tr_color = $this->nextmatchs->alternate_row_color($tr_color);
|
---|
133 |
|
---|
134 | if ($context == 0 && $contextsdn <> "")
|
---|
135 | {
|
---|
136 | if ( trim(strtoupper($varorganizacao_nome)) == trim(strtoupper($sector)))
|
---|
137 | {
|
---|
138 | $sector_options .= "<option selected value='" .$contextsdn. "'>" .$varorganizacao_nome. "</option>";
|
---|
139 | }
|
---|
140 | else
|
---|
141 | {
|
---|
142 | $sector_options .= "<option selected value='" .$contextsdn. "'>" .$varorganizacao_nome. "</option>";
|
---|
143 | $sector_options .= "<option value='" . $sectordn . "'>". $sector . "</option>";
|
---|
144 | }
|
---|
145 |
|
---|
146 | }
|
---|
147 | else
|
---|
148 | {
|
---|
149 | if ( trim(strtoupper($varorganizacao_nome)) != trim(strtoupper($sector)))
|
---|
150 | {
|
---|
151 | $sectorok = trim(strtoupper(ereg_replace("dc=","",$sector)));
|
---|
152 | $sectorok = trim(strtoupper(ereg_replace("DC=","",$sectorok)));
|
---|
153 | $sector_options .= "<option value='" . $sectordn . "'>". $sectorok . "</option>";
|
---|
154 | }
|
---|
155 | }
|
---|
156 |
|
---|
157 | $varselect = Array(
|
---|
158 | 'tr_color' => $tr_color,
|
---|
159 | 'organizacaodn' => $contextsdn,
|
---|
160 | 'group_name' => $sector_options
|
---|
161 | );
|
---|
162 | }
|
---|
163 | $p->set_var($varselect);
|
---|
164 | }
|
---|
165 |
|
---|
166 | // ************** inicio carregar a sub-lista das organizações ****************
|
---|
167 | //Admin make a search
|
---|
168 | if ($GLOBALS['organizacaodn'] != '')
|
---|
169 | {
|
---|
170 | // Conta a quantidade de Usuario do grupo raiz
|
---|
171 | $account_user = $this->functions->get_list_user_sector($contextsdn,$contexts,0);
|
---|
172 | $totaluser = "(".count($account_user).")";
|
---|
173 |
|
---|
174 | $p->set_var('organizacao', $varorganizacao_nome);
|
---|
175 | $p->set_var('all_user', lang('all'));
|
---|
176 | $p->set_var('total_user', $totaluser);
|
---|
177 |
|
---|
178 | $setorg = $contextsdn;
|
---|
179 |
|
---|
180 | $groups_info = $this->functions->get_sectors_list($contexts,$setorg);
|
---|
181 |
|
---|
182 | if (!count($groups_info))
|
---|
183 | {
|
---|
184 | $p->set_var('message',lang('No sector found'));
|
---|
185 | $p->parse('rows','row_empty',True);
|
---|
186 | }
|
---|
187 | else
|
---|
188 | {
|
---|
189 | $ii = 0;
|
---|
190 | foreach($groups_info as $context=>$groups)
|
---|
191 | {
|
---|
192 | $explode_groups = explode("#",$groups);
|
---|
193 |
|
---|
194 | $ii = $ii + 1;
|
---|
195 |
|
---|
196 | $tr_color = $this->nextmatchs->alternate_row_color($tr_color);
|
---|
197 |
|
---|
198 | $varsuborg = Array(
|
---|
199 | 'tr_color' => $tr_color,
|
---|
200 | 'formname' => "form".$ii,
|
---|
201 | 'formsubmit' => "document.form".$ii.".submit()",
|
---|
202 | 'sector_name' => $explode_groups[0],
|
---|
203 | 'sector_namedn' => $explode_groups[1],
|
---|
204 | 'sector_namedn_completo' => $explode_groups[2],
|
---|
205 | );
|
---|
206 |
|
---|
207 | $p->set_var($varsuborg);
|
---|
208 | $p->parse('rows','row',True);
|
---|
209 | }
|
---|
210 | }
|
---|
211 | }
|
---|
212 |
|
---|
213 | $p->pfp('out','list');
|
---|
214 | }
|
---|
215 |
|
---|
216 | function report_cota_group_setor_print()
|
---|
217 | {
|
---|
218 | $grouplist = trim($_POST[setor]);
|
---|
219 | $grouplist = trim(ereg_replace("-","",$grouplist));
|
---|
220 | $organizacao = trim($_POST[organizacao]);
|
---|
221 | $setordn = trim($_POST[setordn]);
|
---|
222 | $organizacaodn = trim($_POST[organizacaodn]);
|
---|
223 | $sectornamedncompleto = trim($_POST[sectornamedncompleto]);
|
---|
224 | $Psectornamedncompleto = trim($_POST[Psectornamedncompleto]);
|
---|
225 |
|
---|
226 | if ($sectornamedncompleto=="" && $Psectornamedncompleto=="")
|
---|
227 | {
|
---|
228 | $sectornamedncompleto = $organizacao;
|
---|
229 | }
|
---|
230 | else if ($sectornamedncompleto=="" && $Psectornamedncompleto <> "")
|
---|
231 | {
|
---|
232 | $sectornamedncompleto = $Psectornamedncompleto;
|
---|
233 | }
|
---|
234 | else
|
---|
235 | {
|
---|
236 | $sectornamedncompleto = $organizacao." | ".$sectornamedncompleto;
|
---|
237 | }
|
---|
238 |
|
---|
239 | $data_atual = date("d/m/Y");
|
---|
240 | $titulo_system = $GLOBALS['phpgw_info']['apps']['reports']['title'];
|
---|
241 |
|
---|
242 | $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
|
---|
243 | $acl = $this->functions->read_acl($account_lid);
|
---|
244 | $raw_context = $acl['raw_context'];
|
---|
245 | $contexts = $acl['contexts'];
|
---|
246 | foreach ($acl['contexts_display'] as $index=>$tmp_context)
|
---|
247 | {
|
---|
248 | $context_display .= $tmp_context;
|
---|
249 | }
|
---|
250 | // Verifica se o administrador tem acesso.
|
---|
251 | if (!$this->functions->check_acl($account_lid,'list_users'))
|
---|
252 | {
|
---|
253 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/reports/inc/access_denied.php'));
|
---|
254 | }
|
---|
255 |
|
---|
256 | unset($GLOBALS['phpgw_info']['flags']['noheader']);
|
---|
257 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
|
---|
258 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['reports']['title'].' - '.lang('report user');
|
---|
259 | $GLOBALS['phpgw']->common->phpgw_header();
|
---|
260 |
|
---|
261 | $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
|
---|
262 | $p->set_file(Array('accounts' => 'report_cota_group_print.tpl'));
|
---|
263 | $p->set_block('accounts','body');
|
---|
264 | $p->set_block('accounts','rowpag');
|
---|
265 | $p->set_block('accounts','row');
|
---|
266 | $p->set_block('accounts','row_empty');
|
---|
267 |
|
---|
268 | $var = Array(
|
---|
269 | 'bg_color' => $GLOBALS['phpgw_info']['theme']['bg_color'],
|
---|
270 | 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'],
|
---|
271 | 'subtitulo' => lang('reports title4'),
|
---|
272 | 'subtitulo1' => $sectornamedncompleto,
|
---|
273 | 'context' => $raw_context,
|
---|
274 | 'titulo' => $titulo_system,
|
---|
275 | 'data_atual' => $data_atual,
|
---|
276 | 'context_display' => $context_display,
|
---|
277 | 'organizacaodn' => $organizacaodn,
|
---|
278 | 'organizacao' => $organizacao,
|
---|
279 | 'sector_name' => $grouplist,
|
---|
280 | 'sector_namedn' => $setordn,
|
---|
281 | 'graphic' => lang('Generate graphic'),
|
---|
282 | 'imapDelimiter' => $_SESSION['phpgw_info']['expresso']['email_server']['imapDelimiter']
|
---|
283 | );
|
---|
284 |
|
---|
285 | $p->set_var($var);
|
---|
286 | $p->set_var($this->functions->make_dinamic_lang($p, 'body'));
|
---|
287 |
|
---|
288 | // ************ PAGINAÇÃO *******************************
|
---|
289 |
|
---|
290 | // verifica se exixte usuarios no LDAP
|
---|
291 | $account_info = $this->functions->get_list_user_sector ($setordn,$contexts,0);
|
---|
292 |
|
---|
293 | if (!count($account_info))
|
---|
294 | {
|
---|
295 | $p->set_var('message',lang('No user found'));
|
---|
296 | $p->parse('rows','row_empty',True);
|
---|
297 | }
|
---|
298 | else if (count($account_info))
|
---|
299 | {
|
---|
300 | //url do paginador
|
---|
301 | $url = '/index.php?menuaction=reports.uireports_cota.report_cota_group_setor_print';
|
---|
302 |
|
---|
303 | // **** Grupo de paginas ****
|
---|
304 | $gpag = $_POST[gpage];
|
---|
305 |
|
---|
306 | $grupopage = 20;
|
---|
307 |
|
---|
308 | if (!$gpag){
|
---|
309 | $gpag = 1;
|
---|
310 | }
|
---|
311 |
|
---|
312 | // recebe o numero da pagina
|
---|
313 | $npag = $_POST[page];
|
---|
314 |
|
---|
315 | // verifica se o get com o numero da pagina é nulo
|
---|
316 | if (!$npag)
|
---|
317 | {
|
---|
318 | $npag = 1;
|
---|
319 | }
|
---|
320 |
|
---|
321 | // conta total dos registros
|
---|
322 | $numreg = count($account_info);
|
---|
323 |
|
---|
324 | // numero de registro por paginação
|
---|
325 | $numpage = 53;
|
---|
326 |
|
---|
327 | $tp = ceil($numreg/$numpage);
|
---|
328 | $inicio = $page - 1;
|
---|
329 | $inicio = $inicio * $numpage;
|
---|
330 |
|
---|
331 | // valor maximo de paginação
|
---|
332 | $totalnpag = (int)($tp/$grupopage);
|
---|
333 | $restonpag = $tp % $grupopage;
|
---|
334 |
|
---|
335 | if ($restonpag > 0)
|
---|
336 | {
|
---|
337 | $maxtotalnpag = $totalnpag + 1;
|
---|
338 | }
|
---|
339 | else
|
---|
340 | {
|
---|
341 | $maxtotalnpag = $totalnpag;
|
---|
342 | }
|
---|
343 | // inicio fim para imprimir a paginação
|
---|
344 | if( $tp > $grupopage)
|
---|
345 | {
|
---|
346 | // inicio do for da paginação
|
---|
347 | if ($gpag <= ($totalnpag))
|
---|
348 | {
|
---|
349 | $fimgpg = $gpag * $grupopage;
|
---|
350 | $iniciogpg = (($fimgpg - $grupopage)+1);
|
---|
351 | }
|
---|
352 | else
|
---|
353 | {
|
---|
354 | $iniciogpg = (($gpag - 1) * $grupopage);
|
---|
355 | $fimgpg = $iniciogpg + $restonpag;
|
---|
356 | }
|
---|
357 | }
|
---|
358 | else
|
---|
359 | {
|
---|
360 | // inicio do for da paginação
|
---|
361 | $iniciogpg = 1;
|
---|
362 | $fimgpg = $tp;
|
---|
363 | }
|
---|
364 |
|
---|
365 | // Imprime valores de contagen de registro e pagina
|
---|
366 | $p->set_var('cont_user',$numreg);
|
---|
367 | $p->set_var('cont_page',$tp);
|
---|
368 | $p->set_var('page_now',$npag);
|
---|
369 |
|
---|
370 | // ********** busca no LDAP as informação paginada e imprime ****************
|
---|
371 | $paginas = $this->functions->Paginate_user('accounts',$setordn,$contexts,'cn','asc',$npag,$numpage);
|
---|
372 |
|
---|
373 | $tmpp = array();
|
---|
374 |
|
---|
375 | while (list($null,$accountp) = each($paginas))
|
---|
376 | {
|
---|
377 | $tmpp[$accountp['uid'][0]]['account_id'] = $accountp['uidNumber'][0];
|
---|
378 | $tmpp[$accountp['uid'][0]]['account_lid'] = $accountp['uid'][0];
|
---|
379 | $tmpp[$accountp['uid'][0]]['account_cn'] = $accountp['cn'][0];
|
---|
380 | $tmpp[$accountp['uid'][0]]['account_status']= $accountp['accountStatus'][0];
|
---|
381 | $tmpp[$accountp['uid'][0]]['account_mail']= $accountp['mail'][0];
|
---|
382 | $sortp[] = $accountp['uid'][0];
|
---|
383 | if (count($sortp))
|
---|
384 | {
|
---|
385 | natcasesort($sortp);
|
---|
386 | foreach ($sortp as $user_uidp)
|
---|
387 | $returnp[$user_uidp] = $tmpp[$user_uidp];
|
---|
388 | }
|
---|
389 | }
|
---|
390 |
|
---|
391 | while (list($null,$accountr) = each($returnp))
|
---|
392 | {
|
---|
393 | $this->nextmatchs->template_alternate_row_color($p);
|
---|
394 |
|
---|
395 | $user_info_cota = $this->imap_functions->get_user_info($accountr['account_lid']);
|
---|
396 | $user_mailquota = $user_info_cota['mailquota'] == '-1' ? 0 : $user_info_cota['mailquota'];
|
---|
397 | $user_mailquota_used = $user_info_cota['mailquota_used'] == '-1' ? 0 : $user_info_cota['mailquota_used'];
|
---|
398 |
|
---|
399 | $user_mailquota = number_format(round($user_mailquota,2), 2, '.', ',');
|
---|
400 | $user_mailquota_used = number_format(round($user_mailquota_used,2), 2, '.', ',');
|
---|
401 |
|
---|
402 |
|
---|
403 | if ($user_mailquota > 0)
|
---|
404 | {
|
---|
405 | $percent_cota = number_format(round((($user_mailquota_used * 100)/$user_mailquota),2), 2, '.', ',');
|
---|
406 | }
|
---|
407 | else
|
---|
408 | {
|
---|
409 | $percent_cota = number_format(0, 2, '.', ',');
|
---|
410 | }
|
---|
411 |
|
---|
412 |
|
---|
413 | if ($percent_cota < 91)
|
---|
414 | {
|
---|
415 | $percent_cota_c = '<font color="#0033FF">'.$percent_cota.'%</font>';
|
---|
416 | }
|
---|
417 | elseif ($percent_cota < 97)
|
---|
418 | {
|
---|
419 | $percent_cota_c = '<font color="#CC3300">'.$percent_cota.'%</font>';
|
---|
420 | }
|
---|
421 | else
|
---|
422 | {
|
---|
423 | $percent_cota_c = '<font color="#FF0000"><b>'.$percent_cota.'%</b></font>';
|
---|
424 | }
|
---|
425 |
|
---|
426 | $varr = array(
|
---|
427 | 'mailquota' => $user_mailquota,
|
---|
428 | 'mailquota_used' => $user_mailquota_used,
|
---|
429 | 'row_loginid' => $accountr['account_lid'],
|
---|
430 | 'row_cn' => $accountr['account_cn'],
|
---|
431 | 'percent_cota' => $percent_cota_c,
|
---|
432 | 'row_status' => $accountr['account_status'] == 'active' ? '<font color="#0033FF">Ativado</font> ' : '<font color="#FF0000">Desativado</font>',
|
---|
433 | 'row_mail' => (!$accountr['account_mail']?'<font color=red>Sem E-mail</font>':$accountr['account_mail'])
|
---|
434 | );
|
---|
435 |
|
---|
436 | $p->set_var($varr);
|
---|
437 |
|
---|
438 | $p->parse('rows','row',True);
|
---|
439 | }
|
---|
440 | // ********************** Fim ****************************
|
---|
441 |
|
---|
442 | // grupo de pagina anteriores
|
---|
443 | if ($gpag > 1)
|
---|
444 | {
|
---|
445 | $gpaga = $gpag - 1;
|
---|
446 | $varp = Array(
|
---|
447 | 'paginat' => "<form name='anterior' method='POST' action='$url'>
|
---|
448 | <input type='hidden' name='setor' value='$grouplist'>
|
---|
449 | <input type='hidden' name='organizacao' value='$organizacao'>
|
---|
450 | <input type='hidden' name='setordn' value='$setordn'>
|
---|
451 | <input type='hidden' name='organizacaodn' value='$organizacaodn'>
|
---|
452 | <input type='hidden' name='page' value='$npag'>
|
---|
453 | <input type='hidden' name='gpage' value='$gpaga'>
|
---|
454 | <input type='hidden' name='Psectornamedncompleto' value='$sectornamedncompleto'>
|
---|
455 | <div style='float:left;' onClick='document.anterior.submit()'><a href='#'>".lang('Previous Pages')."<< </a></div></form>"
|
---|
456 | );
|
---|
457 | $p->set_var($varp);
|
---|
458 |
|
---|
459 | $p->parse('pages','rowpag',True);
|
---|
460 | }
|
---|
461 | // **** FIM *******
|
---|
462 |
|
---|
463 | // imprime a paginação
|
---|
464 | if ($fimgpg > 1)
|
---|
465 | {
|
---|
466 | for($x = $iniciogpg; $x <= $fimgpg; $x++)
|
---|
467 | {
|
---|
468 | $varp = Array(
|
---|
469 | 'paginat' => "<form name='form".$x."' method='POST' action='$url'>
|
---|
470 | <input type='hidden' name='setor' value='$grouplist'>
|
---|
471 | <input type='hidden' name='organizacao' value='$organizacao'>
|
---|
472 | <input type='hidden' name='setordn' value='$setordn'>
|
---|
473 | <input type='hidden' name='organizacaodn' value='$organizacaodn'>
|
---|
474 | <input type='hidden' name='page' value='$x'>
|
---|
475 | <input type='hidden' name='gpage' value='$gpag'>
|
---|
476 | <input type='hidden' name='Psectornamedncompleto' value='$sectornamedncompleto'>
|
---|
477 | <div style='float:left;' onClick='document.form".$x.".submit()'><a href='#'>$x </a></div></form>"
|
---|
478 | );
|
---|
479 | $p->set_var($varp);
|
---|
480 |
|
---|
481 | $p->parse('pages','rowpag',True);
|
---|
482 | }
|
---|
483 | }
|
---|
484 |
|
---|
485 | // proximo grupo de pagina
|
---|
486 | if ($gpag < $maxtotalnpag && $maxtotalnpag > 0)
|
---|
487 | {
|
---|
488 | $gpagp = $gpag + 1;
|
---|
489 | $varp = Array(
|
---|
490 | 'paginat' => "<form name='proximo' method='POST' action='$url'>
|
---|
491 | <input type='hidden' name='setor' value='$grouplist'>
|
---|
492 | <input type='hidden' name='organizacao' value='$organizacao'>
|
---|
493 | <input type='hidden' name='setordn' value='$setordn'>
|
---|
494 | <input type='hidden' name='organizacaodn' value='$organizacaodn'>
|
---|
495 | <input type='hidden' name='page' value='$npag'>
|
---|
496 | <input type='hidden' name='gpage' value='$gpagp'>
|
---|
497 | <input type='hidden' name='Psectornamedncompleto' value='$sectornamedncompleto'>
|
---|
498 | <div style='float:left;' onClick='document.proximo.submit()'><a href='#'> >>".lang('Next Page')."</a></div></form>"
|
---|
499 | );
|
---|
500 | $p->set_var($varp);
|
---|
501 |
|
---|
502 | $p->parse('pages','rowpag',True);
|
---|
503 | }
|
---|
504 |
|
---|
505 | // ************************* FIM PAGINAÇÃO ***********************
|
---|
506 | }
|
---|
507 | $p->pfp('out','body');
|
---|
508 | }
|
---|
509 |
|
---|
510 | function report_users_cota_print_pdf()
|
---|
511 | {
|
---|
512 | $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
|
---|
513 | $acl = $this->functions->read_acl($account_lid);
|
---|
514 | $raw_context = $acl['raw_context'];
|
---|
515 | $contexts = $acl['contexts'];
|
---|
516 | foreach ($acl['contexts_display'] as $index=>$tmp_context)
|
---|
517 | {
|
---|
518 | $context_display .= $tmp_context;
|
---|
519 | }
|
---|
520 |
|
---|
521 |
|
---|
522 | if (!$this->functions->check_acl($account_lid,'list_users'))
|
---|
523 | {
|
---|
524 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/reports/inc/access_denied.php'));
|
---|
525 | }
|
---|
526 |
|
---|
527 | $grouplist = trim($_POST[setor]);
|
---|
528 | $grouplist = trim(ereg_replace("-","",$grouplist));
|
---|
529 |
|
---|
530 | $setordn = trim($_POST[setordn]);
|
---|
531 | $subtitulo1 = trim($_POST[subtitulo]);
|
---|
532 |
|
---|
533 | define('FPDF_FONTPATH','font/');
|
---|
534 | $data_atual = date("d/m/Y");
|
---|
535 | $titulo_system = $GLOBALS['phpgw_info']['apps']['reports']['title'];
|
---|
536 |
|
---|
537 | $pdf=new uireports_fpdf("L");
|
---|
538 | $pdf->Open();
|
---|
539 | $pdf->AddPage();
|
---|
540 | $pdf->SetTitle('Relatório Gerado pelo Expresso Reports');
|
---|
541 |
|
---|
542 | //Set font and colors
|
---|
543 | $pdf->SetFont('Arial','B',14);
|
---|
544 | $pdf->SetFillColor(0,0,0);
|
---|
545 | $pdf->SetTextColor(0,0,200);
|
---|
546 | $pdf->SetDrawColor(0,0,0);
|
---|
547 | $pdf->SetLineWidth(.2);
|
---|
548 |
|
---|
549 | //Table header
|
---|
550 | $SubTitulo = lang('reports title4');
|
---|
551 | $SubTituloR = lang('report cota organization');
|
---|
552 | $SubTitulo1 = $subtitulo1;
|
---|
553 | $GLOBALS['phpgw_info']['apps']['reports']['subtitle'] = $SubTituloR;
|
---|
554 | $pdf->Cell(0,8,$SubTitulo,0,1,'C',0);
|
---|
555 |
|
---|
556 |
|
---|
557 | //Set font and colors
|
---|
558 | $pdf->SetFont('Arial','B',8);
|
---|
559 | $pdf->SetFillColor(0,0,0);
|
---|
560 | $pdf->SetTextColor(0,0,200);
|
---|
561 | $pdf->SetDrawColor(0,0,0);
|
---|
562 | $pdf->SetLineWidth(.3);
|
---|
563 |
|
---|
564 | // $pdf->Cell(0,10,$SubTitulo1,0,1,'C',0);
|
---|
565 | $pdf->MultiCell(0,3,$SubTitulo1,0,'C',0);
|
---|
566 |
|
---|
567 |
|
---|
568 | $pdf->Cell(0,2,' ',0,1,'C',0);
|
---|
569 | $pdf->Cell(0,5,'Data..: '.$data_atual,0,0,'L',0);
|
---|
570 | $pdf->Cell(0,5,$titulo_system,0,1,'R',0);
|
---|
571 |
|
---|
572 | $account_info = $this->functions->get_list_user_sector($setordn,$contexts,0);
|
---|
573 |
|
---|
574 | if (count($account_info))
|
---|
575 | {
|
---|
576 | //Restore font and colors
|
---|
577 | $pdf->SetFont('Arial','',8);
|
---|
578 | $pdf->SetFillColor(224,235,255);
|
---|
579 | $pdf->SetTextColor(0);
|
---|
580 |
|
---|
581 | $pdf->Cell(55,5,lang('loginid'),1,0,'L',1);
|
---|
582 | $pdf->Cell(55,5,lang('name'),1,0,'L',1);
|
---|
583 | $pdf->Cell(70,5,lang('report email'),1,0,'L',1);
|
---|
584 | $pdf->Cell(17,5,lang('cota'),1,0,'C',1);
|
---|
585 | $pdf->Cell(31,5,lang('cota used'),1,0,'C',1);
|
---|
586 | $pdf->Cell(29,5,lang('percent cota'),1,0,'C',1);
|
---|
587 | $pdf->Cell(20,5,lang('status'),1,1,'C',1);
|
---|
588 |
|
---|
589 | while (list($null,$account) = each($account_info))
|
---|
590 | {
|
---|
591 | $user_info_cota = $this->imap_functions->get_user_info($account['account_lid']);
|
---|
592 | $user_mailquota = $user_info_cota['mailquota'] == '-1' ? 0 : $user_info_cota['mailquota'];
|
---|
593 | $user_mailquota_used = $user_info_cota['mailquota_used'] == '-1' ? 0 : $user_info_cota['mailquota_used'];
|
---|
594 |
|
---|
595 | $user_mailquota = number_format(round($user_mailquota,2), 2, '.', ',');
|
---|
596 | $user_mailquota_used = number_format(round($user_mailquota_used,2), 2, '.', ',');
|
---|
597 |
|
---|
598 |
|
---|
599 | if ($user_mailquota > 0)
|
---|
600 | {
|
---|
601 | $percent_cota = number_format(round((($user_mailquota_used * 100)/$user_mailquota),2), 2, '.', ',');
|
---|
602 | }
|
---|
603 | else
|
---|
604 | {
|
---|
605 | $percent_cota = number_format(0, 2, '.', ',');
|
---|
606 | }
|
---|
607 |
|
---|
608 | $account_lid = $account['account_lid'];
|
---|
609 | $row_cn = $account['account_cn'];
|
---|
610 | $row_mail = (!$account['account_mail']?'<font color=red>Sem E-mail</font>':$account['account_mail']);
|
---|
611 | $row_mailquota = $user_mailquota;
|
---|
612 | $row_mailquota_used = $user_mailquota_used;
|
---|
613 | $row_percent_cota = $percent_cota;
|
---|
614 | $row_status = $account['account_accountstatus'] == 'active' ? 'Ativado' : 'Desativado';
|
---|
615 |
|
---|
616 |
|
---|
617 | $pdf->Cell(55,5,$account_lid,0,0,'L',0);
|
---|
618 | $pdf->Cell(55,5,$row_cn,0,0,'L',0);
|
---|
619 | $pdf->Cell(70,5,$row_mail,0,0,'L',0);
|
---|
620 | $pdf->Cell(17,5,$row_mailquota,0,0,'R',0);
|
---|
621 | $pdf->Cell(31,5,$row_mailquota_used,0,0,'R',0);
|
---|
622 |
|
---|
623 | if ($percent_cota < 91)
|
---|
624 | {
|
---|
625 | //Restaura cor fonte
|
---|
626 | $pdf->SetTextColor(0);
|
---|
627 | $pdf->Cell(29,5,$row_percent_cota,0,0,'R',0);
|
---|
628 | }
|
---|
629 | elseif ($percent_cota < 97)
|
---|
630 | {
|
---|
631 | //Muda cor fonte
|
---|
632 | $pdf->SetTextColor(0,256,0);
|
---|
633 | $pdf->Cell(29,5,$row_percent_cota,0,0,'R',0);
|
---|
634 | //Restaura cor fonte
|
---|
635 | $pdf->SetTextColor(0);
|
---|
636 | }
|
---|
637 | else
|
---|
638 | {
|
---|
639 | //Muda cor fonte
|
---|
640 | $pdf->SetTextColor(256,0,0);
|
---|
641 | $pdf->Cell(29,5,$row_percent_cota,0,0,'R',0);
|
---|
642 | //Restaura cor fonte
|
---|
643 | $pdf->SetTextColor(0);
|
---|
644 | }
|
---|
645 |
|
---|
646 | if ($row_status == 'Ativado')
|
---|
647 | {
|
---|
648 | //Restaura cor fonte
|
---|
649 | $pdf->SetTextColor(0);
|
---|
650 | $pdf->Cell(20,5,$row_status,0,1,'C',0);
|
---|
651 | }
|
---|
652 | else
|
---|
653 | {
|
---|
654 | //Muda cor fonte
|
---|
655 | $pdf->SetTextColor(256,0,0);
|
---|
656 | $pdf->Cell(20,5,$row_status,0,1,'C',0);
|
---|
657 | //Restaura cor fonte
|
---|
658 | $pdf->SetTextColor(0);
|
---|
659 | }
|
---|
660 | }
|
---|
661 | }
|
---|
662 |
|
---|
663 | $pdf->Output();
|
---|
664 |
|
---|
665 | return;
|
---|
666 | }
|
---|
667 |
|
---|
668 | function get_user_info($userdn,$usercontexts,$usersizelimit)
|
---|
669 | {
|
---|
670 | // $user_info = $this->functions->Paginate_user('accounts',$setordn,$contexts,'cn','asc',$npag,$numpage);
|
---|
671 | $user_info_imap = $this->imap_functions->get_user_info($user_info_ldap['uid']);
|
---|
672 |
|
---|
673 | return $user_info;
|
---|
674 | }
|
---|
675 |
|
---|
676 | function css()
|
---|
677 | {
|
---|
678 | $appCSS =
|
---|
679 | 'th.activetab
|
---|
680 | {
|
---|
681 | color:#000000;
|
---|
682 | background-color:#D3DCE3;
|
---|
683 | border-top-width : 1px;
|
---|
684 | border-top-style : solid;
|
---|
685 | border-top-color : Black;
|
---|
686 | border-left-width : 1px;
|
---|
687 | border-left-style : solid;
|
---|
688 | border-left-color : Black;
|
---|
689 | border-right-width : 1px;
|
---|
690 | border-right-style : solid;
|
---|
691 | border-right-color : Black;
|
---|
692 | font-size: 12px;
|
---|
693 | font-family: Tahoma, Arial, Helvetica, sans-serif;
|
---|
694 | }
|
---|
695 |
|
---|
696 | th.inactivetab
|
---|
697 | {
|
---|
698 | color:#000000;
|
---|
699 | background-color:#E8F0F0;
|
---|
700 | border-bottom-width : 1px;
|
---|
701 | border-bottom-style : solid;
|
---|
702 | border-bottom-color : Black;
|
---|
703 | font-size: 12px;
|
---|
704 | font-family: Tahoma, Arial, Helvetica, sans-serif;
|
---|
705 | }
|
---|
706 |
|
---|
707 | .td_left {border-left:1px solid Gray; border-top:1px solid Gray; border-bottom:1px solid Gray;}
|
---|
708 | .td_right {border-right:1px solid Gray; border-top:1px solid Gray; border-bottom:1px solid Gray;}
|
---|
709 |
|
---|
710 | div.activetab{ display:inline; }
|
---|
711 | div.inactivetab{ display:none; }';
|
---|
712 |
|
---|
713 | return $appCSS;
|
---|
714 | }
|
---|
715 |
|
---|
716 | }
|
---|
717 | ?>
|
---|