<?php
	session_start();
	include ("conexion_bd.php");
	if(!$conexion)
	{
		die("error al intentar conectar: " .mysql_error());
	}
mysql_query("SET NAMES 'utf8'");// para configurar acentos y eñes
	//conexión realizada
	$pass=$_POST['password'];
	if($pass=="nellyjim")
		$_SESSION["administrador"]=$pass;
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script>
function imprimir(id)
{
	document.forms['formulario'].campo.value=id;
	document.forms['formulario'].submit();
	//window.location="http://www.cristalab.com";
}
</script>
<style>
#celda_foto{ width:100px;}
#celda_nombre{ width:400px; font-family:"Trebuchet MS", Arial, Helvetica, sans-serif; font-size:16px; color:#333;}
#celda_impresora{ width:35px; padding-left:3px; padding-right:3px; color:#999; font-family:"Trebuchet MS", Arial, Helvetica, sans-serif; font-size:11px; text-align:center;}

#div_tabla{ margin-top:25px; float:left; clear:both; margin-left:15%;}
#tabla{border:#CCC;}
#titulo{ font-family:"Trebuchet MS", Arial, Helvetica, sans-serif; font-size:25px; text-align:center; margin-top:25px; background-color:#F90}
#subtitulo{ font-family:"Trebuchet MS", Arial, Helvetica, sans-serif; font-size:14px; text-align:center;}
#parentesis{ font-family:"Trebuchet MS", Arial, Helvetica, sans-serif; font-size:10px; text-align:center; margin-top:25px; color:#999;}
#pass{ font-family:"Trebuchet MS", Arial, Helvetica, sans-serif; font-size:14px; text-align:center; margin-top:100px;}
</style>
<title>SiEPs</title>
</head>

<body>

<br />
<div id="titulo">SiEPs</div>
<div id="subtitulo">Sistema de Evaluaci&oacute;n Psicol&oacute;gica</div>
<div id="parentesis">(Fotografías almacenadas de los candidatos)</div>

<?php
	if(isset($_SESSION["administrador"]))
	{
		$consulta="SELECT id, nombre, foto FROM fotografia ORDER BY nombre";
		$sql=mysql_query($consulta,$conexion);
		$total_registros=mysql_num_rows($sql);
		if($total_registros>0)
		{
			$vuelta=1;
			$color="#e7e6e6";
			echo "<div style=\"width:100%; float:left; clear:both;\">\n";
			echo "<div id=\"div_tabla\">\n";
			echo "<table id=\"tabla\" cellspacing=\"2\" border=\"1\">\n";
			echo "<tr style=\"font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; font-size:12px; color:#999;\"><td>Fotograf&iacute;a</td><td>Nombre del candidato</td><td></td>\n"; 
			echo "</tr>\n";
			while($rowEmp=mysql_fetch_assoc($sql))
			{//-------------------INICIA RENGLON----
				if($vuelta)
				{
					$color="#EBEBEB";
					$vuelta=0;
				}
				else
				{
					$color="#f5f5f5";
					$vuelta=1;
				}
				echo "  <tr style=\" border:2px; border-top-style:solid; border-top-color:#000;\">\n";
				echo " <td style=\" padding:3px; background-color:".$color.";\"  id=\"celda_foto\"><img alt=Embedded Image src=\"data:image/png;base64,".$rowEmp['foto']."\" width=\"100px\" /></td>\n"; 
				echo "    <td style=\"padding:3px; background-color:".$color.";\" id=\"celda_nombre\">".$rowEmp['nombre']."</td>\n"; 
				echo "    <td id=\"celda_impresora\"><img onclick=\"imprimir(".$rowEmp['id'].")\" src=\"images/impresora.png\" /><br />Imprimir </td>\n"; 
				echo "  </tr>\n";
				//-------------------TERMINA RENGLON------
			}
			echo "</table>\n"; 
			echo "</div>\n"; 
			echo "</div>\n";
		}
	}
	else
	{
		echo "<div style=\" margin-top:200px;   text-align:center; font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; font-size:14px; color:#666;\">Usted no tiene permiso para visualizar el contenido de esta p&aacute;gina...</div>\n";
	}
?>

<form id="formulario" method="post" action="print.php">
<input id="campo" type="hidden" name="campo" />
</form>
</body>
</html>
