<?

if($_SESSION['nivel'] == '2'){

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

$codigocli=$_SESSION['idUser'];

$resultadados=mysql_query("select id, empresa from crm_cliente where id='$codigocli'");
$resultupload=mysql_query("select * from crm_agenda where codcli='$codigocli' and down = 's' order by id desc");

list($codigo, $empresa)=$linhadados=mysql_fetch_array($resultadados);
?>
<table width="700" height="183" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td width="450" bgcolor="#FFFFFF" class="style7"><? echo "Empresa: $empresa"; ?></td>
    <td height="30" colspan="5" align="right" valign="middle" bgcolor="#FFFFFF"><a href="javascript:history.go(-1);" class="style7">Voltar</a></td>
  </tr>

  <tr> 
    <td height="30" colspan="6" bgcolor="#E9E9E9"><span class="style5">Lista de 
      Downloads Agenda </span></td>
   
  </tr>
  <?
unset($linhadados, $resultadados);
while ($linhaupload=mysql_fetch_array($resultupload)){
list($cod, $codcli, $compromisso, $dtcomp, $data, $hora, $arquivo, $down)=$linhaupload;
list($ano, $mes, $dia)=explode("-",$data);
$data="$dia/$mes/$ano";

list($ano, $mes, $dia)=explode("-",$dtcomp);
$dtcomp="$dia/$mes/$ano";

echo " <tr><td bgcolor='#ffffff'><font size='2' face='arial'>Compromisso:</font></td><td bgcolor='#ffffff'><font size='2' face='arial'><b>$compromisso</b></font></td></tr>
<tr><td bgcolor='#ffffff'><span class='style6'>Data de vencimento do compromisso:</span></td><td bgcolor='#ffffff'><span class='style6'>$dtcomp  </span></td></tr>
<tr><td bgcolor='#ffffff'><span class='style6'>Data/Hora do Compromisso:</span></td><td bgcolor='#ffffff'><span class='style6'>$data- $hora  </span></td></tr>
	  <tr><td bgcolor='#ffffff'><span class='style6'>Arquivo:</span></td><td bgcolor='#ffffff'><span class='style6'><a href='arquivos/crm/$arquivo'><b>$arquivo</b></a></span></td></tr>
      <tr><td colspan='2' bgcolor='#ffffff'><hr /></td></tr>";
}

unset($linhaupload, $resultupload);
$query=mysql_query("update cliente set statusag='SIM' where id='$codigo'");

}
?>
</table>