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

  $result = mysql_query("select id, empresa, email, email01, email02, email03 from crm_cliente  where statusCliente = 1 order by empresa asc");
   //and credito<>0 

  ?>
  <table width="100%" height="58" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF">
    <!-- <tr>
      <td height="30" align="center" bgcolor="#DDDDDD"><a href="gerenciar.php?arquivo=inserirempresa.php"><strong><font color="#000000" size="2" face="Arial, Helvetica, sans-serif">Cadastrar Empresa</font></strong></a></td>
      <td height="30" colspan="7" align="center" bgcolor="#DDDDDD"><a href="datavencida.php" class="titulo"></a><a href="emailsempresa.txt" target="_blank"><strong><font color="#000000" size="2" face="Arial, Helvetica, sans-serif">Gerar Lista  Emails </font></strong></a></td>
    </tr> -->
    <tr class="linha-topo">
      <td width="100" height="25" align="center" valign="middle" ><strong><font size="2" face="Arial, Helvetica, sans-serif">Nome da Empresa </font></strong></td>
<!--       <td width="75" height="25" colspan="1" align="center" valign="middle" ><strong><font size="2" face="Arial, Helvetica, sans-serif">Chamado</font></strong></td>
 -->      <td width="48" height="25" align="center" valign="middle" ><strong><font size="2" face="Arial, Helvetica, sans-serif">Arquivos</font></strong></td>
      <td width="48" align="center" valign="middle" ><strong><font size="2" face="Arial, Helvetica, sans-serif">Relat&oacute;rios</font></strong></td>
      <td width="48" align="center" valign="middle" ><strong><font size="2" face="Arial, Helvetica, sans-serif">Enviar Arquivo</font></strong></td>
      <td width="48" align="center" valign="middle" ><strong><font size="2" face="Arial, Helvetica, sans-serif">Ver Hist&oacute;rico</font></strong></td>
      <td width="74" height="25" align="center" valign="middle" ><strong><font size="2" face="Arial, Helvetica, sans-serif">Alterar</font></strong></td>
      <td width="47" height="25" align="center" valign="middle" ><strong><font size="2" face="Arial, Helvetica, sans-serif">Excluir</font></strong></td>
    </tr>
   
    <?
  while($linha = mysql_fetch_array($result)){
  list($cod, $empresa, $email01, $email02, $email03) = $linha;

  // if ($email!=""){
  // 	$listaemails.=$email.";\n ";
  // }
  // if ($email01!=""){
  // 	$listaemails.=$email01.";\n ";
  // }
  // if ($email02!=""){
  // 	$listaemails.=$email.";\n ";
  // }
  // if ($email03!=""){
  // 	$listaemails.=$email.";\n ";
  // }
  echo "<tr bgcolor='#cccccc'><td colspan='8' height='3'></td></tr>
  <tr>
      <td height='35' align='center' width='213'><font size='2' face='Arial, Helvetica, sans-serif'><b>".utf8_encode($empresa)."</b></font> </td>
      <td height='35' align='center' width='66'><font size='2' face='Arial, Helvetica, sans-serif'><a href='miolo.php?miolo=arquivos&acao=gerenciar&cod=$cod'>Arquivos</a></font></td>
      <td height='35' align='center' width='66'><font size='2' face='Arial, Helvetica, sans-serif'><a href='miolo.php?miolo=relatorios&acao=gerenciar&cod=$cod'> Relatórios</a></font></td>
      <td height='35' align='center'><font size='2' face='Arial, Helvetica, sans-serif'><a href='miolo.php?miolo=enviaArquivo&cod=$cod'>Gerenciar</a></font></td>
      <td height='35' align='center'><font size='2' face='Arial, Helvetica, sans-serif'><a href='miolo.php?miolo=clientes&acao=historico&ref=".sha1($cod)."'>Hist&oacute;rico</a></font></td>
      <td height='35' align='center'><font size='2' face='Arial, Helvetica, sans-serif'><a href='miolo.php?miolo=clientes&acao=alterar&cod=$cod'>Alterar</a></font></td>
      <td height='35' align='center'><font size='2' face='Arial, Helvetica, sans-serif'><a href='miolo.php?miolo=clientes&acao=excluir&cod=$cod'>Excluir</a></font></td>
    </tr>
    <tr bgcolor='#cccccc'><td colspan='8' height='3'></td></tr>";

  }


  // $fp = fopen("emailsempresa.txt", "w"); 
  // fwrite($fp, $listaemails); 
  // fclose($fp); 

  ?>
  </table>

<?php 
}
 ?>