<?php
error_reporting(0);
ini_set("display_errors", 0 );
header('Content-Type: text/html; charset=utf-8');
include("configuracao.php");//confirma no banco de dados
include("inclusos/funcoes.php");
include("seguranca.php"); // Inclui o arquivo com o sistema de seguran?a
protegePagina(); // Protege a página

if($_GET['AtualizaAviso'] == "Sim"){
	$idaviso = $_REQUEST['idaviso'];
	$idusuario_leitura = $_REQUEST['idusuario'];
    $idfilial = $_SESSION['idfilial_usuario'];
	$AlterarAviso = Alterar("avisos", "status='Lido', idusuario_leitura='$idusuario_leitura', idfilial='$idfilial'", "idaviso", $idaviso);
	$redireciona = VerificaSqlSemAlert($AlterarAviso, "listar_avisos.php?idusuario=".$idusuario_leitura."&cargo=".$_GET['cargo']."", "listar_avisos.php?idusuario=".$idusuario_leitura."&cargo=".$_GET['cargo']."");	
}



?>
<!doctype html>
<html ng-app="myApp">
<head>
<title>LISTA DE AVISOS</title>

<script src="https://code.jquery.com/jquery-1.7.1.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/themes/base/minified/jquery-ui.min.css" type="text/css" />
<script type="text/javascript" src="https://code.jquery.com/ui/1.10.1/jquery-ui.min.js"></script> 
<script type="text/javascript" src="inclusos/jquery-ui-1.8.20.custom.min.js"></script>
<link href="inclusos/css_precopratico.css" rel="stylesheet" type="text/css">

<style type="text/css">
.TextoVerdeMax {
	color: #060;
}
body {
	background-color: #FFFFFF;
}
</style>
<meta charset="utf-8">
</head>

<body>
<table width="100%" border="0" cellspacing="2" cellpadding="0">
  <tr>
    <td height="60" align="center" bgcolor="#F0B656"><span class="TituloBranco"><strong class="TextoCinzaGrande">AVISOS</strong></span><strong class="TextoCinzaGrande"></strong></td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="3" style="border:1px solid #333;">
      <tr>
        <td style="background-color:#CCC;"><strong>DATA</strong></td>
        <td style="background-color:#CCC;"><strong>TITULO</strong></td>
        <td width="10" align="center" style="background-color:#CCC;"><strong>STATUS</strong></td>
        <td width="10" align="center" style="background-color:#CCC;"><strong>ACESSAR</strong></td>
        <td width="10" align="center" style="background-color:#CCC;">&nbsp;</td>
      </tr>
      <?php
	  $SelecionaAviso = Seleciona("avisos", "WHERE status = 'Aberto' AND idusuario='".$_GET['idusuario']."' OR cargo='".$_GET['cargo']."'", "");
	  while($aviso = mysql_fetch_array($SelecionaAviso)){			  
		  		  
	  ?>
      <tr >
        <td style="border:1px solid #333;"><?php echo date('d/m/Y H:i:s', strtotime($aviso['datacadastro']));?></td>
        <td style="border:1px solid #333;"><?php echo $aviso['titulo'];?></td>
        <td align="center" style="border:1px solid #333;"><?php echo $aviso['status'];?></td>
        <td align="center" style="border:1px solid #333;">
		<?php 
		if($aviso['destino'] == "compra"){
		?>
		<a href="index.php?pagina=listar_compras_obra.php&idobra=<?php echo $aviso['idobra'];?>&idorcamento=<?php echo $aviso['idorcamento_compras'];?>&AbrirOrcamento=Sim&Origem=Compras" target="_parent">ACESSAR</a>
		<?php } ?>  
              
        </td>
        <td align="center" style="border:1px solid #333;">
        <?php if($aviso['status'] == "Aberto"){?>
        <div id="<?php echo $aviso['idaviso']; ?>"> 
        <a href="listar_avisos.php?idaviso=<?php echo $aviso['idaviso'];?>&idusuario=<?php echo $_GET['idusuario'];?>&cargo=<?php echo $_GET['cargo'];?>&AtualizaAviso=Sim">
        <img src="img/icone_sucesso_inativo.png" width="24" height="24" alt="" style="cursor:pointer;">
        </a>
        </div>
        <?php }else{?>
        <img src="img/icone_sucesso.png" width="24" height="24" alt="">
        <?php }?>
        </td>
        </tr>
      <?php 
	  }?>         

    </table></td>
  </tr>
</table>
</body>
</html>
