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