Index: /branches/2.2/reports/setup/phpgw_pt-br.lang
===================================================================
--- /branches/2.2/reports/setup/phpgw_pt-br.lang	(revision 3666)
+++ /branches/2.2/reports/setup/phpgw_pt-br.lang	(revision 4570)
@@ -1,2 +1,11 @@
+Activated	reports	pt-br	Ativado
+Date	reports	pt-br	Data
+Without E-mail	reports	pt-br	Sem E-mail
+Report of shared accounts of the Organization	reports	pt-br	Relatório das contas compartilhadas da Organização
+Report shared accounts by Organization	reports	pt-br	Relatório de contas compartilhadas por Organização
+Report Generated by Expresso Reports	reports	pt-br	Relatório gerado pelo Expresso Reports
+report institutional account organization	reports	pt-br	Relatório de contas institucionais por Organização
+Report of institutional accounts of the Organization	reports	pt-br	Relatório de contas institucionais da Organização
+Report institutional accounts by Organization	reports	pt-br	Relatório de contas institucionais por Organização
 uidNumber	reports	pt-br	UID
 user login	reports	pt-br	Login do usuário
@@ -27,4 +36,5 @@
 reports	reports	pt-br	Relatórios
 report organization	reports	pt-br	Relatório de usuários por Organização
+report share account organization	reports	pt-br	Relatório de contas compartilhadas por Organização
 report cota organization	reports	pt-br	Relatório de cotas por Organização
 report maillists organization	reports	pt-br	Relatório de lista de emails por Organização
Index: /branches/2.2/reports/inc/class.uireports_maillists.inc.php
===================================================================
--- /branches/2.2/reports/inc/class.uireports_maillists.inc.php	(revision 4035)
+++ /branches/2.2/reports/inc/class.uireports_maillists.inc.php	(revision 4570)
@@ -78,5 +78,5 @@
 			$pdf->Open();
 			$pdf->AddPage();
-			$pdf->SetTitle('Relatório Gerado pelo Expresso Reports');
+			$pdf->SetTitle(lang('Report Generated by Expresso Reports'));
 
 			//Set font and colors
@@ -89,5 +89,5 @@
 			//Table header
 			$SubTitulo = lang('reports title8');
-			$SubTituloR = lang('report organization');
+			$SubTituloR = lang('Report Generated by Expresso Reports');
 			$SubTitulo1 = $subtitulo1;
 			$GLOBALS['phpgw_info']['apps']['reports']['subtitle'] = $SubTituloR;
@@ -125,5 +125,5 @@
 					$row_loginid = $account['uid'];
 					$row_cn = $account['name'];
-					$row_mail = (!$account['email']?'<font color=red>Sem E-mail</font>':$account['email']);
+					$row_mail = (!$account['email']?'<font color=red>'.lang('Without E-mail').'</font>':$account['email']);
 					$pdf->Cell(40,5,$row_loginid,0,0,'L',0);
 					$pdf->Cell(75,5,$row_cn,0,0,'L',0);
@@ -461,5 +461,5 @@
 					$tmpp[$accountp['uid'][0]]['account_lid'] = $accountp['uid'][0];
 					$tmpp[$accountp['uid'][0]]['account_cn']	 = $accountp['cn'][0];
-					$tmpp[$accountp['uid'][0]]['account_mail']= $accountp['mail'][0];
+					$tmpp[$accountp['uid'][0]]['account_mail']	= $accountp['mail'][0];
 					$sortp[] = $accountp['uid'][0];
 					if (count($sortp))
@@ -478,5 +478,5 @@
 						'row_loginid'	=> $accountr['account_lid'],
 						'row_cn'		=> $accountr['account_cn'],
-						'row_mail'		=> (!$accountr['account_mail']?'<font color=red>Sem E-mail</font>':$accountr['account_mail'])
+						'row_mail'		=> (!$accountr['account_mail']?'<font color=red>'.lang('Without E-mail').'</font>':$accountr['account_mail'])
 					);
 					
Index: /branches/2.2/reports/inc/class.uireports_users.inc.php
===================================================================
--- /branches/2.2/reports/inc/class.uireports_users.inc.php	(revision 4035)
+++ /branches/2.2/reports/inc/class.uireports_users.inc.php	(revision 4570)
@@ -78,5 +78,5 @@
 			$pdf->Open();
 			$pdf->AddPage();
-			$pdf->SetTitle('Relatório Gerado pelo Expresso Reports');
+			$pdf->SetTitle(lang('Report Generated by Expresso Reports'));
 
 			//Set font and colors
@@ -89,9 +89,8 @@
 			//Table header
 			$SubTitulo = lang('reports title2');
-			$SubTituloR = lang('report organization');
+			$SubTituloR = lang('Report Generated by Expresso Reports');
 			$SubTitulo1 = $subtitulo1;
 			$GLOBALS['phpgw_info']['apps']['reports']['subtitle'] = $SubTituloR;
 			$pdf->Cell(0,8,$SubTitulo,0,1,'C',0);
-
 
 			//Set font and colors
@@ -127,12 +126,12 @@
 						$row_loginid = $account['account_lid'];
 						$row_cn = $account['account_cn'];
-						$row_mail = (!$account['account_mail'] ? '<font color=red>Sem E-mail</font>' : $account['account_mail']);
+						$row_mail = (!$account['account_mail'] ? '<font color=red>'.lang('Without E-mail').'</font>' : $account['account_mail']);
 						$row_phone = (!$account['account_phone'] ? '-' : $account['account_phone']);
-						$row_status = $account['account_accountstatus'] == 'active' ? 'Ativado' : 'Desativado';
+						$row_status = $account['account_accountstatus'] == 'active' ? lang('Activated') : lang('Disabled');
 						$pdf->Cell(55,5,$row_loginid,0,0,'L',0);
 						$pdf->Cell(80,5,$row_cn,0,0,'L',0);
 						$pdf->Cell(80,5,$row_mail,0,0,'L',0);
 						$pdf->Cell(35,5,$row_phone,0,0,'L',0);
-					if ($row_status == 'Ativado')
+					if ($row_status == lang('Activated'))
 					{
 						//Restaura cor fonte
@@ -499,7 +498,7 @@
 						'row_loginid'	=> $accountr['account_lid'],
 						'row_cn'		=> $accountr['account_cn'],
-						'row_status'	=> $accountr['account_status'] == 'active' ? '<font color="#0033FF">Ativado</font> ' : '<font color="#FF0000">Desativado</font>',
+						'row_status'    => $accountr['account_status'] == 'active' ? '<font color="#0033FF">'.lang('Activated').'</font> ' : '<font color="#FF0000">'.lang('Disabled').'</font>',
 						'row_phone'		=> (!$accountr['account_phone'] ? '-' : $accountr['account_phone']),
-						'row_mail'		=> (!$accountr['account_mail'] ? '<font color=red>Sem E-mail</font>' : $accountr['account_mail'])
+						'row_mail'      => (!$accountr['account_mail'] ? '<font color=red>'.lang('Without E-mail').'</font>' : $accountr['account_mail'])
 					);
 					
Index: /branches/2.2/reports/inc/class.uireports_usersgroups.inc.php
===================================================================
--- /branches/2.2/reports/inc/class.uireports_usersgroups.inc.php	(revision 4035)
+++ /branches/2.2/reports/inc/class.uireports_usersgroups.inc.php	(revision 4570)
@@ -78,5 +78,5 @@
 			$pdf->Open();
 			$pdf->AddPage();
-			$pdf->SetTitle('Relatório Gerado pelo Expresso Reports');
+			$pdf->SetTitle(lang('Report of institutional accounts of the Organization'));
 
 			//Set font and colors
@@ -89,5 +89,5 @@
 			//Table header
 			$SubTitulo = lang('reports title10');
-			$SubTituloR = lang('report organization');
+			$SubTituloR = lang('Report Generated by Expresso Reports');
 			$SubTitulo1 = $subtitulo1;
 			$GLOBALS['phpgw_info']['apps']['reports']['subtitle'] = $SubTituloR;
Index: /branches/2.2/reports/inc/class.imap_functions.inc.php
===================================================================
--- /branches/2.2/reports/inc/class.imap_functions.inc.php	(revision 3946)
+++ /branches/2.2/reports/inc/class.imap_functions.inc.php	(revision 4570)
@@ -39,3 +39,25 @@
 		return $quota;
 	}
+
+	function getMembersShareAccount($uid)
+	{
+		$owner_user_share = imap_getacl($this->imap, "user" . $this->imapDelimiter . $uid);
+
+                //Organiza participantes da conta compartilha em um array, retira apenas os members, 
+		$i =0;
+		foreach($owner_user_share as $key => $value)
+		{
+			if ($i != 0)
+			{
+				$return[$i] = $key;
+			}
+			$i++;
+		}
+
+		//Ordena os participantes da conta compartilhada
+		sort($return);
+
+	        return $return;
+	}
+
 }
