<?php
if($_SESSION['nivel'] == 1) {
  	
  $codigocli = $_GET['cod'];
  $result = mysql_query("select * from crm_arquivo where id_cliente = '".$codigocli."' AND statusArquivo = 1 order by dataInsercao desc");
  $rescli = mysql_query("select cli.empresa, cli.email, cli.email01, cli.email02, cli.email03, cli.login, cli.senha from crm_cliente cli where cli.id='".$codigocli."'") or die (mysql_error());
  $aempre = mysql_fetch_array($rescli);
  list($empresa, $email, $email01, $email02, $email03, $login, $senha) = $aempre;

?>

    <table width="600" border="0" align="center" cellpadding="2" cellspacing="2" bgcolor="#FFFFFF">
    <form id="form1" name="form1" method="post" action="miolo.php?miolo=uploadArquivo" enctype="multipart/form-data">
  <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 class="linha-topo">
        <td height="35" colspan="2" align="left" valign="middle"><span class="titulo">Arquivos enviados para a empresa: <? echo utf8_encode($empresa); ?></span></td>
      </tr>
      <tr>
        <td colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td width="129" height="35" align="center" valign="middle" bgcolor="#F8F8F8"><span class="rotulo"><font color="#70292b"><b>Novo Arquivo:</b></font></span></td>
        <td height="35" align="left" valign="middle" bgcolor="#F8F8F8"><input name="nomearquivo" type="file" id="nomearquivo">
        <input name="empresa" type="hidden" id="empresa" value="<? echo $empresa; ?>"></td>
      </tr>
      <tr>
        <td width="129" height="35" align="center" valign="middle" bgcolor="#F8F8F8"><span class="rotulo"><font color="#70292b"><b>Descri&ccedil;&atilde;o:</b></font></span></td>
        <td height="35" align="left" valign="middle" bgcolor="#F8F8F8">
        <textarea name="upload" id="upload" cols="45" rows="5"></textarea></td>
      </tr>
      <tr>
        <td height="35" colspan="2" align="center" valign="middle" bgcolor="#F8F8F8"><input name="enviar" type="submit" id="enviar" value="Enviar" />
        <input type="reset" name="Reset" value="Limpar" />
        <label></label>
      </form>
      
      <tr>
  	
        <td height="13" colspan="2"><hr /></td></tr>
  	  <tr>
        <td height="25" colspan="2" align="center" valign="middle" ><span class="titulo">Lista de Arquivos Enviados: </span></td>
  	  </tr>
  <table width="600" align="center" border="0" cellpadding="1" cellspacing="3">
  <?

  require 'auxiliares/formata-data.php';
  while ($linha=mysql_fetch_array($result)){
  list($cod, $codcli, $nomearquivo, $upload, $down, $data_hora)=$linha;

  if ($down == '1'){
  	$hein="Sim";
  } else {
  	$hein="Nao";
  }

  ?>
  <tr><td colspan="3" height='25'><span class='titulo'>Protocolo:</span><?php echo $cod;?></td></tr>
    <tr><td colspan="3" height='25'><span class='titulo'>Data/Hora:</span><?php echo dataPTBRTime($data_hora);?></td></tr>
  	  <tr><td colspan="3" height='25'><span class='titulo'>Arquivo:</span><a href='arquivos/crm/<? echo $nomearquivo;?>' target='_blank'><b><?php echo $upload; ?></b></a>
  	  <tr><td colspan='3'><span class-"titulo" >Baixado: </span><?php echo $hein; ?></td></tr>
        <tr><td colspan='3' bgcolor='#E9E9E9' height='1'><hr /></td></tr>

  <?

  }
  
  ?>
  </table>
  </table>
  <?
}
?>