<?php
if($_SESSION['nivel'] == 1 || $_SESSION['nivel'] == 3){
  $queryLembrete = "select * from crm_lembrete where codcli='".$_GET['cod']."' AND codusuario = '".$_SESSION['idUser']."' order by id desc";
  $result = mysql_query($queryLembrete);
  $rescli = mysql_query("select empresa, email, email01, email02, email03, login, senha from crm_cliente where id='".$_GET['cod']."'");
  $aempre = mysql_fetch_array($rescli);
  $empresa = $aempre['empresa'];
  $email = $aempre['email'];
  $email01 = $aempre['email01'];
  $email02 = $aempre['email02'];
  $email03 = $aempre['email03'];
  $login = $aempre['login'];
  $senha = $aempre['senha'];
  require 'auxiliares/formata-data.php';
  ?>
  <body onLoad="document.form1.lembrete.focus();">
  <table width="700" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
    <form id="form1" name="form1" method="post" action="miolo.php?miolo=chamados&acao=insert">
  <input type="hidden" name="codcli" value="<? echo $cod; ?>">
  <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">
  <input name="login" value="<? echo $login; ?>" type="hidden">
  <input name="senha" value="<? echo $senha; ?>" 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 height="30" colspan="2"><span class="titulo">Novo Chamado:</span></td>
      </tr>
      <tr>
        <td colspan="2"><textarea name="lembrete" cols="60" rows="5" class="mceEditor"></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" />
      </form><tr bgcolor="#CCCCCC"><td width="93"></td>
      </tr>
      <tr bgcolor="#CCCCCC">
    
      <td colspan="2"><hr /></td></tr>
      <tr>
        <td height="25" colspan="2"><span class="rotulo">Lista de chamados enviados</span></td>
    </tr>

  <?

  while ($linha = mysql_fetch_array($result)){
  list($cod, $codcli, $lembrete, $data_hora) = $linha;

  ?>
    <tr><td><span class='rotulo'>Data/Hora:</span></td><td><span class='rotulo'><?php echo dataPTBRTime($data_hora); ?> </span></td></tr>
    <tr><td><span class='rotulo'>Lembrete:</span></td><td><span class='rotulo'><b><?php echo $lembrete; ?></b></span></td></tr>
    <tr><td colspan='2'><hr /></td></tr>
        <?
  }
  ?>
  </table>

<?php 
}
?>