source: branches/2.2/reports/inc/class.uireports_cota.inc.php @ 4035

Revision 4035, 23.2 KB checked in by niltonneto, 13 years ago (diff)

Ticket #1756 - Corrigido problema na paginação, sem utilizar contexto do Expresso

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