<script type="text/javascript">
	jQuery(document).ready(function($) {
		jQuery(".link_download").click(function (){
			var id = $(this).attr("id");

			$.ajax({
				type: "GET",
				url: "controladores/crm-envia-cliente/confirma-download.php",
				data: {'id': id},
				success: function( data ){
					alert("Download de Arquivo confirmado");
					window.location.reload();
				}
			});
		});
	});
	
</script>
<?
if($_SESSION['nivel'] == 1){
	$codemp=$cod;
	$result=mysql_query("select * from crm_arquivo where id_cliente = '".$_GET['cod']."' AND statusArquivo = 1 order by dataInsercao desc");
	$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'];
	?>
	<body>
	  <table width="600" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
	    
	    <tr>
		
	      <td height="13" colspan="2"><hr /></td></tr>
		  <tr>
	      <td height="35"><span class="titulo">Lista de Arquivos Enviados </span></td>
	      <td height="35"><a href="miolo.php?miolo=clientes&acao=gerenciar">Voltar</a></td>
		  </tr>
	      <tr>
	      <td height='35' colspan='2' align='left' valign='middle'><span class='titulo'>Arquivos da empresa:  <?Php echo utf8_encode($empresa); ?> </span></td>
	    </tr>
	<?
	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="Não";
	}
	?>
		<tr><td><span class='titulo'>Data/Hora:</span></td><td><span class='titulo'><?php echo dataPTBRTime($data_hora); ?></span></td></tr>
		<tr><td><br><span class='titulo'>Arquivo:</span></td><td><br><span class='titulo'><a href='arquivos/crm/<? echo $nomearquivo; ?>' target='_blank'><b><?php echo $upload;?></b></a>  <font size='2' face='Arial, Helvetica, sans-serif'>
		<tr><td colspan="2">&nbsp;</td></tr>
		<tr> 
	      <td height='10' align='right' valign='middle'><a href='miolo.php?miolo=arquivos&acao=delete&id=<?php echo $cod; ?>'>Excluir</a>
	    </span></td><td>&nbsp;</td></tr>
		  <tr><td colspan='3'></td></tr>
	      <tr><td colspan='3'><hr /></td></tr>
	<?
	}
		
	?>
	</table>
<?php 
}

if($_SESSION['nivel'] == 2){ 
  $resultadados = mysql_query("SELECT empresa FROM crm_cliente WHERE id = '".$_SESSION['idUser']."'");
  $empresa = mysql_result($resultadados, 0,0);

  $resultupload = mysql_query("SELECT * FROM crm_arquivo where id_cliente = '".$_SESSION['idUser']."' and baixado = '0' AND statusArquivo = '1' order by dataInsercao desc");
  
  ?>
  <table width="700" height="183" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
    <tr> 
      <td height="30" bgcolor="#E9E9E9"><span class="style5">Lista de Downloads</span></td>
      <td height="30" bgcolor="#E9E9E9"><div align="right" class="style7">
        <div align="center"><a href="miolo.php?miolo=verBaixados">Arquivos Baixados </a></div>
      </div></td>
    </tr>
    <?
    require 'auxiliares/formata-data.php';
  while ($linhaupload = mysql_fetch_array($resultupload)){
  list($cod, $codcli, $nomearquivo, $upload, $down, $data_hora) = $linhaupload;
  ?>
  	<tr>
  		<td><span class='style6'>Data/Hora:</span></td>
  		<td><span class='style6'><?php echo dataPTBRTime($data_hora); ?></span></td>
  	</tr>
  	<tr><td><span class='style6'>Arquivo:</span></td>
  		<td><span class='style6'><a target="_blank" href='arquivos/crm/<?php echo $nomearquivo; ?>' id="<?php echo $cod; ?>" class="link_download"><b><?php echo $upload; ?></b></a></span></td>
  	</tr>
    <tr><td width="100%" colspan='2'><hr></td></tr>
  <?
  }

  unset($linhaupload, $resultupload);
  }
  // $query=mysql_query("update cliente set statusup='SIM' where id='$codigocli'");
  ?>
  </table>