Index: /branches/2.2/reports/inc/class.uireports_shareAccounts.inc.php
===================================================================
--- /branches/2.2/reports/inc/class.uireports_shareAccounts.inc.php	(revision 4570)
+++ /branches/2.2/reports/inc/class.uireports_shareAccounts.inc.php	(revision 4570)
@@ -0,0 +1,667 @@
+<?php
+	/*************************************************************************************\
+	* Expresso Relatório                										         *
+	* by Elvio Rufino da Silva (elviosilva@yahoo.com.br, elviosilva@cepromat.mt.gov.br)  *
+	* -----------------------------------------------------------------------------------*
+	*  This program is free software; you can redistribute it and/or modify it			 *
+	*  under the terms of the GNU General Public License as published by the			 *
+	*  Free Software Foundation; either version 2 of the License, or (at your			 *
+	*  option) any later version.														 *
+	*************************************************************************************/
+
+	class uireports_shareAccounts
+	{
+		var $public_functions = array
+		(
+			'report_shareAccounts_print_pdf'		=> True,
+			'report_shareAccounts_group'			=> True,
+			'report_shareAccounts_group_setor_print'	=> True,
+			'get_shareAccount_info'				=> True,
+			'css'						=> True
+		);
+
+		var $nextmatchs;
+		var $user;
+		var $functions;
+		var $current_config;
+		var $ldap_functions;
+		var $db_functions;
+		var $imap_functions;
+
+		function uireports_shareAccounts()
+		{
+			$this->user		= CreateObject('reports.user');
+			$this->nextmatchs	= CreateObject('phpgwapi.nextmatchs');
+			$this->functions	= CreateObject('reports.functions');
+			$this->ldap_functions 	= CreateObject('reports.ldap_functions');
+			$this->db_functions 	= CreateObject('reports.db_functions');
+			$this->fpdf 		= CreateObject('reports.uireports_fpdf'); // Class para PDF
+			$this->imap_functions 	= CreateObject('reports.imap_functions');
+									
+			$c = CreateObject('phpgwapi.config','reports'); // cria o objeto relatorio no $c
+			$c->read_repository(); // na classe config do phpgwapi le os dados da tabela phpgw_config where relatorio, como passagem acima
+			$this->current_config = $c->config_data; // carrega os dados em do array no current_config
+
+			if(!@is_object($GLOBALS['phpgw']->js))
+			{
+				$GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
+			}
+			$GLOBALS['phpgw']->js->validate_file('jscode','cc','reports');
+		}
+		
+		function report_shareAccounts_print_pdf()
+		{
+			$account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
+			$acl = $this->functions->read_acl($account_lid);
+			$raw_context = $acl['raw_context'];
+			$contexts = $acl['contexts'];
+			foreach ($acl['contexts_display'] as $index=>$tmp_context)
+			{
+				$context_display .= $tmp_context;
+			}
+
+
+			if (!$this->functions->check_acl($account_lid,'list_users'))
+			{
+				$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/reports/inc/access_denied.php'));
+			}
+
+			$grouplist = trim($_POST[setor]);
+			$grouplist = trim(ereg_replace("-","",$grouplist));
+
+			$setordn = trim($_POST[setordn]);
+			$subtitulo1 = trim($_POST[subtitulo]);
+
+			define('FPDF_FONTPATH','font/');
+			$data_atual = date("d/m/Y"); 
+			$titulo_system = $GLOBALS['phpgw_info']['apps']['reports']['title'];			
+
+			$pdf=new uireports_fpdf("L");
+			$pdf->Open();
+			$pdf->AddPage();
+
+			//Set font and colors
+			$pdf->SetFont('Arial','B',14);
+			$pdf->SetFillColor(0,0,0);
+			$pdf->SetTextColor(0,0,200);
+			$pdf->SetDrawColor(0,0,0);
+			$pdf->SetLineWidth(.2);
+
+			//Table header
+			$SubTitulo = lang('Report of shared accounts of the Organization');
+			$SubTituloR = lang('Report Generated by Expresso Reports');
+			$SubTitulo1 = $subtitulo1;
+			$GLOBALS['phpgw_info']['apps']['reports']['subtitle'] = $SubTituloR;
+			$pdf->Cell(0,8,$SubTitulo,0,1,'C',0);
+
+			//Set font and colors
+			$pdf->SetFont('Arial','B',8);
+			$pdf->SetFillColor(0,0,0);
+			$pdf->SetTextColor(0,0,200);
+			$pdf->SetDrawColor(0,0,0);
+			$pdf->SetLineWidth(.3);
+			$pdf->MultiCell(0,3,$SubTitulo1,0,'C',0);
+			$pdf->Cell(0,2,' ',0,1,'C',0);
+			$pdf->Cell(0,5,lang('Date').'..: '.$data_atual,0,0,'L',0);
+			$pdf->Cell(0,5,$titulo_system,0,1,'R',0);
+												
+			$account_info = $this->functions->get_list_shareAccounts_sector($setordn,$contexts,0);
+						
+			if (count($account_info))
+			{ 
+				//Restore font and colors
+				$pdf->SetFont('Arial','',8);
+				$pdf->SetFillColor(224,235,255);
+				$pdf->SetTextColor(0);
+
+				$pdf->Cell(55,5,lang('loginid'),1,0,'L',1);
+				$pdf->Cell(80,5,lang('name'),1,0,'L',1);
+				$pdf->Cell(70,5,lang('report email'),1,0,'L',1);
+                                $pdf->Cell(20,5,lang('status'),1,0,'L',1);
+                                $pdf->Cell(55,5,lang('Participants'),1,1,'L',1);				
+
+				while (list($null,$account) = each($account_info))
+				{
+						$row_loginid = $account['account_lid'];
+						$row_cn = $account['account_cn'];
+						$row_mail = (!$account['account_mail'] ? '<font color=red>'.lang('Without E-mail').'</font>' : $account['account_mail']);
+						$row_status = $account['account_accountstatus'] == 'active' ? lang('Activated') : lang('Disabled');
+
+						$pdf->Cell(55,5,$row_loginid,0,0,'L',0);
+						$pdf->Cell(80,5,$row_cn,0,0,'L',0);
+						$pdf->Cell(70,5,$row_mail,0,0,'L',0);
+
+					if ($row_status == lang('Activated'))
+					{
+						//Restaura cor fonte
+						$pdf->SetTextColor(0);
+						$pdf->Cell(20,5,$row_status,0,0,'L',0);
+					}
+					else
+					{
+						//Muda cor fonte
+						$pdf->SetTextColor(256,0,0);
+						$pdf->Cell(20,5,$row_status,0,0,'L',0);					
+						//Restaura cor fonte
+						$pdf->SetTextColor(0);
+					}
+
+
+						//Pega participantes da conta compartilhada						
+						$owner_user_share = $this->imap_functions->getMembersShareAccount($account['account_lid']);
+
+						//Imprimir os participantes da conta compartilhada no PDF
+		                                $max = count($owner_user_share);
+        	                                for ($i=0; $i <= $max; $i++)
+                	                        {
+							if ($max == $i)
+							{
+								$pdf->Cell(55,5,$owner_user_share[$i],0,1,'L',0);
+                                                	}
+							else
+							{
+								$pdf->Cell(55,5,$owner_user_share[$i],0,2,'L',0);
+							}
+						}
+				}
+			}
+
+			$pdf->Output();
+
+			return; 
+		}
+
+		function report_shareAccounts_group()
+		{
+			$account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
+			$manager_acl = $this->functions->read_acl($account_lid);
+			$raw_context = $acl['raw_context'];
+			$contexts = $manager_acl['contexts'];
+			$conta_context = count($manager_acl['contexts_display']);
+			foreach ($manager_acl['contexts_display'] as $index=>$tmp_context)
+			{
+				$index = $index +1;
+
+				if ($conta_context == $index)
+				{
+					$context_display .= $tmp_context;
+				}
+				else
+				{
+					$context_display .= $tmp_context.'&nbsp;|&nbsp;';
+				}
+			}
+			
+			// Verifica se tem acesso a este modulo
+			if (!$this->functions->check_acl($account_lid,'list_sectors'))
+			{
+				$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/reports/inc/access_denied.php'));
+			}
+
+			unset($GLOBALS['phpgw_info']['flags']['noheader']);
+			unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
+			
+			$GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['reports']['title'].' - '.lang('Report shared accounts by Organization');
+			$GLOBALS['phpgw']->common->phpgw_header();
+
+			$p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
+			$p->set_file(array('groups'   => 'report_shareAccounts_group.tpl'));
+			$p->set_block('groups','list','list');
+			$p->set_block('groups','row','row');
+			$p->set_block('groups','row_empty','row_empty');
+
+			// Seta as variaveis padroes.
+			$var = Array(
+				'th_bg'				=> $GLOBALS['phpgw_info']['theme']['th_bg'],
+				'back_url'			=> $GLOBALS['phpgw']->link('/reports/index.php'),
+				'context_display'		=> $context_display
+			);
+			$p->set_var($var);
+			$p->set_var($this->functions->make_dinamic_lang($p, 'list'));
+			
+
+			$GLOBALS['organizacaodn'] = $_POST['organizacaodn'];
+
+			$contextsdn = $GLOBALS['organizacaodn'];
+
+			// Save query
+			$varorganizacao = explode(",",$contextsdn);
+			$varorganizacao_nome = trim(strtoupper(ereg_replace("ou=","",$varorganizacao[0])));
+			$varorganizacao_nome = trim(strtoupper(ereg_replace("DC=","",$varorganizacao_nome)));
+			$user_logon = $GLOBALS['phpgw_info']['user'][account_lid];
+
+			$sectors_info = $this->functions->get_list_context_logon($user_logon,$contexts,0);
+			$sectors_info_dn = $this->functions->get_list_groups_dn($user_logon,$contexts,0);
+
+			if (!count($sectors_info))
+			{
+				$p->set_var('notselect',lang('No matches found'));
+			}
+			else
+			{
+				foreach($sectors_info as $context=>$sector)
+				{
+					
+					$sectordn = $sectors_info_dn[$context];
+
+					$tr_color = $this->nextmatchs->alternate_row_color($tr_color);
+					
+					if ($context == 0 && $contextsdn <> "")
+					{
+						if (trim(strtoupper($varorganizacao_nome)) ==  trim(strtoupper($sector)))
+						{
+							$sector_options .= "<option selected value='" .$contextsdn. "'>" .$varorganizacao_nome. "</option>";
+						}
+						else
+						{
+							$sector_options .= "<option selected value='" .$contextsdn. "'>" .$varorganizacao_nome. "</option>";
+							$sector_options .= "<option value='" . $sectordn . "'>". $sector . "</option>";
+						}
+
+					}
+					else
+					{
+						if ( trim(strtoupper($varorganizacao_nome)) !=  trim(strtoupper($sector)))
+						{
+							$sectorok = trim(strtoupper(ereg_replace("dc=","",$sector)));
+							$sectorok = trim(strtoupper(ereg_replace("dc=","",$sectorok)));
+							$sector_options .= "<option value='" . $sectordn . "'>". $sectorok . "</option>";
+						}
+					}
+
+					$varselect = Array(
+						'tr_color'    	=> $tr_color,
+						'organizacaodn'	=> $contextsdn,
+						'group_name'  	=> $sector_options
+					);					
+				}
+
+				$p->set_var($varselect);
+			}
+
+			// ************** inicio carregar a sub-lista das organizações ****************
+			//Admin make a search
+			if ($GLOBALS['organizacaodn'] != '')
+			{
+				// Conta a quantidade de Usuario do grupo raiz
+				$account_user = $this->functions->get_count_shareAccount_sector($contextsdn,$contexts,0);
+				$totaluser = "(".$account_user.")";
+
+				$p->set_var('organizacao', $varorganizacao_nome);
+				$p->set_var('all_user', lang('all'));
+				$p->set_var('total_user', $totaluser);
+
+				$setorg = $contextsdn;
+
+				$groups_info = $this->functions->get_sectors_list($contexts,$setorg);
+
+				if (!count($groups_info))
+				{
+					$p->set_var('message',lang('No sector found'));
+					$p->parse('rows','row_empty',True);				
+				}
+				else
+				{
+					$ii = 0;
+					foreach($groups_info as $context=>$groups)
+					{
+						$explode_groups = explode("#",$groups);
+						$ii = $ii + 1;
+						$tr_color = $this->nextmatchs->alternate_row_color($tr_color);
+						$varsuborg = Array(
+							'tr_color'					=> $tr_color,
+							'formname'					=> "form".$ii,
+							'formsubmit'				=> "document.form".$ii.".submit()",
+							'sector_name'				=> $explode_groups[0],
+							'sector_namedn'				=> $explode_groups[1],
+							'sector_namedn_completo'	=> $explode_groups[2],			
+						);					
+
+						$p->set_var($varsuborg);					
+						$p->parse('rows','row',True);
+					}
+				}
+			}
+
+			$p->pfp('out','list');
+		}
+
+		function report_shareAccounts_group_setor_print()
+		{
+			$grouplist = trim($_POST[setor]);
+			$grouplist = trim(ereg_replace("-","",$grouplist));
+			$organizacao = trim($_POST[organizacao]);
+			$setordn = trim($_POST[setordn]);
+			$organizacaodn = trim($_POST[organizacaodn]);
+			$sectornamedncompleto = trim($_POST[sectornamedncompleto]);
+			$Psectornamedncompleto = trim($_POST[Psectornamedncompleto]);
+
+			if ($sectornamedncompleto=="" && $Psectornamedncompleto=="")
+			{			
+				$sectornamedncompleto = $organizacao;
+			}
+			else if ($sectornamedncompleto=="" && $Psectornamedncompleto <> "")
+			{
+				$sectornamedncompleto = $Psectornamedncompleto;
+			}
+			else
+			{
+				$sectornamedncompleto = $organizacao." | ".$sectornamedncompleto;
+			}
+
+			$data_atual = date("d/m/Y"); 
+			$titulo_system = $GLOBALS['phpgw_info']['apps']['reports']['title'];
+			
+			$account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
+			$acl = $this->functions->read_acl($account_lid);
+			$raw_context = $acl['raw_context'];
+			$contexts = $acl['contexts'];
+			foreach ($acl['contexts_display'] as $index=>$tmp_context)
+			{
+				$context_display .= $tmp_context;
+			}
+			// Verifica se o administrador tem acesso.
+			if (!$this->functions->check_acl($account_lid,'list_users'))
+			{
+				$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/reports/inc/access_denied.php'));
+			}
+
+			unset($GLOBALS['phpgw_info']['flags']['noheader']);
+			unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
+			$GLOBALS['phpgw_info']['flags']['app_header'] =  $GLOBALS['phpgw_info']['apps']['reports']['title'].' - '.lang('Report shared accounts by Organization');
+			$GLOBALS['phpgw']->common->phpgw_header();
+
+			$p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
+			$p->set_file(Array('accounts' => 'report_shareAccounts_group_print.tpl'));
+			$p->set_block('accounts','body');
+			$p->set_block('accounts','rowpag');
+			$p->set_block('accounts','row');
+			$p->set_block('accounts','row_empty');
+			
+			$var = Array(
+				'bg_color'				=> $GLOBALS['phpgw_info']['theme']['bg_color'],
+				'th_bg'					=> $GLOBALS['phpgw_info']['theme']['th_bg'],
+				'subtitulo'				=> lang('Report of shared accounts of the Organization'),
+				'subtitulo1'				=> $sectornamedncompleto,
+				'context'				=> $raw_context,
+				'titulo'				=> $titulo_system,
+				'data_atual'				=> $data_atual,				
+				'context_display'			=> $context_display,
+				'organizacaodn'				=> $organizacaodn,
+				'organizacao'				=> $organizacao,
+				'sector_name'				=> $grouplist,
+				'sector_namedn'				=> $setordn,
+				'imapDelimiter'				=> $_SESSION['phpgw_info']['expresso']['email_server']['imapDelimiter']
+			);
+
+			$p->set_var($var);
+			$p->set_var($this->functions->make_dinamic_lang($p, 'body'));
+
+			// ************ PAGINAÇÃO *******************************
+
+			// verifica se exixte usuarios no LDAP
+			$account_info = $this->functions->get_list_shareAccounts_sector($setordn,$contexts,0);
+
+			if (!count($account_info))
+			{
+				$p->set_var('message',lang('No user found'));
+				$p->parse('rows','row_empty',True);
+			}
+			else if (count($account_info))
+			{ 
+				//url do paginador 
+				$url = $GLOBALS['phpgw_info']['server']['webserver_url'].'/index.php?menuaction=reports.uireports_shareAccounts.report_shareAccounts_group_setor_print';
+
+				// **** Grupo de paginas ****
+				$gpag = $_POST[gpage];
+
+				$grupopage = 20;
+				
+				if (!$gpag){
+					$gpag  = 1;
+				}
+
+				// recebe o numero da pagina
+				$npag = $_POST[page];
+
+				// verifica se o get com o numero da pagina é nulo
+				if (!$npag)
+				{
+					$npag = 1;
+				}
+
+				// conta total dos registros
+				$numreg = count($account_info);
+				
+				// numero de registro por paginação
+				$numpage = 53;
+				
+				$tp = ceil($numreg/$numpage);
+				$inicio = $page - 1;
+				$inicio = $inicio * $numpage;
+	
+				// valor maximo de paginação
+				$totalnpag =  (int)($tp/$grupopage);
+				$restonpag = $tp % $grupopage;
+
+				if ($restonpag > 0)
+				{
+					$maxtotalnpag = $totalnpag + 1;
+				}
+				else
+				{
+					$maxtotalnpag = $totalnpag;
+				}
+				// inicio fim para imprimir a paginação
+				if( $tp > $grupopage)
+				{
+					// inicio do for da paginação
+					if ($gpag <= ($totalnpag))
+					{
+						$fimgpg = $gpag * $grupopage;
+						$iniciogpg = (($fimgpg - $grupopage)+1);
+					}
+					else
+					{
+						$iniciogpg = (($gpag - 1) * $grupopage);
+						$fimgpg = $iniciogpg + $restonpag;
+					}
+				}
+				else
+				{
+					// inicio do for da paginação
+					$iniciogpg = 1;
+					$fimgpg =  $tp;
+				}
+
+				// Imprime valores de contagen de registro e pagina
+				$p->set_var('cont_user',$numreg);
+				$p->set_var('cont_page',$tp);
+				$p->set_var('page_now',$npag);
+
+				// ********** busca no LDAP as informação paginada e imprime ****************
+				$paginas = $this->functions->Paginate_shareAccount('accounts',$setordn,$contexts,'cn','asc',$npag,$numpage);
+
+				$tmpp = array();
+
+				while (list($null,$accountp) = each($paginas))
+				{
+					$tmpp[$accountp['uid'][0]]['account_id']	= $accountp['uidNumber'][0]; 
+					$tmpp[$accountp['uid'][0]]['account_lid']	= $accountp['uid'][0];
+					$tmpp[$accountp['uid'][0]]['account_cn']	= $accountp['cn'][0];
+					$tmpp[$accountp['uid'][0]]['account_phone']	= $accountp['telephoneNumber'][0];
+					$tmpp[$accountp['uid'][0]]['account_status']	= $accountp['accountStatus'][0];
+					$tmpp[$accountp['uid'][0]]['account_mail']	= $accountp['mail'][0];
+
+	                                //Pega participantes da conta compartilhada
+        	                        $owner_user_share = $this->imap_functions->getMembersShareAccount($accountp['uid'][0]);
+
+					//Prepara para exibição na WEB
+                                        $max = count($owner_user_share);
+                                        $row_participants = array();
+					for ($i=0; $i <= $max; $i++)
+	                                {
+                                                if (0 == $i)
+                                                {
+                                                        $row_participants = $owner_user_share[$i];
+                                                }
+                                                elseif ($max == $i)
+                                                {
+                                                        $row_participants = $row_participants . $owner_user_share[$i];
+                                                }
+                                                else
+                                                {
+                                                        $row_participants = $row_participants . '<br>' . $owner_user_share[$i];
+                                                }
+                                         }
+
+					$tmpp[$accountp['uid'][0]]['participants_mail']      = $row_participants;
+
+					$sortp[] = $accountp['uid'][0];
+					if (count($sortp))
+					{
+						natcasesort($sortp);
+						foreach ($sortp as $user_uidp)
+						$returnp[$user_uidp] = $tmpp[$user_uidp];
+					}
+				}
+
+
+				while (list($null,$accountr) = each($returnp))
+				{
+					$this->nextmatchs->template_alternate_row_color($p);
+                                
+					$varr = array(
+                                                'row_participants'    =>   $accountr['participants_mail'],
+						'row_loginid'	=> $accountr['account_lid'],
+						'row_cn'	=> $accountr['account_cn'],
+						'row_status'	=> $accountr['account_status'] == 'active' ? '<font color="#0033FF">'.lang('Activated').'</font> ' : '<font color="#FF0000">'.lang('Disabled').'</font>',
+						'row_mail'	=> (!$accountr['account_mail'] ? '<font color=red>'.lang('Without E-mail').'</font>' : $accountr['account_mail'])
+					);
+
+
+					
+					$p->set_var($varr);
+					$p->parse('rows','row',True);
+				}
+				// ********************** Fim ****************************
+
+				// grupo de pagina anteriores
+				if ($gpag > 1)
+				{
+					$gpaga = $gpag - 1;
+					$varp = Array(
+						'paginat'	=> 	"<form name='anterior' method='POST' action='$url'>
+						<input type='hidden' name='setor' value='$grouplist'>
+						<input type='hidden' name='organizacao' value='$organizacao'>
+						<input type='hidden' name='setordn' value='$setordn'>
+						<input type='hidden' name='organizacaodn' value='$organizacaodn'>
+						<input type='hidden' name='page' value='$npag'>
+						<input type='hidden' name='gpage' value='$gpaga'>
+						<input type='hidden' name='Psectornamedncompleto' value='$sectornamedncompleto'>
+						<div style='float:left;' onClick='document.anterior.submit()'><a href='#'>".lang('Previous Pages')."<<&nbsp;&nbsp;&nbsp;</a></div></form>"
+					);
+					$p->set_var($varp);						
+	
+						$p->parse('pages','rowpag',True);
+				}
+				// **** FIM *******
+
+				// imprime a paginação
+				if ($fimgpg > 1)
+				{
+					for($x = $iniciogpg; $x <= $fimgpg; $x++)
+					{
+						$varp = Array(
+							'paginat'	=>  "<form name='form".$x."' method='POST' action='$url'>
+							<input type='hidden' name='setor' value='$grouplist'>
+							<input type='hidden' name='organizacao' value='$organizacao'>
+							<input type='hidden' name='setordn' value='$setordn'>
+							<input type='hidden' name='organizacaodn' value='$organizacaodn'>
+							<input type='hidden' name='page' value='$x'>
+							<input type='hidden' name='gpage' value='$gpag'>
+							<input type='hidden' name='Psectornamedncompleto' value='$sectornamedncompleto'>
+							<div style='float:left;' onClick='document.form".$x.".submit()'><a href='#'>$x&nbsp;</a></div></form>"
+						);
+
+						$p->set_var($varp);						
+	
+						$p->parse('pages','rowpag',True);
+					}
+				}
+		
+				// proximo grupo de pagina
+				if ($gpag < $maxtotalnpag && $maxtotalnpag > 0) 
+				{
+					$gpagp = $gpag + 1;
+					$varp = Array(
+						'paginat'	=>  "<form name='proximo' method='POST' action='$url'>
+						<input type='hidden' name='setor' value='$grouplist'>
+						<input type='hidden' name='organizacao' value='$organizacao'>
+						<input type='hidden' name='setordn' value='$setordn'>
+						<input type='hidden' name='organizacaodn' value='$organizacaodn'>
+						<input type='hidden' name='page' value='$npag'>
+						<input type='hidden' name='gpage' value='$gpagp'>
+						<input type='hidden' name='Psectornamedncompleto' value='$sectornamedncompleto'>
+						<div style='float:left;' onClick='document.proximo.submit()'><a href='#'>&nbsp;&nbsp;&nbsp;>>".lang('Next Page')."</a></div></form>"
+					);
+					$p->set_var($varp);						
+
+					$p->parse('pages','rowpag',True);
+				}
+
+			// ************************* FIM PAGINAÇÃO ***********************							
+			}
+
+			$p->pfp('out','body');
+		}
+
+		function get_shareAccount_info($userdn,$usercontexts,$usersizelimit)
+		{
+			$user_info = $this->functions->Paginate_shareAccount('accounts',$setordn,$contexts,'cn','asc',$npag,$numpage);
+
+			return $user_info;
+		}
+
+		function css()
+		{
+			$appCSS = 
+			'th.activetab
+			{
+				color:#000000;
+				background-color:#D3DCE3;
+				border-top-width : 1px;
+				border-top-style : solid;
+				border-top-color : Black;
+				border-left-width : 1px;
+				border-left-style : solid;
+				border-left-color : Black;
+				border-right-width : 1px;
+				border-right-style : solid;
+				border-right-color : Black;
+				font-size: 12px;
+				font-family: Tahoma, Arial, Helvetica, sans-serif;
+			}
+			
+			th.inactivetab
+			{
+				color:#000000;
+				background-color:#E8F0F0;
+				border-bottom-width : 1px;
+				border-bottom-style : solid;
+				border-bottom-color : Black;
+				font-size: 12px;
+				font-family: Tahoma, Arial, Helvetica, sans-serif;				
+			}
+			
+			.td_left {border-left:1px solid Gray; border-top:1px solid Gray; border-bottom:1px solid Gray;}
+			.td_right {border-right:1px solid Gray; border-top:1px solid Gray; border-bottom:1px solid Gray;}
+			
+			div.activetab{ display:inline; }
+			div.inactivetab{ display:none; }';
+			
+			return $appCSS;
+		}
+
+	}
+?>
Index: /branches/2.2/reports/inc/class.uireports_institutionalAccounts.inc.php
===================================================================
--- /branches/2.2/reports/inc/class.uireports_institutionalAccounts.inc.php	(revision 4570)
+++ /branches/2.2/reports/inc/class.uireports_institutionalAccounts.inc.php	(revision 4570)
@@ -0,0 +1,651 @@
+<?php
+	/*************************************************************************************\
+	* Expresso Relatório                										         *
+	* by Elvio Rufino da Silva (elviosilva@yahoo.com.br, elviosilva@cepromat.mt.gov.br)  *
+	* -----------------------------------------------------------------------------------*
+	*  This program is free software; you can redistribute it and/or modify it			 *
+	*  under the terms of the GNU General Public License as published by the			 *
+	*  Free Software Foundation; either version 2 of the License, or (at your			 *
+	*  option) any later version.														 *
+	*************************************************************************************/
+
+	class uireports_institutionalAccounts
+	{
+		var $public_functions = array
+		(
+			'report_institutionalAccounts_print_pdf'		=> True,
+			'report_institutionalAccounts_group'			=> True,
+			'report_institutionalAccounts_group_setor_print'	=> True,
+			'get_institutionalAccount_info'				=> True,
+			'css'						=> True
+		);
+
+		var $nextmatchs;
+		var $user;
+		var $functions;
+		var $current_config;
+		var $ldap_functions;
+		var $db_functions;
+
+		function uireports_institutionalAccounts()
+		{
+			$this->user		= CreateObject('reports.user');
+			$this->nextmatchs	= CreateObject('phpgwapi.nextmatchs');
+			$this->functions	= CreateObject('reports.functions');
+			$this->ldap_functions 	= CreateObject('reports.ldap_functions');
+			$this->db_functions 	= CreateObject('reports.db_functions');
+			$this->fpdf 		= CreateObject('reports.uireports_fpdf'); // Class para PDF
+									
+			$c = CreateObject('phpgwapi.config','reports'); // cria o objeto relatorio no $c
+			$c->read_repository(); // na classe config do phpgwapi le os dados da tabela phpgw_config where relatorio, como passagem acima
+			$this->current_config = $c->config_data; // carrega os dados em do array no current_config
+
+			if(!@is_object($GLOBALS['phpgw']->js))
+			{
+				$GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
+			}
+			$GLOBALS['phpgw']->js->validate_file('jscode','cc','reports');
+		}
+		
+		function report_institutionalAccounts_print_pdf()
+		{
+			$account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
+			$acl = $this->functions->read_acl($account_lid);
+			$raw_context = $acl['raw_context'];
+			$contexts = $acl['contexts'];
+			foreach ($acl['contexts_display'] as $index=>$tmp_context)
+			{
+				$context_display .= $tmp_context;
+			}
+
+
+			if (!$this->functions->check_acl($account_lid,'list_users'))
+			{
+				$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/reports/inc/access_denied.php'));
+			}
+
+			$grouplist = trim($_POST[setor]);
+			$grouplist = trim(ereg_replace("-","",$grouplist));
+
+			$setordn = trim($_POST[setordn]);
+			$subtitulo1 = trim($_POST[subtitulo]);
+
+			define('FPDF_FONTPATH','font/');
+			$data_atual = date("d/m/Y"); 
+			$titulo_system = $GLOBALS['phpgw_info']['apps']['reports']['title'];			
+
+			$pdf=new uireports_fpdf("L");
+			$pdf->Open();
+			$pdf->AddPage();
+
+			//Set font and colors
+			$pdf->SetFont('Arial','B',14);
+			$pdf->SetFillColor(0,0,0);
+			$pdf->SetTextColor(0,0,200);
+			$pdf->SetDrawColor(0,0,0);
+			$pdf->SetLineWidth(.2);
+
+			//Table header
+			$SubTitulo = lang('Report of institutional accounts of the Organization');
+			$SubTituloR = lang('Report Generated by Expresso Reports');
+			$SubTitulo1 = $subtitulo1;
+			$GLOBALS['phpgw_info']['apps']['reports']['subtitle'] = $SubTituloR;
+			$pdf->Cell(0,8,$SubTitulo,0,1,'C',0);
+
+			//Set font and colors
+			$pdf->SetFont('Arial','B',8);
+			$pdf->SetFillColor(0,0,0);
+			$pdf->SetTextColor(0,0,200);
+			$pdf->SetDrawColor(0,0,0);
+			$pdf->SetLineWidth(.3);
+			$pdf->MultiCell(0,3,$SubTitulo1,0,'C',0);
+			$pdf->Cell(0,2,' ',0,1,'C',0);
+			$pdf->Cell(0,5,lang('Date').'..: '.$data_atual,0,0,'L',0);
+			$pdf->Cell(0,5,$titulo_system,0,1,'R',0);
+												
+			$account_info = $this->functions->get_list_institutionalAccounts_sector($setordn,$contexts,0);
+			
+			sort($account_info);
+									
+			if (count($account_info))
+			{ 
+				//Restore font and colors
+				$pdf->SetFont('Arial','',8);
+				$pdf->SetFillColor(224,235,255);
+				$pdf->SetTextColor(0);
+
+				$pdf->Cell(80,5,lang('name'),1,0,'L',1);
+				$pdf->Cell(80,5,lang('report email'),1,0,'L',1);
+				$pdf->Cell(20,5,lang('status'),1,0,'L',1);
+	                        $pdf->Cell(80,5,lang('Participants'),1,1,'L',1);
+
+				while (list($null,$account) = each($account_info))
+				{
+						$row_cn = $account['account_cn'];
+						$row_mail = (!$account['account_mail'] ? '<font color=red>'.lang('Without E-mail').'</font>' : $account['account_mail']);
+						$row_status = $account['account_accountstatus'] == 'active' ? lang('Activated') : lang('Disabled');
+						$row_mailforwardingaddress = $account['account_mailforwardingaddress'];
+						
+						$pdf->Cell(80,5,$row_cn,0,0,'L',0);
+						$pdf->Cell(80,5,$row_mail,0,0,'L',0);
+
+					if ($row_status == lang('Activated'))
+					{
+						//Restaura cor fonte
+						$pdf->SetTextColor(0);
+						$pdf->Cell(20,5,$row_status,0,0,'L',0);
+					}
+					else
+					{
+						//Muda cor fonte
+						$pdf->SetTextColor(256,0,0);
+						$pdf->Cell(20,5,$row_status,0,0,'L',0);					
+						//Restaura cor fonte
+						$pdf->SetTextColor(0);
+					}
+
+					// Lista os participantes da conta institucional
+					$max = count($row_mailforwardingaddress);
+					for ($i=0; $i <= $max; $i++)
+					{
+						if ($max == $i)
+					        {
+							$pdf->Cell(80,5,$row_mailforwardingaddress[$i],0,1,'L',0);
+						} 
+						else
+						{
+							$pdf->Cell(80,5,$row_mailforwardingaddress[$i],0,2,'L',0);
+						}
+					}
+
+				}
+			}
+
+			$pdf->Output();
+
+			return; 
+		}
+
+		function report_institutionalAccounts_group()
+		{
+			$account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
+			$manager_acl = $this->functions->read_acl($account_lid);
+			$raw_context = $acl['raw_context'];
+			$contexts = $manager_acl['contexts'];
+			$conta_context = count($manager_acl['contexts_display']);
+			foreach ($manager_acl['contexts_display'] as $index=>$tmp_context)
+			{
+				$index = $index +1;
+
+				if ($conta_context == $index)
+				{
+					$context_display .= $tmp_context;
+				}
+				else
+				{
+					$context_display .= $tmp_context.'&nbsp;|&nbsp;';
+				}
+			}
+			
+			// Verifica se tem acesso a este modulo
+			if (!$this->functions->check_acl($account_lid,'list_sectors'))
+			{
+				$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/reports/inc/access_denied.php'));
+			}
+
+			unset($GLOBALS['phpgw_info']['flags']['noheader']);
+			unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
+			
+			$GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['reports']['title'].' - '.lang('Report institutional accounts by Organization');
+			$GLOBALS['phpgw']->common->phpgw_header();
+
+			$p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
+			$p->set_file(array('groups'   => 'report_institutionalAccounts_group.tpl'));
+			$p->set_block('groups','list','list');
+			$p->set_block('groups','row','row');
+			$p->set_block('groups','row_empty','row_empty');
+
+			// Seta as variaveis padroes.
+			$var = Array(
+				'th_bg'				=> $GLOBALS['phpgw_info']['theme']['th_bg'],
+				'back_url'			=> $GLOBALS['phpgw']->link('/reports/index.php'),
+				'context_display'		=> $context_display
+			);
+			$p->set_var($var);
+			$p->set_var($this->functions->make_dinamic_lang($p, 'list'));
+			
+
+			$GLOBALS['organizacaodn'] = $_POST['organizacaodn'];
+
+			$contextsdn = $GLOBALS['organizacaodn'];
+
+			// Save query
+			$varorganizacao = explode(",",$contextsdn);
+			$varorganizacao_nome = trim(strtoupper(ereg_replace("ou=","",$varorganizacao[0])));
+			$varorganizacao_nome = trim(strtoupper(ereg_replace("DC=","",$varorganizacao_nome)));
+			$user_logon = $GLOBALS['phpgw_info']['user'][account_lid];
+
+			$sectors_info = $this->functions->get_list_context_logon($user_logon,$contexts,0);
+			$sectors_info_dn = $this->functions->get_list_groups_dn($user_logon,$contexts,0);
+
+			if (!count($sectors_info))
+			{
+				$p->set_var('notselect',lang('No matches found'));
+			}
+			else
+			{
+				foreach($sectors_info as $context=>$sector)
+				{
+					
+					$sectordn = $sectors_info_dn[$context];
+
+					$tr_color = $this->nextmatchs->alternate_row_color($tr_color);
+					
+					if ($context == 0 && $contextsdn <> "")
+					{
+						if (trim(strtoupper($varorganizacao_nome)) ==  trim(strtoupper($sector)))
+						{
+							$sector_options .= "<option selected value='" .$contextsdn. "'>" .$varorganizacao_nome. "</option>";
+						}
+						else
+						{
+							$sector_options .= "<option selected value='" .$contextsdn. "'>" .$varorganizacao_nome. "</option>";
+							$sector_options .= "<option value='" . $sectordn . "'>". $sector . "</option>";
+						}
+
+					}
+					else
+					{
+						if ( trim(strtoupper($varorganizacao_nome)) !=  trim(strtoupper($sector)))
+						{
+							$sectorok = trim(strtoupper(ereg_replace("dc=","",$sector)));
+							$sectorok = trim(strtoupper(ereg_replace("dc=","",$sectorok)));
+							$sector_options .= "<option value='" . $sectordn . "'>". $sectorok . "</option>";
+						}
+					}
+
+					$varselect = Array(
+						'tr_color'    	=> $tr_color,
+						'organizacaodn'	=> $contextsdn,
+						'group_name'  	=> $sector_options
+					);					
+				}
+
+				$p->set_var($varselect);
+			}
+
+			// ************** inicio carregar a sub-lista das organizações ****************
+			//Admin make a search
+			if ($GLOBALS['organizacaodn'] != '')
+			{
+				// Conta a quantidade de Usuario do grupo raiz
+				$account_user = $this->functions->get_count_institutionalAccount_sector($contextsdn,$contexts,0);
+				$totaluser = "(".$account_user.")";
+
+				$p->set_var('organizacao', $varorganizacao_nome);
+				$p->set_var('all_user', lang('all'));
+				$p->set_var('total_user', $totaluser);
+
+				$setorg = $contextsdn;
+
+				$groups_info = $this->functions->get_sectors_list($contexts,$setorg);
+
+				if (!count($groups_info))
+				{
+					$p->set_var('message',lang('No sector found'));
+					$p->parse('rows','row_empty',True);				
+				}
+				else
+				{
+					$ii = 0;
+					foreach($groups_info as $context=>$groups)
+					{
+						$explode_groups = explode("#",$groups);
+						$ii = $ii + 1;
+						$tr_color = $this->nextmatchs->alternate_row_color($tr_color);
+						$varsuborg = Array(
+							'tr_color'					=> $tr_color,
+							'formname'					=> "form".$ii,
+							'formsubmit'				=> "document.form".$ii.".submit()",
+							'sector_name'				=> $explode_groups[0],
+							'sector_namedn'				=> $explode_groups[1],
+							'sector_namedn_completo'	=> $explode_groups[2],			
+						);					
+
+						$p->set_var($varsuborg);					
+						$p->parse('rows','row',True);
+					}
+				}
+			}
+
+			$p->pfp('out','list');
+		}
+
+		function report_institutionalAccounts_group_setor_print()
+		{
+			$grouplist = trim($_POST[setor]);
+			$grouplist = trim(ereg_replace("-","",$grouplist));
+			$organizacao = trim($_POST[organizacao]);
+			$setordn = trim($_POST[setordn]);
+			$organizacaodn = trim($_POST[organizacaodn]);
+			$sectornamedncompleto = trim($_POST[sectornamedncompleto]);
+			$Psectornamedncompleto = trim($_POST[Psectornamedncompleto]);
+
+			if ($sectornamedncompleto=="" && $Psectornamedncompleto=="")
+			{			
+				$sectornamedncompleto = $organizacao;
+			}
+			else if ($sectornamedncompleto=="" && $Psectornamedncompleto <> "")
+			{
+				$sectornamedncompleto = $Psectornamedncompleto;
+			}
+			else
+			{
+				$sectornamedncompleto = $organizacao." | ".$sectornamedncompleto;
+			}
+
+			$data_atual = date("d/m/Y"); 
+			$titulo_system = $GLOBALS['phpgw_info']['apps']['reports']['title'];
+			
+			$account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
+			$acl = $this->functions->read_acl($account_lid);
+			$raw_context = $acl['raw_context'];
+			$contexts = $acl['contexts'];
+			foreach ($acl['contexts_display'] as $index=>$tmp_context)
+			{
+				$context_display .= $tmp_context;
+			}
+			// Verifica se o administrador tem acesso.
+			if (!$this->functions->check_acl($account_lid,'list_users'))
+			{
+				$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/reports/inc/access_denied.php'));
+			}
+
+			unset($GLOBALS['phpgw_info']['flags']['noheader']);
+			unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
+			$GLOBALS['phpgw_info']['flags']['app_header'] =  $GLOBALS['phpgw_info']['apps']['reports']['title'].' - '.lang('Report institutional accounts by Organization');
+			$GLOBALS['phpgw']->common->phpgw_header();
+
+			$p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
+			$p->set_file(Array('accounts' => 'report_institutionalAccounts_group_print.tpl'));
+			$p->set_block('accounts','body');
+			$p->set_block('accounts','rowpag');
+			$p->set_block('accounts','row');
+			$p->set_block('accounts','row_empty');
+			
+			$var = Array(
+				'bg_color'				=> $GLOBALS['phpgw_info']['theme']['bg_color'],
+				'th_bg'					=> $GLOBALS['phpgw_info']['theme']['th_bg'],
+				'subtitulo'				=> lang('Report of institutional accounts of the Organization'),
+				'subtitulo1'				=> $sectornamedncompleto,
+				'context'				=> $raw_context,
+				'titulo'				=> $titulo_system,
+				'data_atual'				=> $data_atual,				
+				'context_display'			=> $context_display,
+				'organizacaodn'				=> $organizacaodn,
+				'organizacao'				=> $organizacao,
+				'sector_name'				=> $grouplist,
+				'sector_namedn'				=> $setordn,
+				'imapDelimiter'				=> $_SESSION['phpgw_info']['expresso']['email_server']['imapDelimiter']
+			);
+
+			$p->set_var($var);
+			$p->set_var($this->functions->make_dinamic_lang($p, 'body'));
+
+			// ************ PAGINAÇÃO *******************************
+
+			// verifica se exixte usuarios no LDAP
+			$account_info = $this->functions->get_list_institutionalAccounts_sector($setordn,$contexts,0);
+
+			if (!count($account_info))
+			{
+				$p->set_var('message',lang('No user found'));
+				$p->parse('rows','row_empty',True);
+			}
+			else if (count($account_info))
+			{ 
+				//url do paginador 
+				$url = $GLOBALS['phpgw_info']['server']['webserver_url'].'/index.php?menuaction=reports.uireports_institutionalAccounts.report_institutionalAccounts_group_setor_print';
+
+				// **** Grupo de paginas ****
+				$gpag = $_POST[gpage];
+
+				$grupopage = 20;
+				
+				if (!$gpag){
+					$gpag  = 1;
+				}
+
+				// recebe o numero da pagina
+				$npag = $_POST[page];
+
+				// verifica se o get com o numero da pagina é nulo
+				if (!$npag)
+				{
+					$npag = 1;
+				}
+
+				// conta total dos registros
+				$numreg = count($account_info);
+				
+				// numero de registro por paginação
+				$numpage = 53;
+				
+				$tp = ceil($numreg/$numpage);
+				$inicio = $page - 1;
+				$inicio = $inicio * $numpage;
+	
+				// valor maximo de paginação
+				$totalnpag =  (int)($tp/$grupopage);
+				$restonpag = $tp % $grupopage;
+
+				if ($restonpag > 0)
+				{
+					$maxtotalnpag = $totalnpag + 1;
+				}
+				else
+				{
+					$maxtotalnpag = $totalnpag;
+				}
+				// inicio fim para imprimir a paginação
+				if( $tp > $grupopage)
+				{
+					// inicio do for da paginação
+					if ($gpag <= ($totalnpag))
+					{
+						$fimgpg = $gpag * $grupopage;
+						$iniciogpg = (($fimgpg - $grupopage)+1);
+					}
+					else
+					{
+						$iniciogpg = (($gpag - 1) * $grupopage);
+						$fimgpg = $iniciogpg + $restonpag;
+					}
+				}
+				else
+				{
+					// inicio do for da paginação
+					$iniciogpg = 1;
+					$fimgpg =  $tp;
+				}
+
+				// Imprime valores de contagen de registro e pagina
+				$p->set_var('cont_user',$numreg);
+				$p->set_var('cont_page',$tp);
+				$p->set_var('page_now',$npag);
+
+				// ********** busca no LDAP as informação paginada e imprime ****************
+				$paginas = $this->functions->Paginate_institutionalAccount('accounts',$setordn,$contexts,'cn','asc',$npag,$numpage);
+
+				$tmpp = array();
+
+				while (list($null,$accountp) = each($paginas))
+				{
+					$tmpp[$accountp['uid'][0]]['account_cn']	= $accountp['cn'][0];
+					$tmpp[$accountp['uid'][0]]['account_status']	= $accountp['accountStatus'][0];
+					$tmpp[$accountp['uid'][0]]['account_mail']	= $accountp['mail'][0];
+					$tmpp[$accountp['uid'][0]]['account_mailForwardingAddress']      = $accountp['mailForwardingAddress'];
+
+					$sortp[] = $accountp['uid'][0];
+					if (count($sortp))
+					{
+						natcasesort($sortp);
+						foreach ($sortp as $user_uidp)
+						$returnp[$user_uidp] = $tmpp[$user_uidp];
+					}
+				}
+
+				while (list($null,$accountr) = each($returnp))
+				{
+					$this->nextmatchs->template_alternate_row_color($p);
+
+                                        $max = count($accountr['account_mailForwardingAddress']);
+					$row_participants = '';
+                                        for ($i=0; $i <= $max; $i++)
+                                       {
+                                                if (0 == $i)
+                                                {
+                                                        $row_participants = $accountr['account_mailForwardingAddress'][$i];
+                                                }
+						elseif ($max == $i)
+						{
+							$row_participants = $row_participants . $accountr['account_mailForwardingAddress'][$i];
+						}
+                                                else
+                                                {
+							$row_participants = $row_participants . '<br>' . $accountr['account_mailForwardingAddress'][$i];
+                                                }
+                                        }
+
+					$varr = array(
+						'row_participants'    =>    $row_participants ,
+						'row_cn'	=> $accountr['account_cn'],
+						'row_status'	=> $accountr['account_status'] == 'active' ? '<font color="#0033FF">'.lang('Activated').'</font> ' : '<font color="#FF0000">'.lang('Disabled').'</font>',
+						'row_mail'	=> (!$accountr['account_mail'] ? '<font color=red>'.lang('Without E-mail').'</font>' : $accountr['account_mail'])
+					);
+					
+					$p->set_var($varr);
+	
+					$p->parse('rows','row',True);
+				}
+				// ********************** Fim ****************************
+
+				// grupo de pagina anteriores
+				if ($gpag > 1)
+				{
+					$gpaga = $gpag - 1;
+					$varp = Array(
+						'paginat'	=> 	"<form name='anterior' method='POST' action='$url'>
+						<input type='hidden' name='setor' value='$grouplist'>
+						<input type='hidden' name='organizacao' value='$organizacao'>
+						<input type='hidden' name='setordn' value='$setordn'>
+						<input type='hidden' name='organizacaodn' value='$organizacaodn'>
+						<input type='hidden' name='page' value='$npag'>
+						<input type='hidden' name='gpage' value='$gpaga'>
+						<input type='hidden' name='Psectornamedncompleto' value='$sectornamedncompleto'>
+						<div style='float:left;' onClick='document.anterior.submit()'><a href='#'>".lang('Previous Pages')."<<&nbsp;&nbsp;&nbsp;</a></div></form>"
+					);
+					$p->set_var($varp);						
+	
+						$p->parse('pages','rowpag',True);
+				}
+				// **** FIM *******
+
+				// imprime a paginação
+				if ($fimgpg > 1)
+				{
+					for($x = $iniciogpg; $x <= $fimgpg; $x++)
+					{
+						$varp = Array(
+							'paginat'	=>  "<form name='form".$x."' method='POST' action='$url'>
+							<input type='hidden' name='setor' value='$grouplist'>
+							<input type='hidden' name='organizacao' value='$organizacao'>
+							<input type='hidden' name='setordn' value='$setordn'>
+							<input type='hidden' name='organizacaodn' value='$organizacaodn'>
+							<input type='hidden' name='page' value='$x'>
+							<input type='hidden' name='gpage' value='$gpag'>
+							<input type='hidden' name='Psectornamedncompleto' value='$sectornamedncompleto'>
+							<div style='float:left;' onClick='document.form".$x.".submit()'><a href='#'>$x&nbsp;</a></div></form>"
+						);
+
+						$p->set_var($varp);						
+	
+						$p->parse('pages','rowpag',True);
+					}
+				}
+		
+				// proximo grupo de pagina
+				if ($gpag < $maxtotalnpag && $maxtotalnpag > 0) 
+				{
+					$gpagp = $gpag + 1;
+					$varp = Array(
+						'paginat'	=>  "<form name='proximo' method='POST' action='$url'>
+						<input type='hidden' name='setor' value='$grouplist'>
+						<input type='hidden' name='organizacao' value='$organizacao'>
+						<input type='hidden' name='setordn' value='$setordn'>
+						<input type='hidden' name='organizacaodn' value='$organizacaodn'>
+						<input type='hidden' name='page' value='$npag'>
+						<input type='hidden' name='gpage' value='$gpagp'>
+						<input type='hidden' name='Psectornamedncompleto' value='$sectornamedncompleto'>
+						<div style='float:left;' onClick='document.proximo.submit()'><a href='#'>&nbsp;&nbsp;&nbsp;>>".lang('Next Page')."</a></div></form>"
+					);
+					$p->set_var($varp);						
+
+					$p->parse('pages','rowpag',True);
+				}
+
+			// ************************* FIM PAGINAÇÃO ***********************							
+			}
+
+			$p->pfp('out','body');
+		}
+
+		function get_institutionalAccount_info($userdn,$usercontexts,$usersizelimit)
+		{
+			$user_info = $this->functions->Paginate_institutionalAccount('accounts',$setordn,$contexts,'cn','asc',$npag,$numpage);
+
+			return $user_info;
+		}
+
+		function css()
+		{
+			$appCSS = 
+			'th.activetab
+			{
+				color:#000000;
+				background-color:#D3DCE3;
+				border-top-width : 1px;
+				border-top-style : solid;
+				border-top-color : Black;
+				border-left-width : 1px;
+				border-left-style : solid;
+				border-left-color : Black;
+				border-right-width : 1px;
+				border-right-style : solid;
+				border-right-color : Black;
+				font-size: 12px;
+				font-family: Tahoma, Arial, Helvetica, sans-serif;
+			}
+			
+			th.inactivetab
+			{
+				color:#000000;
+				background-color:#E8F0F0;
+				border-bottom-width : 1px;
+				border-bottom-style : solid;
+				border-bottom-color : Black;
+				font-size: 12px;
+				font-family: Tahoma, Arial, Helvetica, sans-serif;				
+			}
+			
+			.td_left {border-left:1px solid Gray; border-top:1px solid Gray; border-bottom:1px solid Gray;}
+			.td_right {border-right:1px solid Gray; border-top:1px solid Gray; border-bottom:1px solid Gray;}
+			
+			div.activetab{ display:inline; }
+			div.inactivetab{ display:none; }';
+			
+			return $appCSS;
+		}
+
+	}
+?>
Index: /branches/2.2/reports/inc/class.uireports_logon.inc.php
===================================================================
--- /branches/2.2/reports/inc/class.uireports_logon.inc.php	(revision 4035)
+++ /branches/2.2/reports/inc/class.uireports_logon.inc.php	(revision 4570)
@@ -76,5 +76,5 @@
 
 			if ($vnumacesso==999){
-				$numacesso = "Nunca logou";
+				$numacesso = lang('Never login');
 			}
 
