<?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-comment"></span><span class="titulo">Sugestões</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" src="jquery/jquery.maskedinput-1.3.min.js"></script>
  <script type="text/javascript">
  	$(function() {
		$("#menu_opcoes").accordion({ collapsible: true, active: false });
		$("#dataSugestao").datepicker({dateFormat:'dd/mm/yy',showOn:"button",buttonImage:"imagens/calendar.png", buttonImageOnly:true}).css('display','inline-block');
		$("#dataSugestao").mask("99/99/9999");
		$('#dialogExcSugest').dialog({autoOpen: false, width: 400, modal:true});
	});
	function excluirSugestao(id){
		$('#idExcSugestao').val(id);
		$('#dialogExcSugest').dialog('open');
	}
	function mudaSituacao(situacao, id){
		situacao = (situacao == 0 ? 1 : 0);
		$('#idSugestao').val(id);
		$('#situacaoAlt').val(situacao);
		$('#formAltSugestao').submit();		
	}
  </script>
  
 <div class="formulario">
   <form action="sugestoes.php" method="post"> 
   <div class="ui-widget ui-widget-content menus" align="right">
  	<div class="menus_esq">
    <?php
        require 'beans/GerenciadorSugestoes.class.php';
		$service = ServiceMessages::getInstancia(); $service->printMessage();
		$sugestoesMB = new GerenciadorSugestoes();
		$sugestoes = array();
		$total = 0;
		$data = (!empty($_POST['dataSugestao']) ? $_POST['dataSugestao'] : "");
		$texto = (!empty($_POST['texto']) ? $_POST['texto'] : "");
		$situacao = (!empty($_POST['situacao']) ? $_POST['situacao'] : "");
		$todos = (!empty($_POST['todos']) ? $_POST['todos'] : "");
		if($texto != "" || $data != "" || $situacao != "" || $todos != ""){
			$sugestoes = $sugestoesMB->buscarSugestoes($texto, $data,$situacao);
			$total = count($sugestoes);
	?>
    <strong>Total: ( <strong id="total"> <?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 { $sugestoes = $sugestoesMB->getSugestoes(); } ?>
    </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>Busca <input type="text" name="texto" id="texto" class="ui-widget ui-widget-content ui-corner-all campo" size="50"/></li>
        <li>Data <br /><input type="text" name="dataSugestao" id="dataSugestao" size="30" class="ui-widget ui-widget-content ui-corner-all campo"/></li>
        <li>Situação <select name="situacao" id="situacao" class="ui-widget ui-widget-content ui-corner-all campoSelect">
        	<option value="0">Não lida</option>
            <option value="1">Lida</option>
        	</select></li>
        </ul>
	</div>
  </div>
</form>

<ul class="sugestoes">
<?php
	foreach($sugestoes as $s){
		$data = $s->getDataEnvio();
        echo "<li class=\"ui-widget ui-widget-content ui-corner-all\">
			<div class=\"ui-widget ui-widget-content ui-corner-all usuario\">
			<img src=\"imagens/usuario.gif\" align=\"absmiddle\"/> ".$s->getUsuario()."
			<img src=\"imagens/situacao".$s->getSituacao().".png\" class=\"situacao\" onclick=\"mudaSituacao(".$s->getSituacao().", ".$s->getId().");\" title=\"\"/>
			</div>
			<div class=\"texto\">".$s->getTexto()."</div>
				<div class=\"opcoes\">
				<img src=\"imagens/excluir.png\" title=\"Excluir\" onclick=\"excluirSugestao(".$s->getId().");\"/>
				<div class=\"opcoesDir\"><div class=\"data\">".$s->getDataEnvio()."</div></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-comment"></span> Total: <?php echo $total; ?></span>
    <a name="fim"></a>
</div>
</div>
        
  <form method="post" action="Servico.php" id="formExcSugestoes">
  	<input type="hidden" name="metodo" value="GerenciadorSugestoes.excluirSugestao" />
  	<input type="hidden" id="idExcSugestao" name="id" />
  </form>
  
  <form method="post" action="Servico.php" id="formAltSugestao">
  	<input type="hidden" name="metodo" value="GerenciadorSugestoes.alterarSugestao" />
  	<input type="hidden" id="idSugestao" name="id" />
    <input type="hidden" id="situacaoAlt" name="situacao" />
  </form>
  
  <div id="dialogExcSugest" title="Excluir Sugestão">
  	<p>Tem certeza que deseja excluir esta sugestão?</p>
    <div class="ui-widget ui-widget-content ui-corner-all texto-conteudo" align="center">
    	<input type="button" onclick="javascript: $('#formExcSugestoes').submit();" value="OK" class="ui-button ui-widget ui-widget-header ui-corner-all"/>
        <input type="button" onclick="javascript: $('#dialogExcSugest').dialog('close');" value="Cancelar" class="ui-button ui-widget ui-widget-header ui-corner-all"/>
    </div>
  </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>
