<?
if($_SESSION['nivel'] == 1){
	$codemp=$cod;
	$result=mysql_query("select * from crm_upload where codcli='".$_GET['cod']."' AND statusUpload = 1 order by id 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'];
	?>
	<body>
	 <table border="0" cellspacing="5" class="tabela-conteudo">
	    
	    <tr>
	      <td colspan="4" height="35" class="titulos-internos"><span>Lista de Arquivos Gravados </span></td>
	      <td height="35" align="center"><a href="miolo.php?miolo=clientes&acao=gerenciar">Voltar</a></td>
		</tr>
	    <tr>
	      <td colspan="5" class="subtitulos-internos"><span>Arquivos da empresa:  <?php echo utf8_encode($empresa); ?> </span></td>
	    </tr>
	    <tr>
	    	<td>&nbsp;</td>
	    </tr>
	    <tr bgcolor="#AAAAAA">
	    	<th width="5%">N&ordm;</th>
	    	<th width="30%">Arquivo</th>
	    	<th width="25%">Data/Hora</th>
	    	<th width="20%">Status</th>
	    	<th width="20%">Fun&ccedil;&otilde;es</th>
	    </tr>
	<?
	require 'auxiliares/formata-data.php';

	$cont = 1;

	while ($linha=mysql_fetch_array($result)){
		list($cod, $codcli, $nomearquivo, $upload,$down, $data_hora, $statusUpload, $statusAndamentos)=$linha;

		if ($down == '1'){
			$hein="Sim";
		} else {
			$hein="Não";
		}

		// Status andamentos
		
		$selectStatusAndamentos = mysql_query("SELECT a.`tituloReferencia`, a.`cor` FROM aux_andamentos AS a WHERE a.`idAndamento` = '".$statusAndamentos."'");

		while ($resultAndamentos = mysql_fetch_array($selectStatusAndamentos)) {
			
			$nomeStatusAndamentos = utf8_encode($resultAndamentos[0]);
			$cor = $resultAndamentos[1];
		}

		$bgcolor = ($cont % 2 == 0) ? "#E5DCDE" : "#E0E0E0";
	?>
			<tr bgcolor="<?php echo($bgcolor); ?>">
				<td align="center">
					<?php echo $cod;?>
				</td>
				<td>
					<span class='titulo'>
						<a href='arquivos/crm/<? echo $nomearquivo; ?>' target='_blank'>
							<b>
								<?php echo $upload;?>
							</b>
						</a>
					</span>
				</td>
				<td align="center">
					<span class='titulo'><?php echo dataPTBRTime($data_hora); ?></span>
				</td>
				<td align="center" style="color: <?php echo($cor); ?>; font-weight: bold;">
					<?php echo $nomeStatusAndamentos;?>
				</td>
				<td align="center">
					<a href='miolo.php?miolo=arquivos&acao=alt_status&id=<?php echo $cod; ?>'>
						<img src="images/tools.png" width="20px" height="20px" alt="status" title="Alterar status">
					</a>
					&nbsp;&bull;&nbsp;
					<a href='miolo.php?miolo=arquivos&acao=delete&id=<?php echo $cod; ?>'>
						<img src="images/lixo.png" width="20px" height="20px" alt="deletar" title="Deletar">
					</a>
				</td>
			</tr>
	<?
		$cont++;
	}
		
	?>
	</table>
<?php 
}
?>