@@ -87,5 +87,4 @@
 			$pdf->Open();
 			$pdf->AddPage();
-			$pdf->SetTitle('Relatório Gerado pelo Expresso Reports');
 
 			//Set font and colors
@@ -98,5 +97,5 @@
 			//Table header
 			$SubTitulo = lang('reports title6');
-			$SubTituloR = lang('report of time without logging by Organization');
+			$SubTituloR = lang('Report Generated by Expresso Reports');
 			$SubTitulo1 = $subtitulo1;
 			$GLOBALS['phpgw_info']['apps']['reports']['subtitle'] = $SubTituloR;
@@ -181,9 +180,9 @@
 						$row_cn = $accountr['account_cn'];
 						$account_lid = $accountr['account_lid'];
-						$row_mail = (!$accountr['account_mail'] ? 'Sem E-mail' : $accountr['account_mail']);
+						$row_mail = (!$accountr['account_mail'] ? lang('Without E-mail') : $accountr['account_mail']);
 						$row_timestamp = substr($accountr['createTimestamp'], 6, 2)."/".substr($accountr['createTimestamp'], 4, 2)."/".substr($accountr['createTimestamp'], 0, 4);
-						$row_li_date = $accountr['li_date'] == 'Nunca logou' ? 'Nunca logou' : $accountr['li_date'];
+						$row_li_date = $accountr['li_date'] == lang('Never login') ? lang('Never login') : $accountr['li_date'];
 						$row_li_dias = $accountr['li_dias'];
