<?session_start();
 require('../conectar.php');
$empleado=mysql_query("select * from empleados where id_empleado='$_SESSION[usuario_id]'",$db_conexion);
if($re=mysql_fetch_array($empleado))
{
 $id_empleado=$re['id_empleado'];
 $nom=$re['nombre'];
 $a_pat=$re['a_pat'];
 $a_mat=$re['a_mat'];
}
?>
 <html>
<head>
<title>Registrar anuncio</title>
<style>
		     .cont-busc{position:relative;width:850px;height:auto;min-height:400px !important;font-family:arial;color:#086A87;top:10px;overflow-x:hidden;margin:auto;}
			  .cont-res{position:relative;width:850px;font-family:arial;color:#086A87;top:0px;margin:auto;}
			  .datos{border:0;-moz-border-radius: 5px;-webkit-border-radius: 5px;border-radius: 5px;-khtml-border-radius: 5px;border-collapse: collapse;color:#0d0d0d;}
			  .datos .tl{-moz-box-shadow:inset 0 0 20px #000000;-webkit-box-shadow: inset 0 0 20px #000000;box-shadow: inset 0 0 20px #000000;}
			  .datos .trs{min-height:30px !important;max-height:30px !important;height:30px !important;background:url(images/tcancion.jpg) repeat-x;color:#ffffff;font-size:12px;}
              .datos .trsb{min-height:15px !important;max-height:15px !important;height:15px !important;background:url(images/tcancion2.png);color:#58D3F7;font-size:12px;}
			  .datos .trsb td{border-left:solid 1px #6E6E6E;}
			  .datos .trsb td:first-child{border-left:none;}
			  .datos .tr{min-height:20px !important;max-height:20px !important;height:20px !important;background:#ffffff;border-top:solid 1px #D8D8D8; color:#084B8A;font-size:13px;}
			  .datos .trb{min-height:20px !important;max-height:20px !important;height:20px !important;background:#ffffff;border-top:solid 1px #D8D8D8; color:#084B8A;font-size:13px;}
			  .datos .trb td{border-left:solid 1px #D8D8D8;padding-left:10px;}
			  .datos .trb td:first-child{border-left:none;}
			  .datos .trssb{min-height:15px !important;max-height:15px !important;height:15px !important;background:url(images/tcancion2.png);color:#848484;}	
			  .datos .tr td{border-left:solid 1px #D8D8D8;padding-left:10px;}
			  .datos .tr td:first-child{border-left:none;}
	          .datos .tr:hover{background:#01A9DB;color:#ffffff;}	
	          .datos .tr:hover a{color:#ffffff;}
              .datos .tr1{min-height:20px !important;max-height:20px !important;height:20px !important;background:#E0F8F7;border-top:solid 1px #D8D8D8; color:#084B8A;font-size:13px;}	
              .datos .tr1 td{border-left:solid 1px #D8D8D8;padding-left:10px;}
			  .datos .tr1 td:first-child{border-left:none;}
	          .datos .tr1:hover{background:#01A9DB;color:#ffffff;}	
	          .datos .tr1:hover a{color:#ffffff;}	
			  .datos .tr2{min-height:20px !important;max-height:20px !important;height:20px !important;background:#FFFFFF;border-top:solid 1px #D8D8D8; color:#084B8A;font-size:13px;}	
              .datos .tr2 td{border-left:solid 1px #D8D8D8;padding-left:10px;}
			  .datos .tr2 td:first-child{border-left:none;}
			  .datos .activo{min-height:20px !important;max-height:20px !important;height:20px !important;background:#F3E2A9;border-top:solid 1px #D8D8D8; color:#084B8A;font-size:13px;}
			  .ipt{border:none;background:none;color:#ffffff;font-weight:bold;}
			  .loading{position:fixed;left:50%;top:50%;width:250px;height:70px;margin-left:-125px;margin-top:-35px;display:none;background:url(images/bkloading.png);background-repeat:no-repeat;color:#ffffff;padding-top:25px;text-align:center;font-family:arial;font-size:12px;}
               .rentas{position:absolute;top:40px;width:800px;left:50%;margin-left:-421px;border:solid 1px  #D8D8D8; background:#FFFFFF; display:none;padding:20px;-Moz-box-shadow: 0 0 85px #000;-webkit-box-shadow: 0 0 85px #000; box-shadow: 0 0 85px #000;}
               .rentatab{border-collapse:collapse;color:#0d0d0d;font-family:arial;font-size:12px;}
               .rentatab .filatit{min-height:20px !important;max-height:20px !important;height:20px !important;background:#D8D8D8;border-top:solid 1px #D8D8D8;font-size:13px;}			   
               .rentatab .fila{min-height:20px !important;max-height:20px !important;height:20px !important;background:#ffffff;border-top:solid 1px #D8D8D8; color:#084B8A;font-size:12px;}
               .rentatab .fila td{border-left:solid 1px #D8D8D8;padding-left:5px;}
               .rentatab .fila td:first-child{border-left:none;}
               .cerrar{float:right;margin-top:-20px;margin-right:-20px;}	
               .notif{display:none;background:#D8F781;position:absolute;left:50%;margin-left:-250px;width:500px;height:auto;padding:20px;-moz-border-radius: 15px;-webkit-border-radius: 15px;border-radius: 5px;-khtml-border-radius: 15px;-Moz-box-shadow: 0 0 25px #000;-webkit-box-shadow: 0 0 25px #000; box-shadow: 0 0 25px #000;color:#173B0B;text-align:center;}			   
	     </style>
</head>
<body>
    <div class="cont-busc">
	    <form name="form1" action="" method="post" onsubmit="return validar(this)">
			<table class="datos" width="850" align="center" id="anuncios">
				 <tr>
					<td colspan="6" class="tl" align="center">SUBIR PAGINA</td> 
				 </tr>
			<tr class="trsb">
			  <td align="right">Pagina</td>
			  <td><input type="hidden" name="fecha" value="<?echo date('Y-m-d');?>"><input type="hidden" name="id" value="<?echo $id_empleado;?>">
			  <input type="text" name="pagina" onChange="javascript:this.value=this.value.toUpperCase();"></td>
			</tr>
            <tr class="trsb">			
			  <td align="right">Link</td><td><input type="text" name="link">
			</tr>
			<tr class="trsb">
			  <td colspan="4" align="center"><input type="submit" value="REGISTRAR" name="botonregistro"></td>
			</tr>
			</table>
		</form>
			<?
			if(isset($_POST['botonregistro']))
			  {					  
				$id_empleado=$_POST['id'];
				$fecha=$_POST['fecha'];
				$directorio=$_POST['pagina'];
				$link=$_POST['link'];
				//INSERTA DIRECTORIOS SIEMPRE Y CUANDO NO SE REPITA
				$sql="SELECT id,descripcion FROM directorios WHERE descripcion='$directorio'";					  
				$con=mysql_query($sql);
				$r=mysql_fetch_array($con);
				$iddir=$r["id"];
				$no=mysql_num_rows($con);
					if($no==0){
						$sql="insert into directorios(descripcion,borrar,idempleado,fechasubida,validar,link) values('$directorio','1','$id_empleado','$fecha','n','$link')";
						mysql_query($sql);
						$iddir=mysql_insert_id($db_conexion);
                        echo "El anuncio se subio correctamente, espere a que sea validado por administracion";						
					}else{
					    echo "Esta pagina ya esta registrada";
					}
			   }
		?>
		<!--<table class="datos" width="100%" align="center" id="anuncios">
		     <tr>
			    <td colspan="9" class="tl" align="center">Anuncios registrados hoy</td> 
		     </tr>
             <tr class="trsb">
	            <td align="center">No</td>
	            <td align="center">Pagina</td>
	            <td align="center">Fecha</td>
				<td align="center">Validar</td>
             </tr>-->
			 <?
			/* $sql="SELECT a.status2 as status2, a.id_anuncio as idanuncio,d.descripcion as descripcion, s.descripcion as categoria, a.anuncio as link, c.nombre as propiedad,dp.clave as departamento, a.idioma FROM anuncios as a INNER JOIN directorios as d ON a.sitio_web=d.id INNER JOIN subdirectorios as s ON a.subdirectorio=s.id_subdir INNER JOIN complejo as c ON a.propiedad=c.id_complejo INNER JOIN departamentos as dp ON a.departamento=dp.id_departamento WHERE id_empleado='$id_empleado' AND fecha_ingreso=CURDATE()";
			 $con=mysql_query($sql);
			 $i=1;
			 while($ls=mysql_fetch_array($con)){?>
			 <tr class="tr2">
			    <td><?echo $i?></td>
			    <td><?echo $ls["descripcion"];?></td>
			    <td><?echo $ls["categoria"];?></td>
				<td><?if($ls["idioma"]==1){echo htmlentities("ESP");}if($ls["idioma"]==2){echo htmlentities("ING");}?></td>
			    <td><a href="<?echo $ls["link"];?>"target="_blank"><?echo substr($ls["link"], 0, 30);?>...</a></td>
			    <td><?echo $ls["propiedad"];?></td>
			    <td><?echo $ls["departamento"];?></td>
			    <td><a href="anuncio_modificar3.php?id=<?echo $ls["idanuncio"]?>" target="modificar" onclick="window.open(this.href, this.target, 'width=900,height=300'); return false;"><img src="images/mod.png" border="0" width="16" height="16"></a></td>
				<!--<td>
				<a href="javascript:valanuncio('<?echo $i?>','<?echo $ls["idanuncio"]?>','<?echo $ls["status2"]?>');"><img src="images/<?if($ls['status2']=='0'){?>cerrardiv.png<?}else{?>emok.png<?}?>" id="destino<?echo$i?>" width="15" height="15"></a>-->
				</tr>
			 <?$i++;}*/?>
        <!--</table>-->		
	</div>	
</body>
</html>