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

    $codigocli = $_SESSION['idUser'];	
		$resultadados=mysql_query("select id, empresa from crm_cliente where id='".$codigocli."'");
		$resultlembrete=mysql_query("select * from crm_lembrete where codcli='".$codigocli."' order by id desc");
		$result=mysql_query("select * from crm_lembrete where codcli='".$codigocli."' order by id desc");
		$rescli=mysql_query("select empresa, email, email01, email02, email03 from crm_cliente where id='".$codigocli."'");
		$aempre=mysql_fetch_array($rescli);
		$empresa=$aempre['empresa'];
		$email=$aempre['email'];
		$email01=$aempre['email01'];
		$email02=$aempre['email02'];
		$email03=$aempre['email03'];

list($codigo, $empresa)=$linhadados=mysql_fetch_array($resultadados);
?>

<table width="700" height="60" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td height="30" bgcolor="#E9E9E9"><span class="titulo">Lista de 
      chamados</span></td>
  </tr>
  <tr>
    <td height="30" bgcolor="#E9E9E9">
    <table width="700" border="0" align="center" cellpadding="2" cellspacing="0" bgcolor="#FFFFFF">
  <form id="form1" name="form1" method="post" action="miolo.php?miolo=insertChamado">
<input type="hidden" name="codcli" value="<? echo $codigocli; ?>">
<input name="email" value="<? echo $email; ?>" type="hidden">
<input name="email01" value="<? echo $email01; ?>" type="hidden">
<input name="email02" value="<? echo $email02; ?>" type="hidden">
<input name="email03" value="<? echo $email03; ?>" type="hidden">
    <tr bgcolor="#CCCCCC">
      <td height="30" colspan="2" align="left" valign="middle">
      
      <table width="700" height="25" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="546" height="25"><span class="titulo">Chamados da empresa: <? echo $empresa; ?></span></td>
          <td width="154">&nbsp;</td>
        </tr>
      </table></td>
    </tr>
    <tr>
      <td colspan="2"><span class="titulo">Novo Chamado:</span></td>
    </tr>
    <tr>
      <td colspan="2"><textarea name="lembrete" cols="85" rows="5"></textarea></td>
    </tr>
    <tr>
      <td height="39" colspan="2" align="center" valign="middle">
        <input name="enviar" type="submit" id="enviar" value="Enviar" />
        <input type="reset" name="Reset" value="Limpar" />
      </td>
    </tr>
    <tr bgcolor="#CCCCCC">
	
    <td colspan="2"><hr /></td></tr>
    </table>    
    
    </td>
  </tr>
  <table align="center" border="1" width="100%" bordercolor="#999999">
    <?


unset($linhadados, $resultadados);
require 'auxiliares/formata-data.php';
while ($linhalembrete=mysql_fetch_array($resultlembrete)){
list($cod, $codcli, $lembrete, $data_hora)=$linhalembrete;

?>
<tr><td bgcolor='#ffffff'><span class='rotulo'>Data/Hora:</span></td><td bgcolor='#ffffff'><span class='rotulo'><?php echo dataPTBRTime($data_hora); ?> </span></td></tr>
	  <tr><td bgcolor='#ffffff'><span class='rotulo'>Chamado:</span></td><td bgcolor='#ffffff'><span class='rotulo'><b><?php echo $lembrete;?></b></span></td></tr>
      <tr><td bgcolor='#ffffff' colspan='2' height='2'><hr /></td></tr>
<?
}
unset($linhalembrete,$reultalembrete);
}
$query=mysql_query("update crm_cliente set statusle='1' where id='".$codigocli."'");
?>

</table>