-						$row_status = $accountr['account_status'] == 'active' ? 'Ativado' : 'Desativado';
+						$row_status = $accountr['account_status'] == 'active' ? lang('Activated') : lang('Disabled');
 						
 						$pdf->Cell(60,5,$account_lid,0,0,'L',0);
@@ -192,5 +191,5 @@
 						$pdf->Cell(25,5,$row_timestamp,0,0,'C',0);
 
-						if ($row_li_date == 'Nunca logou')
+						if ($row_li_date == lang('Never login'))
 						{
 							//Muda cor fonte
@@ -612,5 +611,5 @@
 							'row_mail'		=> (!$accountr['account_mail']?'<font color=red>Sem E-mail</font>':$accountr['account_mail']),
 							'row_timestamp'		=> substr($accountr['createTimestamp'], 6, 2)."/".substr($accountr['createTimestamp'], 4, 2)."/".substr($accountr['createTimestamp'], 0, 4),
-							'row_li_date'		=> $accountr['li_date'] =='Nunca logou' ? '<font color="#FF0000">'.$accountr['li_date'].'</font>' : $accountr['li_date'],
+							'row_li_date'		=> $accountr['li_date'] ==lang('Never login') ? '<font color="#FF0000">'.$accountr['li_date'].'</font>' : $accountr['li_date'],
 							'row_li_dias'		=> $accountr['li_dias']
 						);
