<?php ob_start(); @session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/templateCliente.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>E-TIcons, Empresa de tecnologia</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<link rel="stylesheet" href="jquery/skin.css" media="screen" />
<link rel="stylesheet" href="css/cssCliente.css" media="screen"/>
<script type="text/javascript" src="jquery/jquery-1.8.2.js"></script>
<script type="text/javascript" src="jquery/jquery-ui-1.9.1.custom.min.js"></script>
<script type="text/javascript" src="jquery/jquery-themeswitchertool.js"></script>
<script type="text/javascript" src="jquery/jquery-clientes.js"></script>
</head>
<body>
<?php
$usuarioLogado = $_SESSION['usuarioCliente'];
if($usuarioLogado == NULL || $usuarioLogado == ""){ 
	header('location: login.php');
} else {
	$nivel = $_SESSION['nivel'];
	$display = ($nivel == '2' ? '' : 'none');
?>
<div class="tudo">
  <div class="topoAdmin">
    <div class="topo_int"> <img src="imagens/bg_topo_esq_preto.png" align="left"/>
      <div class="opcoes_topo"> 
        <form action="./Servico.php" method="post" name="formSair">
          <input type="hidden" name="metodo" value="GerenciadorUsuario.sair" />
          <ul id="menuTopo">
            <li class="usuario" id="usuario"><?php echo @utf8_encode($usuarioLogado); ?></li>
            <li><span class="ui-icon ui-icon-close"></span><a onclick="javascript:formSair.submit();">Sair</a></li>
            <li><span class="ui-icon ui-icon-home"></span><a href="inicio.php" title="Inicio">Home</a></li>
            <li><span class="ui-icon ui-icon-help"></span><a href="ajuda.php" title="Ajuda/Help-Desk">Ajuda</a></li>
            <li><span class="ui-icon ui-icon-contact"></span><a href="contato.php" title="Contato">Contato</a></li>
          </ul>
        </form>
      </div>
      <!-- opcoes_topo -->
      <div class="logomarca"><img src="imagens/areacliente.png"/></div>
      <img src="imagens/bg_topo_dir_preto.png" align="right"/> </div>
    <!-- topo_int --> 
  </div>
  <!-- topo -->
  <div class="menu_sup">
    <div class="titulo_pagina"><!-- InstanceBeginEditable name="titulo" -->
    <div class="ui-widget ui-corner-top"><span class="ui-icon ui-icon-person"></span><span class="titulo">Visitantes Interessados</span></div><!-- InstanceEndEditable --></div>
    <ul id="menu_sup" class="ui-menu-horizontal">
      <li><a href="downloads.php"><span class="ui-icon ui-icon-arrowthickstop-1-s"></span>Downloads</a></li>
      <li><a><span class="ui-icon ui-icon-comment"></span>Sugestões</a>
        <ul><li style="display:<?php echo $display; ?>"><a href="sugestoes.php"><span class="ui-icon ui-icon-search"></span>Consultar</a></li><li><a href="cadastroSugestao.php"><span class="ui-icon ui-icon-plus"></span>Novo</a></li></ul>
      </li>
      <li style="display:<?php echo $display; ?>"><a><span class="ui-icon ui-icon-person"></span>Usuários</a>
      	<ul><li><a href="usuarios.php"><span class="ui-icon ui-icon-search"></span>Consultar</a></li><li><a href="usuario.php"><span class="ui-icon ui-icon-plus"></span>Novo</a></li><li><a href="solicitantes.php"><span class="ui-icon ui-icon-contact"></span>Solicitações</a></li>
        	<li style="display:<?php echo $display; ?>"><a><span class="ui-icon ui-icon-contact"></span>Interessados</a><ul><li><a href="interessados.php"><span class="ui-icon ui-icon-search"></span>Consultar</a></li></ul></li>
        </ul>
      </li>
      <li style="display:<?php echo $display; ?>"><a><span class="ui-icon ui-icon-newwin"></span>Sistemas</a>
      	<ul><li><a href="sistemas.php"><span class="ui-icon ui-icon-gear"></span>Gerenciar</a></li><li><a href="cadastroSistema.php"><span class="ui-icon ui-icon-plus"></span>Novo</a></li><li><a href="downloads.php"><span class="ui-icon ui-icon-search"></span>Consultar</a></li></ul>
      </li>
      <li style="display:<?php echo $display; ?>"><a><span class="ui-icon ui-icon-signal-diag"></span>Notícias</a>
      	<ul><li><a href="noticias.php"><span class="ui-icon ui-icon-search"></span>Consultar</a></li><li><a href="cadastroNoticia.php"><span class="ui-icon ui-icon-plus"></span>Novo</a></li></ul>
      </li>
      <li><a><span class="ui-icon ui-icon-wrench"></span>Ferramentas</a>
      	<ul><li style="display:<?php echo $display; ?>"><a href="clientes.php"><span class="ui-icon ui-icon-suitcase"></span>Gerenciar Clientes</a></li><li style="display:<?php echo $display; ?>;"><a href="email.php"><span class="ui-icon ui-icon-mail-closed"></span>Enviar E-mail</a></li><li><a href="ajuda.php"><span class="ui-icon ui-icon-help"></span>Ajuda</a></li><li><a href="configuracoes.php"><span class="ui-icon ui-icon-gear"></span>Configurações</a></li><li><a href="inicio.php"><span class="ui-icon ui-icon-home"></span>Início</a></li><li><a onclick="javascript:formSair.submit();"><span class="ui-icon ui-icon-close"></span>Sair</a></li></ul>
      </li>
    </ul>
  </div>
  <!-- menu_sup -->
  <div class="conteudo"> <!-- InstanceBeginEditable name="conteudo" -->
<?php if($nivel != "2"){ header("location: inicio.php"); } ?>
<script type="text/javascript">
$(function(){
	$('#checks').buttonset();
	$("#menu_opcoes").accordion({ collapsible: true, active: false });
	$('#dialogDetInter').dialog({autoOpen: false, width: 800, modal:true});
	$('#dialogExcInter').dialog({autoOpen: false, width: 400, modal:true});
});
function deletarInteressado(id){
	$('#idInteressado').val(id);
	$('#dialogExcInter').dialog('open');
}
function detalharInteressado(id){
	$.post('detalheInteressado.php',{id:id},function(data){ $('#detalhe').html(data); });
	$('#dialogDetInter').dialog('open');
}
</script>

<div class="formulario">
 <form action="interessados.php" method="post" >
  <div class="ui-widget ui-widget-content menus" align="right">
   <div class="menus_esq">
	 <?php
        include 'beans/GerenciadorSistemas.class.php';
        $service = ServiceMessages::getInstancia();
        $service->printMessage();
		$nome = (!empty($_POST['nome']) ? $_POST['nome'] : "");
		$tipo = (!empty($_POST['tipo']) ? $_POST['tipo'] : "");
		$sistema = (!empty($_POST['sistema']) ? $_POST['sistema'] : "");
		$todos = (!empty($_POST['todos']) ? $_POST['todos'] : "");
		$total = 0;
        $sistemaMB = new GerenciadorSistemas();
        $sistemas = $sistemaMB->listaSistemas();
		if($nome != "" || $tipo != "" || $sistema != "" || $todos != ""){
			include 'beans/GerenciadorInteressados.class.php';
			$interessadosMB = new GerenciadorInteressados();
			$interessados = $interessadosMB->buscarInteressados($nome, $tipo, $sistema);
			$total = count($interessados);
     ?>
     <strong>Total: ( <strong id="totalClientes"> <?php echo $total; ?> </strong> )</strong>
     <a class="icone" title="Fim da página (Totais)" href="#fim"><span class="ui-icon ui-icon-triangle-1-s"></span></a>
     <?php } else { $interessados = array(); } ?>
    </div>
    <div class="menus_dir">
      <input type="checkbox"  name="todos" id="todos" value="todos" <?php echo $todos != "" ? "checked" : ""; ?>/><label for="todos">Todos</label>
      <button type="submit" class="button"><span class="ui-icon ui-icon-search"></span>Buscar</button>
    </div>
  </div>
  <div id="menu_opcoes" class="jquery">
    <h3>Opções de busca</h3>
	<div>
      <ul class="campos-vertical">
        <li>Nome <input type="text" name="nome" id="nome" class="ui-widget ui-widget-content ui-corner-right campo" size="50"/></li>
        <li>Tipo <br /><span id="checks"><input type="checkbox" name="tipo" id="tipoPf" value="PF" <?php echo ($tipo == "PF" ? "checked" : ""); ?>/><label for="tipoPf">PF</label>
        		<input type="checkbox" name="tipo" id="tipoPj" value="PJ" <?php echo ($tipo == "PJ" ? "checked" : ""); ?>/><label for="tipoPj">PJ</label></span>
        </li>
        <li>Sistema <select id="sistema" name="sistema" class="ui-widget ui-widget-content campoSelect">
			<?php
				echo "<option value=\"".$sistema."\" selected=\"selected\">".$sistema."</option>";
                foreach($sistemas as $i => $sis){
					if(utf8_encode($sis->getNome()) != $sistema){
                    	echo "<option value=\"".utf8_encode($sis->getNome())."\">".utf8_encode($sis->getNome())."</option>";
					}
                }
            ?>
           	</select></li>
      </ul>
     </div>
    </div>
 </form>
<br />
 <ul class="noticias">
      	<?php
			foreach($interessados as $in){
				echo "<li class=\"ui-widget ui-widget-content ui-corner-all\">
						<div><table width=\"100%\"><tr><td class=\"titulo\">Nome: ".utf8_encode($in->getNome())."</td>
							<td align=\"right\" class=\"data\">E-mail: ".utf8_encode($in->getEmail())."</td></tr></table></div>
						<img src=\"imagens/user.png\" />
						<div class=\"texto\"><div class=\"subtitulo\">Assunto: ".utf8_encode($in->getAssunto())."</div>
							Mensagem: ".utf8_encode($in->getMensagem())."<fieldset><legend>Sistemas Interessados</legend><ul class=\"sistems\">".utf8_encode($in->getSistemas())."</ul></fieldset></div>
						<div class=\"ui-widget ui-widget-content ui-corner-all rodapeNoticia\"><div class=\"rodapeNoticiaEsq\">".utf8_encode($in->getDataEnvio())."</div>
						<div class=\"rodapeNoticiaDir\"><img src=\"imagens/detalhar.png\" title=\"Detalhar\" onclick=\"detalharInteressado(".$in->getId().");\"/>
							<img src=\"imagens/del.png\" title=\"Deletar\" onclick=\"deletarInteressado(".$in->getId().");\"/>
							<a href=\"email.php?email=".$in->getEmail()."\"><img title=\"Enviar E-mail para este usuário\" src=\"imagens/mail.png\"/></a></div></div>
					 </li>";
			}
		?>
 </ul>
 <div class="ui-widget ui-widget-content menus">
   <a class="icone" title="Voltar ao topo" href="#top"><span class="ui-icon ui-icon-triangle-1-n"></span></a>
   <span class="button"><span class="ui-icon ui-icon-contact"></span> Total: <?php echo $total; ?></span>
 </div>
</div>
    
  <a name="fim"></a>

<form method="post" action="Servico.php" id="formExcInteressado">
  	<input type="hidden" name="metodo" value="GerenciadorInteressados.excluirInteressado" />
  	<input type="hidden" id="idInteressado" name="id" />
</form>
  <div id="dialogExcInter" title="Excluir Interessado" class="dialogs">
  	<p>Tem certeza que deseja excluir este interessado?</p>
    <div class="ui-widget ui-widget-content ui-corner-all texto-conteudo" align="center">
    	<input type="button" onclick="javascript: $('#formExcInteressado').submit();" value="OK" class="ui-button ui-widget ui-widget-header ui-corner-all"/>
        <input type="button" onclick="javascript: $('#dialogExcInter').dialog('close');" value="Cancelar" class="ui-button ui-widget ui-widget-header ui-corner-all"/>
    </div>
</div>
  
<div id="dialogDetInter" title="Detalhe do Interessado" class="dialogs">
	<p id="detalhe">carregando...</p>
</div>

  <!-- InstanceEndEditable --> </div>
  <!-- conteudo -->
  <div class="rodape" id="rodape">&copy; 2008 E-Ticons, Todos os direitos reservados
    <div align="center">- www.e-ticons.com.br, fone/fax: (83) 3241-9973 -</div>
  </div>
  <span id="log" class="ajaxStatus"><img src="imagens/ajaxload.gif"/></span></div>
<!-- tudo --> 
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-27091929-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>
<?php } ?>
</body>
<!-- InstanceEnd --></html>
