<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>SISTEMA CRM VRS. 1.0</title>
<script>
function detalhes(cod) {
	newWindow = window.open('detalhes.php?cod=' + cod,'detalhes','height=100, width=100,resizable=no') ;
	newWindow.focus() ;
}
</script>
<style type="text/css">
<!--
.style5 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; }
-->
<!--
.style6 {font-family: Arial, Helvetica, sans-serif; font-size: 12px;}
-->
<!--
.style7 {font-family: Arial, Helvetica, sans-serif; font-size: 16px; font-weight: bold; }
body {
	background-image: url(../imagens/fundo.gif);
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style>
</head>

<body>
<?
if(count($_GET)>0){
  while (list($variavelNOME,$variavelGET) = each($_GET)) {
    $$variavelNOME= $variavelGET;
  }
}
if(count($_POST)>0){
  while (list($variavelNOME,$variavelPOST) = each($_POST)) {
    $$variavelNOME= $variavelPOST;
  }
}

//var_dump($_SESSION); // var_dump($_COOKIE); // var_dump($_POST); // var_dump($_GET);

if($_COOKIE[logar] == "on"){
	echo "<meta http-equiv=\"refresh\" content=\"0;URL=index.php\">" ;
	echo "</head>";
	echo "<body topmargin=\"300\">"; 
	echo "<center>";
	echo "<font size=\"3\" name=\"Arial\">Acesso negado!!!</font>";
	echo "</center>";
	echo "</body>";
	
	} else {
	
// include 'db.php';
db_connect() or die ("Não foi possível se conectar ao banco de dados!");
$clicli=mysql_query("SELECT empresa FROM crm_cliente WHERE id='".$_SESSION['idUser']."'");
$resultupload=mysql_query("SELECT * FROM crm_documentos WHERE codcli='".$_SESSION['idUser']."' ORDER BY id DESC");
$liclicli=mysql_fetch_array($clicli);
$empresa=$liclicli["empresa"];

?>

<table width="690" height="183" border="0" align="center" cellpadding="0" cellspacing="0">
<!--   <tr> 
    <td height="123" colspan="2"><img src="imagens/tit-sistema.gif" width="700" height="123" /></td>
  </tr> -->
  <tr> 
    <td class="style7" colspan="2"><table border="0" width="100%">
      <tr><td bgcolor="#FFFFFF">Empresa: <?php echo utf8_encode($empresa); ?></td>
    <td align="center" bgcolor="#FFFFFF"></td>
    <!-- <td height="30" align="right" valign="middle" bgcolor="#FFFFFF"><a href="javascript:history.go(-1);" class="style7">Voltar</a></td> -->
  </tr>
</table></td></tr>
  <tr> 
    <td height="30" width="50%" bgcolor="#E9E9E9"><span class="style5">Lista de Certid&otilde;es</span></td>
    <td  height="30" bgcolor="#E9E9E9"></td>
  </tr>
  <?

while ($linhaupload=mysql_fetch_array($resultupload)){
  list($cod, $certidao, $emissao, $documento, $validade, $nomearquivo, $codcli)=$linhaupload;
  list($ano, $mes, $dia)=explode("-",$emissao);
  $emissao="$dia/$mes/$ano";
  list($ano, $mes, $dia)=explode("-",$validade);
  $validade="$dia/$mes/$ano";
?>

<tr><td><span class='style6'>Certid&atilde;o:</span></td><td><span class='style6'><?php echo utf8_encode($certidao); ?></span></td></tr>
<tr><td><span class='style6'>Emiss&atilde;o:</span></td><td><span class='style6'><?php echo utf8_encode($emissao); ?></span></td></tr>
<tr><td><span class='style6'>Validade:</span></td><td><span class='style6'><?php echo utf8_encode($validade); ?></span></td></tr>
<tr><td><span class='style6'>N&#186; do Documento:</span></td><td><span class='style6'><?php echo utf8_encode($documento); ?></span></td></tr>
<tr><td><span class='style6'>Arquivo:</span></td><td><span class='style6'><a href='arquivos/crm/<?php echo $nomearquivo ?>' ><b><?php echo utf8_encode($nomearquivo); ?></b></a></span></td></tr>
<tr><td colspan='2'><hr /></td></tr>";

<?php
  }
  unset($linhaupload, $resultupload);
}

?>
</table>
</body>
</html>