@@ -718,5 +717,5 @@
 						$access_log_array = explode("#",$access_log);
 						
-						if ($numacesso<>"Nunca logou"){
+						if ($numacesso<>lang('Never login')){
 							$accountp['li_dias'] = $access_log_array[1];
 							$accountp['li_date'] = $access_log_array[0];
@@ -778,8 +777,8 @@
 							'row_loginid'	=> $accountr['account_lid'],
 							'row_cn'		=> $accountr['account_cn'],
-							'row_status'	=> $accountr['account_status'] == 'active' ? '<font color="#0033FF">Ativado</font> ' : '<font color="#FF0000">Desativado</font>',
-							'row_mail'		=> (!$accountr['account_mail']?'<font color=red>Sem E-mail</font>':$accountr['account_mail']),
+							'row_status'	=> $accountr['account_status'] == 'active' ? '<font color="#0033FF">'.lang('Activated').'</font> ' : '<font color="#FF0000">'.lang('Disabled').'</font>',
+							'row_mail'		=> (!$accountr['account_mail']?'<font color=red>'.lang('Without E-mail').'</font>':$accountr['account_mail']),
 							'row_timestamp'		=> substr($accountr['createTimestamp'], 6, 2)."/".substr($accountr['createTimestamp'], 4, 2)."/".substr($accountr['createTimestamp'], 0, 4),
-							'row_li_date'		=> $accountr['li_date'] =='Nunca logou' ? '<font color="#FF0000">'.$accountr['li_date'].'</font>' : $accountr['li_date'],
+							'row_li_date'		=> $accountr['li_date'] ==lang('Never login') ? '<font color="#FF0000">'.$accountr['li_date'].'</font>' : $accountr['li_date'],
 							'row_li_dias'		=> $accountr['li_dias']
 						);
Index: /branches/2.2/reports/inc/class.uireports_fpdf.inc.php
===================================================================
--- /branches/2.2/reports/inc/class.uireports_fpdf.inc.php	(revision 3666)
+++ /branches/2.2/reports/inc/class.uireports_fpdf.inc.php	(revision 4570)
@@ -120,27 +120,7 @@
 	}
 
-	/*	function Header()
-	 {
-		$SubTituloR = lang('report cota organization');
-
-		//Restore font and colors
-		$this->SetFont('Arial','',8);
-		$this->SetFillColor(224,235,255);
-		$this->SetTextColor(0);
-
-		$this->Cell(95,5,lang('name'),1,0,'L',1);
-		//				$pdf->Cell(53,5,lang('report email'),1,0,'L',1);
-		$this->Cell(17,5,lang('cota'),1,0,'C',1);
-		$this->Cell(31,5,lang('cota used'),1,0,'C',1);
-		$this->Cell(29,5,lang('percent cota'),1,0,'C',1);
-		$this->Cell(20,5,lang('status'),1,1,'C',1);
-
-		return;
-		}
-		*/
 	function Footer()
 	{
 		// Esta função foi implemantada para realizar o rodapé dos relatórios
-
 		$titulo_system = $GLOBALS['phpgw_info']['apps']['reports']['title'];
 		$SubTitulo = $GLOBALS['phpgw_info']['apps']['reports']['subtitle'];
@@ -153,6 +133,4 @@
 
 		//Imprime o número da página
-		//		$this->Cell(0,5,$titulo_system.'                  '.$SubTitulo.'                  Página n. '.$this->PageNo(),1,0,'C',1);
-
 		$this->Rect(9,281,197,6,'D');
 		$this->Cell(55,4,$titulo_system,0,0,'L',1);
Index: /branches/2.2/reports/inc/class.uireports_cota.inc.php
===================================================================
--- /branches/2.2/reports/inc/class.uireports_cota.inc.php	(revision 4035)
+++ /branches/2.2/reports/inc/class.uireports_cota.inc.php	(revision 4570)
@@ -38,5 +38,4 @@
 			$this->imap_functions = CreateObject('reports.imap_functions');
 			$this->fpdf = CreateObject('reports.uireports_fpdf'); // Class para PDF
-//			$this->fpdf = CreateObject('reports.fpdf'); // Class para PDF
 						
 			$c = CreateObject('phpgwapi.config','reports'); // cria o objeto relatorio no $c
@@ -157,5 +156,5 @@
 			{
 				// Conta a quantidade de Usuario do grupo raiz
-				$account_user = $this->functions->get_count_user_sector($contextsdn,$contexts,0);
+				$account_user = $this->functions->get_count_cota_sector($contextsdn,$contexts,0);
 				$totaluser = "(".$account_user.")";
 
@@ -277,5 +276,5 @@
 
 			// verifica se exixte usuarios no LDAP
-			$account_info = $this->functions->get_list_user_sector ($setordn,$contexts,0);
+			$account_info = $this->functions->get_list_cota_sector ($setordn,$contexts,0);
 
 			if (!count($account_info))
@@ -357,5 +356,5 @@
 
 				// ********** busca no LDAP as informação paginada e imprime ****************
-				$paginas =  $this->functions->Paginate_user('accounts',$setordn,$contexts,'cn','asc',$npag,$numpage);
+				$paginas =  $this->functions->Paginate_cota('accounts',$setordn,$contexts,'cn','asc',$npag,$numpage);
 
 				$tmpp = array();
@@ -418,6 +417,6 @@
 						'row_cn'			=> $accountr['account_cn'],
 						'percent_cota'		=> $percent_cota_c,
-						'row_status'		=> $accountr['account_status'] == 'active' ? '<font color="#0033FF">Ativado</font> ' : '<font color="#FF0000">Desativado</font>',
-						'row_mail'			=> (!$accountr['account_mail']?'<font color=red>Sem E-mail</font>':$accountr['account_mail'])
+						'row_status'		=> $accountr['account_status'] == 'active' ? '<font color="#0033FF">'.lang('Activated').'</font> ' : '<font color="#FF0000">'.lang('Disabled').'</font>',
+						'row_mail'			=> (!$accountr['account_mail']?'<font color=red>'.lang('Without E-mail').'</font>':$accountr['account_mail'])
 					);
 					
@@ -526,5 +525,4 @@
 			$pdf->Open();
 			$pdf->AddPage();
-			$pdf->SetTitle('Relatório Gerado pelo Expresso Reports');
 
 			//Set font and colors
@@ -537,5 +535,5 @@
 			//Table header
 			$SubTitulo = lang('reports title4');
-			$SubTituloR = lang('report cota organization');
+			$SubTituloR = lang('Report Generated by Expresso Reports');
 			$SubTitulo1 = $subtitulo1;
 			$GLOBALS['phpgw_info']['apps']['reports']['subtitle'] = $SubTituloR;
@@ -550,5 +548,4 @@
 			$pdf->SetLineWidth(.3);
 
-//			$pdf->Cell(0,10,$SubTitulo1,0,1,'C',0);
 			$pdf->MultiCell(0,3,$SubTitulo1,0,'C',0);
 
@@ -558,5 +555,5 @@
 			$pdf->Cell(0,5,$titulo_system,0,1,'R',0);
 												
-			$account_info = $this->functions->get_list_user_sector($setordn,$contexts,0);
+			$account_info = $this->functions->get_list_cota_sector($setordn,$contexts,0);
 
 			if (count($account_info))
@@ -596,9 +593,9 @@
 					$account_lid = $account['account_lid'];
 					$row_cn = $account['account_cn'];
-					$row_mail = (!$account['account_mail']?'<font color=red>Sem E-mail</font>':$account['account_mail']);
+					$row_mail = (!$account['account_mail']?'<font color=red>'.lang('Without E-mail').'</font>':$account['account_mail']);
 					$row_mailquota = $user_mailquota;
 					$row_mailquota_used = $user_mailquota_used;
 					$row_percent_cota = $percent_cota;
-					$row_status = $account['account_accountstatus'] == 'active' ? 'Ativado' : 'Desativado';
+					$row_status = $account['account_accountstatus'] == 'active' ? lang('Activated') : lang('Disabled');
 
 					
@@ -656,5 +653,4 @@
 		function get_user_info($userdn,$usercontexts,$usersizelimit)
 		{
-//			$user_info = $this->functions->Paginate_user('accounts',$setordn,$contexts,'cn','asc',$npag,$numpage);
 			$user_info_imap = $this->imap_functions->get_user_info($user_info_ldap['uid']);
 
Index: /branches/2.2/reports/inc/class.functions.inc.php
===================================================================
--- /branches/2.2/reports/inc/class.functions.inc.php	(revision 4033)
+++ /branches/2.2/reports/inc/class.functions.inc.php	(revision 4570)
@@ -24,4 +24,7 @@
 			'array_invert'				=> True,
 			'Paginate_user'				=> True,
+			'Paginate_cota'				=> True,
+			'Paginate_shareAccount'			=> True,
+			'Paginate_institutionalAccount'		=> True,
 			'Paginate_user_logon'		=> True,
 			'get_list_all'				=> True,
@@ -854,4 +857,135 @@
 		}
 
+                function get_list_cota_sector($query, $contexts,$sizelimit)
+                {
+                        $dn                     = $GLOBALS['phpgw_info']['server']['ldap_root_dn'];
+                        $passwd         = $GLOBALS['phpgw_info']['server']['ldap_root_pw'];
+                        $ldap_conn      = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']);
+                        ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+                        ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0);
+                        ldap_bind($ldap_conn,$dn,$passwd);
+
+                        $filter="(|(phpgwAccountType=u)(|(phpgwAccountType=s)))";
+                        $justthese = array("uidnumber", "uid", "cn", "mail","accountstatus","dn","createtimestamp","telephoneNumber");
+
+                        $tmp = array();
+
+                        foreach ($contexts as $index=>$context)
+                        {
+
+                                $search = ldap_search($ldap_conn, $query, $filter, $justthese, 0, $sizelimit);
+                                $info = ldap_get_entries($ldap_conn, $search);
+
+                                for ($i=0; $i < $info['count']; $i++)
+                                {
+                                        $tmp[$info[$i]['uid'][0]]['account_id']  = $info[$i]['uidnumber'][0];
+                                        $tmp[$info[$i]['uid'][0]]['account_lid'] = $info[$i]['uid'][0];
+                                        $tmp[$info[$i]['uid'][0]]['account_cn']  = $info[$i]['cn'][0];
+                                        $tmp[$info[$i]['uid'][0]]['account_mail']= $info[$i]['mail'][0];
+                                        $tmp[$info[$i]['uid'][0]]['account_phone']= $info[$i]['telephonenumber'][0];
+                                        $tmp[$info[$i]['uid'][0]]['account_accountstatus']= $info[$i]['accountstatus'][0];
+                                        $tmp[$info[$i]['uid'][0]]['createtimestamp']= $info[$i]['createtimestamp'][0];
+                                        $sort[] = $info[$i]['uid'][0];
+                                }
+                        }
+
+                        ldap_close($ldap_conn);
+
+                        if (count($sort))
+                        {
+                                natcasesort($sort);
+                                foreach ($sort as $user_uid)
+                                        $return[$user_uid] = $tmp[$user_uid];
+                        }
+
+                        return $return;
+
+                }
+
+
+                function get_list_shareAccounts_sector($query, $contexts,$sizelimit)
+                {
+                        $dn		= $GLOBALS['phpgw_info']['server']['ldap_root_dn'];
+                        $passwd         = $GLOBALS['phpgw_info']['server']['ldap_root_pw'];
+                        $ldap_conn      = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']);
+                        ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+                        ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0);
+                        ldap_bind($ldap_conn,$dn,$passwd);
+
+                        $filter="(phpgwAccountType=s)";
+                        $justthese = array("uid", "cn", "mail","accountstatus");
+
+                        $tmp = array();
+
+                        foreach ($contexts as $index=>$context)
+                        {
+
+                                $search = ldap_search($ldap_conn, $query, $filter, $justthese, 0, $sizelimit);
+                                $info = ldap_get_entries($ldap_conn, $search);
+
+                                for ($i=0; $i < $info['count']; $i++)
+                                {
+                                        $tmp[$info[$i]['uid'][0]]['account_lid'] = $info[$i]['uid'][0];
+                                        $tmp[$info[$i]['uid'][0]]['account_cn']  = $info[$i]['cn'][0];
+                                        $tmp[$info[$i]['uid'][0]]['account_mail']= $info[$i]['mail'][0];
+                                        $tmp[$info[$i]['uid'][0]]['account_accountstatus']= $info[$i]['accountstatus'][0];
+                                        $sort[] = $info[$i]['uid'][0];
+                                }
+                        }
+
+                        ldap_close($ldap_conn);
+
+                        if (count($sort))
+                        {
+                                natcasesort($sort);
+                                foreach ($sort as $user_uid)
+                                        $return[$user_uid] = $tmp[$user_uid];
+                        }
+
+                        return $return;
+                }
+
+                function get_list_institutionalAccounts_sector($query, $contexts,$sizelimit)
+                {
+                        $dn             = $GLOBALS['phpgw_info']['server']['ldap_root_dn'];
+                        $passwd         = $GLOBALS['phpgw_info']['server']['ldap_root_pw'];
+                        $ldap_conn      = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']);
+                        ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+                        ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0);
+                        ldap_bind($ldap_conn,$dn,$passwd);
+
+                        $filter="(phpgwAccountType=i)";
+                        $justthese = array("uid", "cn", "mail","accountstatus","mailForwardingAddress");
+
+                        $tmp = array();
+
+                        foreach ($contexts as $index=>$context)
+                        {
+
+                                $search = ldap_search($ldap_conn, $query, $filter, $justthese, 0, $sizelimit);
+                                $info = ldap_get_entries($ldap_conn, $search);
+
+                                for ($i=0; $i < $info['count']; $i++)
+                                {
+                                        $tmp[$info[$i]['uid'][0]]['account_cn']  = $info[$i]['cn'][0];
+                                        $tmp[$info[$i]['uid'][0]]['account_mail']= $info[$i]['mail'][0];
+                                        $tmp[$info[$i]['uid'][0]]['account_accountstatus']= $info[$i]['accountstatus'][0];
+					$tmp[$info[$i]['uid'][0]]['account_mailforwardingaddress']= $info[$i]['mailforwardingaddress']; 
+                                        $sort[] = $info[$i]['uid'][0];
+                                }
+                        }
+
+                        ldap_close($ldap_conn);
+
+                        if (count($sort))
+                        {
+                                natcasesort($sort);
+                                foreach ($sort as $user_uid)
+                                        $return[$user_uid] = $tmp[$user_uid];
+                        }
+
+                        return $return;
+                }
+
 		function get_count_user_sector($query, $contexts,$sizelimit)
 		{
@@ -871,18 +1005,108 @@
 					$entries = ldap_get_entries($ldap_conn, $search);
 					$contexts = array();
-					for ($i=0; $i< $entries['count']; $i++){
-						$contexts[] = $entries[$i]['dn'];
 					}
 				}
+
+                        $filter="(phpgwAccountType=u)";
+                        $justthese = array("dn");
+                        $search = ldap_search($ldap_conn, $context, $filter, $justthese, 0, $sizelimit);
+                        $entries = ldap_get_entries($ldap_conn, $search);
+                        $total_count = $entries["count"];
+
+                        ldap_close($ldap_conn);
+
+                        return $total_count;
 			}	
-			$filter="(&(phpgwAccountType=u)(|(uid=*)))";
-			$justthese = array("uidnumber");
-			$total_count = 0;
-			
+			
+                function get_count_cota_sector($query, $contexts,$sizelimit)
+                {
+                        $dn                     = $GLOBALS['phpgw_info']['server']['ldap_root_dn'];
+                        $passwd         = $GLOBALS['phpgw_info']['server']['ldap_root_pw'];
+                        $ldap_conn      = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']);
+                        ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+                        ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0);
+                        ldap_bind($ldap_conn,$dn,$passwd);
+                        // counting users by sector.
 			foreach ($contexts as $index=>$context)	{				
+                                if($context == $GLOBALS['phpgw_info']['server'] ["ldap_context"]) {
+                                        $contexts[$index] = null;
+                                        $justthese = array("dn");
+                                        $filter="(objectClass=OrganizationalUnit)";
+                                        $search = ldap_list($ldap_conn, $context, $filter, $justthese);
+                                        $entries = ldap_get_entries($ldap_conn, $search);
+                                        $contexts = array();
+                                }
+                        }
+
+                        $filter="(|(phpgwAccountType=u)(|(phpgwAccountType=s)))";
+                        $justthese = array("dn");
 				$search = ldap_search($ldap_conn, $context, $filter, $justthese, 0, $sizelimit);
-				$total_count += ldap_count_entries($ldap_conn, $search);							
-			}
+                        $entries = ldap_get_entries($ldap_conn, $search);
+                        $total_count = $entries["count"];
+
+                        ldap_close($ldap_conn);
+
+                        return $total_count;
+			}
+
+                function get_count_shareAccount_sector($query, $contexts,$sizelimit)
+                {
+                        $dn             = $GLOBALS['phpgw_info']['server']['ldap_root_dn'];
+                        $passwd         = $GLOBALS['phpgw_info']['server']['ldap_root_pw'];
+                        $ldap_conn      = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']);
+                        ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+                        ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0);
+                        ldap_bind($ldap_conn,$dn,$passwd);
+                        // counting users by sector.
+                        foreach ($contexts as $index=>$context) {
+                                if($context == $GLOBALS['phpgw_info']['server'] ["ldap_context"]) {
+                                        $contexts[$index] = null;
+                                        $justthese = array("dn");
+                                        $filter="(objectClass=OrganizationalUnit)";
+                                        $search = ldap_list($ldap_conn, $context, $filter, $justthese);
+                                        $entries = ldap_get_entries($ldap_conn, $search);
+                                        $contexts = array();
+                                }
+                        }
+
+                        $filter="(phpgwAccountType=s)";
+                        $justthese = array("dn");
+			$search = ldap_search($ldap_conn, $context, $filter, $justthese, 0, $sizelimit);
+			$entries = ldap_get_entries($ldap_conn, $search);
+			$total_count = $entries["count"];
+
+                        ldap_close($ldap_conn);
+                        
+			return $total_count;
+                }
+
+                function get_count_institutionalAccount_sector($query, $contexts,$sizelimit)
+                {
+                        $dn             = $GLOBALS['phpgw_info']['server']['ldap_root_dn'];
+                        $passwd         = $GLOBALS['phpgw_info']['server']['ldap_root_pw'];
+                        $ldap_conn      = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']);
+                        ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+                        ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0);
+                        ldap_bind($ldap_conn,$dn,$passwd);
+                        // counting users by sector.
+                        foreach ($contexts as $index=>$context) {
+                                if($context == $GLOBALS['phpgw_info']['server'] ["ldap_context"]) {
+                                        $contexts[$index] = null;
+                                        $justthese = array("dn");
+                                        $filter="(objectClass=OrganizationalUnit)";
+                                        $search = ldap_list($ldap_conn, $context, $filter, $justthese);
+                                        $entries = ldap_get_entries($ldap_conn, $search);
+                                        $contexts = array();
+                                }
+                        }
+                        
+			$filter="(phpgwAccountType=i)";
+                        $justthese = array("dn");
+                        $search = ldap_search($ldap_conn, $context, $filter, $justthese, 0, $sizelimit);
+                        $entries = ldap_get_entries($ldap_conn, $search);
+                        $total_count = $entries["count"];
+
 			ldap_close($ldap_conn);
+
 			return $total_count;
 		}
@@ -897,5 +1121,5 @@
 			ldap_bind($ldap_conn,$dn,$passwd);
 
-			$filter="(&(phpgwAccountType=u)(|(uid=*)))";
+			$filter="(phpgwAccountType=u)";
 			$justthese = array("uidnumber", "uid", "cn", "mail","accountstatus","dn","createtimestamp");
 			
@@ -1254,5 +1478,5 @@
 			ldap_bind($ldap_conn,$dn,$passwd);
 			
-			$filter="(&(phpgwAccountType=u)(|(uid=*)))";
+			$filter="(&(phpgwAccountType=u))";
 			$justthese = array("uidnumber", "uid", "cn", "mail","accountstatus","dn","createtimestamp","telephoneNumber");											
 							
@@ -1318,4 +1542,221 @@
 			return $sOrder === "desc" ? array_reverse( $aList ) : $aList;
 		}
+
+		function Paginate_cota($type, $query, $contexts, $Field, $Order = 'asc', $Page = null, $PerPage = null )
+                {
+                        $dn                     = $GLOBALS['phpgw_info']['server']['ldap_root_dn'];
+                        $passwd         = $GLOBALS['phpgw_info']['server']['ldap_root_pw'];
+                        $ldap_conn      = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']);
+                        ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+                        ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0);
+                        ldap_bind($ldap_conn,$dn,$passwd);
+
+                        $filter="(|(phpgwAccountType=u)(|(phpgwAccountType=s)))";
+                        $justthese = array("uidnumber", "uid", "cn", "mail","accountstatus","dn","createtimestamp","telephoneNumber");                                 
+
+                        foreach ($contexts as $index=>$context)
+                        {
+                                $search=ldap_search($ldap_conn, $query, $filter, $justthese);
+
+                                $rConnection = $ldap_conn;
+                                $rSearch = $search;
+                                $sOrder = $Order;
+                                $iPage = $Page;
+                                $iPerPage = $PerPage;
+                                $sField = $Field;
+
+                                $iTotalEntries = ldap_count_entries( $rConnection, $rSearch );
+
+                                if ( $iPage === null || $iPerPage === null )
+                                {
+                                        # fetch all in one page
+                                        $iStart = 0;
+                                        $iEnd = $iTotalEntries - 1;
+                                }
+                                else
+                                {
+                                        # calculate range of page
+                                        $iFimPage = ( ceil( $iTotalEntries / $iPerPage ) - 1 ) * $iPage;
+
+                                        $iStart = ( ceil( ($iPage -1) * $iPerPage ));
+                                        $iEnd = $iPage * $iPerPage;
+
+
+                                        if ( $sOrder === "desc" )
+                                        {
+                                                # revert range
+                                                $iStart = $iTotalEntries - 1 - $iEnd;
+                                                $iEnd = $iStart + $iPerPage - 1;
+                                        }
+                                }
+
+                                /********* Importante Mostra o resultado da paginação **********
+                                var_dump( $iStart . " " . $iEnd );
+                                ****************** Só descomentar ******************************/
+
+                                 # fetch entries
+	                        ldap_sort( $rConnection, $rSearch, $sField );
+
+                                $aList = array();
+                                for (
+                                        $iCurrent = 0, $rEntry = ldap_first_entry( $rConnection, $rSearch );
+                                        $iCurrent <= $iEnd && is_resource( $rEntry );
+                                        $iCurrent++, $rEntry = ldap_next_entry( $rConnection, $rEntry )
+                                        )
+                                {
+                                        if ( $iCurrent >= $iStart )
+                                        {
+                                                array_push( $aList, ldap_get_attributes( $rConnection, $rEntry ));
+                                        }
+                                }
+                        }
+
+                        ldap_close($ldap_conn);
+
+                        # if order is desc revert page's entries
+                        return $sOrder === "desc" ? array_reverse( $aList ) : $aList;
+                }
+
+                function Paginate_shareAccount($type, $query, $contexts, $Field, $Order = 'asc', $Page = null, $PerPage = null )
+
+                {
+                        $dn                     = $GLOBALS['phpgw_info']['server']['ldap_root_dn'];
+                        $passwd         = $GLOBALS['phpgw_info']['server']['ldap_root_pw'];
+                        $ldap_conn      = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']);
+                        ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+                        ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0);
+                        ldap_bind($ldap_conn,$dn,$passwd);
+
+                        $filter="(phpgwAccountType=s)";
+                        $justthese = array("uid", "cn", "mail","accountstatus");                                 
+
+                        foreach ($contexts as $index=>$context)
+                        {
+                                $search=ldap_search($ldap_conn, $query, $filter, $justthese);
+
+                                $rConnection = $ldap_conn;
+                                $rSearch = $search;
+                                $sOrder = $Order;
+                                $iPage = $Page;
+                                $iPerPage = $PerPage;
+                                $sField = $Field;
+
+                                $iTotalEntries = ldap_count_entries( $rConnection, $rSearch );
+
+                                if ( $iPage === null || $iPerPage === null )
+                                {
+                                        # fetch all in one page
+                                        $iStart = 0;
+                                        $iEnd = $iTotalEntries - 1;
+                                }
+                                else
+                                {
+                                        # calculate range of page
+                                        $iFimPage = ( ceil( $iTotalEntries / $iPerPage ) - 1 ) * $iPage;
+
+                                        $iStart = ( ceil( ($iPage -1) * $iPerPage ));
+                                        $iEnd = $iPage * $iPerPage;
+
+                                        if ( $sOrder === "desc" )
+                                        {
+                                                # revert range
+                                                $iStart = $iTotalEntries - 1 - $iEnd;
+                                                $iEnd = $iStart + $iPerPage - 1;
+                                        }
+                                }
+
+                                 # fetch entries
+				ldap_sort( $rConnection, $rSearch, $sField );
+
+                                $aList = array();
+                                for (
+                                        $iCurrent = 0, $rEntry = ldap_first_entry( $rConnection, $rSearch );
+                                        $iCurrent <= $iEnd && is_resource( $rEntry );
+                                        $iCurrent++, $rEntry = ldap_next_entry( $rConnection, $rEntry )
+                                        )
+                                {
+                                        if ( $iCurrent >= $iStart )
+                                        {
+                                                array_push( $aList, ldap_get_attributes( $rConnection, $rEntry ));
+                                        }
+                                }
+                        }
+
+                        ldap_close($ldap_conn);
+
+                        # if order is desc revert page's entries
+                        return $sOrder === "desc" ? array_reverse( $aList ) : $aList;
+                }
+
+                function Paginate_institutionalAccount($type, $query, $contexts, $Field, $Order = 'asc', $Page = null, $PerPage = null )
+                {
+                        $dn                     = $GLOBALS['phpgw_info']['server']['ldap_root_dn'];
+                        $passwd         = $GLOBALS['phpgw_info']['server']['ldap_root_pw'];
+                        $ldap_conn      = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']);
+                        ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+                        ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0);
+                        ldap_bind($ldap_conn,$dn,$passwd);
+
+                        $filter="(phpgwAccountType=i)";
+                        $justthese = array("uid", "cn", "mail","accountstatus","mailforwardingaddress");
+
+                        foreach ($contexts as $index=>$context)
+                        {
+                                $search=ldap_search($ldap_conn, $query, $filter, $justthese);
+
+                                $rConnection = $ldap_conn;
+                                $rSearch = $search;
+                                $sOrder = $Order;
+                                $iPage = $Page;
+                                $iPerPage = $PerPage;
+                                $sField = $Field;
+
+                                $iTotalEntries = ldap_count_entries( $rConnection, $rSearch );
+
+                                if ( $iPage === null || $iPerPage === null )
+                                {
+                                        # fetch all in one page
+                                        $iStart = 0;
+                                        $iEnd = $iTotalEntries - 1;
+                                }
+                                else
+                                {
+                                        # calculate range of page
+                                        $iFimPage = ( ceil( $iTotalEntries / $iPerPage ) - 1 ) * $iPage;
+
+                                        $iStart = ( ceil( ($iPage -1) * $iPerPage ));
+                                        $iEnd = $iPage * $iPerPage;
+
+                                        if ( $sOrder === "desc" )
+                                        {
+                                                # revert range
+                                                $iStart = $iTotalEntries - 1 - $iEnd;
+                                                $iEnd = $iStart + $iPerPage - 1;
+                                        }
+                                }
+
+                                 # fetch entries
+                                ldap_sort( $rConnection, $rSearch, $sField );
+
+                                $aList = array();
+                                for (
+                                        $iCurrent = 0, $rEntry = ldap_first_entry( $rConnection, $rSearch );
+                                        $iCurrent <= $iEnd && is_resource( $rEntry );
+                                        $iCurrent++, $rEntry = ldap_next_entry( $rConnection, $rEntry )
+                                        )
+                                {
+                                        if ( $iCurrent >= $iStart )
+                                        {
+                                                array_push( $aList, ldap_get_attributes( $rConnection, $rEntry ));
+                                        }
+                                }
+                        }
+
+                        ldap_close($ldap_conn);
+
+                        # if order is desc revert page's entries
+                        return $sOrder === "desc" ? array_reverse( $aList ) : $aList;
+                }
+
 
 		function get_list_ou_user_logon($query,$contexts,$sizelimit)
Index: /branches/2.2/reports/index.php
===================================================================
--- /branches/2.2/reports/index.php	(revision 3948)
+++ /branches/2.2/reports/index.php	(revision 4570)
@@ -28,4 +28,6 @@
 		'lang_rel_title'			=> lang('reports'),
 		'lang_rel_user_org'			=> lang('report organization'),
+		'lang_rel_share_account_org'		=> lang('report share account organization'),
+		'lang_rel_institutional_account_org'	=> lang('report institutional account organization'),
 		'lang_rel_cota_org' 		=> lang('report cota organization'),
 		'lang_rel_logon_org' 		=> lang('report of time without logging by Organization'),
Index: /branches/2.2/reports/templates/default/report_shareAccounts_group_print.tpl
===================================================================
--- /branches/2.2/reports/templates/default/report_shareAccounts_group_print.tpl	(revision 4570)
+++ /branches/2.2/reports/templates/default/report_shareAccounts_group_print.tpl	(revision 4570)
@@ -0,0 +1,147 @@
+<!-- BEGIN body -->
+<style type="text/css">
+.myBox
+{
+    margin: 24px 0px 0px 0px;
+    border: 0px solid #ffffff;
+    color: #000000;
+    width: 99%;
+    padding: 20px;
+    text-align: left;
+    background-color: #ffffff;
+    border: 3px solid #ffffff;
+
+
+}
+
+.myBox2
+{
+    margin: 24px 0px 0px 0px;
+    border: 0px solid #ffffff;
+    width: 99%;
+    padding: 5px;
+    text-align: left;
+    background-color: #ECECE5;
+    border: 3px solid #ECECE5;
+}
+
+#loader{
+position:absolute;
+width:100%;
+height:600px;
+}
+
+.info{
+width:100px;
+float:left;
+margin-right:25%;
+margin-top: 300px;
+}
+
+.style1 {
+	font-size: 20px;
+	font-weight: bold;
+	color: #0000FF;
+}
+.style2 {
+	font-size: 18px
+	font-weight: bold;
+}
+.style4 {color: #000000}
+
+.style6 {
+	font-size: 12px;
+	font-weight: bold;
+	color: #0000FF;
+}
+</style>
+ <div id="conteudo"> <!-- Elemento camufla o contéudo até que todas as tags de imagens sejam carregadas -->
+<input type="hidden" id="accounts_form_imapDelimiter" value="{imapDelimiter}">
+{error_messages}
+<p>
+   <div align="center">
+		<table width="90%"  border="0">
+			<tr>
+			  <td colspan="2" align="left">
+			  	<div align="right" style="float:right">
+					<form name="back" method="post" action="./index.php?menuaction=reports.uireports_shareAccounts.report_shareAccounts_group">
+			  	    	<input type="hidden" name="organizacaodn" value="{organizacaodn}">
+			  	    	<input type="button" value="{lang_back}" onClick="document.back.submit()">
+			      </form>
+	            </div>
+			  </td>
+		      <td width="9%" align="left">				  
+				  <div align="right" style="float:left">
+					<form action="./index.php?menuaction=reports.uireports_shareAccounts.report_shareAccounts_print_pdf" method="post" name="pdf" target="_blank">
+				      <input name="button" type="button" onClick="document.pdf.submit()" value="Imprimir">
+				      <input type="hidden" name="setor" value="{sector_name}">
+				      <input type="hidden" name="setordn" value="{sector_namedn}">			
+				      <input type="hidden" name="subtitulo" value="{subtitulo1}">			
+				    </form>		      
+			      </div>
+		  </tr>
+        </table>
+		<table border="0" width="90%">
+			<tr>
+			  <td colspan="3" align="left"><div align="center" class="style1">{subtitulo}</div><br></td>
+	      </tr>
+			<tr>
+			  <td colspan="3" align="left"><div align="center" class="style6">{subtitulo1}</div><br></td>
+	      </tr>
+			<tr>
+			  <td width="25%" align="left"><div align="left" class="style2">{lang_report date}:{data_atual}</div></td>
+		      <td width="60%" align="left">{lang_total_users}&nbsp;<strong>{cont_user}</strong>			  </td>
+		      <td width="15%" align="left">
+			  <div align="right" class="style2">{titulo}</div></td>
+		  </tr>
+			<tr>
+			  <td colspan="3" align="left">
+				<table width="100%" border="0" align="center">
+					<tr bgcolor="{th_bg}">
+						<td colspan="2"></td>
+					</tr>
+					<tr>
+				  		<td width="50%">&nbsp;
+						</td>
+				  	    <td width="50%"><div align="right">{lang_page_now}:&nbsp;<strong>{page_now}</strong>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;{lang_total_pages}:&nbsp;<strong>{cont_page}</strong>&nbsp;&nbsp;<br></div></td>
+					</tr>
+			  </table>
+			</td>
+		  </tr>
+		</table>
+   </div>
+ 
+	<div align="center">
+		<table border="0" width="90%">
+			<tr>
+			  <td colspan="3" align="center">{pages}</td>
+		  </tr>
+			<tr bgcolor="{th_bg}">
+				<td width="20%">{lang_loginid}</td>
+				<td width="20%">{lang_name}</td>
+				<td width="20%">{lang_report email}</td>
+				<td width="5%">{lang_status}</td>
+                                <td width="20%">{lang_participants}</td>
+			</tr>
+			{rows}
+		</table>
+	</div>
+<!-- END body -->
+<!-- BEGIN rowpag -->
+    <b>{paginat}</b>
+<!-- END rowpag -->
+<!-- BEGIN row -->
+	<tr bgcolor="{tr_color}">
+		<td>{row_loginid}</td>
+		<td>{row_cn}</td>
+		<td>{row_mail}</td>
+		<td>{row_status}</td>
+		<td>{row_participants}</td>
+	</tr>
+<!-- END row -->
+<!-- BEGIN row_empty -->
+	<tr>
+		<td colspan="7" align="center"><font color="red"><b>{message}</b></font></td>
+	</tr>
+<!-- END row_empty -->
+</div>
Index: /branches/2.2/reports/templates/default/report_institutionalAccounts_group_print.tpl
===================================================================
--- /branches/2.2/reports/templates/default/report_institutionalAccounts_group_print.tpl	(revision 4570)
+++ /branches/2.2/reports/templates/default/report_institutionalAccounts_group_print.tpl	(revision 4570)
@@ -0,0 +1,145 @@
+<!-- BEGIN body -->
+<style type="text/css">
+.myBox
+{
+    margin: 24px 0px 0px 0px;
+    border: 0px solid #ffffff;
+    color: #000000;
+    width: 99%;
+    padding: 20px;
+    text-align: left;
+    background-color: #ffffff;
+    border: 3px solid #ffffff;
+
+
+}
+
+.myBox2
+{
+    margin: 24px 0px 0px 0px;
+    border: 0px solid #ffffff;
+    width: 99%;
+    padding: 5px;
+    text-align: left;
+    background-color: #ECECE5;
+    border: 3px solid #ECECE5;
+}
+
+#loader{
+position:absolute;
+width:100%;
+height:600px;
+}
+
+.info{
+width:100px;
+float:left;
+margin-right:25%;
+margin-top: 300px;
+}
+
+.style1 {
+	font-size: 20px;
+	font-weight: bold;
+	color: #0000FF;
+}
+.style2 {
+	font-size: 18px
+	font-weight: bold;
+}
+.style4 {color: #000000}
+
+.style6 {
+	font-size: 12px;
+	font-weight: bold;
+	color: #0000FF;
+}
+</style>
+ <div id="conteudo"> <!-- Elemento camufla o contéudo até que todas as tags de imagens sejam carregadas -->
+<input type="hidden" id="accounts_form_imapDelimiter" value="{imapDelimiter}">
+{error_messages}
+<p>
+   <div align="center">
+		<table width="90%"  border="0">
+			<tr>
+			  <td colspan="2" align="left">
+			  	<div align="right" style="float:right">
+					<form name="back" method="post" action="./index.php?menuaction=reports.uireports_institutionalAccounts.report_institutionalAccounts_group">
+			  	    	<input type="hidden" name="organizacaodn" value="{organizacaodn}">
+			  	    	<input type="button" value="{lang_back}" onClick="document.back.submit()">
+			      </form>
+	            </div>
+			  </td>
+		      <td width="9%" align="left">				  
+				  <div align="right" style="float:left">
+					<form action="./index.php?menuaction=reports.uireports_institutionalAccounts.report_institutionalAccounts_print_pdf" method="post" name="pdf" target="_blank">
+				      <input name="button" type="button" onClick="document.pdf.submit()" value="Imprimir">
+				      <input type="hidden" name="setor" value="{sector_name}">
+				      <input type="hidden" name="setordn" value="{sector_namedn}">			
+				      <input type="hidden" name="subtitulo" value="{subtitulo1}">			
+				    </form>		      
+			      </div>
+		  </tr>
+        </table>
+		<table border="0" width="90%">
+			<tr>
+			  <td colspan="3" align="left"><div align="center" class="style1">{subtitulo}</div><br></td>
+	      </tr>
+			<tr>
+			  <td colspan="3" align="left"><div align="center" class="style6">{subtitulo1}</div><br></td>
+	      </tr>
+			<tr>
+			  <td width="25%" align="left"><div align="left" class="style2">{lang_report date}:{data_atual}</div></td>
+		      <td width="60%" align="left">{lang_total_users}&nbsp;<strong>{cont_user}</strong>			  </td>
+		      <td width="15%" align="left">
+			  <div align="right" class="style2">{titulo}</div></td>
+		  </tr>
+			<tr>
+			  <td colspan="3" align="left">
+				<table width="100%" border="0" align="center">
+					<tr bgcolor="{th_bg}">
+						<td colspan="2"></td>
+					</tr>
+					<tr>
+				  		<td width="50%">&nbsp;
+						</td>
+				  	    <td width="50%"><div align="right">{lang_page_now}:&nbsp;<strong>{page_now}</strong>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;{lang_total_pages}:&nbsp;<strong>{cont_page}</strong>&nbsp;&nbsp;<br></div></td>
+					</tr>
+			  </table>
+			</td>
+		  </tr>
+		</table>
+   </div>
+ 
+	<div align="center">
+		<table border="0" width="90%">
+			<tr>
+			  <td colspan="3" align="center">{pages}</td>
+		  </tr>
+			<tr bgcolor="{th_bg}">
+				<td width="20%">{lang_name}</td>
+				<td width="20%">{lang_report email}</td>
+				<td width="5%">{lang_status}</td>
+				<td width="20%">{lang_participants}</td>
+			</tr>
+			{rows}
+		</table>
+	</div>
+<!-- END body -->
+<!-- BEGIN rowpag -->
+    <b>{paginat}</b>
+<!-- END rowpag -->
+<!-- BEGIN row -->
+	<tr bgcolor="{tr_color}">
+		<td>{row_cn}</td>
+		<td>{row_mail}</td>
+		<td>{row_status}</td>
+		<td>{row_participants}</td>
+	</tr>
+<!-- END row -->
+<!-- BEGIN row_empty -->
+	<tr>
+		<td colspan="7" align="center"><font color="red"><b>{message}</b></font></td>
+	</tr>
+<!-- END row_empty -->
+</div>
Index: /branches/2.2/reports/templates/default/index.tpl
===================================================================
--- /branches/2.2/reports/templates/default/index.tpl	(revision 3948)
+++ /branches/2.2/reports/templates/default/index.tpl	(revision 4570)
@@ -12,16 +12,20 @@
 </style>
 <table width="90%" border="0" cellspacing="10" cellpadding="0" align="center">
-<!-- TODOS OS USUARIOS DO CONTEXTO
-	<tr>
-	  <td width="1%" align="center"><img src='./templates/default/images/user.png'></td>
-	  <td>
-	 	 <a href="../index.php?menuaction=reports.uireports.report_users_print">{lang_rel_user_all}</a>
-	  </td>
-  	</tr>
--->	
 	<tr>
 	  <td width="1%" align="center"><img src='./templates/default/images/user.png'></td>
 	  <td>
 	 	 <a href="../index.php?menuaction=reports.uireports_users.report_users_group">{lang_rel_user_org}</a>
+	  </td>
+  	</tr>
+	<tr>
+          <td width="1%" align="center"><img src='./templates/default/images/institutional_account.png'></td>
+	  <td>
+                 <a href="../index.php?menuaction=reports.uireports_institutionalAccounts.report_institutionalAccounts_group">{lang_rel_institutional_account_org}</a>
+          </td>
+        </tr>
+	<tr>
+          <td width="1%" align="center"><img src='./templates/default/images/mail_share.png'></td>
+          <td>
+                 <a href="../index.php?menuaction=reports.uireports_shareAccounts.report_shareAccounts_group">{lang_rel_share_account_org}</a>
 	  </td>
   	</tr>
Index: /branches/2.2/reports/templates/default/report_shareAccounts_group.tpl
===================================================================
--- /branches/2.2/reports/templates/default/report_shareAccounts_group.tpl	(revision 4570)
+++ /branches/2.2/reports/templates/default/report_shareAccounts_group.tpl	(revision 4570)
@@ -0,0 +1,102 @@
+<style type="text/css">
+#link a:hover { 
+	background-color:#ffffcc; 
+} 
+.style2 {
+	font-size: 16px;
+	font-family: Arial, Helvetica, sans-serif;
+}
+.style3 {color: #999999}
+</style>
+<!-- BEGIN list -->
+<p>
+<div align="center">
+   <table border="0" width="90%">
+    <tr>
+	 	<td align="left">
+			<div align="center" class="style2">{lang_Report_of_shared_accounts_of_the_Organization}:<br><br>&nbsp;<font color="blue">{context_display}</font><br><br>
+	 	    </div></td>
+ 	 </tr>
+    <tr>
+      <td align="left"><form method="POST" action="./index.php?menuaction=reports.uireports_shareAccounts.report_shareAccounts_group">
+  {lang_search}:
+      <select name="organizacaodn">
+     			    {group_name}
+	  </select>
+      &nbsp;&nbsp;&nbsp;<input name="Enviar" type="submit" value="Enviar">
+      &nbsp;&nbsp;&nbsp;<input name="button" type="button" onClick="document.location.href='{back_url}'" value="{lang_back}">
+            </form>
+	  </td>
+     </tr>
+   </table>
+</div>
+ 
+ <div align="center">
+  <table border="0" width="90%">
+   <tr>
+	<form  name="org" method="POST" action="./index.php?menuaction=reports.uireports_shareAccounts.report_shareAccounts_group_setor_print">
+    	<td width="89%">
+			<div align="center">
+				<font color="#0000FF"><strong><font size="3" face="Arial, Helvetica, sans-serif">
+    		   		<div onClick="document.org.submit()"><a href="#">{organizacao}</a></div>
+    			</font></strong></font>
+			</div>
+		</td>
+        <td width="9%">
+			<div align="right">
+   		   		  <div style="float:left" onClick="document.org.submit()" align="right">
+				  	<font color="#0000FF">
+						<strong>
+							<font size="2" face="Arial, Helvetica, sans-serif">
+								<a href="#">{all_user}</a>
+							</font>
+						</strong>
+					</font>
+				</div>
+					<strong>
+						<font size="2" face="Arial, Helvetica, sans-serif">
+							{total_user}
+						</font>
+					</strong>
+			</div>
+		</td>
+        <td width="2%">
+			<input type="hidden" name="setor" value="{organizacao}">
+			<input type="hidden" name="organizacao" value="{organizacao}">
+			<input type="hidden" name="setordn" value="{organizacaodn}">
+			<input type="hidden" name="organizacaodn" value="{organizacaodn}">
+		</td>
+	</form>										
+   </tr>
+   <tr bgcolor="{th_bg}">
+     <td colspan="3">{lang_groups_names}</td>
+   </tr>
+
+   {rows}
+
+  </table>
+ </div>
+<!-- END list -->
+
+<!-- BEGIN row -->
+   <tr bgcolor="{tr_color}">
+<form name="{formname}" method="POST" action="./index.php?menuaction=reports.uireports_shareAccounts.report_shareAccounts_group_setor_print">
+    <td width="30%">
+		<div onClick="{formsubmit}">
+			<a href="#">{sector_name}</a>
+			<input type="hidden" name="setor" value="{sector_name}">
+			<input type="hidden" name="organizacao" value="{organizacao}">
+			<input type="hidden" name="setordn" value="{sector_namedn}">
+			<input type="hidden" name="organizacaodn" value="{organizacaodn}">
+			<input type="hidden" name="sectornamedncompleto" value="{sector_namedn_completo}">
+		</div>
+	</td>
+</form>
+   </tr>
+<!-- END row -->
+
+<!-- BEGIN row_empty -->
+	<tr>
+    	<td colspan="5" align="center"><font color="red"><b>{message}</b></font></td>
+	</tr>
+<!-- END row_empty -->
Index: /branches/2.2/reports/templates/default/report_institutionalAccounts_group.tpl
===================================================================
--- /branches/2.2/reports/templates/default/report_institutionalAccounts_group.tpl	(revision 4570)
+++ /branches/2.2/reports/templates/default/report_institutionalAccounts_group.tpl	(revision 4570)
@@ -0,0 +1,102 @@
+<style type="text/css">
+#link a:hover { 
+	background-color:#ffffcc; 
+} 
+.style2 {
+	font-size: 16px;
+	font-family: Arial, Helvetica, sans-serif;
+}
+.style3 {color: #999999}
+</style>
+<!-- BEGIN list -->
+<p>
+<div align="center">
+   <table border="0" width="90%">
+    <tr>
+	 	<td align="left">
+			<div align="center" class="style2">{lang_Report_of_institutional_accounts_of_the_Organization}:<br><br>&nbsp;<font color="blue">{context_display}</font><br><br>
+	 	    </div></td>
+ 	 </tr>
+    <tr>
+      <td align="left"><form method="POST" action="./index.php?menuaction=reports.uireports_institutionalAccounts.report_institutionalAccounts_group">
+  {lang_search}:
+      <select name="organizacaodn">
+     			    {group_name}
+	  </select>
+      &nbsp;&nbsp;&nbsp;<input name="Enviar" type="submit" value="Enviar">
+      &nbsp;&nbsp;&nbsp;<input name="button" type="button" onClick="document.location.href='{back_url}'" value="{lang_back}">
+            </form>
+	  </td>
+     </tr>
+   </table>
+</div>
+ 
+ <div align="center">
+  <table border="0" width="90%">
+   <tr>
+	<form  name="org" method="POST" action="./index.php?menuaction=reports.uireports_institutionalAccounts.report_institutionalAccounts_group_setor_print">
+    	<td width="89%">
+			<div align="center">
+				<font color="#0000FF"><strong><font size="3" face="Arial, Helvetica, sans-serif">
+    		   		<div onClick="document.org.submit()"><a href="#">{organizacao}</a></div>
+    			</font></strong></font>
+			</div>
+		</td>
+        <td width="9%">
+			<div align="right">
+   		   		  <div style="float:left" onClick="document.org.submit()" align="right">
+				  	<font color="#0000FF">
+						<strong>
+							<font size="2" face="Arial, Helvetica, sans-serif">
+								<a href="#">{all_user}</a>
+							</font>
+						</strong>
+					</font>
+				</div>
+					<strong>
+						<font size="2" face="Arial, Helvetica, sans-serif">
+							{total_user}
+						</font>
+					</strong>
+			</div>
+		</td>
+        <td width="2%">
+			<input type="hidden" name="setor" value="{organizacao}">
+			<input type="hidden" name="organizacao" value="{organizacao}">
+			<input type="hidden" name="setordn" value="{organizacaodn}">
+			<input type="hidden" name="organizacaodn" value="{organizacaodn}">
+		</td>
+	</form>										
+   </tr>
+   <tr bgcolor="{th_bg}">
+     <td colspan="3">{lang_groups_names}</td>
+   </tr>
+
+   {rows}
+
+  </table>
+ </div>
+<!-- END list -->
+
+<!-- BEGIN row -->
+   <tr bgcolor="{tr_color}">
+<form name="{formname}" method="POST" action="./index.php?menuaction=reports.uireports_institutionalAccounts.report_institutionalAccounts_group_setor_print">
+    <td width="30%">
+		<div onClick="{formsubmit}">
+			<a href="#">{sector_name}</a>
+			<input type="hidden" name="setor" value="{sector_name}">
+			<input type="hidden" name="organizacao" value="{organizacao}">
+			<input type="hidden" name="setordn" value="{sector_namedn}">
+			<input type="hidden" name="organizacaodn" value="{organizacaodn}">
+			<input type="hidden" name="sectornamedncompleto" value="{sector_namedn_completo}">
+		</div>
+	</td>
+</form>
+   </tr>
+<!-- END row -->
+
+<!-- BEGIN row_empty -->
+	<tr>
+    	<td colspan="5" align="center"><font color="red"><b>{message}</b></font></td>
+	</tr>
+<!-- END row_empty -->
